Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

HPS uses a conditions database which is accessible through the DatabaseConditionsManager.  The conditions framework provides classes that read information from the database and return them as lists of typed Java objects with methods for accessing each data field.  Users can access these objects to configure their jobs, typically in the detectorChanged() method of their Driver classes.  The conditions system is setup by specifying the unique name of a detector description and the run number.  Typically, this is done by reading this information automatically from the event headers in an LCIO file.

Database Connection

Command Line Options

The URL, username and password parameters for connecting to the database can be specified from the command line as global Java properties.

The default connection information for reading from the database corresponds to the following command line options:

Code Block
titleConditions Database Command Line Options
java -Dorg.hps.conditions.url=jdbc:mysql://hpsdb.jlab.org:3306/hps_conditions \ 
    -Dorg.hps.conditions.user=hpsuser \
    -Dorg.hps.conditions.password=darkphoton [...]

These options should always be provided immediately after the java command as they are global Java properties and not rather than command line options provided to a specific application or program within hps-java.

The default database connection uses a read-only replica of the primary MySQL conditions database at Jefferson Lab.  Therefore, when connecting from a computer which is outside of the jlab.org domain, you will  not be able to make any changes to this database.  If you need to insert records into the database, i.e. for new calibrations, then it must be done behind the JLab firewall.  You , and you must provide proper valid credentials that will allow writing to the database (they are not given provided here!).

Using a Local Conditions Database

Support for SQLite is included in the database conditions manager for running jobs locally Local jobs can be run without an internet connection using the built-in support for SQLite.

A db file compatible with sqlite3 may be obtained by using the following commands:

...

No username or password is required when connecting locally in this way.

This file may or may not be up to date with the current master in the JLab conditions database!

Creating Creating a Local SQLite Database

In order to create a local SQLite database, you will need to create a snapshot of the MySQL database and then convert it to a SQLite db file.   

...

Code Block
titleCreating a Database Dump
mysqldump --skip-extended-insert --compact -u hpsuser --password=darkphoton -h hpsdb.jlab.org  --lock-tables=false hps_conditions > hps_conditions.mysql

Now, you can load it the database dump into SQLite sqlite3 as follows:

Code Block
titleLoading Dump into SQLite
  mysql2sqlite hps_conditions.mysql | sqlite3 hps_conditions.db

You should now have an up to date copy of the master conditions database locally , nowthat can be specified on the command line.

Administration

Creating a Conditions Database Backup

...

The conditions configuration is typically done via performed using arguments to command line programs, or the system is setup automatically from information in the LCIO or EVIO events.

The detector name and run number to be used can be provided explicitly to the job manager to override these settings from input files.

Code Block
languagejava
themeMidnight
java -jar hps-distribution-bin.jar -d detector_name -R 5772 [args]

Configuration of the EvioToLcio utility is similardone similarly.

Code Block
languagejava
themeMidnight
java -cp hps-distribution-bin.jar org.hps.evio.EvioToLcio -d detector_name -R 5772 [args]

Providing conditions in this way will cause the manager to automatically "freeze" itself after it initializes initialization so that subsequent run numbers and detector header information from the input file files will be ignored in the job.

Additionally, tags can be specified to filter out the available conditions records in the job, which is described in the Detector Conditions Tags documentation.

...

If an instance has not already been instantiated, one will be created.Users should not normally need to install their own conditions manager as this is typically done for them in the setup of the various job tools, but it may be necessary when writing standalone scripts and command line tools which do not use these classes.

The conditions system is initialized using the ConditionsManager's setDetector method which takes the name of a detector and a run number.

...

This can be done by calling a special static method on the manager.

Code Block
titleResetting the Conditions Manager
DatabaseConditionsManager.reset();

...

This is useful to force the system to load a specific configuration by run number if the actual event data does not have the same run number (or for run 0 events from simulation).

The conditions system will be initialized for you automatically or configured using switches to the various HPS Java command line tools (exact syntax depends on the tool).

...

titleInitializing the Conditions System

...

Accessing Conditions from a Driver

...