Belle II Software  release-06-00-14
EventT0DQM.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 <reconstruction/modules/EventT0DQM/EventT0DQM.h>
10 #include <framework/core/HistoModule.h>
11 
12 using namespace Belle2;
13 
14 REG_MODULE(EventT0DQM)
15 
16 //---------------------------------
18 {
19  setPropertyFlags(c_ParallelProcessingCertified); // parallel processing
20  setDescription("Make data quality monitoring plots for event t0 for bhabha, mu mu, and hadron samples seeded by different trigger times.");
21 }
22 
23 //---------------------------------
25 
26 
27 //---------------------------------
29 {
30 
31  TDirectory* oldDir = gDirectory;
32  oldDir->mkdir("EventT0DQMdir")->cd();
33 
34  int nBins = 400 ;
35  double minT0 = -100 ;
36  double maxT0 = 100 ;
37 
38  m_histEventT0_ECL_bhabha_L1_ECLTRG = new TH1F("m_histEventT0_ECL_bhabha_L1_ECLTRG",
39  "ECL event t0 - bhabhas - ECLTRG time;event t0 [ns];events / 0.5 ns",
40  nBins, minT0, maxT0);
41  m_histEventT0_CDC_bhabha_L1_ECLTRG = new TH1F("m_histEventT0_CDC_bhabha_L1_ECLTRG",
42  "CDC event t0 - bhabhas - ECLTRG time;event t0 [ns];events / 0.5 ns",
43  nBins, minT0, maxT0);
44  m_histEventT0_TOP_bhabha_L1_ECLTRG = new TH1F("m_histEventT0_TOP_bhabha_L1_ECLTRG",
45  "TOP event t0 - bhabhas - ECLTRG time;event t0 [ns];events / 0.5 ns",
46  nBins, minT0, maxT0);
47  m_histEventT0_ECL_hadron_L1_ECLTRG = new TH1F("m_histEventT0_ECL_hadron_L1_ECLTRG",
48  "ECL event t0 - hadrons - ECLTRG time;event t0 [ns];events / 0.5 ns",
49  nBins, minT0, maxT0);
50  m_histEventT0_CDC_hadron_L1_ECLTRG = new TH1F("m_histEventT0_CDC_hadron_L1_ECLTRG",
51  "CDC event t0 - hadrons - ECLTRG time;event t0 [ns];events / 0.5 ns",
52  nBins, minT0, maxT0);
53  m_histEventT0_TOP_hadron_L1_ECLTRG = new TH1F("m_histEventT0_TOP_hadron_L1_ECLTRG",
54  "TOP event t0 - hadrons - ECLTRG time;event t0 [ns];events / 0.5 ns",
55  nBins, minT0, maxT0);
56  m_histEventT0_ECL_mumu_L1_ECLTRG = new TH1F("m_histEventT0_ECL_mumu_L1_ECLTRG",
57  "ECL event t0 - mu mu - ECLTRG time;event t0 [ns];events / 0.5 ns",
58  nBins, minT0, maxT0);
59  m_histEventT0_CDC_mumu_L1_ECLTRG = new TH1F("m_histEventT0_CDC_mumu_L1_ECLTRG",
60  "CDC event t0 - mu mu - ECLTRG time;event t0 [ns];events / 0.5 ns",
61  nBins, minT0, maxT0);
62  m_histEventT0_TOP_mumu_L1_ECLTRG = new TH1F("m_histEventT0_TOP_mumu_L1_ECLTRG",
63  "TOP event t0 - mu mu - ECLTRG time;event t0 [ns];events / 0.5 ns",
64  nBins, minT0, maxT0);
65 
66 
67 
68 
69 
70  m_histEventT0_ECL_bhabha_L1_CDCTRG = new TH1F("m_histEventT0_ECL_bhabha_L1_CDCTRG",
71  "ECL event t0 - bhabhas - CDCTRG time;event t0 [ns];events / 0.5 ns",
72  nBins, minT0, maxT0);
73  m_histEventT0_CDC_bhabha_L1_CDCTRG = new TH1F("m_histEventT0_CDC_bhabha_L1_CDCTRG",
74  "CDC event t0 - bhabhas - CDCTRG time;event t0 [ns];events / 0.5 ns",
75  nBins, minT0, maxT0);
76  m_histEventT0_TOP_bhabha_L1_CDCTRG = new TH1F("m_histEventT0_TOP_bhabha_L1_CDCTRG",
77  "TOP event t0 - bhabhas - CDCTRG time;event t0 [ns];events / 0.5 ns",
78  nBins, minT0, maxT0);
79  m_histEventT0_ECL_hadron_L1_CDCTRG = new TH1F("m_histEventT0_ECL_hadron_L1_CDCTRG",
80  "ECL event t0 - hadrons - CDCTRG time;event t0 [ns];events / 0.5 ns",
81  nBins, minT0, maxT0);
82  m_histEventT0_CDC_hadron_L1_CDCTRG = new TH1F("m_histEventT0_CDC_hadron_L1_CDCTRG",
83  "CDC event t0 - hadrons - CDCTRG time;event t0 [ns];events / 0.5 ns",
84  nBins, minT0, maxT0);
85  m_histEventT0_TOP_hadron_L1_CDCTRG = new TH1F("m_histEventT0_TOP_hadron_L1_CDCTRG",
86  "TOP event t0 - hadrons - CDCTRG time;event t0 [ns];events / 0.5 ns",
87  nBins, minT0, maxT0);
88  m_histEventT0_ECL_mumu_L1_CDCTRG = new TH1F("m_histEventT0_ECL_mumu_L1_CDCTRG",
89  "ECL event t0 - mu mu - CDCTRG time;event t0 [ns];events / 0.5 ns",
90  nBins, minT0, maxT0);
91  m_histEventT0_CDC_mumu_L1_CDCTRG = new TH1F("m_histEventT0_CDC_mumu_L1_CDCTRG",
92  "CDC event t0 - mu mu - CDCTRG time;event t0 [ns];events / 0.5 ns",
93  nBins, minT0, maxT0);
94  m_histEventT0_TOP_mumu_L1_CDCTRG = new TH1F("m_histEventT0_TOP_mumu_L1_CDCTRG",
95  "TOP event t0 - mu mu - CDCTRG time;event t0 [ns];events / 0.5 ns",
96  nBins, minT0, maxT0);
97 
98  oldDir->cd();
99 
100 }
101 
102 
103 //---------------------------------
105 {
106 
107  m_TrgResult.isOptional();
108  m_eventT0.isOptional();
109 
110  REG_HISTOGRAM
111 
112 }
113 
114 
115 
116 //---------------------------------
118 {
119  if (!m_eventT0.isValid()) {
120  B2WARNING("Missing event t0, EventT0DQM is skipped.");
121  return;
122  }
123 
124  if (!m_TrgResult.isValid()) {
125  B2WARNING("Missing SoftwareTriggerResult, EventT0DQM is skipped.");
126  return;
127  }
128 
138 
148 
149 }
150 
151 
152 //---------------------------------
154 {
155  if (!m_objTrgSummary.isValid()) {
156  B2WARNING("TRGSummary object not available but required to indicate which detector provided the L1 trigger time");
157  return;
158  } else {
159  m_L1TimingSrc = m_objTrgSummary->getTimType();
160  }
161 
162  bool Is_ECL_L1TriggerSource = false ;
163  bool Is_CDC_L1TriggerSource = false ;
164  if (m_L1TimingSrc == 0) { // for L1 timing source is "ecl trigger"
165  Is_ECL_L1TriggerSource = true ;
166  } else if (m_L1TimingSrc == 3) { // for L1 timing source is "cdc trigger"
167  Is_CDC_L1TriggerSource = true ;
168  }
169  // else if(m_L1TimingSrc==5){ // for L1 timing source is "delayed Bhabha" }
170  B2DEBUG(20, "Is_ECL_L1TriggerSource = " << Is_ECL_L1TriggerSource) ;
171  B2DEBUG(20, "Is_CDC_L1TriggerSource= " << Is_CDC_L1TriggerSource) ;
172 
173 
174  if (!m_TrgResult.isValid()) {
175  B2WARNING("SoftwareTriggerResult object not available but require to select bhabha/mumu/hadron events for this module");
176  return;
177  }
178 
179  const std::map<std::string, int>& fresults = m_TrgResult->getResults();
180  if ((fresults.find("software_trigger_cut&skim&accept_bhabha") == fresults.end()) ||
181  (fresults.find("software_trigger_cut&skim&accept_mumu_2trk") == fresults.end()) ||
182  (fresults.find("software_trigger_cut&skim&accept_hadron") == fresults.end())) {
183  B2WARNING("EventT0DQMModule: Can't find required bhabha or mumu or hadron trigger identifier");
184  return;
185  }
186 
187 
188 
189  // Skip this event if there is no event t0, to avoid crashing other DQM
190  if (!m_eventT0.isOptional()) {
191  B2WARNING("Missing event t0, EventT0DQM is skipped.");
192  return;
193  }
194 
195  // Determine if there is a valid event t0 to use and then extract the information about it
196  if (!m_eventT0.isValid()) {
197  return ;
198  }
199 
200  // determine if the event was part of the hadron skim or bhabha skim or mumu skim
201  const bool IsEvtAcceptedBhabha = (m_TrgResult->getResult("software_trigger_cut&skim&accept_bhabha") ==
203  const bool IsEvtAcceptedHadron = (m_TrgResult->getResult("software_trigger_cut&skim&accept_hadron") ==
205  const bool IsEvtAcceptedMumu = (m_TrgResult->getResult("software_trigger_cut&skim&accept_mumu_2trk") ==
207 
208 
209  B2DEBUG(20, "bhabha trigger result = " << static_cast<std::underlying_type<SoftwareTriggerCutResult>::type>
210  (m_TrgResult->getResult("software_trigger_cut&skim&accept_bhabha"))) ;
211  B2DEBUG(20, "hadron trigger result = " << static_cast<std::underlying_type<SoftwareTriggerCutResult>::type>
212  (m_TrgResult->getResult("software_trigger_cut&skim&accept_hadron"))) ;
213  B2DEBUG(20, "mu mu trigger result = " << static_cast<std::underlying_type<SoftwareTriggerCutResult>::type>
214  (m_TrgResult->getResult("software_trigger_cut&skim&accept_mumu_2trk"))) ;
215  B2DEBUG(20, "bhabha trigger comparison bool = " << IsEvtAcceptedBhabha) ;
216  B2DEBUG(20, "hadron trigger comparison bool = " << IsEvtAcceptedHadron) ;
217  B2DEBUG(20, "mumu trigger comparison bool = " << IsEvtAcceptedMumu) ;
218 
219 
220  // default values of the event t0 given that there may not be a value for every event depending on the detector measuring it.
221  double eventT0_ECL = -1000 ;
222  double eventT0_CDC = -1000 ;
223  double eventT0_TOP = -1000 ;
224 
225  // Set the CDC event t0 value if it exists
226  if (m_eventT0->hasTemporaryEventT0(Const::EDetector::CDC)) {
227  auto evtT0List_CDC = m_eventT0->getTemporaryEventT0s(Const::EDetector::CDC) ;
228 
229  // set the CDC event t0 value for filling into the histogram
230  // The most accurate CDC event t0 value is the last one in the list.
231  eventT0_CDC = evtT0List_CDC.back().eventT0 ;
232  }
233 
234  // Set the ECL event t0 value if it exists
235  if (m_eventT0->hasTemporaryEventT0(Const::EDetector::ECL)) {
236  // Get the list of ECL event t0 values. There are several event t0 values, not just one.
237  auto evtT0List_ECL = m_eventT0->getTemporaryEventT0s(Const::EDetector::ECL) ;
238 
239  // Select the event t0 value from the ECL as the one with the smallest chi squared value (defined as ".quality")
240  double smallest_ECL_t0_minChi2 = evtT0List_ECL[0].quality ;
241  int smallest_ECL_t0_minChi2_idx = 0 ;
242  for (long unsigned int ECLi = 0; ECLi < evtT0List_ECL.size(); ECLi++) {
243  if (evtT0List_ECL[ECLi].quality < smallest_ECL_t0_minChi2) {
244  smallest_ECL_t0_minChi2 = evtT0List_ECL[ECLi].quality ;
245  smallest_ECL_t0_minChi2_idx = ECLi ;
246  }
247  }
248  // set the ECL event t0 value for filling into the histogram
249  // It is the value found to have the small chi square
250  eventT0_ECL = evtT0List_ECL[smallest_ECL_t0_minChi2_idx].eventT0 ;
251  }
252 
253  // Set the TOP event t0 value if it exists
254  if (m_eventT0->hasTemporaryEventT0(Const::EDetector::TOP)) {
255  auto evtT0List_TOP = m_eventT0->getTemporaryEventT0s(Const::EDetector::TOP) ;
256 
257  // set the TOP event t0 value for filling into the histogram
258  // There should only be at most one value in the list per event
259  eventT0_TOP = evtT0List_TOP.back().eventT0 ;
260  }
261 
262 
263 
264 
265  // Fill the plots that used the ECL trigger as the L1 timing source
266  if (Is_ECL_L1TriggerSource) {
267  // Fill the histograms with the event t0 values
268  if (IsEvtAcceptedBhabha) { // fill the bha bha skim event t0s
269  m_histEventT0_ECL_bhabha_L1_ECLTRG->Fill(eventT0_ECL);
270  m_histEventT0_CDC_bhabha_L1_ECLTRG->Fill(eventT0_CDC);
271  m_histEventT0_TOP_bhabha_L1_ECLTRG->Fill(eventT0_TOP);
272  }
273 
274  if (IsEvtAcceptedHadron) { // fill the hadron skim event t0s
275  m_histEventT0_ECL_hadron_L1_ECLTRG->Fill(eventT0_ECL);
276  m_histEventT0_CDC_hadron_L1_ECLTRG->Fill(eventT0_CDC);
277  m_histEventT0_TOP_hadron_L1_ECLTRG->Fill(eventT0_TOP);
278  }
279 
280  if (IsEvtAcceptedMumu) { // fill the mumu skim event t0s
281  m_histEventT0_ECL_mumu_L1_ECLTRG->Fill(eventT0_ECL);
282  m_histEventT0_CDC_mumu_L1_ECLTRG->Fill(eventT0_CDC);
283  m_histEventT0_TOP_mumu_L1_ECLTRG->Fill(eventT0_TOP);
284  }
285  }
286  // Fill the plots that used the CDC trigger as the L1 timing source
287  else if (Is_CDC_L1TriggerSource) {
288  // Fill the histograms with the event t0 values
289  if (IsEvtAcceptedBhabha) { // fill the bha bha skim event t0s
290  m_histEventT0_ECL_bhabha_L1_CDCTRG->Fill(eventT0_ECL);
291  m_histEventT0_CDC_bhabha_L1_CDCTRG->Fill(eventT0_CDC);
292  m_histEventT0_TOP_bhabha_L1_CDCTRG->Fill(eventT0_TOP);
293  }
294 
295  if (IsEvtAcceptedHadron) { // fill the hadron skim event t0s
296  m_histEventT0_ECL_hadron_L1_CDCTRG->Fill(eventT0_ECL);
297  m_histEventT0_CDC_hadron_L1_CDCTRG->Fill(eventT0_CDC);
298  m_histEventT0_TOP_hadron_L1_CDCTRG->Fill(eventT0_TOP);
299  }
300 
301  if (IsEvtAcceptedMumu) { // fill the mumu skim event t0s
302  m_histEventT0_ECL_mumu_L1_CDCTRG->Fill(eventT0_ECL);
303  m_histEventT0_CDC_mumu_L1_CDCTRG->Fill(eventT0_CDC);
304  m_histEventT0_TOP_mumu_L1_CDCTRG->Fill(eventT0_TOP);
305  }
306  }
307 
308  B2DEBUG(20, "eventT0_ECL = " << eventT0_ECL << " ns") ;
309  B2DEBUG(20, "eventT0_CDC = " << eventT0_CDC << " ns") ;
310  B2DEBUG(20, "eventT0_TOP = " << eventT0_TOP << " ns") ;
311 }
312 
313 
314 //---------------------------------
316 {
317 
318 }
319 
320 
321 //---------------------------------
323 {
324 
325 }
This module to design collect the event t0 values base on different detectors and physics processes.
Definition: EventT0DQM.h:32
TH1F * m_histEventT0_CDC_bhabha_L1_CDCTRG
event t0 histogram for CDC and bha bha events wrt the CDC trigger time
Definition: EventT0DQM.h:89
virtual ~EventT0DQMModule()
Destructor.
Definition: EventT0DQM.cc:24
TH1F * m_histEventT0_ECL_hadron_L1_ECLTRG
event t0 histogram for ECL and hadronic events wrt the ECL trigger time
Definition: EventT0DQM.h:81
TH1F * m_histEventT0_ECL_bhabha_L1_CDCTRG
event t0 histogram for ECL and bha bha events wrt the CDC trigger time
Definition: EventT0DQM.h:88
StoreObjPtr< EventT0 > m_eventT0
Store array for event t0.
Definition: EventT0DQM.h:76
TH1F * m_histEventT0_CDC_hadron_L1_ECLTRG
event t0 histogram for CDC and hadronic events wrt the ECL trigger time
Definition: EventT0DQM.h:82
virtual void initialize() override
Initialize the module.
Definition: EventT0DQM.cc:104
TH1F * m_histEventT0_CDC_mumu_L1_CDCTRG
event t0 histogram for CDC and mu mu events wrt the CDC trigger time
Definition: EventT0DQM.h:95
virtual void event() override
This method is called for each event.
Definition: EventT0DQM.cc:153
TH1F * m_histEventT0_CDC_mumu_L1_ECLTRG
event t0 histogram for CDC and mu mu events wrt the ECL trigger time
Definition: EventT0DQM.h:85
virtual void endRun() override
This method is called at the end of each run.
Definition: EventT0DQM.cc:315
virtual void terminate() override
End of the event processing.
Definition: EventT0DQM.cc:322
TH1F * m_histEventT0_TOP_bhabha_L1_ECLTRG
event t0 histogram for TOP and bha bha events wrt the ECL trigger time
Definition: EventT0DQM.h:80
StoreObjPtr< TRGSummary > m_objTrgSummary
Trigger Summary data object.
Definition: EventT0DQM.h:66
virtual void beginRun() override
This method is called for each run.
Definition: EventT0DQM.cc:117
TH1F * m_histEventT0_TOP_mumu_L1_ECLTRG
event t0 histogram for TOP and mu mu events wrt the ECL trigger time
Definition: EventT0DQM.h:86
TH1F * m_histEventT0_TOP_hadron_L1_CDCTRG
event t0 histogram for TOP and hadronic events wrt the CDC trigger time
Definition: EventT0DQM.h:93
TH1F * m_histEventT0_ECL_mumu_L1_CDCTRG
event t0 histogram for ECL and mu mu events wrt the CDC trigger time
Definition: EventT0DQM.h:94
TH1F * m_histEventT0_ECL_mumu_L1_ECLTRG
event t0 histogram for ECL and mu mu events wrt the ECL trigger time
Definition: EventT0DQM.h:84
TH1F * m_histEventT0_TOP_mumu_L1_CDCTRG
event t0 histogram for TOP and mu mu events wrt the CDC trigger time
Definition: EventT0DQM.h:96
TH1F * m_histEventT0_TOP_bhabha_L1_CDCTRG
event t0 histogram for TOP and bha bha events wrt the CDC trigger time
Definition: EventT0DQM.h:90
TH1F * m_histEventT0_TOP_hadron_L1_ECLTRG
event t0 histogram for TOP and hadronic events wrt the ECL trigger time
Definition: EventT0DQM.h:83
int m_L1TimingSrc
L1 timing source from getTimeType() in TRGSummary See ETimingTYpe in mdst/dataobjects/include/TRGSumm...
Definition: EventT0DQM.h:73
TH1F * m_histEventT0_CDC_hadron_L1_CDCTRG
event t0 histogram for CDC and hadronic events wrt the CDC trigger time
Definition: EventT0DQM.h:92
StoreObjPtr< SoftwareTriggerResult > m_TrgResult
Store array for Trigger selection.
Definition: EventT0DQM.h:75
TH1F * m_histEventT0_CDC_bhabha_L1_ECLTRG
event t0 histogram for CDC and bha bha events wrt the ECL trigger time
Definition: EventT0DQM.h:79
TH1F * m_histEventT0_ECL_hadron_L1_CDCTRG
event t0 histogram for ECL and hadronic events wrt the CDC trigger time
Definition: EventT0DQM.h:91
virtual void defineHisto() override
Defination of histograms.
Definition: EventT0DQM.cc:28
TH1F * m_histEventT0_ECL_bhabha_L1_ECLTRG
event t0 histogram for ECL and bha bha events wrt the ECL trigger time
Definition: EventT0DQM.h:78
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
@ c_accept
Accept this event.
Abstract base class for different kinds of events.