1 / 16

The JANA Calibrations and Conditions Database API

The JANA Calibrations and Conditions Database API. March 23, 2009 David Lawrence JLab. Newport News, Virginia. The GlueX Experiment. Conventional meson has quantum numbers determined only by constituent quarks.

yin
Download Presentation

The JANA Calibrations and Conditions Database API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The JANA Calibrations and Conditions Database API March 23, 2009 David Lawrence JLab Newport News, Virginia JANA Calibration API David Lawrence -- JLab

  2. The GlueX Experiment Conventional meson has quantum numbers determined only by constituent quarks The “continuous wave” 12GeV electron beam at JLabhas a beam bunch every 2 ns Forward EM calorimeter and forward TOF wall downstream 2 Tesla solenoid magnet 30 cm LH2 target Hybrid meson has some quantum properties due to contributions from the “glue” Barrel EM calorimeter inside magnet Cylindrical and planar drift chambers inside magnet real g beam JANA Calibration API David Lawrence -- JLab

  3. Data Rates in 12GeV era private comm. JLab CHEP2007 talk Sylvain Chapelin LHC * BNL ** * NIM A499 Mar. 2003 ppg 762-765 ** CHEP2006 talk MartinL. Purschke JANA Calibration API David Lawrence -- JLab

  4. Targeted Customers for JCalibration • “B”-coders = reconstruction code authors(“A”-coders = framework authors; “C”-coders = physics analysis) The minimal information needed from the reconstruction code is the nameof the constants and a container to put them in. (The container implicitly contains a data type.) JCalibration URL run_number context (string) … Reconstruction Program Reconstruction Code namepath(string) STL container ref. Database B-coders A-coders JANA Calibration API David Lawrence -- JLab

  5. API For Accessing Constants Constants can be stored in either arrays (1D) or tables (2D) and can be indexed either by name (key-value) or by position. // Get 1-D array of values indexed by name boolGet(stringnamepath, map<string, T> &vals) // Get 1-D array of values indexed by row boolGet(stringnamepath, vector<T> &vals) // Get 2-D table of values indexed by row and name boolGet(stringnamepath, vector< map<string, T> > &vals) // Get 2-D table of values indexed by row and column boolGet(stringnamepath, vector< vector<T> > &vals) arrays tables // Get list of available namepathsfrom backend void GetListOfNamepaths(vector<string> &namepaths) discovery JANA Calibration API David Lawrence -- JLab

  6. Example of Accessing Calibration Constants as key-value pairs ... in factory class definition … double slope, offset, exponent; ... in brun() method ... map<string, double> twpars; loop->Get("FDC/driftvelocity/timewalk_parameters", twpars); slope = twpars["slope"]; offset = twpars["offset"]; exponent = twpars["exponent"]; Template method converts values to doubles using stringstream class For a few parameters like this, it makes sense to copy them into local data members of the factory class JANA Calibration API David Lawrence -- JLab

  7. Backend Requirements To implement a JCalibration interface to a new backend, only 3 virtual methods need to be implemented! virtual boolGetCalib(stringnamepath, map<string, string> &svals) • virtual boolGetCalib(stringnamepath, vector< map<string, string> > &svals) • virtual void GetListOfNamepaths(vector<string> &namepaths) OK, actually, it’s closer to 6, but these 3 are for the generator class and are trivial. • virtual const char* Description(void) • virtual double CheckOpenable(stringurl, intrun, string context) • virtual JCalibration* MakeJCalibration(stringurl, intrun, string context) • The generator mechanism allows access to multiple types of databases in the same executable. • Access to a new type can even be brought in through a plugin. JANA Calibration API David Lawrence -- JLab

  8. Calibration Web Service • Calibration constants will need to be accessible from remote computers via the internet • Direct access to a database is problematic due to cybersecurity concerns • Web services work over HTTP and so are the appropriate mechanism for remote access • The JCalibrationWSclass provides calibration constants through a web service • Implemented as a plugin soremote access can be added to an existing executable • Allows read-only access to calibration constants from anywhere in the world over HTTP(http://www.jlab.org/Hall-D/cgi-bin/calib) • Uses gSOAP, a C++ SOAP implementation • Currently works like a proxy for JCalibrationFileon server side, but could trivially be made to use another type of backend JANA Calibration API David Lawrence -- JLab

  9. Saving a (semi-)complete set of calibration constants to the local disk All JANA programs have the command line option: --dumpcalibrations • Records which namepathsare requested during a job and writes the constants into ASCII files compatible with JCalibrationFile • Avoids copying and running entire database or even copying a “complete” set of calibration constants (which could include obsolete ones or ones not applicable to the current run/code version) JANA Calibration API David Lawrence -- JLab

  10. Summary • A simple API for accessing calibration/conditions DB exists in JANA that allows code development prior to developing the actual database • C++ templates + ANSI stringstream allows handling of all data types • Web Service is a good option for allowing remote access to constants in a cyber-secure way • SOAP standard (Java, C++, …) • JANA has a built-in mechanism for dumping constants to the local disk regardless of the source • Local access is (almost) always faster than network access http://www.jlab.org/JANA JANA Calibration API David Lawrence -- JLab

  11. Backup Slides JANA Calibration API David Lawrence -- JLab

  12. Threads in JANA • Each thread in JANA is composed of its own event processing loop and a complete set of factories • Reconstruction of a given event is done entirely inside of a single thread • No mutex locking is required by authors of reconstruction code • Threads work asynchronously to maximize rates at the expense of not maintaining the event order on output raw data read in reconstructed values written out (e.g. ROOT tree) JANA Calibration API David Lawrence -- JLab

  13. Example of Accessing Calibration Constants as an array ... in factory class definition ... vector<double> tof_tdc_offsets; ... in brun() method ... loop->GetCalib(”TOF/tdc_offsets",tof_tdc_offsets); if(tof_tdc_offsets.size()!=Ntof) throw JException(“BadNtof!”); ... in evnt() method ... double t = tof->tdc - tof_tdc_offsets[tof->id]; JANA Calibration API David Lawrence -- JLab

  14. Backend Database • The API defines the routines B-coders will use to obtain calibration constants independent of the details of how the actual database is implemented • This does impose some requirements of the database design itself: • Store both 1-D arrays and 2-D tables • Index either by name or position • Uniquely identify constants by • Run number • Context string (may include timestamp) • URL • JCalibrationFileimplements a trivial calibration backend that maps directly to ASCII files on the local file system • Represents snapshot of constants and so ignores run number and context string • URL points to root directory (e.g. file:///group/halld/calib) • Constants currently kept in svn(https://halldsvn.jlab.org/repos/trunk/calib) JANA Calibration API David Lawrence -- JLab

  15. Calibration object generators and namepathDiscovery • Generator mechanism for JCalibration • JCalibrationGeneratorclass added • Allows multiple types of database backends to be supported in same binary • Allows new calibration database backends to be added dynamically to pre-compiled binaries • Useful for private development of backend alongside trunk without disturbing standard builds • Discovery mechanism • JCalibrationnow has a new virtual method called GetListOfNamepaths() that can be used to probe a calibration backend for the available constants • This is utilized in the jcalibreadutility using the “-L” switch JANA Calibration API David Lawrence -- JLab

  16. Recycled Containers A new templatedGet() method has been added to JCalibrationthat instructs it to keep ownership of the constants and just return a const pointer to the container. Since STL vectors keep internal data sequential in memory, the values can be accessed via a standard array pointer while maintaining const correctness. ... in factory class definition ... const double *fcal_gains; ... in brun() method ... • const vector<double> *my_fcal_gains; • loop->GetCalib(”FCAL/Energy/gains", my_fcal_gains); • fcal_gains = &(my_fcal_gains->front()); • ... in evnt() method ... • double Ecorr = fcal_hit->E * fcal_gains[fcal_hit->id]; • fcal_gains[3] =1.2; // This will generate compile time error! JANA Calibration API David Lawrence -- JLab

More Related