Belle II Software development
PhysicsObjectsMiraBelleTauModule.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/modules/PhysicsObjectsMiraBelle/PhysicsObjectsMiraBelleTauModule.h>
10#include <analysis/dataobjects/ParticleList.h>
11#include <framework/datastore/StoreObjPtr.h>
12#include <framework/datastore/StoreArray.h>
13#include <mdst/dataobjects/TRGSummary.h>
14#include <mdst/dataobjects/SoftwareTriggerResult.h>
15#include <TDirectory.h>
16#include <TMath.h>
17
18#include <cmath>
19#include <map>
20
21using namespace Belle2;
22
23REG_MODULE(PhysicsObjectsMiraBelleTau);
24
26{
27 setDescription("Monitor Physics Objects Quality");
29
30 addParam("TriggerIdentifierTau2trk", m_triggerIdentifierTau2trk,
31 "Trigger identifier string used to select 1x1 tau mode for the histograms",
32 std::string("software_trigger_cut&skim&accept_tau_2trk"));
33 addParam("TriggerIdentifierTauNtrk", m_triggerIdentifierTauNtrk,
34 "Trigger identifier string used to select 1x3 tau mode for the histograms",
35 std::string("software_trigger_cut&skim&accept_tau_Ntrk"));
36 addParam("tautau1x1PListName", m_tautau1x1PListName, "Name of the Z0 list reconstructed from 1x1 topology of tau decays",
37 std::string("Z0:physMiraBelleTau1x1"));
38 addParam("tautau1x3PListName", m_tautau1x3PListName, "Name of the Z0 list reconstructed from 1x3 topology of tau decays",
39 std::string("Z0:physMiraBelleTau1x3"));
40
41}
42
44{
45 TDirectory* oldDir = gDirectory;
46 oldDir->mkdir("PhysicsObjectsMiraBelleTau");
47 oldDir->cd("PhysicsObjectsMiraBelleTau");
48
49 // Create histograms for efficiency of ECL bits
50 m_h_L1ECL1x1 = new TH1F("hist_L1ECL1x1", "hist_L1ECL1x1", 30, 0, 30);
51 m_h_L1ECL1x1->GetXaxis()->SetBinLabel(1, "fff_or_ffo");
52 m_h_L1ECL1x3 = new TH1F("hist_L1ECL1x3", "hist_L1ECL1x3", 30, 0, 30);
53 m_h_L1ECL1x3->GetXaxis()->SetBinLabel(1, "fff_or_ffo");
54
55 int bin = 2;
56
57 // ECL bits
58 for (const auto& bit : m_ECLTrgBit) {
59 m_h_L1ECL1x1->GetXaxis()->SetBinLabel(bin, bit.c_str());
60 m_h_L1ECL1x3->GetXaxis()->SetBinLabel(bin, bit.c_str());
61 ++bin;
62 }
63
64 // Create histograms for efficiency of CDC bits
65 m_h_L1CDC1x1 = new TH1F("hist_L1CDC1x1", "hist_L1CDC1x1", 30, 0, 30);
66 m_h_L1CDC1x1->GetXaxis()->SetBinLabel(1, "hie_or_c4_or_eclmumu");
67 m_h_L1CDC1x3 = new TH1F("hist_L1CDC1x3", "hist_L1CDC1x3", 30, 0, 30);
68 m_h_L1CDC1x3->GetXaxis()->SetBinLabel(1, "hie_or_c4_or_eclmumu");
69
70 bin = 2;
71
72 // CDC bits
73 for (const auto& bit : m_CDCTrgBit) {
74 m_h_L1CDC1x1->GetXaxis()->SetBinLabel(bin, bit.c_str());
75 m_h_L1CDC1x3->GetXaxis()->SetBinLabel(bin, bit.c_str());
76 ++bin;
77 }
78
79 // Create histograms for efficiency of CDC-KLM bits
80 m_h_L1CDCKLM1x1 = new TH1F("hist_L1CDCKLM1x1", "hist_L1CDCKLM1x1", 30, 0, 30);
81 m_h_L1CDCKLM1x1->GetXaxis()->SetBinLabel(1, "hie_or_c4_or_eclmumu");
82 m_h_L1CDCKLM1x3 = new TH1F("hist_L1CDCKLM1x3", "hist_L1CDCKLM1x3", 30, 0, 30);
83 m_h_L1CDCKLM1x3->GetXaxis()->SetBinLabel(1, "hie_or_c4_or_eclmumu");
84
85 bin = 2;
86
87 // CDC-KLM bits
88 for (const auto& bit : m_CDCKLMTrgBit) {
89 m_h_L1CDCKLM1x1->GetXaxis()->SetBinLabel(bin, bit.c_str());
90 m_h_L1CDCKLM1x3->GetXaxis()->SetBinLabel(bin, bit.c_str());
91 ++bin;
92 }
93
94
95 oldDir->cd();
96}
97
98
100{
101 REG_HISTOGRAM
102
104 result.isOptional();
105}
106
108{
109 m_h_L1ECL1x1->Reset();
110 m_h_L1ECL1x3->Reset();
111 m_h_L1CDC1x1->Reset();
112 m_h_L1CDC1x3->Reset();
113 m_h_L1CDCKLM1x1->Reset();
114 m_h_L1CDCKLM1x3->Reset();
115
116}
117
119{
120
122 if (!result.isValid()) {
123 B2WARNING("SoftwareTriggerResult object not available but needed to select events for the histograms.");
124 return;
125 }
126
127 const std::map<std::string, int>& results = result->getResults();
128
129 StoreObjPtr<TRGSummary> m_trgSummary;
130 if (m_trgSummary.isValid()) {
131 try {
132 m_ECL_ref = (m_trgSummary->testFtdl("hie") || m_trgSummary->testFtdl("c4") || m_trgSummary->testFtdl("eclmumu"));
133 } catch (const std::exception&) {
134 m_ECL_ref = false;
135 }
136 try {
137 m_CDC_ref = (m_trgSummary->testFtdl("fff") || m_trgSummary->testFtdl("ffo"));
138 } catch (const std::exception&) {
139 m_CDC_ref = false;
140 }
141 }
142
143
144 //--- Monitor efficiency of L1 bits with 1x1 tau pairs ---//
145 if (results.find(m_triggerIdentifierTau2trk) == results.end()) {
146 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierTau2trk);
147 } else {
148
149 //Get 1x1 tau pairs for L1 efficiency calculation
151 if (Z0Particles1x1.isValid()) {
152 for (unsigned int i = 0; i < Z0Particles1x1->getListSize(); i++) {
153 // Fill ECL histogram
154 // Reference: CDC bits (fff||ffo), Target: ECL bits
155 // Bin x=1: N(reference), Bin x>1: N(reference&&target) [Efficiency of ECL bit in x>1 bin = N(x>1)/N(x=1)]
156 if (m_CDC_ref)
157 m_h_L1ECL1x1->Fill(0);
158 int bin = 1;
159 // Loop over ECL bits
160 for (const auto& bit : m_ECLTrgBit) {
161 if (m_trgSummary.isValid()) {
162 bool m_ECL_target = false;
163 try {
164 m_ECL_target = m_trgSummary->testFtdl(bit.c_str());
165 } catch (const std::exception&) {
166 m_ECL_target = false;
167 }
168
169 if (m_CDC_ref && m_ECL_target)
170 m_h_L1ECL1x1->Fill(bin);
171 }
172 bin++;
173 }
174
175 // Fill CDC histogram
176 // Reference: ECL bits (hie||c4||eclmumu), Target: CDC bits
177 // Bin x=1: N(reference), Bin x>1: N(reference&&target) [Efficiency of CDC bit in x>1 bin = N(x>1)/N(x=1)]
178 if (m_ECL_ref)
179 m_h_L1CDC1x1->Fill(0);
180 bin = 1;
181 // Loop over CDC bits
182 for (const auto& bit : m_CDCTrgBit) {
183 if (m_trgSummary.isValid()) {
184 bool m_CDC_target = false;
185 try {
186 m_CDC_target = m_trgSummary->testFtdl(bit.c_str());
187 } catch (const std::exception&) {
188 m_CDC_target = false;
189 }
190
191 if (m_ECL_ref && m_CDC_target)
192 m_h_L1CDC1x1->Fill(bin);
193 }
194 bin++;
195 }
196
197 // Fill CDC-KLM histogram
198 // Reference: ECL bits (hie||c4||eclmumu), Target: CDC-KLM bits
199 // Bin x=1: N(reference), Bin x>1: N(reference&&target) [Efficiency of CDC-KLM bit in x>1 bin = N(x>1)/N(x=1)]
200 if (m_ECL_ref)
201 m_h_L1CDCKLM1x1->Fill(0);
202 bin = 1;
203 // Loop over CDC bits
204 for (const auto& bit : m_CDCKLMTrgBit) {
205 if (m_trgSummary.isValid()) {
206 bool m_CDCKLM_target = false;
207 try {
208 m_CDCKLM_target = m_trgSummary->testFtdl(bit.c_str());
209 } catch (const std::exception&) {
210 m_CDCKLM_target = false;
211 }
212
213 if (m_ECL_ref && m_CDCKLM_target)
214 m_h_L1CDCKLM1x1->Fill(bin);
215 }
216 bin++;
217 }
218
219 }
220
221 }
222
223 }
224
225 //--- Monitor efficiency of L1 bits with 1x3 tau pairs ---//
226 if (results.find(m_triggerIdentifierTauNtrk) == results.end()) {
227 B2WARNING("PhysicsObjectsDQM: Can't find trigger identifier: " << m_triggerIdentifierTauNtrk);
228 } else {
229
230 //Get 1x3 tau pairs for L1 efficiency calculation
232 if (Z0Particles1x3.isValid()) {
233 for (unsigned int i = 0; i < Z0Particles1x3->getListSize(); i++) {
234 // Fill ECL histogram
235 // Reference: CDC bits (fff||ffo), Target: ECL bits
236 // Bin x=1: N(reference), Bin x>1: N(reference&&target) [Efficiency of ECL bit in x>1 bin = N(x>1)/N(x=1)]
237 if (m_CDC_ref)
238 m_h_L1ECL1x3->Fill(0);
239 int bin = 1;
240 // Loop over ECL bits
241 for (const auto& bit : m_ECLTrgBit) {
242 if (m_trgSummary.isValid()) {
243 bool m_ECL_target = false;
244 try {
245 m_ECL_target = m_trgSummary->testFtdl(bit.c_str());
246 } catch (const std::exception&) {
247 m_ECL_target = false;
248 }
249
250 if (m_CDC_ref && m_ECL_target)
251 m_h_L1ECL1x3->Fill(bin);
252 }
253 bin++;
254 }
255 // Fill CDC histogram
256 // Reference: ECL bits (hie||c4||eclmumu), Target: CDC bits
257 // Bin x=1: N(reference), Bin x>1: N(reference&&target) [Efficiency of CDC bit in x>1 bin = N(x>1)/N(x=1)]
258 if (m_ECL_ref)
259 m_h_L1CDC1x3->Fill(0);
260 bin = 1;
261 // Loop over CDC bits
262 for (const auto& bit : m_CDCTrgBit) {
263 if (m_trgSummary.isValid()) {
264 bool m_CDC_target = false;
265 try {
266 m_CDC_target = m_trgSummary->testFtdl(bit.c_str());
267 } catch (const std::exception&) {
268 m_CDC_target = false;
269 }
270
271 if (m_ECL_ref && m_CDC_target)
272 m_h_L1CDC1x3->Fill(bin);
273 }
274 bin++;
275 }
276 // Fill CDC-KLM histogram
277 // Reference: ECL bits (hie||c4||eclmumu), Target: CDC-KLM bits
278 // Bin x=1: N(reference), Bin x>1: N(reference&&target) [Efficiency of CDC-KLM bit in x>1 bin = N(x>1)/N(x=1)]
279 if (m_ECL_ref)
280 m_h_L1CDCKLM1x3->Fill(0);
281 bin = 1;
282 // Loop over CDC bits
283 for (const auto& bit : m_CDCKLMTrgBit) {
284 if (m_trgSummary.isValid()) {
285 bool m_CDCKLM_target = false;
286 try {
287 m_CDCKLM_target = m_trgSummary->testFtdl(bit.c_str());
288 } catch (const std::exception&) {
289 m_CDCKLM_target = false;
290 }
291
292 if (m_ECL_ref && m_CDCKLM_target)
293 m_h_L1CDCKLM1x3->Fill(bin);
294 }
295 bin++;
296 }
297 }
298 }
299 }
300}
301
HistoModule()
Constructor.
Definition HistoModule.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
std::string m_tautau1x3PListName
Name of the tau+tau- (1x3) particle list.
TH1F * m_h_L1ECL1x1
histogram for efficiency of ECL TRG bits using 1x1 prong tau pairs
TH1F * m_h_L1ECL1x3
histogram for efficiency of ECL TRG bits using 1x3 prong tau pairs
std::string m_triggerIdentifierTauNtrk
Trigger identifier string used to select 1x3 tau pairs for the histograms.
void event() override
This method is called for each event.
TH1F * m_h_L1CDCKLM1x3
histogram for efficiency of CDC-KLM TRG bits using 1x3 prong tau pairs
std::array< std::string, 9 > m_CDCTrgBit
Array of CDC trigger bits.
TH1F * m_h_L1CDC1x1
histogram for efficiency of CDC TRG bits using 1x1 prong tau pairs
TH1F * m_h_L1CDCKLM1x1
histogram for efficiency of CDC-KLM TRG bits using 1x1 prong tau pairs
void beginRun() override
Called when entering a new run.
TH1F * m_h_L1CDC1x3
histogram for efficiency of CDC TRG bits using 1x3 prong tau pairs
std::string m_tautau1x1PListName
Name of the tau+tau- (1x1) particle list.
std::string m_triggerIdentifierTau2trk
Trigger identifier string used to select 1x1 tau pairs for the histograms.
std::array< std::string, 13 > m_ECLTrgBit
Array of ECL trigger bits.
bool m_ECL_ref
Reference bits for L1 Trigger efficiency monitor.
std::array< std::string, 17 > m_CDCKLMTrgBit
Array of KLM and CDC-KLM bits.
void defineHisto() override
Definition of the histograms.
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
bool isValid() const
Check whether the object was created.
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.