Belle II Software  release-05-02-19
DQMHistAnalysisExampleFlags.cc
1 //+
2 // File : DQMHistAnalysisExampleFlags.cc
3 // Description : Example code, creates a new "flag" histo in DQM analysis
4 //
5 // Author : Bjoern Spruck, Univerisity Mainz
6 // Date : 2017
7 //-
8 
9 
10 #include <dqm/analysis/modules/DQMHistAnalysisExampleFlags.h>
11 #include <TROOT.h>
12 #include <TStyle.h>
13 
14 using namespace std;
15 using namespace Belle2;
16 
17 //-----------------------------------------------------------------
18 // Register the Module
19 //-----------------------------------------------------------------
20 REG_MODULE(DQMHistAnalysisExampleFlags)
21 
22 //-----------------------------------------------------------------
23 // Implementation
24 //-----------------------------------------------------------------
25 
28 {
29  //Parameter definition
30  B2DEBUG(20, "DQMHistAnalysisExampleFlags: Constructor done.");
31 }
32 
33 
34 void DQMHistAnalysisExampleFlagsModule::initialize()
35 {
36  B2DEBUG(20, "DQMHistAnalysisExampleFlags: initialized.");
37 
38  gROOT->cd(); // this seems to be important, or strange things happen
39  m_cFlagtest = new TCanvas("c_Flagtest");
40  m_hFlagtest = new TH2F("Flagtest", "Flagtest;xxx;yyy", 12, 0, 12, 4, 0, 4);
41 }
42 
43 
44 void DQMHistAnalysisExampleFlagsModule::beginRun()
45 {
46  B2DEBUG(20, "DQMHistAnalysisExampleFlags: beginRun called.");
47 
48  m_cFlagtest->Clear();
49  m_hFlagtest->Reset();
50 }
51 
52 void DQMHistAnalysisExampleFlagsModule::event()
53 {
54  m_hFlagtest->Reset(); // dont sum up!!!
55  static int nr = 0;
56  m_hFlagtest->Fill(nr + 0., 0., -2.);
57  m_hFlagtest->Fill(nr + 1., 1., -1.);
58  m_hFlagtest->Fill(nr + 2., 2., +1.);
59  m_hFlagtest->Fill(nr + 3., 3., +2.);
60  nr = (nr + 1) % 4;
61 
62  // search for hist is missing in this example look at Fitter code
63 
64  // doesnt change
65  const Int_t colNum = 5;
66  Int_t palette[colNum] {13 /* (dark) grey*/, 0 /* White*/ , 3 /* Green */, 5 /* Yellow */, 2 /* Red */};
67 
68  // Guess I have to set this for every update
69  gStyle->SetPalette(5, palette);
70 
71  // Nice try, but jsroot is not using the palette stored in canvas
72  // FIXED in jsroot 5.3.0 ... but this is not in externals yet
73  // needs root 6.12 ... until then no color palette is saved
74  if (m_cFlagtest) {
75  m_cFlagtest->cd();
76  m_cFlagtest->Clear();
77  if (m_hFlagtest) {
78  m_hFlagtest->Draw("colz"); // ,PFC,PLC,PMC
79 
80  }
81  m_cFlagtest->Modified();
82  m_cFlagtest->Update();
83  }
84 }
85 
86 void DQMHistAnalysisExampleFlagsModule::endRun()
87 {
88  B2DEBUG(20, "DQMHistAnalysisExampleFlags : endRun called");
89 }
90 
91 
92 void DQMHistAnalysisExampleFlagsModule::terminate()
93 {
94  B2DEBUG(20, "DQMHistAnalysisExampleFlags: terminate called");
95 
96  // should delete canvas here, maybe hist, too? Who owns it?
97 }
98 
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::DQMHistAnalysisExampleFlagsModule
Class definition for the output module of Sequential ROOT I/O.
Definition: DQMHistAnalysisExampleFlags.h:23
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DQMHistAnalysisModule
The base class for the histogram analysis module.
Definition: DQMHistAnalysis.h:27