Belle II Software  release-06-02-00
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 
11 using namespace std;
12 using namespace Belle2;
13 
14 //-----------------------------------------------------------------
15 // Register the Module
16 //-----------------------------------------------------------------
17 REG_MODULE(DQMHistAnalysisExample)
18 
19 //-----------------------------------------------------------------
20 // Implementation
21 //-----------------------------------------------------------------
22 
25 {
26  //Parameter definition
27  addParam("HistoName", m_histoname, "Name of Histogram (incl dir)", std::string(""));
28  addParam("Function", m_function, "Fit function definition", std::string("gaus"));
29  B2DEBUG(20, "DQMHistAnalysisExample: Constructor done.");
30 }
31 
32 
33 DQMHistAnalysisExampleModule::~DQMHistAnalysisExampleModule() { }
34 
35 void DQMHistAnalysisExampleModule::initialize()
36 {
37  B2DEBUG(20, "DQMHistAnalysisExample: initialized.");
38  TString a = m_histoname;
39  a.ReplaceAll("/", "_");
40  m_c = new TCanvas("c_" + a);
41  m_f = new TF1("f_" + a, TString(m_function), -100, 100);
42 }
43 
44 
45 void DQMHistAnalysisExampleModule::beginRun()
46 {
47  //B2DEBUG(20, "DQMHistAnalysisExample: beginRun called.");
48 }
49 
50 void DQMHistAnalysisExampleModule::event()
51 {
52  TH1* h = findHist(m_histoname);
53  if (h != NULL) {
54  m_c->Clear();
55  m_c->cd();
56  h->Fit(m_f, "R");
57  h->Draw();
58  m_c->Modified();
59  B2DEBUG(20, "mean " << m_f->GetParameter(1));
60  B2DEBUG(20, "sigma" << m_f->GetParameter(2));
61  } else {
62  B2DEBUG(20, "Histo " << m_histoname << " not found");
63  }
64 }
65 
66 void DQMHistAnalysisExampleModule::endRun()
67 {
68  B2DEBUG(20, "DQMHistAnalysisExample : endRun called");
69 }
70 
71 
72 void DQMHistAnalysisExampleModule::terminate()
73 {
74  B2DEBUG(20, "terminate called");
75 }
76 
Class definition for the output module of Sequential ROOT I/O.
The base class for the histogram analysis module.
#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.