Quick start guide

The sam_web_client product is available via ups/upd.

Alternatively, to obtain the latest version via git, run

$ git clone

The product has no dependencies aside from python, and will run with any version of python 2.4-2.7

Command line client

The product provides a single command, samweb.

Running samweb alone will list all available commands, and the general options. For any command to work, the script must know the experiment name. This is set by the -e <experiment> option, or if this is not used, by the SAM_EXPERIMENT environment variable.

Some commands require authenticated access. This requires a KCA certificate. By default this will look in the standard user grid proxy location (which is where the get-cert command puts it). If you want to use a certificate from another location, specify --cert=<path to certificate> or the X509_USER_CERT enviroment variable. (Note: RFC compliant grid proxies will also work, but the subject must be explicitly registered with the SAM database first.)


Query the Minerva development database for the given run number:

$ samweb -e minerva --dev list-files "run_number 1165.4" 

Get the metadata for that file:

$ samweb -e minerva --dev get-metadata MN_00001165_0004_numib_v04_1002132253_RawEvents.root
               File Name: MN_00001165_0004_numib_v04_1002132253_RawEvents.root
                 File Id: 1999336
               File Type: importedDetector
             File Format: root
               File Size: 449779482
                     Crc: 2468993163L (adler 32 crc type)
          Content Status: good
                   Group: minerva
               Data Tier: raw
             Application: online v04 v05-14-00
             Event Count: 1500
             First Event: 6891022
              Last Event: 6892521
              Start Time: 2010-02-14T04:55:56
                End Time: 2010-02-14T05:53:40
             Data Stream: alldata
        Beam.HornCurrent: -185
       Beam.TargetConfig: LE010
       Beam.TargetNumber: NT03
MinosConfig.MagnetConfig: Reverse
         Quality.MINERvA: Good
    online.triggerconfig: unknown
      online.triggertype: MTM
                    Runs: 1165.0004 (mtm)
          File Partition: 1
        Lum Block Ranges: 6891022-6892521

Python API

The API should work with python version 2.4 and up (but not python 3.0 onwards). Performance in some cases will be improved by using 2.6 or 2.7. Commands that want to do a lot of operations in quick succession will benefit from having the requests library ( available, as it enables HTTP connection reuse. It will automatically used if it can be imported.

To use the python API, add the python directory to your PYTHONPATH (the ups setup does this for you).

$ python
Python 2.7.3 (default, May  7 2012, 17:17:10) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import samweb_client
>>> samweb = samweb_client.SAMWebClient(experiment='minerva/dev')
>>> import pprint
>>> pprint.pprint(list(samweb.listFiles("run_number 1165.4")))

>>> pprint.pprint(samweb.getMetadata('MN_00001165_0004_numib_v04_1002132253_RawEvents.root'))
{u'Beam.HornCurrent': u'-185',
 u'Beam.TargetConfig': u'LE010',
 u'Beam.TargetNumber': u'NT03',
 u'MinosConfig.MagnetConfig': u'Reverse',
 u'Quality.MINERvA': u'Good',
 u'application': {u'family': u'online',
                  u'name': u'v04',
                  u'version': u'v05-14-00'},
 u'content_status': u'good',
 u'crc': [u'2468993163L', u'adler 32 crc type'],
 u'data_stream': u'alldata',
 u'data_tier': u'raw',
 u'end_time': u'2010-02-14T05:53:40',
 u'event_count': 1500,
 u'file_format': u'root',
 u'file_id': 1999336,
 u'file_name': u'MN_00001165_0004_numib_v04_1002132253_RawEvents.root',
 u'file_partition': 1,
 u'file_size': 449779482,
 u'file_type': u'importedDetector',
 u'first_event': 6891022,
 u'group': u'minerva',
 u'last_event': 6892521,
 u'lum_block_ranges': [[6891022, 6892521]],
 u'online.triggerconfig': u'unknown',
 u'online.triggertype': u'MTM',
 u'runs': [[1165, 4, u'mtm']],
 u'start_time': u'2010-02-14T04:55:56'}

Example running a project using the API

Detailed Dependencies