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}
34
36{
37 // make monitoring object related to this module (use arich as an example)
38 // if monitoring object already exists this will return pointer to it
40
41 // make canvases to be added to MonitoringObject
42 m_c_main = new TCanvas("main");
43 m_c_mask = new TCanvas("mask");
44
45 // add canvases to MonitoringObject
48}
49
50
52{
53
54 // get existing histograms produced by DQM modules
55 TH1* hits = findHist("ARICH/hitsPerEvent");
56 TH1* bits = findHist("ARICH/bits");
57
58 // set the content of main canvas
59 m_c_main->Clear(); // clear existing content
60 m_c_main->Divide(2, 1);
61 m_c_main->cd(1);
62 if (hits) hits->Draw();
63 m_c_main->cd(2);
64 if (bits) bits->Draw();
65
66 // set values of monitoring variables (if variable already exists this will change its value, otherwise it will insert new variable)
67 // with error (also asymmetric error can be used as m_monObj->setVariable(name, value, upError, downError))
68 m_monObj->setVariable("hitsPerEvent", hits ? hits->GetMean() : 0, hits ? hits->GetMeanError() : -1);
69 // without error
70 m_monObj->setVariable("bitsMean", bits ? bits->GetMean() : 0);
71
72 // set string variable
73 m_monObj->setVariable("mode", "nominal");
74
75
76 B2DEBUG(20, "DQMHistAnalysisMonObj : endRun called");
77}
78
80{
81
82 B2DEBUG(20, "terminate called");
83}
The base class for the histogram analysis module.
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).
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
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.
STL namespace.