Belle II Software development
PXDGatedModeDQMModule.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 <pxd/modules/pxdDQM/PXDGatedModeDQMModule.h>
10#include <pxd/dataobjects/PXDRawHit.h>
11#include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
12#include "TDirectory.h"
13
14using namespace std;
15using namespace Belle2;
16using namespace Belle2::PXD;
17using namespace Belle2::VXD;
18
19//-----------------------------------------------------------------
20// Register the Module
21//-----------------------------------------------------------------
22REG_MODULE(PXDGatedModeDQM);
23
24//-----------------------------------------------------------------
25// Implementation
26//-----------------------------------------------------------------
27
29{
30 //Set module properties
31 setDescription("Monitor GatedMode");
33 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed",
34 std::string("PXDINJ"));
35 addParam("PXDRawHitsName", m_PXDRawHitsName, "Name of PXD raw hits", std::string(""));
36 addParam("perGate", m_perGate, "Make plots per GM Start Gate", true);
37 addParam("minTimeCutLER", m_minTimeCutLER, "minimum time cut in us after LER kick", 20);
38 addParam("maxTimeCutLER", m_maxTimeCutLER, "maximum time cut in us after LER kick", 4980);
39 addParam("minTimeCutHER", m_minTimeCutHER, "minimum time cut in us after HER kick", 20);
40 addParam("maxTimeCutHER", m_maxTimeCutHER, "maximum time cut in us after HER kick", 4980);
41 addParam("outsideTimeCut", m_outsideTimeCut, "outside GM time cut in us after kick", 20000);
42 addParam("chargeCut", m_chargeCut, "minimum pixel ADU charge cut", 5);
43 addParam("chargeCutHigh", m_chargeCutHigh, "minimum pixel ADU charge cut for second set of histograms", 20);
44}
45
47{
48 TDirectory* oldDir = gDirectory;
49 oldDir->mkdir(m_histogramDirectoryName.c_str());// do not rely on return value, might be ZERO
50 oldDir->cd(m_histogramDirectoryName.c_str());//changing to the right directory
51
52 hBunchInjHER = new TH1F("hBunchInjHER", "Last Inj Bunch HER;Counts;BunchNr/4", 1280, 0, 1280);
53 hBunchInjLER = new TH1F("hBunchInjLER", "Last Inj Bunch LER;Counts;BunchNr/4", 1280, 0, 1280);
54 hBunchTrg = new TH1F("hBunchTrg", "Triggered Bunch;Counts;BunchNr/4", 1280, 0, 1280);
55
56
57 std::vector<VxdID> sensors = m_vxdGeometry.getListOfSensors();
58 for (VxdID& avxdid : sensors) {
59 VXD::SensorInfoBase info = m_vxdGeometry.getSensorInfo(avxdid);
60 if (info.getType() != VXD::SensorInfoBase::PXD) continue;
61 // Only interested in PXD sensors
62
63 TString buff = (std::string)avxdid;
64 TString buffus = buff;
65 buffus.ReplaceAll(".", "_");
66
67 for (int rgate = m_perGate ? 0 : 96; rgate <= 96; rgate++) { // 96 is no gating
68 hGatedModeMapLER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapLER_%d_", rgate) + buffus,
69 Form("PXDGatedModeMapLER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
70 hGatedModeMapHER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapHER_%d_", rgate) + buffus,
71 Form("PXDGatedModeMapHER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
72 hGatedModeMapCutLER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapCutLER_%d_", rgate) + buffus,
73 Form("PXDGatedModeMapCutLER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
74 hGatedModeMapCutHER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapCutHER_%d_", rgate) + buffus,
75 Form("PXDGatedModeMapCutHER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
76
77 hGatedModeMapADCLER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapADCLER_%d_", rgate) + buffus,
78 Form("PXDGatedModeMapADCLER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
79 hGatedModeMapADCHER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapADCHER_%d_", rgate) + buffus,
80 Form("PXDGatedModeMapADCHER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
81 hGatedModeMapCutADCLER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapCutADCLER_%d_", rgate) + buffus,
82 Form("PXDGatedModeMapCutADCLER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
83 hGatedModeMapCutADCHER[std::make_pair(avxdid, rgate)] = new TH2F(Form("PXDGatedModeMapCutADCHER_%d_", rgate) + buffus,
84 Form("PXDGatedModeMapCutADCHER %d ", rgate) + buff + ";U;V", 25, 0, 250, 192, 0, 768);
85 }
86 hGatedModeProjLER[avxdid] = new TH2F("PXDGatedModeProjLER_" + buffus,
87 "PXDGatedModeProjLER " + buff + ";Gate;V", 96, 0, 96, 192, 0, 768);
88 hGatedModeProjHER[avxdid] = new TH2F("PXDGatedModeProjHER_" + buffus,
89 "PXDGatedModeProjHER " + buff + ";Gate;V", 96, 0, 96, 192, 0, 768);
90
91 hGatedModeMapSubLER[avxdid] = new TH2F("PXDGatedModeMapSubLER_" + buffus,
92 "PXDGatedModeMapSubLER " + buff + ";U;V-G", 25, 0, 250, 192, 0, 768);
93 hGatedModeMapSubHER[avxdid] = new TH2F("PXDGatedModeMapSubHER_" + buffus,
94 "PXDGatedModeMapSubHER " + buff + ";U;V-G", 25, 0, 250, 192, 0, 768);
95 hGatedModeMapAddLER[avxdid] = new TH2F("PXDGatedModeMapAddLER_" + buffus,
96 "PXDGatedModeMapAddLER " + buff + ";U;V+G", 25, 0, 250, 192, 0, 768);
97 hGatedModeMapAddHER[avxdid] = new TH2F("PXDGatedModeMapAddHER_" + buffus,
98 "PXDGatedModeMapAddHER " + buff + ";U;V+G", 25, 0, 250, 192, 0, 768);
99
100 hGatedModeProjADCLER[avxdid] = new TH2F("PXDGatedModeProjADCLER_" + buffus,
101 "PXDGatedModeProjADCLER " + buff + ";Gate;V", 96, 0, 96, 192, 0, 768);
102 hGatedModeProjADCHER[avxdid] = new TH2F("PXDGatedModeProjADCHER_" + buffus,
103 "PXDGatedModeProjADCHER " + buff + ";Gate;V", 96, 0, 96, 192, 0, 768);
104
105 hGatedModeMapSubADCLER[avxdid] = new TH2F("PXDGatedModeMapSubADCLER_" + buffus,
106 "PXDGatedModeMapSubADCLER " + buff + ";U;V-G", 25, 0, 250, 192, 0, 768);
107 hGatedModeMapSubADCHER[avxdid] = new TH2F("PXDGatedModeMapSubADCHER_" + buffus,
108 "PXDGatedModeMapSubADCHER " + buff + ";U;V-G", 25, 0, 250, 192, 0, 768);
109 hGatedModeMapAddADCLER[avxdid] = new TH2F("PXDGatedModeMapAddADCLER_" + buffus,
110 "PXDGatedModeMapAddADCLER " + buff + ";U;V+G", 25, 0, 250, 192, 0, 768);
111 hGatedModeMapAddADCHER[avxdid] = new TH2F("PXDGatedModeMapAddADCHER_" + buffus,
112 "PXDGatedModeMapAddADCHER " + buff + ";U;V+G", 25, 0, 250, 192, 0, 768);
113
114 }
115 // cd back to root directory
116 oldDir->cd();
117}
118
120{
121 REG_HISTOGRAM
123 m_EventLevelTriggerTimeInfo.isRequired();
124
125}
126
128{
129 // reset all histograms
130 hBunchInjHER->Reset();
131 hBunchInjLER->Reset();
132 hBunchTrg->Reset();
133
134 for (auto& it : hGatedModeMapLER) if (it.second) it.second->Reset();
135 for (auto& it : hGatedModeMapHER) if (it.second) it.second->Reset();
136 for (auto& it : hGatedModeMapCutLER) if (it.second) it.second->Reset();
137 for (auto& it : hGatedModeMapCutHER) if (it.second) it.second->Reset();
138 for (auto& it : hGatedModeMapADCLER) if (it.second) it.second->Reset();
139 for (auto& it : hGatedModeMapADCHER) if (it.second) it.second->Reset();
140 for (auto& it : hGatedModeMapCutADCLER) if (it.second) it.second->Reset();
141 for (auto& it : hGatedModeMapCutADCHER) if (it.second) it.second->Reset();
142
143 for (auto& it : hGatedModeProjLER) if (it.second) it.second->Reset();
144 for (auto& it : hGatedModeProjHER) if (it.second) it.second->Reset();
145 for (auto& it : hGatedModeMapSubLER) if (it.second) it.second->Reset();
146 for (auto& it : hGatedModeMapSubHER) if (it.second) it.second->Reset();
147 for (auto& it : hGatedModeMapAddLER) if (it.second) it.second->Reset();
148 for (auto& it : hGatedModeMapAddHER) if (it.second) it.second->Reset();
149 for (auto& it : hGatedModeProjADCLER) if (it.second) it.second->Reset();
150 for (auto& it : hGatedModeProjADCHER) if (it.second) it.second->Reset();
151 for (auto& it : hGatedModeMapSubADCLER) if (it.second) it.second->Reset();
152 for (auto& it : hGatedModeMapSubADCHER) if (it.second) it.second->Reset();
153 for (auto& it : hGatedModeMapAddADCLER) if (it.second) it.second->Reset();
154 for (auto& it : hGatedModeMapAddADCHER) if (it.second) it.second->Reset();
155}
156
158{
159 // And check if the stored data is valid
160 if (m_EventLevelTriggerTimeInfo.isValid() and m_EventLevelTriggerTimeInfo->isValid()) {
161 // check time overflow, too long ago
162 if (m_EventLevelTriggerTimeInfo->hasInjection()) {
163 // get last injection time
164 auto isher = m_EventLevelTriggerTimeInfo->isHER();
165 float difference = m_EventLevelTriggerTimeInfo->getTimeSinceLastInjection() / 127. ; // 127MHz clock ticks to us, inexact rounding
166 int bunch_trg = m_EventLevelTriggerTimeInfo->getBunchNumber();
167 int time_inj = m_EventLevelTriggerTimeInfo->getTimeSinceLastInjection();
168 int bunch_inj = (bunch_trg - time_inj) % 1280;
169 if (bunch_inj < 0) bunch_inj += 1280;
170 int rgate = bunch_inj / (1280. / 96.); // 0-96 ?
171 if ((isher && difference >= m_minTimeCutHER && difference <= m_maxTimeCutHER) ||
172 (!isher && difference >= m_minTimeCutLER && difference <= m_maxTimeCutLER)
173 ) { // be sure that we fill only in gating region
174 hBunchTrg->Fill(m_EventLevelTriggerTimeInfo->getBunchNumber() & 0x7FF);
175 if (isher) hBunchInjHER->Fill(bunch_inj);
176 else hBunchInjLER->Fill(bunch_inj);
177 for (auto& p : m_storeRawHits) {
178 auto charge = p.getCharge();
179 if (charge > m_chargeCut) {
180 int v = int(p.getVCellID()) - rgate * 4;
181 if (v < 0) v += 768;
182 int v2 = int(p.getVCellID()) + rgate * 4;
183 if (v2 >= 768) v2 -= 768;
184 if (isher) {
185 auto h = hGatedModeMapHER[std::make_pair(p.getSensorID(), rgate)];
186 if (h) {
187 h->Fill(p.getUCellID(), p.getVCellID());
188 }
189 auto h2 = hGatedModeProjHER[p.getSensorID()];
190 if (h2) {
191 h2->Fill(rgate, p.getVCellID());
192 }
193 auto h3 = hGatedModeMapSubHER[p.getSensorID()];
194 if (h3) {
195 h3->Fill(p.getUCellID(), v);
196 }
197 auto h4 = hGatedModeMapAddHER[p.getSensorID()];
198 if (h4) {
199 h4->Fill(p.getUCellID(), v2);
200 }
201 auto h5 = hGatedModeMapADCHER[std::make_pair(p.getSensorID(), rgate)];
202 if (h5) {
203 h5->Fill(p.getUCellID(), p.getVCellID(), p.getCharge());
204 }
205 auto h6 = hGatedModeProjADCHER[p.getSensorID()];
206 if (h6) {
207 h6->Fill(rgate, p.getVCellID(), p.getCharge());
208 }
209 auto h7 = hGatedModeMapSubADCHER[p.getSensorID()];
210 if (h7) {
211 h7->Fill(p.getUCellID(), v, p.getCharge());
212 }
213 auto h8 = hGatedModeMapAddADCHER[p.getSensorID()];
214 if (h8) {
215 h8->Fill(p.getUCellID(), v2, p.getCharge());
216 }
217 } else {
218 auto h = hGatedModeMapLER[std::make_pair(p.getSensorID(), rgate)];
219 if (h) {
220 h->Fill(p.getUCellID(), p.getVCellID());
221 }
222 auto h2 = hGatedModeProjLER[p.getSensorID()];
223 if (h2) {
224 h2->Fill(rgate, p.getVCellID());
225 }
226 auto h3 = hGatedModeMapSubLER[p.getSensorID()];
227 if (h3) {
228 h3->Fill(p.getUCellID(), v);
229 }
230 auto h4 = hGatedModeMapAddLER[p.getSensorID()];
231 if (h4) {
232 h4->Fill(p.getUCellID(), v2);
233 }
234 auto h5 = hGatedModeMapADCLER[std::make_pair(p.getSensorID(), rgate)];
235 if (h5) {
236 h5->Fill(p.getUCellID(), p.getVCellID(), p.getCharge());
237 }
238 auto h6 = hGatedModeProjADCLER[p.getSensorID()];
239 if (h6) {
240 h6->Fill(rgate, p.getVCellID(), p.getCharge());
241 }
242 auto h7 = hGatedModeMapSubADCLER[p.getSensorID()];
243 if (h7) {
244 h7->Fill(p.getUCellID(), v, p.getCharge());
245 }
246 auto h8 = hGatedModeMapAddADCLER[p.getSensorID()];
247 if (h8) {
248 h8->Fill(p.getUCellID(), v2, p.getCharge());
249 }
250 }
251 }
252 if (m_chargeCutHigh > 30) {
253
254 if (isher) {
255 auto h = hGatedModeMapCutHER[std::make_pair(p.getSensorID(), rgate)];
256 if (h) {
257 h->Fill(p.getUCellID(), p.getVCellID());
258 }
259 auto h2 = hGatedModeMapCutADCHER[std::make_pair(p.getSensorID(), rgate)];
260 if (h2) {
261 h2->Fill(p.getUCellID(), p.getVCellID(), p.getCharge());
262 }
263 } else {
264 auto h = hGatedModeMapCutLER[std::make_pair(p.getSensorID(), rgate)];
265 if (h) {
266 h->Fill(p.getUCellID(), p.getVCellID());
267 }
268 auto h2 = hGatedModeMapCutADCLER[std::make_pair(p.getSensorID(), rgate)];
269 if (h2) {
270 h2->Fill(p.getUCellID(), p.getVCellID(), p.getCharge());
271 }
272 }
273 }
274 }
275 } else if (difference > m_outsideTimeCut) {
276 rgate = 96;
277 for (auto& p : m_storeRawHits) {
278 if (isher) {
279 auto h = hGatedModeMapHER[std::make_pair(p.getSensorID(), rgate)];
280 if (h) {
281 h->Fill(p.getUCellID(), p.getVCellID());
282 }
283 auto h2 = hGatedModeMapADCHER[std::make_pair(p.getSensorID(), rgate)];
284 if (h2) {
285 h2->Fill(p.getUCellID(), p.getVCellID(), p.getCharge());
286 }
287 } else {
288 auto h = hGatedModeMapLER[std::make_pair(p.getSensorID(), rgate)];
289 if (h) {
290 h->Fill(p.getUCellID(), p.getVCellID());
291 }
292 auto h2 = hGatedModeMapADCLER[std::make_pair(p.getSensorID(), rgate)];
293 if (h2) {
294 h2->Fill(p.getUCellID(), p.getVCellID(), p.getCharge());
295 }
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::map< VxdID, TH2F * > hGatedModeProjLER
Histogram Occupancy after LER injection.
std::string m_PXDRawHitsName
The name of the StoreArray of PXDRawHits to be generated.
std::map< VxdID, TH2F * > hGatedModeProjHER
Histogram Occupancy after HER injection.
void initialize() override final
initialize function
bool m_perGate
make one plot per possible gate
PXDGatedModeDQMModule()
Constructor defining the parameters.
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapHER
Histogram Occupancy after HER injection.
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapADCLER
Histogram Occupancy after LER injection.
int m_minTimeCutLER
minimum time cut in us after LER kick
std::map< VxdID, TH2F * > hGatedModeMapSubHER
Histogram Occupancy after HER injection.
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapLER
Histogram Occupancy after LER injection.
std::map< VxdID, TH2F * > hGatedModeMapAddADCHER
Histogram Occupancy after HER injection.
int m_outsideTimeCut
outside GM time cut in us after kick
void defineHisto() override final
defineHisto function
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapADCHER
Histogram Occupancy after HER injection.
std::map< VxdID, TH2F * > hGatedModeMapSubADCLER
Histogram Occupancy after LER injection.
std::map< VxdID, TH2F * > hGatedModeMapAddLER
Histogram Occupancy after LER injection.
int m_maxTimeCutLER
maximum time cut in us after LER kick
int m_maxTimeCutHER
maximum time cut in us after HER kick
int m_chargeCut
minimum charge cut in ADU
void event() override final
event function
int m_minTimeCutHER
minimum time cut in us after HER kick
std::map< VxdID, TH2F * > hGatedModeProjADCLER
Histogram Occupancy after LER injection.
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
TH1F * hBunchInjLER
Histo for last LER injected bunches.
int m_chargeCutHigh
minimum charge cut for second set of histograms in ADU
std::map< VxdID, TH2F * > hGatedModeMapSubLER
Histogram Occupancy after LER injection.
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapCutLER
Histogram Occupancy after LER injection.
std::map< VxdID, TH2F * > hGatedModeMapSubADCHER
Histogram Occupancy after HER injection.
void beginRun() override final
beginRun function
std::map< VxdID, TH2F * > hGatedModeMapAddADCLER
Histogram Occupancy after LER injection.
VXD::GeoCache & m_vxdGeometry
the VXD geometry
std::map< VxdID, TH2F * > hGatedModeMapAddHER
Histogram Occupancy after HER injection.
TH1F * hBunchTrg
Histo for triggered bunches.
std::map< VxdID, TH2F * > hGatedModeProjADCHER
Histogram Occupancy after HER injection.
StoreObjPtr< EventLevelTriggerTimeInfo > m_EventLevelTriggerTimeInfo
Object for TTD mdst object.
StoreArray< PXDRawHit > m_storeRawHits
Input array for PXD Raw Hits.
TH1F * hBunchInjHER
Histo for last HER injected bunches.
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapCutHER
Histogram Occupancy after HER injection.
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapCutADCLER
Histogram Occupancy after LER injection.
std::map< std::pair< VxdID, int >, TH2F * > hGatedModeMapCutADCHER
Histogram Occupancy after HER injection.
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
Definition GeoCache.h:38
Base class to provide Sensor Information for PXD and SVD.
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
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
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Namespace to provide code needed by both Vertex Detectors, PXD and SVD, and also testbeam telescopes.
Definition GeoCache.h:33
Abstract base class for different kinds of events.
STL namespace.