Belle II Software development
DQMHistAnalysisEventT0Efficiency.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 : DQMHistAnalysisEventT0Efficiency.h
10// Description : module for DQM histogram analysis of EventT0 algorithm efficiencies
11//-
12
13
14#include <dqm/analysis/modules/DQMHistAnalysisEventT0Efficiency.h>
15
16#include <TROOT.h>
17#include <TGraphAsymmErrors.h>
18#include <TStyle.h>
19
20using namespace Belle2;
21
22//-----------------------------------------------------------------
23// Register the Module
24//-----------------------------------------------------------------
25REG_MODULE(DQMHistAnalysisEventT0Efficiency);
26
27//-----------------------------------------------------------------
28// Implementation
29//-----------------------------------------------------------------
30
33{
34 setDescription("Calculate EventT0 algorithm efficiencies for the different trigger types, EventT0 algorithm sources, and event types (hadron, bhabha, ยตยต).");
35
36 //Parameter definition
37 addParam("min_nEntries", m_nEntriesMin, "Minimum number of entries to process the histogram.", m_nEntriesMin);
38 addParam("prefixCanvas", m_prefixCanvas, "Prefix to be added to canvas filename when saved as pdf.", std::string("c"));
39 addParam("printCanvas", m_printCanvas, "If true, prints pdf of the analysis canvas.", bool(false));
40}
41
42
44{
45 gROOT->cd();
46
47 // EventT0 source fractions
48 m_cT0FractionsHadronECLTRG = new TCanvas("EventT0/c_HadronECLTRG", "Fractions ECLTRG for hadron events");
49 m_cT0FractionsHadronCDCTRG = new TCanvas("EventT0/c_HadronCDCTRG", "Fractions CDCTRG for hadron events");
50 m_cT0FractionsHadronTOPTRG = new TCanvas("EventT0/c_HadronTOPTRG", "Fractions TOPTRG for hadron events");
51
52 m_cT0FractionsBhaBhaECLTRG = new TCanvas("EventT0/c_BhaBhaECLTRG", "Fractions ECLTRG for BhaBha events");
53 m_cT0FractionsBhaBhaCDCTRG = new TCanvas("EventT0/c_BhaBhaCDCTRG", "Fractions CDCTRG for BhaBha events");
54 m_cT0FractionsBhaBhaTOPTRG = new TCanvas("EventT0/c_BhaBhaTOPTRG", "Fractions TOPTRG for BhaBha events");
55
56 m_cT0FractionsMuMuECLTRG = new TCanvas("EventT0/c_MuMuECLTRG", "Fractions ECLTRG for #mu#mu events");
57 m_cT0FractionsMuMuCDCTRG = new TCanvas("EventT0/c_MuMuCDCTRG", "Fractions CDCTRG for #mu#mu events");
58 m_cT0FractionsMuMuTOPTRG = new TCanvas("EventT0/c_MuMuTOPTRG", "Fractions TOPTRG for #mu#mu events");
59
61 new TEfficiency("effAlgorithmSourceFractionsHadronL1ECLTRG",
62 "EventT0 source fractions, hadronic events, L1TRG timing from ECL;Algorithm;Fraction #epsilon",
63 6, 0, 6);
65 new TEfficiency("effAlgorithmSourceFractionsHadronL1CDCTRG",
66 "EventT0 source fractions, hadronic events, L1TRG timing from CDC;Algorithm;Fraction #epsilon",
67 6, 0, 6);
69 new TEfficiency("effAlgorithmSourceFractionsHadronL1TOPTRG",
70 "EventT0 source fractions, hadronic events, L1TRG timing from TOP;Algorithm;Fraction #epsilon",
71 6, 0, 6);
73 new TEfficiency("effAlgorithmSourceFractionsBhaBhaL1ECLTRG",
74 "EventT0 source fractions, Bhabha events, L1TRG timing from ECL;Algorithm;Fraction #epsilon",
75 6, 0, 6);
77 new TEfficiency("effAlgorithmSourceFractionsBhaBhaL1CDCTRG",
78 "EventT0 source fractions, Bhabha events, L1TRG timing from CDC;Algorithm;Fraction #epsilon",
79 6, 0, 6);
81 new TEfficiency("effAlgorithmSourceFractionsBhaBhaL1TOPTRG",
82 "EventT0 source fractions, Bhabha events, L1TRG timing from TOP;Algorithm;Fraction #epsilon",
83 6, 0, 6);
85 new TEfficiency("effAlgorithmSourceFractionsMuMuL1ECLTRG",
86 "EventT0 source fractions, #mu#mu events, L1TRG timing from ECL;Algorithm;Fraction #epsilon",
87 6, 0, 6);
89 new TEfficiency("effAlgorithmSourceFractionsMuMuL1CDCTRG",
90 "EventT0 source fractions, #mu#mu events, L1TRG timing from CDC;Algorithm;Fraction #epsilon",
91 6, 0, 6);
93 new TEfficiency("effAlgorithmSourceFractionsMuMuL1TOPTRG",
94 "EventT0 source fractions, #mu#mu events, L1TRG timing from TOP;Algorithm;Fraction #epsilon",
95 6, 0, 6);
96
97 m_monObj = getMonitoringObject("eventT0");
98}
99
100
113
115{
116 std::string histname = "AlgorithmSourceFractionsHadronL1ECLTRG";
119 m_cT0FractionsHadronECLTRG->SetFillColor(0);
120 m_cT0FractionsHadronECLTRG->Modified();
122 } else {
123 B2DEBUG(29, "Histogram EventT0 source fractions for hadrons from ECLTRG events (" << histname <<
124 ") from EventT0 DQM not processed!");
125 m_cT0FractionsHadronECLTRG->SetFillColor(kGray);
126 }
127
128 histname = "AlgorithmSourceFractionsHadronL1CDCTRG";
131 m_cT0FractionsHadronCDCTRG->SetFillColor(0);
132 m_cT0FractionsHadronCDCTRG->Modified();
134 } else {
135 B2DEBUG(29, "Histogram EventT0 source fractions for hadrons from CDCTRG events (" << histname <<
136 ") from EventT0 DQM not processed!");
137 m_cT0FractionsHadronCDCTRG->SetFillColor(kGray);
138 }
139
140 histname = "AlgorithmSourceFractionsHadronL1TOPTRG";
143 m_cT0FractionsHadronTOPTRG->SetFillColor(0);
144 m_cT0FractionsHadronTOPTRG->Modified();
146 } else {
147 B2DEBUG(29, "Histogram EventT0 source fractions for hadrons from TOPTRG events (" << histname <<
148 ") from EventT0 DQM not processed!");
149 m_cT0FractionsHadronTOPTRG->SetFillColor(kGray);
150 }
151
152
153 histname = "AlgorithmSourceFractionsBhaBhaL1ECLTRG";
156 m_cT0FractionsBhaBhaECLTRG->SetFillColor(0);
157 m_cT0FractionsBhaBhaECLTRG->Modified();
159 } else {
160 B2DEBUG(29, "Histogram EventT0 source fractions for BhaBha from ECLTRG events (" << histname <<
161 ") from EventT0 DQM not processed!");
162 m_cT0FractionsBhaBhaECLTRG->SetFillColor(kGray);
163 }
164
165 histname = "AlgorithmSourceFractionsBhaBhaL1CDCTRG";
168 m_cT0FractionsBhaBhaCDCTRG->SetFillColor(0);
169 m_cT0FractionsBhaBhaCDCTRG->Modified();
171 } else {
172 B2DEBUG(29, "Histogram EventT0 source fractions for BhaBha from CDCTRG events (" << histname <<
173 ") from EventT0 DQM not processed!");
174 m_cT0FractionsBhaBhaCDCTRG->SetFillColor(kGray);
175 }
176
177 histname = "AlgorithmSourceFractionsBhaBhaL1TOPTRG";
180 m_cT0FractionsBhaBhaTOPTRG->SetFillColor(0);
181 m_cT0FractionsBhaBhaTOPTRG->Modified();
183 } else {
184 B2DEBUG(29, "Histogram EventT0 source fractions for BhaBha from TOPTRG events (" << histname <<
185 ") from EventT0 DQM not processed!");
186 m_cT0FractionsBhaBhaTOPTRG->SetFillColor(kGray);
187 }
188
189
190 histname = "AlgorithmSourceFractionsMuMuL1ECLTRG";
193 m_cT0FractionsMuMuECLTRG->SetFillColor(0);
194 m_cT0FractionsMuMuECLTRG->Modified();
195 m_cT0FractionsMuMuECLTRG->Update();
196 } else {
197 B2DEBUG(29, "Histogram EventT0 source fractions for MuMu from ECLTRG events (" << histname << ") from EventT0 DQM not processed!");
198 m_cT0FractionsMuMuECLTRG->SetFillColor(kGray);
199 }
200
201 histname = "AlgorithmSourceFractionsMuMuL1CDCTRG";
204 m_cT0FractionsMuMuCDCTRG->SetFillColor(0);
205 m_cT0FractionsMuMuCDCTRG->Modified();
206 m_cT0FractionsMuMuCDCTRG->Update();
207 } else {
208 B2DEBUG(29, "Histogram EventT0 source fractions for MuMu from CDCTRG events (" << histname << ") from EventT0 DQM not processed!");
209 m_cT0FractionsMuMuCDCTRG->SetFillColor(kGray);
210 }
211
212 histname = "AlgorithmSourceFractionsMuMuL1TOPTRG";
215 m_cT0FractionsMuMuTOPTRG->SetFillColor(0);
216 m_cT0FractionsMuMuTOPTRG->Modified();
217 m_cT0FractionsMuMuTOPTRG->Update();
218 } else {
219 B2DEBUG(29, "Histogram EventT0 source fractions for MuMu from TOPTRG events (" << histname << ") from EventT0 DQM not processed!");
220 m_cT0FractionsMuMuTOPTRG->SetFillColor(kGray);
221 }
222
223 if (m_printCanvas) {
224 m_cT0FractionsHadronECLTRG->Print("EventT0_Algorithm_Efficiency.pdf(");
225 m_cT0FractionsHadronCDCTRG->Print("EventT0_Algorithm_Efficiency.pdf");
226 m_cT0FractionsHadronTOPTRG->Print("EventT0_Algorithm_Efficiency.pdf");
227
228 m_cT0FractionsBhaBhaECLTRG->Print("EventT0_Algorithm_Efficiency.pdf");
229 m_cT0FractionsBhaBhaCDCTRG->Print("EventT0_Algorithm_Efficiency.pdf");
230 m_cT0FractionsBhaBhaTOPTRG->Print("EventT0_Algorithm_Efficiency.pdf");
231
232 m_cT0FractionsMuMuECLTRG->Print("EventT0_Algorithm_Efficiency.pdf");
233 m_cT0FractionsMuMuCDCTRG->Print("EventT0_Algorithm_Efficiency.pdf");
234 m_cT0FractionsMuMuTOPTRG->Print("EventT0_Algorithm_Efficiency.pdf)");
235 }
236
237}
238
239
252
253
254bool DQMHistAnalysisEventT0EfficiencyModule::FillEfficiencyHistogram(const std::string& histname, TEfficiency* eff)
255{
256 B2DEBUG(20, "Begin processing histogram " << histname << " ...");
257 TH1* h = findHist("EventT0/" + histname);
258 if (not h) {
259 return false;
260 }
261
262 // Admittedly quite a hacky way to obtain the normalisation values: Create a new histogram and fill each of the bins with
263 // the bin content of the -1 bin of h which is used for bin counting, and at the same time set the corresponding bin label.
264 const auto totalEntries = h->GetBinContent(-1);
265 const auto nBins = h->GetNbinsX();
266 TH1D totalHist("total", "total;Algorithm;Fraction #epsilon", nBins, 0, nBins);
267 for (int i = 0; i < nBins; i++) {
268 totalHist.SetBinContent(i + 1, totalEntries);
269 }
270 eff->SetPassedHistogram(*h, "f");
271 eff->SetTotalHistogram(totalHist, "f"); // Clones thus no need to keep afterwards
272
273 eff->Paint("AP");
274
275 TGraphAsymmErrors* graph = eff->GetPaintedGraph();
276 if (not graph) {
277 return false;
278 }
279
280 auto ax = graph->GetXaxis();
281 if (not ax) {
282 return false;
283 }
284 // Print x-axis bin labels horizontally
285 ax->SetTitleOffset(1.0);
286 ax->CenterTitle(kTRUE);
287 ax->Set(nBins, 0, nBins);
288 for (int i = 0; i < nBins; i++) {
289 ax->SetBinLabel(i + 1, c_eventT0Algorithms[i]);
290 }
291
292 auto ay = graph->GetYaxis();
293 if (not ay) {
294 return false;
295 }
296 ay->SetTitleOffset(1.0);
297 ay->SetRangeUser(0, 1.05);
298
299 graph->Draw("AP");
300
301 B2DEBUG(20, "Finished processing histogram " << histname << "!");
302
303 return true;
304}
305
TEfficiency * m_eAlgorithmSourceFractionsMuMuL1ECLTRG
Fraction of events with EventT0 from a given algorithm, HLT mumu events, L1 time by ECL trigger.
void initialize() override final
create TCanvas and MonitoringObject
TEfficiency * m_eAlgorithmSourceFractionsBhaBhaL1ECLTRG
Fraction of events with EventT0 from a given algorithm, HLT bhabha events, L1 time by ECL trigger.
const char * c_eventT0Algorithms[6]
EventT0 algorithms for which to calculate fractions of abundance.
TCanvas * m_cT0FractionsMuMuECLTRG
Canvas for time fractions for ECLTRG mumu.
bool FillEfficiencyHistogram(const std::string &histname, TEfficiency *eff)
Fill the TEfficiency plots.
std::string m_prefixCanvas
prefix to be added to canvas name when saved as pdf
MonitoringObject * m_monObj
MonitoringObject to be produced by this module.
TCanvas * m_cT0FractionsBhaBhaCDCTRG
Canvas for time fractions for CDCTRG bhabhas.
TCanvas * m_cT0FractionsHadronCDCTRG
Canvas for time fractions for CDCTRG hadrons.
TEfficiency * m_eAlgorithmSourceFractionsBhaBhaL1CDCTRG
Fraction of events with EventT0 from a given algorithm, HLT bhabha events, L1 time by CDC trigger.
bool m_printCanvas
if true print the pdf of the canvases
TCanvas * m_cT0FractionsBhaBhaECLTRG
Canvas for time fractions for ECLTRG bhabhas.
uint m_nEntriesMin
minimum number of entries to process the histogram
TCanvas * m_cT0FractionsHadronECLTRG
Canvas for time fractions for ECLTRG hadrons.
TEfficiency * m_eAlgorithmSourceFractionsHadronL1ECLTRG
Fraction of events with EventT0 from a given algorithm, HLT hadronic events, L1 time by ECL trigger.
TCanvas * m_cT0FractionsMuMuTOPTRG
Canvas for time fractions for TOPTRG mumu.
TCanvas * m_cT0FractionsMuMuCDCTRG
Canvas for time fractions for CDCTRG mumu.
TEfficiency * m_eAlgorithmSourceFractionsHadronL1CDCTRG
Fraction of events with EventT0 from a given algorithm, HLT hadronic events, L1 time by CDC trigger.
TEfficiency * m_eAlgorithmSourceFractionsMuMuL1TOPTRG
Fraction of events with EventT0 from a given algorithm, HLT mumu events, L1 time by TOP trigger.
TCanvas * m_cT0FractionsHadronTOPTRG
Canvas for time fractions for TOPTRG hadrons.
TEfficiency * m_eAlgorithmSourceFractionsMuMuL1CDCTRG
Fraction of events with EventT0 from a given algorithm, HLT mumu events, L1 time by CDC trigger.
TEfficiency * m_eAlgorithmSourceFractionsBhaBhaL1TOPTRG
Fraction of events with EventT0 from a given algorithm, HLT bhabha events, L1 time by TOP trigger.
TEfficiency * m_eAlgorithmSourceFractionsHadronL1TOPTRG
Fraction of events with EventT0 from a given algorithm, HLT hadronic events, L1 time by TOP trigger.
TCanvas * m_cT0FractionsBhaBhaTOPTRG
Canvas for time fractions for TOPTRG bhabhas.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
DQMHistAnalysisModule()
Constructor / Destructor.
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:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.