DB Class Reference

Ratpac-two: DB Class Reference
Ratpac-two
DB Class Reference

#include <DB.hh>

Detailed Description

Database of constants

Author
Stan Seibert volsu.nosp@m.ng@p.nosp@m.hysic.nosp@m.s.ut.nosp@m.exas..nosp@m.edu

RATDB is the database of constants that will be used by RAT for all adjustable parameters. "Parameters" in this sense includes many things, such as:

  • physical properties of materials (density, optics, etc.)
  • geometric configuration of parts of the detector (dimensions and locations of the acrylic vessel, PMTs, ...)
  • calibration constants
  • lookup tables
  • control parameters which specify how processing should be done

Note that RATDB is NOT intended to hold actual event information, just everything else.

Despite the suggestive name, RATDB is not really a proper Database, like MySQL or Oracle. Rather it is just a simple set of C++ classes used to read parameters from various backends (text files and CouchDB servers) and make the data easily available to other parts of the RAT application.

Data Organization

Information in RATDB is organized into a two-level namespace of @i tables and @i fields. Tables have uppercase names like DAQ, IBD, and PMTLOCATION. Related tables can be given the same name and distinguished by an index string like "vacuum" or "acrylic". The convention for writing this out is to put the index in brackets, after the table name: GEO[tank], MEDIA[acrylic]. Tables without an index (like IBD) implicitly have an index which is the empty string.

Tables contain fields, which have lowercase names like sampling_time and emin. A field contains value, which can have one of 6 data types:

  • integer, float, string
  • array of integers, array of doubles, array of strings

Run Ranges

Frequently, you want to have several sets of the same constants which have different validity ranges. RATDB organizes the notion of validity range into 3 @i planes (think of a stack of transparencies):

  • user plane: This sits on top, and is where constants that users want to override in their macros go.
  • run plane: This is where constants that change with time (like attenuation lengths) go.
  • default plane: This is where a baseline set of constants live. Fields are only retrieved from the default plane if they cannot be found on the user plane or the time plane.

The plane on which a table lives is specified by a few special fields in the table. The range of run numbers (inclusive) are contained the field run_range. The special value [0,0] is used to indicate the default plane and [-1,-1] is used for the user plane.

Usage

To use RATDB, you obtain a pointer to the global database (unless you want to create your own RATDB with some private data). Then you obtain a link to the table you wish to access. Finally you query the link for specific fields. The shortest example of this is:

DB *db = DB::Get();
DBLinkPtr lmedia = db->GetLink("MEDIA", "acrylic"); // Link to MEDIA[acrylic]
double rindex = lmedia->GetD("index_of_refraction");
You can hold onto DBLinkPtr objects as long as you like.  If
you expect you will need to access the same table at various
points in your code, you can obtain a link pointer in your
constructor and reuse it in other methods.

The documentation for this class was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/db/include/RAT/DB.hh