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