Belle II Software development
TRGGDLDQMModule.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#ifndef TRCGDLDQMMODULE_h
9#define TRCGDLDQMMODULE_h
10
11#include <framework/core/HistoModule.h>
12#include <trg/gdl/dataobjects/TRGGDLUnpackerStore.h>
13#include <trg/gdl/modules/trggdlUnpacker/trggdlUnpackerModule.h>
14#include <trg/gdl/TrgBit.h>
15#include <framework/database/DBObjPtr.h>
16#include <trg/gdl/dbobjects/TRGGDLDBUnpacker.h>
17#include <mdst/dbobjects/TRGGDLDBInputBits.h>
18#include <mdst/dbobjects/TRGGDLDBFTDLBits.h>
19#include <string>
20#include <unordered_map>
21#include <utility>
22#include <vector>
23
24#include <TH2I.h>
25#include <TH1I.h>
26#include "trg/ecl/TrgEclMapping.h"
27#include <ecl/dataobjects/ECLDigit.h>
28#include <ecl/dataobjects/ECLCalDigit.h>
29#include <mdst/dataobjects/SoftwareTriggerResult.h>
30#include <mdst/dataobjects/Track.h>
31#include <mdst/dataobjects/HitPatternCDC.h>
32#include <mdst/dataobjects/ECLCluster.h>
33#include "trg/ecl/dataobjects/TRGECLCluster.h"
34
35
36namespace Belle2 {
41
42
44
45 public:
49 virtual ~TRGGDLDQMModule() {}
50
51 public:
53 virtual void initialize() override;
55 virtual void beginRun() override;
57 virtual void event() override;
59 virtual void endRun() override;
61 virtual void terminate() override {}
63 virtual void defineHisto() override;
64
65 protected:
67 static const int nskim_gdldqm = 11;
68 int start_skim_gdldqm = 0;
69 int end_skim_gdldqm = 0;
70 int m_skim = -1;
71
73 TH1I* h_c8_gdlL1TocomL1[nskim_gdldqm] = {nullptr};
75 TH1I* h_c8_topTogdlL1[nskim_gdldqm] = {nullptr};
77 TH1I* h_c8_eclTogdlL1[nskim_gdldqm] = {nullptr};
79 TH1I* h_c8_cdcTogdlL1[nskim_gdldqm] = {nullptr};
81 TH1I* h_c8_ecl8mToGDL[nskim_gdldqm] = {nullptr};
83 TH1I* h_c8_topToGDL[nskim_gdldqm] = {nullptr};
85 TH1I* h_c8_eclToGDL[nskim_gdldqm] = {nullptr};
87 TH1I* h_c8_cdcToGDL[nskim_gdldqm] = {nullptr};
89 TH1I* h_c2_cdcTocomL1[nskim_gdldqm] = {nullptr};
91 TH1D* h_ns_cdcTocomL1[nskim_gdldqm] = {nullptr};
93 TH1D* h_ns_cdcTogdlL1[nskim_gdldqm] = {nullptr};
95 TH1D* h_ns_topToecl[nskim_gdldqm] = {nullptr};
97 TH1D* h_ns_topTocdc[nskim_gdldqm] = {nullptr};
99 TH1I* h_c2_cdcToecl[nskim_gdldqm] = {nullptr};
101 TH1D* h_ns_cdcToecl[nskim_gdldqm] = {nullptr};
102
104 // TH1I* h_inp;
105 // TH1I* h_inp_rise[N_BITS_RESERVED][nskim_gdldqm];
106 // TH1I* h_inp_fall[N_BITS_RESERVED][nskim_gdldqm];
108 TH1I* h_itd[nskim_gdldqm] = {nullptr};
109 TH1I* h_itd_rise[N_BITS_RESERVED][nskim_gdldqm] = {{nullptr}};
110 TH1I* h_itd_fall[N_BITS_RESERVED][nskim_gdldqm] = {{nullptr}};
112 TH1I* h_ftd[nskim_gdldqm] = {nullptr};
113 TH1I* h_ftd_rise[N_BITS_RESERVED][nskim_gdldqm] = {{nullptr}};
114 TH1I* h_ftd_fall[N_BITS_RESERVED][nskim_gdldqm] = {{nullptr}};
116 TH1I* h_psn[nskim_gdldqm] = {nullptr};
117 TH1I* h_psn_rise[N_BITS_RESERVED][nskim_gdldqm] = {{nullptr}};
118 TH1I* h_psn_fall[N_BITS_RESERVED][nskim_gdldqm] = {{nullptr}};
119 TH1I* h_psn_extra[nskim_gdldqm] = {nullptr};
120 TH1I* h_psn_extra_fast[nskim_gdldqm] = {nullptr};
121 TH1I* h_psn_effect_to_l1[nskim_gdldqm] = {nullptr};
122 TH1I* h_psn_raw_rate[nskim_gdldqm] = {nullptr};
123 TH1I* h_psn_pure_extra[nskim_gdldqm] = {nullptr};
125 TH1I* h_timtype[nskim_gdldqm] = {nullptr};
126 std::vector<int> h_0_vec;
128 std::vector<int> h_p_vec;
130 std::vector<int> h_f_vec;
132 std::vector<int> h_i_vec;
133
134 TDirectory* oldDir = nullptr;
135 TDirectory* dirDQM = nullptr;
136
137 bool m_eventByEventTimingHistRecord;
138 bool m_dumpVcdFile;
139 bool m_bitNameOnBinLabel;
140 bool m_generatePostscript;
141 unsigned m_vcdEventStart = 0;
142 unsigned m_vcdNumberOfEvents = 0;
143 std::string m_bitConditionToDumpVcd;
144 std::string m_postScriptName;
145 void fillRiseFallTimings(void);
146 void fillOutputExtra(void);
147 void fillOutputOverlap(void);
148 void fillOutputPureExtra(void);
149
150 void genVcd(void);
151 bool anaBitCondition(void);
152 bool isFired(std::string bitname);
153 bool isFired_quick(const std::string& bitname, const bool& isPsnm);
154 int getinbitnum(const char* c) const;
155 int getoutbitnum(const char* c) const;
156
158 std::unordered_map<std::string, int> m_inbitIndex;
160 std::unordered_map<std::string, int> m_outbitIndex;
162 std::vector<char> m_firedPsnm;
164 std::vector<char> m_firedFtdl;
166 std::vector<char> m_firedInput;
167 unsigned n_clocks = 0;
168 unsigned evtno = 0;
169 unsigned _exp = 0;
170 unsigned _run = 0;
171 std::vector<int> skim;
172
173 static const int n_output_extra = 105;
174 static const char* output_extra[n_output_extra];
175 static const int n_output_overlap = 130;
176 static const char* output_overlap[n_output_overlap];
177 static const int n_output_pure_extra = 13;
178 static const char* output_pure_extra[n_output_pure_extra];
179 static const int nsample_fast = 500;
180 int array_psn_extra_fast[nskim_gdldqm][nsample_fast][n_output_extra] = {{{0}}};
182 int m_fastSum[nskim_gdldqm][n_output_extra] = {{0}};
183 bool m_leavesResolved = false;
184 int m_evtLeaf = -1;
185 int m_clkLeaf = 0;
186 std::vector<std::pair<int, int>> m_leafMap;
187
190 int LeafBitMap[320] = {0};
191 char LeafNames[320][100] = {{0}};
192 int _e_timtype = 0;
193 int _e_gdll1rvc = 0;
194 int _e_coml1rvc = 0;
195 int _e_toptiming = 0;
196 int _e_ecltiming = 0;
197 int _e_cdctiming = 0;
198 int _e_toprvc = 0;
199 int _e_eclrvc = 0;
200 int _e_cdcrvc = 0;
201 int ee_psn[10] = {0};
202 int ee_ftd[10] = {0};
203 int ee_itd[10] = {0};
204 int n_leafs = 0;
205 int n_leafsExtra = 0;
206 int nconf = 0;
207 int nword_input = 0;
208 int nword_output = 0;
209
212 unsigned n_inbit = 0;
213 char inbitname[320][100] = {""};
214
217 unsigned n_outbit = 0;
218 char outbitname[320][100] = {""};
219
220
222 std::string skim_menu[nskim_gdldqm] = {
223 "all",
224 "software_trigger_cut&skim&accept_hadron",
225 "software_trigger_cut&skim&accept_tau_tau",
226 "software_trigger_cut&skim&accept_mumu_1trk",
227 "software_trigger_cut&skim&accept_mumu_2trk",
228 "software_trigger_cut&skim&accept_gamma_gamma",
229 "software_trigger_cut&skim&accept_bhabha",
230 "software_trigger_cut&skim&accept_hadronb",
231 "software_trigger_cut&skim&accept_hadronb1",
232 "software_trigger_cut&skim&accept_hadronb2",
233 "software_trigger_cut&skim&accept_mumutight"
234 };
235
237 std::string skim_smap[nskim_gdldqm] = {
238 "all",
239 "hadron",
240 "tautau",
241 "mumu1trk",
242 "mumu2trk",
243 "gammagamma",
244 "bhabha",
245 "hadronb",
246 "hadronb1",
247 "hadronb2",
248 "mumutight"
249 };
250
251 private:
252
255
258
261
264
267
268 //Input store array of ECL
269 //StoreArray<ECLCluster> ECLClusters;
270 StoreArray<ECLCalDigit> m_ECLCalDigitData;
271 StoreArray<ECLDigit> m_ECLDigitData;
272
273 };
274
276}
277
278#endif
Class for accessing objects in the database.
Definition DBObjPtr.h:21
HistoModule()
Constructor.
Definition HistoModule.h:32
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
std::string skim_menu[nskim_gdldqm]
name of skim from hlt/softwaretrigger/scripts/softwaretrigger/db_access.py
virtual ~TRGGDLDQMModule()
Destrunctor.
int m_evtLeaf
position of the "evt" leaf in m_unpackername, -1 if absent
TH1I * h_c8_cdcTogdlL1[nskim_gdldqm]
timestamp diff from t0(cdc) to gdlL1 in LSB8nsec
std::vector< char > m_firedFtdl
per-event cache: ftdl output bit fired in at least one clock cycle
std::vector< char > m_firedInput
per-event cache: input bit fired in at least one clock cycle
StoreObjPtr< SoftwareTriggerResult > result_soft
Input store array of HLT.
int m_fastPos[nskim_gdldqm]
ring-buffer index of the newest slot of array_psn_extra_fast
TH1I * h_c8_eclTogdlL1[nskim_gdldqm]
timestamp diff from t0(ecl) to gdlL1 in LSB8nsec
virtual void terminate() override
terminate
TH1I * h_c8_topTogdlL1[nskim_gdldqm]
timestamp diff from t0(top) to gdlL1 in LSB8nsec
virtual void initialize() override
initialize
TH1I * h_c8_eclToGDL[nskim_gdldqm]
timestamp diff from t0(ecl) to GDL in LSB8nsec
static const int nskim_gdldqm
number of skims
virtual void event() override
Event.
TH1D * h_ns_topTocdc[nskim_gdldqm]
timestamp diff from top_timing to cdc_timing in nsec
StoreArray< Track > Tracks
Input store array of track.
TH1I * h_ftd[nskim_gdldqm]
ftd bits
DBObjPtr< TRGGDLDBFTDLBits > m_dbftdl
condition database for output bits
virtual void endRun() override
End Run.
static const int nsample_fast
number of sample for fast efficiency monitor
TH1D * h_ns_cdcToecl[nskim_gdldqm]
timestamp diff from cdc_timing to ecl_timing in nsec
TH1I * h_c8_ecl8mToGDL[nskim_gdldqm]
timestamp diff from fit on fam to GDL in LSB8nsec
int array_psn_extra_fast[nskim_gdldqm][nsample_fast][n_output_extra]
array to store past nsample events
TH1I * h_c2_cdcToecl[nskim_gdldqm]
timestamp from cdc_timing to ecl_timing to L1 in LSB2nsec
TH1I * h_c8_gdlL1TocomL1[nskim_gdldqm]
timestamp diff from gdlL1 to comL1 in LSB8nsec
std::vector< int > h_i_vec
event by event input timing distribution
std::string skim_smap[nskim_gdldqm]
name of histograms
StoreObjPtr< EventMetaData > bevt
Input store array of metadata.
TH1D * h_ns_cdcTocomL1[nskim_gdldqm]
timestamp diff from cdc_timing to comL1 in nsec
virtual void beginRun() override
begin Run
TH1I * h_c2_cdcTocomL1[nskim_gdldqm]
timestamp diff from cdc_timing to comL1 in LSB2nsec
TH1I * h_c8_topToGDL[nskim_gdldqm]
timestamp diff from t0(top) to GDL in LSB8nsec
std::vector< int > h_f_vec
event by event ftdl timing distribution
int m_fastSum[nskim_gdldqm][n_output_extra]
running sum of array_psn_extra_fast over the whole ring
int m_clkLeaf
position of the "clk" leaf in m_unpackername
std::vector< std::pair< int, int > > m_leafMap
(position in m_unpacker, leaf number) for every mapped leaf
std::unordered_map< std::string, int > m_outbitIndex
bit name -> output bit number, built once in initialize()
TrgEclMapping * trgeclmap
ecltrg<->ecl mappint
std::unordered_map< std::string, int > m_inbitIndex
bit name -> input bit number, built once in initialize()
DBObjPtr< TRGGDLDBInputBits > m_dbinput
condition database for input bits
StoreArray< TRGGDLUnpackerStore > entAry
Input store array of GDL data.
TH1I * h_psn[nskim_gdldqm]
psn bits
DBObjPtr< TRGGDLDBUnpacker > m_unpacker
condition database for unpacker
TH1D * h_ns_topToecl[nskim_gdldqm]
timestamp diff from top_timing to ecl_timing in nsec
TH1I * h_itd[nskim_gdldqm]
input bits
TH1D * h_ns_cdcTogdlL1[nskim_gdldqm]
timestamp diff from cdc_timing to gdlL1 in nsec
bool m_leavesResolved
whether the leaf positions below are valid for the current run
TH1I * h_timtype[nskim_gdldqm]
timtype
std::vector< char > m_firedPsnm
per-event cache: psnm output bit fired in at least one clock cycle
TH1I * h_c8_cdcToGDL[nskim_gdldqm]
timestamp diff from t0(cdc) to GDL in LSB8nsec
virtual void defineHisto() override
Define Histogram.
A class of TC Mapping.
Abstract base class for different kinds of events.