Belle II Software development
TRGECLEventTimingDQMModule.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 <trg/ecl/modules/trgeclDQM/TRGECLEventTimingDQMModule.h>
10#include <framework/core/HistoModule.h>
11#include <framework/datastore/StoreArray.h>
12#include <iostream>
13#include <string>
14using namespace Belle2;
15
16REG_MODULE(TRGECLEventTimingDQM);
17
18
20{
22 setDescription("ECL trigger event timing histograms");
24
29
30 for (int iii = 0; iii < c_NBinEventT0; iii++) {
31 if (iii <= 1) {
32 m_histEventT0NBin.push_back(100);
33 m_histEventT0XMin.push_back(-200);
34 m_histEventT0XMax.push_back(200);
35 } else if (iii <= 5) {
36 m_histEventT0NBin.push_back(100);
37 m_histEventT0XMin.push_back(-100);
38 m_histEventT0XMax.push_back(100);
39 } else {
40 m_histEventT0NBin.push_back(50);
41 m_histEventT0XMin.push_back(-50);
42 m_histEventT0XMax.push_back(50);
43 }
44 }
45}
46
47
49{
50 delete m_trgecl_map;
51}
52
54{
55
56 TDirectory* oldDir = gDirectory;
57 oldDir->mkdir("TRGECLEventTiming")->cd();
58
60 new TH1F("h_MaxTCE",
61 "[TRGECL] Most Energetic TC Energy ; max TC Energy (ADC) ; Entries / 10 ADC",
62 140, 0, 1400);
64 new TH1F("h_MaxTCId",
65 "[TRGECL] Most Energetic TC ID ; max TC ID ; Entries",
66 578, 0, 578);
68 new TH1F("h_MaxTCThetaId",
69 "[TRGECL] Most Energetic TC Theta ID ; max TC #theta ID ; Entries",
70 19, 0, 19);
72 new TH1F("h_EventTimingQuality",
73 "[TRGECL] Event timing quality ; Event timing quality ; Entries",
74 4, 0, 4);
75
77 new TH1F("h_EventT0Coarse",
78 "[TRGECL] EventT0 with coarse event timing ; EventT0 (ns) ; Entries / 2 ns",
81 new TH1F("h_EventT0Fine",
82 "[TRGECL] EventT0 with fine event timing ; EventT0 (ns) ; Entries / 2 ns",
84
85 // set label for h_EventTimingQuality
86 m_histEventTimingQuality->GetXaxis()->SetBinLabel(1, "None");
87 m_histEventTimingQuality->GetXaxis()->SetBinLabel(2, "Coarse");
88 m_histEventTimingQuality->GetXaxis()->SetBinLabel(3, "Fine");
89 m_histEventTimingQuality->GetXaxis()->SetBinLabel(4, "Super fine");
90
91 // EventT0 histograms for different TC energy region
92 for (int energyBin = 0; energyBin < c_NBinEventT0; energyBin++) {
93
94 // set TC energy(ADC) ranges for each histogram
95 std::stringstream ss1, ss2;
96 ss1 << std::setfill('0') << std::setw(3) << std::to_string(10 + 20 * energyBin);
97 ss2 << std::setfill('0') << std::setw(3) << std::to_string(10 + 20 * (energyBin + 1));
98 TString ECUT1 = ss1.str() + "to" + ss2.str();
99 TString ECUT2 = ss1.str() + "-" + ss2.str();
100
101 // EventT0
102 m_histEventT0[energyBin] =
103 new TH1F("h_EventT0_MaxTCE_" + ECUT1 + "",
104 "[TRGECL] EventT0 MaxTCE (" + ECUT2 + " ADC) ; EventT0 (ns); Entries / 2 ns",
105 m_histEventT0NBin[energyBin],
106 m_histEventT0XMin[energyBin],
107 m_histEventT0XMax[energyBin]);
108 }
109
110 oldDir->cd();
111}
112
114{
115 m_eventT0.isOptional();
116 REG_HISTOGRAM
117}
118
120{
121
122 if (!m_eventT0.isValid()) {
123 B2DEBUG(20, "No EventT0 is found.");
124 return;
125 }
126
127 if (!m_objTrgSummary.isValid()) {
128 B2DEBUG(20, "No TRGSummary is found.");
129 return;
130 }
131
132 m_histMaxTCE->Reset();
133 m_histMaxTCId->Reset();
134 m_histMaxTCThetaId->Reset();
136 m_histEventT0Coarse->Reset();
137 m_histEventT0Fine->Reset();
138
139 for (int energyBin = 0; energyBin < c_NBinEventT0; energyBin++) {
140 m_histEventT0[energyBin]->Reset();
141 }
142
143}
144
146{
147
148 // check TRGSummary object
149 if (!m_objTrgSummary.isValid()) {
150 B2DEBUG(20, "TRGSummary object not available");
151 return;
152 }
156 int m_L1TimingSrc = m_objTrgSummary->getTimType();
157 // accept only event that L1 timing is from ECL trigger
158 if (m_L1TimingSrc != 0) {
159 B2DEBUG(20, "This event is not deternied by ECL trigger.");
160 return ;
161 }
162
163 // Skip this event if there is no EventT0, to avoid crashing other DQM
164 if (!m_eventT0.isOptional()) {
165 B2DEBUG(20, "No EventT0 is found.");
166 return;
167 }
168
169 // Determine if there is a valid EventT0 to use and then extract the information about it
170 if (!m_eventT0.isValid()) {
171 B2DEBUG(20, "No valid EventT0 is found.");
172 return ;
173 }
174
175 // get event timing window of ecl trigger
176 int evt_win = -1000;
177 int evt_time_win = -1000;
179 evt_win = iii.getEvtWin();
180 evt_time_win = iii.getEvtTimeWin();
181 }
182 int flag_win_a = -1;
183 int flag_win_b = -1;
184 if (evt_win == 3) {
185 if (evt_time_win == -1) {
186 flag_win_a = 2;
187 flag_win_b = 3;
188 } else {
189 flag_win_a = 3;
190 flag_win_b = 4;
191 }
192 } else if (evt_win == 4) {
193 if (evt_time_win == -1) {
194 flag_win_a = 3;
195 flag_win_b = 4;
196 } else {
197 flag_win_a = 4;
198 flag_win_b = 5;
199 }
200 } else {
201 B2DEBUG(20, "L1 timing is out of ETM hit window");
202 return;
203 }
204
205 // TC information
206 int MaxTCEnergy = 0;
207 int MaxTCId = -1000;
208 int MaxTCThetaId = 0;
210 // L1 window selection
211 int hit_win = iii.getHitWin();
212 if (!(hit_win == flag_win_a ||
213 hit_win == flag_win_b)) { continue; }
214 int TCId = iii.getTCId();
215 int TCEnergy = iii.getTCEnergy();
216 if (TCId < 1 || TCId > 576 || TCEnergy == 0) { continue; }
217 // select most energetic TC
218 if (TCEnergy > MaxTCEnergy) {
219 MaxTCEnergy = TCEnergy;
220 MaxTCId = TCId;
221 MaxTCThetaId = m_trgecl_map->getTCThetaIdFromTCId(TCId);
222 }
223 }
224 if (MaxTCId == -1000) {
225 B2DEBUG(20, "No max TC is found.");
226 return;
227 }
228 m_histMaxTCE->Fill(MaxTCEnergy);
229 m_histMaxTCId->Fill(MaxTCId);
230 m_histMaxTCThetaId->Fill(MaxTCThetaId);
231
232 // Event timing quality from TRGSummary
233 // 0=none, 1=coarse, 2=fine, 3=super fine
234 int gdlTimQuality = m_objTrgSummary->getTimQuality();
235 m_histEventTimingQuality->Fill(gdlTimQuality);
236
237 // get EventT0
238 const double eventT0 =
239 m_eventT0->hasEventT0() ?
240 m_eventT0->getEventT0() : -1000;
241
242 // EventT0 with coarse or fine event timing
243 if (gdlTimQuality == 1) {
244 // coarse
245 if (eventT0 > m_histEventT0CoarseXMin &&
246 eventT0 < m_histEventT0CoarseXMax) {
247 m_histEventT0Coarse->Fill(eventT0);
248 }
249 } else if (gdlTimQuality >= 2) {
250 // fine or super fine
251 if (eventT0 > m_histEventT0FineXMin &&
252 eventT0 < m_histEventT0FineXMax) {
253 m_histEventT0Fine->Fill(eventT0);
254 }
255 }
256
257 // set TC energy region for EventT0
258 bool IsMaxTCEnergy[c_NBinEventT0] = {false};
259 int EnergyBinWidth = 20;
260 for (int idx = 0; idx < c_NBinEventT0; idx++) {
261 if (MaxTCEnergy >= 10 + EnergyBinWidth * idx &&
262 MaxTCEnergy <= 10 + EnergyBinWidth * (idx + 1)) {
263 IsMaxTCEnergy[idx] = true;
264 }
265 }
266
267 // fill EventT0 for different TC energy region
268 for (int binADC = 0 ; binADC < c_NBinEventT0; binADC++) {
269 if (IsMaxTCEnergy[binADC] == true) {
270 if (eventT0 > m_histEventT0XMin[binADC] &&
271 eventT0 < m_histEventT0XMax[binADC]) {
272 m_histEventT0[binADC]->Fill(eventT0);
273 }
274 }
275 }
276
277}
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
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
double m_histEventT0FineXMin
x-axis minimum for EventT0 with fine event timing
StoreObjPtr< EventT0 > m_eventT0
EventT0 data object.
double m_histEventT0FineXMax
x-axis maximum for EventT0 with fine event timing
TH1F * m_histEventTimingQuality
Event Timing Quality from TRGSummary.
std::vector< double > m_histEventT0XMin
x axis minimum for EventT0 histogram
virtual void initialize() override
Initialize the module.
virtual void event() override
This method is called for each event.
StoreArray< TRGECLUnpackerStore > m_trgeclUnpackerStores
Trg ECL UnpakcerStore.
TH1F * m_histEventT0Coarse
EventT0 with coarse event timing.
StoreObjPtr< TRGSummary > m_objTrgSummary
Trigger Summary data object.
virtual void beginRun() override
This method is called for each run.
TH1F * m_histEventT0Fine
EventT0 with fine event timing.
TrgEclMapping * m_trgecl_map
ecl trigger map
std::vector< int > m_histEventT0NBin
the number of bin for EventT0 histogram
StoreArray< TRGECLUnpackerEvtStore > m_trgeclUnpackerEvtStores
Trg ECL UnpakcerEvtStore.
TH1F * m_histEventT0[c_NBinEventT0]
EventT0 for different max TC E region.
double m_histEventT0CoarseXMin
x-axis minimum for EventT0 with coarse event timing
double m_histEventT0CoarseXMax
x-axis maximum for EventT0 with coarse event timing
static const int c_NBinEventT0
The number of EventT0 histogram for different max TC E region.
std::vector< double > m_histEventT0XMax
x axis maximum for EventT0 histogram
virtual void defineHisto() override
Defination of histograms.
A class of TC Mapping.
Definition: TrgEclMapping.h:26
int getTCThetaIdFromTCId(int)
get [TC Theta ID] from [TC ID]
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.