Belle II Software development
TRGTOPDQMModule.h
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// $Id$
10//---------------------------------------------------------------
11// Filename : TRGTOPDQMModule.h
12// Section : TRG GRL
13// Owner :
14// Email :
15//---------------------------------------------------------------
16// Description : DQM module for TRGTOP
17//---------------------------------------------------------------
18#ifndef TRGGRLDQMMODULE_h
19#define TRGGRLDQMMODULE_h
20
21#include <framework/core/HistoModule.h>
22
23#include <trg/gdl/dataobjects/TRGGDLUnpackerStore.h>
24#include <trg/gdl/modules/trggdlUnpacker/trggdlUnpackerModule.h>
25#include <trg/gdl/TrgBit.h>
26#include <framework/database/DBObjPtr.h>
27#include <trg/gdl/dbobjects/TRGGDLDBUnpacker.h>
28#include <mdst/dbobjects/TRGGDLDBInputBits.h>
29#include <mdst/dbobjects/TRGGDLDBFTDLBits.h>
30
31#include "trg/grl/dataobjects/TRGGRLUnpackerStore.h"
32
33#include "trg/ecl/dataobjects/TRGECLUnpackerStore.h"
34#include "trg/ecl/TrgEclMapping.h"
35
36#include "trg/top/dataobjects/TRGTOPUnpackerStore.h"
37#include "trg/top/dataobjects/TRGTOPSlotTiming.h"
38
39#include <string>
40#include <algorithm>
41
42#include <TH1I.h>
43#include <TH2I.h>
44#include <TH3I.h>
45#include <TH1F.h>
46#include <TH2F.h>
47
48namespace Belle2 {
55
56 public:
60 virtual ~TRGTOPDQMModule() {}
61
62 public:
63
64 static constexpr double clk127To1ns = 7.8;
65
67 virtual void initialize() override;
69 virtual void beginRun() override;
71 virtual void event() override;
73 virtual void endRun() override;
75 virtual void terminate() override {}
77 virtual void defineHisto() override;
78
79 protected:
81 TDirectory* oldDir = nullptr;
83 TDirectory* dirDQM = nullptr;
84
85 // number of skims
86 static const int nskim_topdqm = 11;
87
88 // number of histogram classes
89 static const int nHistClasses = 3;
90 int m_nHistClassesActual = 3;
91
92 // histogramming level
93 int m_histLevel = 3;
94
95 int start_skim_topdqm = 0;
96 int end_skim_topdqm = 0;
97 int m_skim = -1;
98
99 TH2I* h_top_nt0decisions_vs_hist_class[nskim_topdqm] = {nullptr};
100
101 TH1I* h_top_gdl_match_decision_number[nskim_topdqm] = {nullptr};
102
104 TH1I* h_N_decision[nskim_topdqm][nHistClasses] = {{nullptr}};
105
108 TH1I* h_topSlotSegment[nskim_topdqm][16] = {{nullptr}};
109 TH1I* h_topSlotNHits[nskim_topdqm][16] = {{nullptr}};
110 TH1I* h_topSlotLogL[nskim_topdqm][16] = {{nullptr}};
111 TH1I* h_topSlotT0[nskim_topdqm][16] = {{nullptr}};
112
113 TH1I* h_topSlotAll[nskim_topdqm] = {nullptr};
114 TH1I* h_topSegmentAll[nskim_topdqm] = {nullptr};
115 TH1I* h_topNHitsAll[nskim_topdqm] = {nullptr};
116 TH1I* h_topLogLAll[nskim_topdqm] = {nullptr};
117 TH1I* h_topT0All[nskim_topdqm] = {nullptr};
118
119 TH2I* h_topSlotVsSegment[nskim_topdqm] = {nullptr};
120
121 TH2I* h_topSlotVsNHits[nskim_topdqm] = {nullptr};
122 TH2I* h_topSlotVsLogL[nskim_topdqm] = {nullptr};
123 TH2I* h_topSlotVsT0[nskim_topdqm] = {nullptr};
124
125 TH2I* h_topSegmentVsNHits[nskim_topdqm] = {nullptr};
126 TH2I* h_topSegmentVsLogL[nskim_topdqm] = {nullptr};
127 TH2I* h_topSegmentVsT0[nskim_topdqm] = {nullptr};
128
129 TH2I* h_topNHitsVsLogL[nskim_topdqm] = {nullptr};
130 TH2I* h_topNHitsVsT0[nskim_topdqm] = {nullptr};
131 TH2I* h_topLogLVsT0[nskim_topdqm] = {nullptr};
132
133 TH1I* h_ecl_gdl_top_timing_diff_both[nskim_topdqm] = {nullptr};
134 TH1I* h_ecl_top_top_timing_diff_both[nskim_topdqm] = {nullptr};
135
136 TH2I* h_decisionNumberVsNumberDecisionsGood[nskim_topdqm] = {nullptr};
137 TH2I* h_decisionNumberVsNumberDecisionsBad[nskim_topdqm] = {nullptr};
138
139 TH1I* h_ecl_gdl_top_timing_diff_good[nskim_topdqm] = {nullptr};
140 TH1I* h_ecl_top_top_timing_diff_good[nskim_topdqm] = {nullptr};
141
142 TH2I* h_top_ecltop_timing_diff_vs_toptop_good[nskim_topdqm] = {nullptr};
143 TH2I* h_gdl_ecltop_timing_diff_vs_toptop_good[nskim_topdqm] = {nullptr};
144 TH2I* h_gdl_ecltop_timing_diff_vs_ecltop_good[nskim_topdqm] = {nullptr};
145
146 TH1I* h_topCombinedTimingTopGood[nskim_topdqm] = {nullptr};
147 TH1I* h_topNSlotsCombinedTimingTopGood[nskim_topdqm] = {nullptr};
148 TH1I* h_topNHitSumGood[nskim_topdqm] = {nullptr};
149 TH1I* h_topLogLSumGood[nskim_topdqm] = {nullptr};
150
151 TH1I* h_topCombinedTimingTopAll[nskim_topdqm] = {nullptr};
152 TH1I* h_topNSlotsCombinedTimingTopAll[nskim_topdqm] = {nullptr};
153 TH1I* h_topNHitSumAll[nskim_topdqm] = {nullptr};
154 TH1I* h_topLogLSumAll[nskim_topdqm] = {nullptr};
155
156 TH2I* h_topNSlotsCombinedTimingVsNHitsTopAll[nskim_topdqm] = {nullptr};
157
158 TH2I* h_topNHitVsNhit[nskim_topdqm][nHistClasses] = {{nullptr}};
159 TH2I* h_topSlotVsSlot[nskim_topdqm][nHistClasses] = {{nullptr}};
160 TH2I* h_topT0VsT0[nskim_topdqm][nHistClasses] = {{nullptr}};
161 TH2I* h_topSegmentVsSegment[nskim_topdqm][nHistClasses] = {{nullptr}};
162 TH2I* h_topLogLVsLogL[nskim_topdqm][nHistClasses] = {{nullptr}};
163
164 TH1I* h_topTrigType[nskim_topdqm] = {nullptr};
165 TH1I* h_topTimingResiduals[nskim_topdqm] = {nullptr};
166 TH1I* h_topTimingVariance[nskim_topdqm] = {nullptr};
167
168 TH1I* h_topRvcDiff1All[nskim_topdqm] = {nullptr};
169 TH1I* h_topRvcDiff2All[nskim_topdqm] = {nullptr};
170 TH1I* h_topRvcDiff3All[nskim_topdqm] = {nullptr};
171 TH1I* h_topRvcDiff4All[nskim_topdqm] = {nullptr};
172
173 TH1I* h_topGdlRvcDiff1All[nskim_topdqm] = {nullptr};
174 TH1I* h_topGdlRvcDiff2All[nskim_topdqm] = {nullptr};
175 TH1I* h_topGdlRvcDiff3All[nskim_topdqm] = {nullptr};
176
177 TH1I* h_topRvcDiff1Good[nskim_topdqm] = {nullptr};
178 TH1I* h_topRvcDiff2Good[nskim_topdqm] = {nullptr};
179 TH1I* h_topRvcDiff3Good[nskim_topdqm] = {nullptr};
180 TH1I* h_topRvcDiff4Good[nskim_topdqm] = {nullptr};
181
182 TH1I* h_topGdlRvcDiff1Good[nskim_topdqm] = {nullptr};
183 TH1I* h_topGdlRvcDiff2Good[nskim_topdqm] = {nullptr};
184 TH1I* h_topGdlRvcDiff3Good[nskim_topdqm] = {nullptr};
185
186 TH1I* h_ecl_gdl_top_timing_diff_bad[nskim_topdqm] = {nullptr};
187 TH1I* h_ecl_top_top_timing_diff_bad[nskim_topdqm] = {nullptr};
188
189 TH2I* h_top_ecltop_timing_diff_vs_toptop_bad[nskim_topdqm] = {nullptr};
190 TH2I* h_gdl_ecltop_timing_diff_vs_toptop_bad[nskim_topdqm] = {nullptr};
191 TH2I* h_gdl_ecltop_timing_diff_vs_ecltop_bad[nskim_topdqm] = {nullptr};
192
193 TH1I* h_topCombinedTimingTopBad[nskim_topdqm] = {nullptr};
194 TH1I* h_topNSlotsCombinedTimingTopBad[nskim_topdqm] = {nullptr};
195 TH1I* h_topNHitSumBad[nskim_topdqm] = {nullptr};
196 TH1I* h_topLogLSumBad[nskim_topdqm] = {nullptr};
197
198 TH1I* h_topRvcDiff1Bad[nskim_topdqm] = {nullptr};
199 TH1I* h_topRvcDiff2Bad[nskim_topdqm] = {nullptr};
200 TH1I* h_topRvcDiff3Bad[nskim_topdqm] = {nullptr};
201 TH1I* h_topRvcDiff4Bad[nskim_topdqm] = {nullptr};
202
203 TH1I* h_topGdlRvcDiff1Bad[nskim_topdqm] = {nullptr};
204 TH1I* h_topGdlRvcDiff2Bad[nskim_topdqm] = {nullptr};
205 TH1I* h_topGdlRvcDiff3Bad[nskim_topdqm] = {nullptr};
206
207 TH1I* h_topCombinedTimingTop[nskim_topdqm][nHistClasses] = {{nullptr}};
208 TH1I* h_topNSlotsCombinedTimingTop[nskim_topdqm][nHistClasses] = {{nullptr}};
209 TH1I* h_topNHitSum[nskim_topdqm][nHistClasses] = {{nullptr}};
210 TH1I* h_topNHitBestSlot[nskim_topdqm][nHistClasses] = {{nullptr}};
211 // TH1I* h_topT0DecisionNumberBestSlot[nskim_topdqm][nHistClasses] = {{nullptr}};
212 TH1I* h_topLogLSum[nskim_topdqm][nHistClasses] = {{nullptr}};
213
214 TH1I* h_gdl_ecltop_timing_diff_5ns[nskim_topdqm] = {nullptr};
215 TH1I* h_gdl_cdctop_timing_diff_5ns[nskim_topdqm] = {nullptr};
216
217 TH1I* h_gdl_ecltop_timing_diff_2ns[nskim_topdqm] = {nullptr};
218 TH1I* h_gdl_ecltop_timing_diff_grl_matched_2ns[nskim_topdqm] = {nullptr};
219 TH1I* h_gdl_ecltop_timing_diff_no_grl_matched_2ns[nskim_topdqm] = {nullptr};
220 TH1I* h_gdl_ecltop_timing_diff_no_grl_at_all_2ns[nskim_topdqm] = {nullptr};
221 TH2I* h_gdl_ecltop_timing_diff_vs_nslots_2ns[nskim_topdqm] = {nullptr};
222 TH1I* h_top_ecltop_timing_diff_combined_2ns[nskim_topdqm] = {nullptr};
223 TH1I* h_top_ecltop_timing_diff_best_slot_2ns[nskim_topdqm] = {nullptr};
224 TH1I* h_gdl_cdctop_timing_diff_2ns[nskim_topdqm] = {nullptr};
225
226 TH1I* h_top_ecltop_timing_diff_2ns[nskim_topdqm][nHistClasses] = {{nullptr}};
227 TH1I* h_top_ecltop_timing_combined_diff_2ns[nskim_topdqm][nHistClasses] = {{nullptr}};
228 TH1I* h_top_ecltop_timing_best_slot_diff_2ns[nskim_topdqm][nHistClasses] = {{nullptr}};
229
230 TH2I* h_top_ecltop_timing_diff_vs_toptop[nskim_topdqm][nHistClasses] = {{nullptr}};
231 TH2I* h_gdl_ecltop_timing_diff_vs_toptop[nskim_topdqm][nHistClasses] = {{nullptr}};
232 TH2I* h_gdl_ecltop_timing_diff_vs_ecltop[nskim_topdqm][nHistClasses] = {{nullptr}};
233 TH2I* h_gdl_ecltop_timing_diff_vs_ecltop_best_slot[nskim_topdqm][nHistClasses] = {{nullptr}};
234
235 TH2I* h_gdl_top_rvc_vs_top_timing[nskim_topdqm] = {nullptr};
236
237 TH1I* h_gdl_ecltop_rvc_diff[nskim_topdqm] = {nullptr};
238 TH1I* h_gdl_cdctop_rvc_diff[nskim_topdqm] = {nullptr};
239
240 TH1I* h_gdl_gdltop_rvc_diff_all[nskim_topdqm] = {nullptr};
241 TH1I* h_gdl_comtop_rvc_diff_all[nskim_topdqm] = {nullptr};
242
243 TH1I* h_gdl_gdltop_rvc_diff_good[nskim_topdqm] = {nullptr};
244 TH1I* h_gdl_comtop_rvc_diff_good[nskim_topdqm] = {nullptr};
245
246 TH1I* h_gdl_gdltop_rvc_diff_bad[nskim_topdqm] = {nullptr};
247 TH1I* h_gdl_comtop_rvc_diff_bad[nskim_topdqm] = {nullptr};
248
249 TH2I* h_gdl_ecltop_timing_diff_vs_slot[nskim_topdqm] = {nullptr};
250 TH2I* h_gdl_ecltop_timing_diff_vs_segment[nskim_topdqm] = {nullptr};
251 TH2I* h_gdl_ecltop_timing_diff_vs_nhits[nskim_topdqm] = {nullptr};
252 TH2I* h_gdl_ecltop_timing_diff_vs_logl[nskim_topdqm] = {nullptr};
253
254 TH2I* h_gdl_ecltop_timing_diff_vs_slot_2ns[nskim_topdqm][nHistClasses] = {{nullptr}};
255 TH2I* h_gdl_ecltop_timing_diff_vs_segment_2ns[nskim_topdqm][nHistClasses] = {{nullptr}};
256 TH2I* h_gdl_ecltop_timing_diff_vs_nhits_2ns[nskim_topdqm][nHistClasses] = {{nullptr}};
257 TH2I* h_gdl_ecltop_timing_diff_vs_logl_2ns[nskim_topdqm][nHistClasses] = {{nullptr}};
258
259 TH2I* h_topTC2IdVsTC1IdAll[nskim_topdqm] = {nullptr};
260 TH2I* h_topTC2EnergyVsTC1EnergyAll[nskim_topdqm] = {nullptr};
261 TH2I* h_topTC2ThetaIdVsTC1ThetaIdAll[nskim_topdqm] = {nullptr};
262 TH2I* h_topTC2PhiIdVsTC1PhiIdAll[nskim_topdqm] = {nullptr};
263 TH3I* h_topTCPhiIdVsTCThetaIdAll[nskim_topdqm] = {nullptr};
264
265 TH2I* h_topTC2IdVsTC1IdGRLAll[nskim_topdqm] = {nullptr};
266 TH2I* h_topTC2EnergyVsTC1EnergyGRLAll[nskim_topdqm] = {nullptr};
267 TH2I* h_topTC2ThetaIdVsTC1ThetaIdGRLAll[nskim_topdqm] = {nullptr};
268 TH2I* h_topTC2PhiIdVsTC1PhiIdGRLAll[nskim_topdqm] = {nullptr};
269 TH3I* h_topTCPhiIdVsTCThetaIdGRLAll[nskim_topdqm] = {nullptr};
270
271 TH2I* h_topTC2IdVsTC1Id[nskim_topdqm] = {nullptr};
272 TH2I* h_topTC2EnergyVsTC1Energy[nskim_topdqm] = {nullptr};
273 TH2I* h_topTC2ThetaIdVsTC1ThetaId[nskim_topdqm] = {nullptr};
274 TH2I* h_topTC2PhiIdVsTC1PhiId[nskim_topdqm] = {nullptr};
275 TH3I* h_topTCPhiIdVsTCThetaId[nskim_topdqm] = {nullptr};
276
277 TH2I* h_topTC2IdVsTC1IdGRL[nskim_topdqm] = {nullptr};
278 TH2I* h_topTC2EnergyVsTC1EnergyGRL[nskim_topdqm] = {nullptr};
279 TH2I* h_topTC2ThetaIdVsTC1ThetaIdGRL[nskim_topdqm] = {nullptr};
280 TH2I* h_topTC2PhiIdVsTC1PhiIdGRL[nskim_topdqm] = {nullptr};
281 TH3I* h_topTCPhiIdVsTCThetaIdGRL[nskim_topdqm] = {nullptr};
282
283 TH2I* h_gdl_ecltop_timing_diff_vs_grl_top_l1[nskim_topdqm] = {nullptr};
284 TH2I* h_gdl_top_l1_vs_grl_top_l1[nskim_topdqm] = {nullptr};
285
286 TH2I* h_grl_ntopslots_vs_ncdcslots[nskim_topdqm] = {nullptr};
287 TH1I* h_grl_ncdctopslots_matched[nskim_topdqm] = {nullptr};
288 TH2I* h_grl_topslots_vs_cdcslots_match[nskim_topdqm] = {nullptr};
289
290 //condition database for GDL unpacker
291 DBObjPtr<TRGGDLDBUnpacker> m_gdlUnpacker;
292
293 int gdlLeafBitMap[320] = {0};
294 char gdlLeafNames[320][100] = {{0}};
295
296 int gdl_e_timtype = 0;
297 int gdl_e_gdll1rvc = 0;
298 int gdl_e_coml1rvc = 0;
299 int gdl_e_toptiming = 0;
300 int gdl_e_ecltiming = 0;
301 int gdl_e_cdctiming = 0;
302 int gdl_e_toprvc = 0;
303 int gdl_e_eclrvc = 0;
304 int gdl_e_cdcrvc = 0;
305
306 // event information
307
308 // unsigned n_clocks = 0;
309 unsigned m_evtno = 0;
310 unsigned m_exp = 0;
311 unsigned m_run = 0;
312
313 std::vector<int> skim;
314
315 // ECL TRG
318
319 struct tcEcl {
320 int tcId;
321 double tcEnergy;
322 double tcTiming;
323 int tcThetaId;
324 int tcPhiId;
325 };
326
327 std::vector<tcEcl> tcEclList;
328
330 inline bool operator()(tcEcl const& a, tcEcl const& b)
331 {
332 double i = a.tcEnergy;
333 double j = b.tcEnergy;
334 return i > j;
335 }
336 };
337
338 //
339
341 int slot;
342 int segment;
343 int nHits;
344 int logL;
345 int t0;
346 };
347
348 std::vector<slotDecision> slotDecisionList;
349
351 inline bool operator()(slotDecision const& a, slotDecision const& b)
352 {
353 double i = a.nHits;
354 double j = b.nHits;
355 return i > j;
356 }
357 };
358
359 // various parameters and their interpretation
360
361 bool m_generatePostscriptFile;
362 std::string m_postScriptFileName;
363
364 bool m_doECLCorrelations;
365 bool m_doGDLCorrelations;
366 bool m_doGRLCorrelations;
367
368 bool m_requireEclBarrel;
369 bool m_requireEclBarrelB2B;
370
371 bool m_requireCDC2DTrack;
372
373 // names of skims from hlt/softwaretrigger/scripts/softwaretrigger/db_access.py
374 std::string skim_menu[nskim_topdqm] = {
375 "all",
376 "software_trigger_cut&skim&accept_hadron",
377 "software_trigger_cut&skim&accept_tau_tau",
378 "software_trigger_cut&skim&accept_mumu_1trk",
379 "software_trigger_cut&skim&accept_mumu_2trk",
380 "software_trigger_cut&skim&accept_gamma_gamma",
381 "software_trigger_cut&skim&accept_bhabha",
382 "software_trigger_cut&skim&accept_hadronb",
383 "software_trigger_cut&skim&accept_hadronb1",
384 "software_trigger_cut&skim&accept_hadronb2",
385 "software_trigger_cut&skim&accept_mumutight"
386 };
387
388 // names of histograms
389 std::string skim_smap[nskim_topdqm] = {
390 "all",
391 "hadron",
392 "tautau",
393 "mumu1trk",
394 "mumu2trk",
395 "gammagamma",
396 "bhabha",
397 "hadronb",
398 "hadronb1",
399 "hadronb2",
400 "mumutight"
401 };
402
403 };
404
406}
407
408#endif
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
virtual void terminate() override
terminate
virtual void initialize() override
initialize
StoreArray< TRGECLUnpackerStore > trgeclHitArray
Trg ECL Unpacker TC output.
TDirectory * oldDir
TDirectory.
virtual void event() override
Event.
virtual void endRun() override
End Run.
TH1I * h_topSlotSegment[nskim_topdqm][16]
Combined t0 decisions: all, the earliest and second best.
virtual ~TRGTOPDQMModule()
Destructor.
TH1I * h_N_decision[nskim_topdqm][nHistClasses]
Number of TOP L1 decisions.
virtual void beginRun() override
begin Run
TDirectory * dirDQM
TDirectory.
virtual void defineHisto() override
Define Histogram.
Abstract base class for different kinds of events.