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