ConditionsData
Introduction
In Mu2e it will eventually be necessary to maintain a database of "calibration constants". This will include information like the measuured corrections to the nominal geometry, the gas gain in straws, the time-space relationship for the straws, the gain of the photosensors, the calibration curve for ADC's and so on. This sort of data was traditionally referred to as "calibration constants" or, simply, as "constants".
Many of the calibration constants, however, are actually time dependent, which leads to the tired joke that "constants aren't". In the interests of ridding the field of bad jokes, modern usage is that this sort of data is known as "conditions data".
Using the conditions database
selecting a calibration set
When accessing the conditions database, you select a purpose, such as "PRODUCTION" and version, such a "V1_1". These are entered in the DbService services stanza.
services : { DbService : { purpose : PRODUCTION version : v1_1 dbName : "mu2e_conditions_prd" textFile : ["table.txt"] verbose : 1 } }
The version numbers have three fields:
- major version number, this changes when there a is major change in the content of the calibration set, that a user should probably be aware of, such as going from unaligned data to aligned data.
- minor version number. This changes when the list of tables changes, or if there was a repair to the calibration set. Your previous results may change.
- extension number. This changes when new runs are added to the calibration set - the existing runs do not change.
You need to provide a PURPOSE. If you have no interest in the version number, then you can leave it blank and the code will take the latest available. If you specify only the major version number, then the highest available minor version number will be used. You results might change between runs of your exe. If you provide the major and minor version numbers, then any run numbers that successfully ran before will always run the same way, but runs that previously failed because no calibration were available might succeed at a later time due to an extension of the calibration set. This is probably the right approach for most user work. Finally, if you specify the major, minor and extension number, then you will get the same result every time.
The database parameter should usually be mu2e_condition_prd, and this is the default.
The table parameter allows you to add a table to the calibration set for testing, see below.
overriding a table with a local file
Conditions data maintenance
During data-taking the detector experts responsible for calibrations will need to continually update the database with calibrations for the new data. This section explains their procedures.
strings
Arbitrary string input occurs at two places
- when adding comments to a dbTool create action, such as creating a new purpose or version
- when uploading a calibration table that has a string column
In general, there are three special characters to watch our for: double quotes, used for quoting ("), comma, used for column separation (,), and hash, used for comments (#).
When inputing a string to dbTool to include a comment, there are only two rules:
- if more than one word, use double quotes --comment "two words"
- when using a double quote in a string, escape it --comment "two \"words\""
When writing a file that contain calibration data, the following rules apply
- comments may be included by writing the hash (#) as the first character of a line. Comments are not allowed embedded in lines with data. The hash may be used in a string column. # this is a legal comment TABLE tableName1 1, 1.2 # legal comment # legal comment - first non-whitespace char is the hash 2, 1.1 # illegal comment - will crash on parse (part of number column) TABLE tableName2 1, 1.2, GOOD 2, 1.1, BAD # malformed comment - will appear in string column 3, 1.1, failed check #3 OK, legal to use hash in string
- commas must be quoted TABLE tableName2 1, 1.2, GOOD 2, 1.1, BAD, or not will crash on parse 3, 1.1, "BAD, or not" OK
- embedded double quotes must escaped or doubled TABLE tableName2 1, 1.2, GOOD OK 1, 1.2, "GOOD" OK 3, 1.1, really BAD OK, multiple words OK (as long as no commas or quotes) 3, 1.1, ain't really BAD OK, single quotes OK 2, 1.1, Joe says "BAD" OK 2, 1.1, Joe says "BAD, or not" OK, comma requires quotes 3, 1.1, "Joe says \"BAD\"" OK 4, 1.1, "Joe says ""BAD""" OK 4, 1.1, "Joe says "BAD"" will crash on parse 5, 1.1, "Joe says, ""BAD""" OK, comma requires quotes, embedded quotes must be escaped or doubled
Calibration set maintenance
During data-taking the database managers will need to continually update the database higher-level tables as calibrators enter new data. This section explains these procedures. This section assumes the reader is familiar with the [ConditionsSchema].
The following are several procedures that will typically be needed.
Extend a calibration set
This is the most common procedure. At this point there exists a calibration set - a PURPOSE and VERSION. The VERSION here refers to the major and minor numbers, like v1_1. This procedure extends this set, so takes a new set of tables represented by a GROUP number (or numbers), given to you by calibrators, and extends the calibration set. For example, an extension might take calibration set PRODUCTION v1_1_10, adding some groups of tables, to create PRODUCTION v1_1_11.
dbTool commit-extension --purpose PRODUCTION --version v1_1 --gid 4
the result shows the new full version number with the new extension. --gid can take a list of numbers, or a file containing numbers (see the dbTool help). You can verify the calibration set with
dbTool print-set --purpose PRODUCTION --version v1_1 --details
once an extension is created it is permanent and can't be deleted or undone. If there is a mistake, the procedure is to create a new VERSION, copy over the correct part, then create a new correct extension.
Create a new version of a purpose
A new version of a PURPOSE is needed when either the types of tables included in this calibration set needs to change, or if there was a mistake in the contents of the set.
You will need a list of tables to include in this calibration set.
dbTool commit-version --purpose PRODUCTION --list 3 --major 1 --minor 3 --comment "fix run 1234 of version 1_2"
Create a new purpose
In this case you are creating a whole new purpose. This should be a rare procedure and would indicate a whole new procedure is being introduced, for example, CRV group wants to run a calibration job on new data and needs the nominal calibration as input to the job. They don't care about any other detector calibrations.
dbTool commit-purpose --name CRV_CALIBRATION --comment "input to the CRV calibration job"
the result can be checked with
dbTool print-purposes
this print shows the PID, which uniquely identifies this PURPOSE. Every PURPOSE must have a unique name.
Create a new calibration table
Notes
- Art interface:
- art talk on a db interface.
- csv_qe_api query_engine wrapper and generic table (`upd list -aK+ csv_qe_api`)
- ConDB - urls access to REST server
- ConDB Web Interface urls that return csv, assumes time IOV
- query_engine wiki - a generic query db url/REST interface
- Web Data Access (wda) manual (ups product) c function wrapper, takes urls, runs curl, returns pointer to memory, has utilities for converting csv to values.
- nu products
- nutools - contains nova generic table
- nucond -
- MINOS DB manual
- UconDB unstructured DB
- 5/9/18 created dev conditions
psql -h ifdb04 -p 5444 mu2e_conditions_dev
- query engine
non-cached: http://dbdata0vm.fnal.gov:9090/QE/mu2e/dev/app/SQ/query?t=test cached: http://dbdata0vm.fnal.gov:9091/QE/mu2e/dev/app/SQ/query?t=test
- setup postgresql v9_3_9
- hypernews mu2e-hn-ConditionsDB@listserv.fnal.gov
CREATE ROLE admin_role; GRANT ALL to adm_role; GRANT admin_role to gandr,kutschke,rlc; CREATE ROLE trk_role; GRANT trk_role TO brownd,rbonvent,edmonds; CREATE ROLE cal_role; GRANT cal_role TO echenard,fcp; CREATE ROLE crv_role; GRANT crv_role TO ehrlich,oksuzian;