Belle II Software development
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 header.
10#include <dqm/analysis/modules/DQMHistAnalysisMonObj.h>
11
12#include <TH1F.h>
13
14using namespace std;
15using namespace Belle2;
16
17//-----------------------------------------------------------------
18// Register module
19//-----------------------------------------------------------------
20
21REG_MODULE(DQMHistAnalysisMonObj);
22
25{
26 // set module description (e.g. insert text)
27 setDescription("Example module for making MonitoringObject in DQMHistAnalysis module");
29}
30
32{
33 // make monitoring object related to this module (use arich as an example)
34 // if monitoring object already exists this will return pointer to it
36
37 // make canvases to be added to MonitoringObject
38 m_c_main = new TCanvas("main");
39 m_c_mask = new TCanvas("mask");
40
41 // add canvases to MonitoringObject
42 m_monObj->addCanvas(m_c_main);
43 m_monObj->addCanvas(m_c_mask);
44}
45
46
48{
49
50 // get existing histograms produced by DQM modules
51 TH1* hits = findHist("ARICH/hitsPerEvent");
52 TH1* bits = findHist("ARICH/bits");
53
54 // set the content of main canvas
55 m_c_main->Clear(); // clear existing content
56 m_c_main->Divide(2, 1);
57 m_c_main->cd(1);
58 if (hits) hits->Draw();
59 m_c_main->cd(2);
60 if (bits) bits->Draw();
61
62 // set values of monitoring variables (if variable already exists this will change its value, otherwise it will insert new variable)
63 // with error (also asymmetric error can be used as m_monObj->setVariable(name, value, upError, downError))
64 m_monObj->setVariable("hitsPerEvent", hits ? hits->GetMean() : 0, hits ? hits->GetMeanError() : -1);
65 // without error
66 m_monObj->setVariable("bitsMean", bits ? bits->GetMean() : 0);
67
68 // set string variable
69 m_monObj->setVariable("mode", "nominal");
70
71
72 B2DEBUG(20, "DQMHistAnalysisMonObj : endRun called");
73}
74
76{
77
78 B2DEBUG(20, "terminate called");
79}
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
DQMHistAnalysisModule()
Constructor / Destructor.
void initialize() override final
Initialize the Module.
MonitoringObject * m_monObj
MonitoringObject to be produced by this module.
void terminate() override final
Termination action.
TCanvas * m_c_mask
Canvas with histograms related to channel masking.
TCanvas * m_c_main
Canvas with main run summary histograms.
void endRun() override final
End-of-run action.
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
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.