Belle II Software  release-06-01-15
DQMHistAnalysisMonObj.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 // Own include
10 #include <dqm/analysis/modules/DQMHistAnalysisMonObj.h>
11 
12 //DQM
13 #include <dqm/analysis/modules/DQMHistAnalysis.h>
14 
15 #include <TH1F.h>
16 
17 using namespace std;
18 using namespace Belle2;
19 
20 //-----------------------------------------------------------------
21 // Register module
22 //-----------------------------------------------------------------
23 
24 REG_MODULE(DQMHistAnalysisMonObj);
25 
26 DQMHistAnalysisMonObjModule::DQMHistAnalysisMonObjModule()
28 {
29  // set module description (e.g. insert text)
30  setDescription("Example module for making MonitoringObject in DQMHistAnalysis module");
32 }
33 
35 {
36 }
37 
39 {
40  // make monitoring object related to this module (use arich as an example)
41  // if monitoring object already exists this will return pointer to it
42  m_monObj = getMonitoringObject("arich");
43 
44  // make canvases to be added to MonitoringObject
45  m_c_main = new TCanvas("main");
46  m_c_mask = new TCanvas("mask");
47 
48  // add canvases to MonitoringObject
51 }
52 
54 {
55 }
56 
58 {
59  // can put the analysis code here or in endRun() function
60  // for the start tests we will store output only end of run so better to put code there
61 }
62 
64 {
65 
66  // get existing histograms produced by DQM modules
67  TH1* hits = findHist("ARICH/hitsPerEvent");
68  TH1* bits = findHist("ARICH/bits");
69 
70  // set the content of main canvas
71  m_c_main->Clear(); // clear existing content
72  m_c_main->Divide(2, 1);
73  m_c_main->cd(1);
74  if (hits) hits->Draw();
75  m_c_main->cd(2);
76  if (bits) bits->Draw();
77 
78  // set values of monitoring variables (if variable already exists this will change its value, otherwise it will insert new variable)
79  // with error (also asymmetric error can be used as m_monObj->setVariable(name, value, upError, downError))
80  m_monObj->setVariable("hitsPerEvent", hits ? hits->GetMean() : 0, hits ? hits->GetMeanError() : -1);
81  // without error
82  m_monObj->setVariable("bitsMean", bits ? bits->GetMean() : 0);
83 
84  // set string variable
85  m_monObj->setVariable("mode", "nominal");
86 
87 
88  B2DEBUG(20, "DQMHistAnalysisMonObj : endRun called");
89 }
90 
92 {
93 
94  B2DEBUG(20, "terminate called");
95 }
The base class for the histogram analysis module.
static TH1 * findHist(const std::string &histname)
Find histogram.
static MonitoringObject * getMonitoringObject(const std::string &histname)
Get MonitoringObject with given name (new object is created if non-existing)
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
MonitoringObject * m_monObj
MonitoringObject to be produced by this module.
TCanvas * m_c_mask
Canvas with histograms related to channel masking.
virtual void beginRun() override
Begin run function.
TCanvas * m_c_main
Canvas with main run summary histograms.
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
void addCanvas(TCanvas *canv)
Add Canvas to monitoring object.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.