Creating a compliant DQM and harvesting analyzer

Complete: 5
Detailed Review status

Compliant DQM analyzer

Code

In this section the pseudo code for an compliant analyzer is shown. In particular we concentrate in the creation of two MEs to TH1F histograms. They will be later the numerator and denominator used as an example for operate over histograms in the second step.

At least two functions need to be defined by an analyzer, its constructor and analyze method. In the example below shows how to create two histograms by defining a constructor, a beginJob and analyzer methods.

ConverterTester::ConverterTester(const edm::ParameterSet& iPSet)
{
  ...
  dbe = edm::Service<DQMStore>().operator->();
  ...
}

void ConverterTester::beginJob(const edm::EventSetup& iSetup)
{
  if(dbe){
    meTestTH1FN = 0;
    meTestTH1FD = 0;
    Random = new TRandom3();
    ...   
    dbe->setCurrentFolder("ConverterTest/TH1F");
    meTestTH1FN = dbe->book1D("Random1DN", "Random1D Numerator", 100, -10., 10.);
    meTestTH1FD = dbe->book1D("Random1DD", "Random1D Denominator", 100, -10., 10.);
    ...
    dbe->tag(meTestTH1FN->getFullname(),1);
    dbe->tag(meTestTH1FD->getFullname(),2);    
  }
  return;
}

void ConverterTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
  for(int i = 0; i < 1000; ++i)
  {
    ...
    RandomVal1 = Random->Gaus(0.,1.);
    ...
    meTestTH1FN->Fill(0.5*RandomVal1);
    meTestTH1FD->Fill(RandomVal1);    
    ...
  }
}

A full example can be found at CVS.

Once the analyzer is created then you have to declare it as a CMSSW module or plugin. For this you can create or edit SealModule.cc file and add the following

#include <DQMServices/Examples/interface/ConverterTester.h>
DEFINE_ANOTHER_FWK_MODULE(ConverterTester);

See as example CVS.

Compiling

For compiling go to the src directory of the release where the analyzer is located and run

src> scramv1 b

Cfg file

An example of the cfg files for running the analyzer plus the MEtoEDM converter is given next:

process TestMEtoEDMConverter = 
{
  untracked PSet maxEvents = {untracked int32 input = 1}

  source = EmptySource {}

  include "DQMServices/Components/data/MessageLogger.cfi"
  service = LoadAllDictionaries {}
  
  include "DQMServices/Examples/data/ConverterTester.cff"
  include "DQMServices/Components/data/MEtoEDMConverter.cfi"

  path p1 = {convertertester, MEtoEDMConverter}

  module Output = PoolOutputModule 
  { 
    untracked string fileName = "MEtoEDMConverter.root"
    untracked vstring outputCommands =
    {
      "keep *_MEtoEDMConverter_*_*"
    }
  }
  endpath outpath = {Output}
  schedule = {p1,outpath}
}

This example can be found at CVS.

Extracting histograms from EDM files

Once the DQM compliant analyzer is developed, it is important to test the all the monitor elements that are produced. Because MEs are in a format not compliant with ROOT CINT dictionary it is necessary the extraction of those by using EDMtoMEConverter. The is done by executing the following CMSSW with th following dfg file.

process EDMtoMEConvert =
{
    untracked PSet maxEvents = {untracked int32 input = -1}

    ## setup useful services
    include "DQMServices/Examples/test/MessageLogger.cfi" 
        
    ## read in EDM file
    source = PoolSource
    {
        untracked vstring fileNames =
        {
       "file:Your_EDM_File.root"
        }
    }
    
    ##module EDMtoMEConverter
    include "DQMServices/Components/data/EDMtoMEConverter.cff"
    replace DQMStore.referenceFileName = ""

    //for standard running
    replace dqmSaver.convention = "CMS.RelVal"
    replace dqmSaver.workflow = "/ConverterTester/Test/RECO"

    ## execute path
    ##
    path p1 = { EDMtoMEConverter, dqmSaver }
}

It is important that the option convention CMS.RelVal so all the ME will be merge across all the Run produced by at the relval production.

An example can be found at CVS.

Editing the validation relval sequence

Those developers that have tested their packages and want to add them in to the validation sequence need to edit the relval validation sequence. An example of this file where two of the global packages are added is shown below

include "Validation/GlobalDigis/data/globaldigis_analyze.cfi"
include "Validation/GlobalHits/data/globalhits_analyze.cfi"
include "DQMServices/Components/data/MEtoEDMConverter.cfi"

sequence validation={globaldigisanalyze, globalhitsanalyze, MEtoEDMConverter}

This file can be found at CVS.

Harvesting analyzer

Code

In this section the pseudo code for a harvesting analyzer is shown. This is a special analyzer in where the analyze member function is never used and only endJob function is allowed to be redefined.

In this example, we concentrate in the creation of one ME that contains the results of dividing two histograms.

HarvestingAnalyzer::HarvestingAnalyzer(const edm::ParameterSet& iConfig) {...}

void HarvestingAnalyzer::endJob()
{
  // monitoring element numerator and denominator histogram
  MonitorElement * meN = dqmstore->get("ConverterTest/TH1F/Random1DN");
  MonitorElement * meD = dqmstore->get("ConverterTest/TH1F/Random1DD");

  if(meN && meD)
  {
    // get the numerator and denominator histogram      
    TH1F * numerator = meN->getTH1F();
    TH1F * denominator = meD->getTH1F();

    // set the current directory
    dqmstore->setCurrentFolder("ConverterTest/TH1F");

    // booked the new histogram to contain the result
    MonitorElement * me = dqmstore->book1D("Divide","Divide calculation",
      numerator->GetNbinsX(), numerator->GetXaxis()->GetXmin(), 
      numerator->GetXaxis()->GetXmax()
    );

    // Calculate the division between histograms.
    me->getTH1F()->Divide(numerator, denominator, 1., 1., "b");
  }
}

A full example can be found at CVS.

Once a harvesting analyzer is created then you have to declare it as a CMSSW module or plugin. For this you can create or edit SealModule.cc file and add the following

#include <DQMServices/Examples/interface/HarvestingAnalyzer.h>
DEFINE_ANOTHER_FWK_MODULE(HarvestingAnalyzer);

See as example CVS.

Compiling

For compiling go to the src directory of the release where the processor is located and run

src> scramv1 b

Cfg file

The following cfg file executes three modules : EDMtoMEConverter to extract the produced histograms, the harvesting analyzer to divide the produced histograms and finally the DQMFileSaver to save the extracted and calculated histograms to a ROOT file.

process EDMtoMEConvert =
{
    untracked PSet maxEvents = {untracked int32 input = -1}
  
    ## setup useful services
    include "DQMServices/Examples/test/MessageLogger.cfi"
      
    ## read in EDM file
    source = PoolSource
    {
       untracked vstring fileNames =
       {
         "file:Your_EDM_file.root"
       }
    }
    
    ## module EDMtoMEConverter
    include "DQMServices/Components/data/EDMtoMEConverter.cff"
    replace DQMStore.referenceFileName = ""

    include "DQMServices/Examples/test/HarvestingAnalyzer.cfi"
    
    ## for standard running
    replace dqmSaver.convention = "CMS.RelVal"
    replace dqmSaver.workflow = "/ConverterTester/Test/RECO"

    ## execute path
    ##
    path p1 = {
                EDMtoMEConverter, 
                harvestinganalyzer, 
                dqmSaver
    }
}

See as example CVS.

Reference

Review status

Reviewer/Editor and Date (copy from screen) Comments
Main.VictorBazterra - 03 Apr 2008 Wiki creation.
Main.VictorBazterra - 01 Jul 2008 Updating to the latest harvesting analyzer.

Responsible: Main.VictorBazterra
Last reviewed by: Main.VictorBazterra - 03 Apr 2008

Topic attachments
I Attachment History Action Size Date Who Comment
PDFpdf lpcphys_042408.pdf r1 manage 640.3 K 2008-07-01 - 21:19 VictorBazterra  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2008-07-01 - VictorBazterra
 
    • 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