Belle II Software development
DQMHistAnalysisExample.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#include <dqm/analysis/modules/DQMHistAnalysisExample.h>
10
11using namespace std;
12using namespace Belle2;
13
14//-----------------------------------------------------------------
15// Register the Module
16//-----------------------------------------------------------------
17REG_MODULE(DQMHistAnalysisExample);
18
19//-----------------------------------------------------------------
20// Implementation
21//-----------------------------------------------------------------
22
25{
26 setDescription("Example DQMHistAnalysisModule! with base features");
27
28 //Parameter definition
29 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of Histogram dir", std::string("test"));
30 addParam("histogramName", m_histogramName, "Name of Histogram", std::string("testHist"));
31 addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("DQM:TEST"));
32 B2DEBUG(20, "DQMHistAnalysisExample: Constructor done.");
33}
34
35
37{
38 // if this function is not needed, please remove
39}
40
42{
43 B2DEBUG(20, "DQMHistAnalysisExample: initialized.");
44 TString a = m_histogramName;
45 a.ReplaceAll("/", "_");
46 m_canvas = new TCanvas("c_" + a);
47 m_function = new TF1("f_" + a, TString("gaus"), -100, 100);
48}
49
51{
52 // if this function is not needed, please remove
53 B2DEBUG(20, "DQMHistAnalysisExample : beginRun called");
54}
55
57{
58 TH1* h = findHist(m_histogramName);
59 if (h != NULL) {
60 m_canvas->Clear();
61 m_canvas->cd();
62 h->Fit(m_function, "R");
63 h->Draw();
64 m_canvas->Modified();
65 B2DEBUG(20, "mean " << m_function->GetParameter(1));
66 B2DEBUG(20, "sigma" << m_function->GetParameter(2));
67 } else {
68 B2DEBUG(20, "Histo " << m_histogramName << " not found");
69 }
70}
71
73{
74 // if this function is not needed, please remove
75 B2DEBUG(20, "DQMHistAnalysisExample : endRun called");
76}
77
78
80{
81 // if this function is not needed, please remove
82 B2DEBUG(20, "terminate called");
83}
84
void initialize() override final
Initializer.
std::string m_histogramName
name of histogram
std::string m_pvPrefix
prefix for EPICS PVs
TCanvas * m_canvas
The drawing canvas for the fitting result.
void terminate() override final
This method is called at the end of the event processing.
void event() override final
This method is called for each event.
std::string m_histogramDirectoryName
Parameters accessible from basf2 scripts.
void endRun() override final
This method is called if the current run ends.
void beginRun() override final
Called when entering a new run.
The base class for the histogram analysis module.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.