A Utility Class for Storing Condition Objects in the Offline DB

Complete: 5

General Description of the Base Class


The class ConditionDBWriter can be very useful whenever a CMSSW application needs to store data to the offline DB. Typically such applications require access to event data and/or need to be notified about the start of Run, Lumi section in order to set a correct Interval Of Validity (IOV) for the data they have to store. Therefore the Framework EDAnalyzer is an excellent candidate for the implementation of such applications; this is the reason why ConditionDBWriter inherits from the EDAnalyzer class.

Package: CommonTools/ConditionDBWriter   Class: ConditionDBWriter

The User Class and its Method(s)

The user class should inherit from the ConditionDBWriter class. The templated type must be the type of the object that has to be written on the DB (e.g. MyCalibration). Examples of use of this class can be found in package CalibTracker/SiStripChannelGain. Have a look also at the CommonTools/ConditionDBWriter/test/ directory for examples of full cfg files.

The user must implement in his derived class the abstract method below

 virtual MyCalibration * getNewObject()=0;
in this method, the user must create a new instance of the DB object and return a pointer to it. The object must be created with "new" and never be deleted by the user: it will be the FWK that takes control over it.

The user can optionally implement the following methods

 //Will be called at the beginning of the job
 virtual void algoBeginJob(const edm::EventSetup&){};
 //Will be called at the beginning of each run in the job
 virtual void algoBeginRun(const edm::Run &, const edm::EventSetup &){};
 //Will be called at the beginning of each luminosity block in the run
 virtual void algoBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &){};
 //Will be called at every event
 virtual void algoAnalyze(const edm::Event&, const edm::EventSetup&){};
 //Will be called at the end of each run in the job
 virtual void algoEndRun(const edm::Run &, const edm::EventSetup &){};
 //Will be called at the end of the job
 virtual void algoEndJob(){};

where he can access information needed to build his object. For instance, if he is computing a calibration that is computed as the mean of a certain quantity that varies from event to event, he will implement the algoAnalyze method.

Setting the Interval of Validity in the CMSSW Configuration File

The important part is the setting of the Interval of Validity (IOV). The advantage of using ConditionDBWriter is that this setting is performed almost automatically: the only thing that the user has to do is to pass prescriptions about the IOV setting in the configuration of his module. A typical configuration is as follows:

module prod =  SiStripGainRandomCalculator {
  #parameters of the derived class
  double MinPositiveGain        = 0.1
  double MeanGain                = 1
  double SigmaGain               = 0
  untracked bool  printDebug = true

  #parameters of the base class (ConditionDBWriter)
  string IOVMode = "Run"
  bool SinceAppendMode = true
  string Record = "SiStripApvGainRcd"

Two subsets of parameters can be found. The first subset contains the specific parameters of the user class, which is called in this case SiStripGainRandomCalculator. The second subset contains the parameters of the base class (ConditionDBWriter). A detailed description of the parameters for the IOV settings is given in the next section.

Parameters that Determine the IOV Setting

Parameters: vstring IOVMode

4 possible values can be given: "Job", "Run", "LumiBlock" and "AlgoDriven". This parameter determines the length of the IOV. In other words, together with the number of Lumi sections / runs the user has decided to run his application, this card determines the number of objects that will be stored on the DB (the getNewObject method will be called as many times).

For example if the user is running on the events of one Run, which has 10 luminosity sections and chooses the "LumiBlock" mode, then 10 objects with corresponding IOV will be written. If the "Job" mode is chosen, only one object will be stored irrespective of the dataset on which the user is running.

The "AlgoDriven" option is special. If this choice is made, then it is up to the user to tell in the code when the getNewObject method must be called. This can be done by calling the method below void storeOnDbNow() must be invoked whenever a certain condition that justifies the start/end of an IOV is met.

Parameters: bool SinceAppendMode

If this parameter is set to true, new objects are appended to the chosen tag. The tag itself must be specified in the configuration of the PoolDBOutputService service, which must always be included in the cfg file of your application.

If instead this card is set to false, new objects are appended in till mode. For example if the user runs on 2 Runs (1 to 2), chooses the "Run" IOVMode and the SinceAppendMode, then he will have two objects stored on the DB,

     Object 1 valid for Run 1
     Object 2 valid from Run 2 on (unless new objects are appended later)
If instead he had run in Till mode, then he would get two objects stored:
     Object 1 valid for Run 1
     Object 2 valid for Run 2 only.

WARNING: due to a current misfunctioning of the framework, if the Since mode is chosen, then it is highly recommended to store objects in IOV chronological order. If you have 10 runs, then execute your application starting from run 1 and not for example in two steps: first from Run 6 to Run 10 and then from Run 1 to Run 6.

Parameters: string Record

This is the EventSetup record of your object.

Review Status

Editor/Reviewer and date Comments
DorianKcira - 14 Jun 2007 page content last edited

Responsible: DorianKcira
Last reviewed by:

Topic attachments
I Attachment History Action Size Date Who Comment
JPEGjpg ConditionDBWriter.jpg r1 manage 30.7 K 2007-06-14 - 18:27 DorianKcira  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2007-06-26 - JennyWilliams

    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback