Belle II Software development
TrackingAbortDQMModule.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 "tracking/modules/trackingDQM/TrackingAbortDQMModule.h"
10
11#include <framework/dataobjects/EventMetaData.h>
12#include <svd/dataobjects/SVDShaperDigit.h>
13#include <svd/dataobjects/SVDCluster.h>
14#include <cdc/dataobjects/CDCHit.h>
15#include <mdst/dataobjects/EventLevelTrackingInfo.h>
16#include <mdst/dataobjects/TRGSummary.h>
17
18#include <TDirectory.h>
19#include <TLine.h>
20#include <TStyle.h>
21
22#include <algorithm>
23
24
25using namespace Belle2;
26
27//-----------------------------------------------------------------
28// Register the Module
29//-----------------------------------------------------------------
30REG_MODULE(TrackingAbortDQM);
31
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
38{
39 setDescription("DQM Module to monitor Tracking Aborts and detector-related quantities.");
40
41 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where histograms will be placed.",
42 std::string("TrackingAbort"));
43
45}
46
47
48TrackingAbortDQMModule::~TrackingAbortDQMModule()
49{
50}
51
52//------------------------------------------------------------------
53// Function to define histograms
54//-----------------------------------------------------------------
55
57{
58
59 // Create a separate histogram directories and cd into it.
60 TDirectory* oldDir = gDirectory;
61 if (m_histogramDirectoryName != "") {
62 oldDir->mkdir(m_histogramDirectoryName.c_str());
63 oldDir->cd(m_histogramDirectoryName.c_str());
64 }
65
66 //histogram index:
67 // 0 if the event is triggered OUTSIDE the active_veto window
68 std::string tag[2] = {"OUT", "IN"};
69 std::string title[2] = {"[Outside Active Veto Window]", "[Inside Active Veto Window]"};
70
71
72 //number of events with and without at least one abort
73 //outside active_veto window:
74 std::string histoName = "EventsWithAborts";
75 std::string histoTitle = "Events With at Least one Abort";
76 m_nEventsWithAbort[0] = new TH1F(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
77 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
78 2, -0.5, 1.5);
79 m_nEventsWithAbort[0]->GetYaxis()->SetTitle("Number of Events");
80 m_nEventsWithAbort[0]->GetXaxis()->SetBinLabel(1, "No Abort");
81 m_nEventsWithAbort[0]->GetXaxis()->SetBinLabel(2, "At Least One Abort");
82 m_nEventsWithAbort[0]->SetMinimum(0.1);
83
84 //inside active_veto window:
85 m_nEventsWithAbort[1] = new TH1F(*m_nEventsWithAbort[0]);
86 m_nEventsWithAbort[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
87 m_nEventsWithAbort[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
88
89 //abort flag reason
90 //outside active_veto window:
91 histoName = "TrkAbortReason";
92 histoTitle = "Tracking Abort Reason";
93 m_trackingErrorFlagsReasons[0] = new TH1F(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
94 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
95 5, -0.5, 4.5);
96 m_trackingErrorFlagsReasons[0]->GetXaxis()->SetTitle("Type of error occurred");
97 m_trackingErrorFlagsReasons[0]->GetYaxis()->SetTitle("Number of Events");
98 m_trackingErrorFlagsReasons[0]->GetXaxis()->SetBinLabel(1, "Unspecified PR");
99 m_trackingErrorFlagsReasons[0]->GetXaxis()->SetBinLabel(2, "VXDTF2");
100 m_trackingErrorFlagsReasons[0]->GetXaxis()->SetBinLabel(3, "SVDCKF");
101 m_trackingErrorFlagsReasons[0]->GetXaxis()->SetBinLabel(4, "PXDCKF");
102 m_trackingErrorFlagsReasons[0]->GetXaxis()->SetBinLabel(5, "SpacePoint");
103 //inside active_veto window:
105 m_trackingErrorFlagsReasons[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
106 m_trackingErrorFlagsReasons[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
107
108
109 //SVD L3 occupancy - see SVDDQMDose module for details
110 histoName = "SVDL3UOcc";
111 histoTitle = "SVD L3 u-side ZS5 Occupancy (%)";
112 //outside active_veto window:
113 m_svdL3uZS5Occupancy[0] = new TH1F(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
114 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
115 90, 0, 100.0 / 1536.0 * 90);
116 m_svdL3uZS5Occupancy[0]->GetXaxis()->SetTitle("occupancy [%]");
117 m_svdL3uZS5Occupancy[0]->GetYaxis()->SetTitle("Number of Events");
118 //inside active_veto window:
120 m_svdL3uZS5Occupancy[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
121 m_svdL3uZS5Occupancy[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
122
123 //SVD L3 occupancy when VXDTF2 Aborts- see SVDDQMDose module for details
124 histoName = "SVDL3UOccVXDTF2aborts";
125 histoTitle = "SVD L3 u-side ZS5 Occupancy (%) when VXDTF2 Aborts";
126 //outside active_veto window:
127 m_svdL3uZS5Occupancy_VXDTF2aborts[0] = new TH1F(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
128 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
129 180, 0, 100.0 / 1536.0 * 180);
130 m_svdL3uZS5Occupancy_VXDTF2aborts[0]->GetXaxis()->SetTitle("occupancy [%]");
131 m_svdL3uZS5Occupancy_VXDTF2aborts[0]->GetYaxis()->SetTitle("Number of Events");
132 //inside active_veto window:
134 m_svdL3uZS5Occupancy_VXDTF2aborts[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
135 m_svdL3uZS5Occupancy_VXDTF2aborts[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
136
137//SVD L3 occupancy when toSVDCFK Aborts- see SVDDQMDose module for details
138 histoName = "SVDL3UOccToSVDCKFaborts";
139 histoTitle = "SVD L3 u-side ZS5 Occupancy (%) when toSVDCKF Aborts";
140 //outside active_veto window:
141 m_svdL3uZS5Occupancy_toSVDCKFaborts[0] = new TH1F(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
142 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
143 180, 0, 100.0 / 1536.0 * 180);
144 m_svdL3uZS5Occupancy_toSVDCKFaborts[0]->GetXaxis()->SetTitle("occupancy [%]");
145 m_svdL3uZS5Occupancy_toSVDCKFaborts[0]->GetYaxis()->SetTitle("Number of Events");
146 //inside active_veto window:
148 m_svdL3uZS5Occupancy_toSVDCKFaborts[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
149 m_svdL3uZS5Occupancy_toSVDCKFaborts[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
150
151 //CDC extra hits
152 histoName = "nCDCExtraHits";
153 histoTitle = "Number of CDC Extra Hits";
154 //outside active_veto window:
155 m_nCDCExtraHits[0] = new TH1F(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
156 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
157 200, 0, 5000);
158 m_nCDCExtraHits[0]->GetXaxis()->SetTitle("nCDCExtraHits");
159 m_nCDCExtraHits[0]->GetYaxis()->SetTitle("Number of Events");
160 //inside active_veto window:
161 m_nCDCExtraHits[1] = new TH1F(*m_nCDCExtraHits[0]);
162 m_nCDCExtraHits[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
163 m_nCDCExtraHits[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
164
165 //SVD L3 v-side cluster time
166 histoName = "svdL3VTime";
167 histoTitle = "Layer3 v-side Cluster Time Distribution";
168 //outside active_veto window:
169 m_svdTime[0] = new TH1F(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
170 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
171 300, -150, 150);
172 m_svdTime[0]->GetXaxis()->SetTitle("cluster time (ns)");
173 m_svdTime[0]->GetYaxis()->SetTitle("Number of Events");
174 //inside active_veto window:
175 m_svdTime[1] = new TH1F(*m_svdTime[0]);
176 m_svdTime[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
177 m_svdTime[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
178
179 //SVD, CDC Averages
180 histoName = "averages";
181 histoTitle = "Averages from SVD and CDC";
182 //outside active_veto window:
183 m_integratedAverages[0] = new TH1D(TString::Format("%s_%s", histoName.c_str(), tag[0].c_str()),
184 TString::Format("%s %s", histoTitle.c_str(), title[0].c_str()),
185 5, 0, 5);
186 m_integratedAverages[0]->GetYaxis()->SetTitle("Number of X [bin-dependent]");
187 m_integratedAverages[0]->GetXaxis()->SetBinLabel(1, "nCDCHitsInner");
188 m_integratedAverages[0]->GetXaxis()->SetBinLabel(2, "nCDCHitsOuter");
189 m_integratedAverages[0]->GetXaxis()->SetBinLabel(3, "nStripsZS5_L3V");
190 m_integratedAverages[0]->GetXaxis()->SetBinLabel(4, "nStripsZS5_L4U");
191 m_integratedAverages[0]->GetXaxis()->SetBinLabel(5, "nStripsZS5_L4V");
192 //inside active_veto window:
194 m_integratedAverages[1]->SetName(TString::Format("%s_%s", histoName.c_str(), tag[1].c_str()));
195 m_integratedAverages[1]->SetTitle(TString::Format("%s %s", histoTitle.c_str(), title[1].c_str()));
196
197 oldDir->cd();
198
199}
200
202{
203 m_eventLevelTrackingInfo.isOptional();
204 m_eventMetaData.isOptional();
205 m_trgSummary.isOptional();
206 m_strips.isOptional();
207 m_cdcHits.isOptional();
208
209 // Register histograms (calls back defineHisto)
210 REG_HISTOGRAM
211}
212
213
215{
216
217 if (m_trackingErrorFlagsReasons[0] != nullptr) m_trackingErrorFlagsReasons[0]->Reset();
218 if (m_trackingErrorFlagsReasons[1] != nullptr) m_trackingErrorFlagsReasons[1]->Reset();
219 if (m_nEventsWithAbort[0] != nullptr) m_nEventsWithAbort[0]->Reset();
220 if (m_nEventsWithAbort[1] != nullptr) m_nEventsWithAbort[1]->Reset();
221 if (m_svdL3uZS5Occupancy[0] != nullptr) m_svdL3uZS5Occupancy[0]->Reset();
222 if (m_svdL3uZS5Occupancy[1] != nullptr) m_svdL3uZS5Occupancy[1]->Reset();
227 if (m_nCDCExtraHits[0] != nullptr) m_nCDCExtraHits[0]->Reset();
228 if (m_nCDCExtraHits[1] != nullptr) m_nCDCExtraHits[1]->Reset();
229 if (m_svdTime[0] != nullptr) m_svdTime[0]->Reset();
230 if (m_svdTime[1] != nullptr) m_svdTime[1]->Reset();
231 if (m_integratedAverages[0] != nullptr) m_integratedAverages[0]->Reset();
232 if (m_integratedAverages[1] != nullptr) m_integratedAverages[1]->Reset();
233}
234
235
237{
238
239 //skip events in which we do not have EventMetaData or TRGSummary
240 if (!m_eventMetaData.isValid()) return;
241 if (!m_trgSummary.isValid()) return;
242
243 //skip the empty events
245 return;
246
248 return;
249
251 return;
252
254 return;
255
256 //find out if we are in the passive veto (i=0) or in the active veto window (i=1)
257 int index = 0; //events accepted in the passive veto window but not in the active
258 try {
259 if (m_trgSummary->testInput("passive_veto") == 1 && m_trgSummary->testInput("cdcecl_veto") == 0) index = 1;
260 } catch (const std::exception&) {
261 }
262
263 //fill the tracking abort reason histogram & nEvents with Abort
264 if (m_eventLevelTrackingInfo.isValid()) {
265 if (m_eventLevelTrackingInfo->hasAnErrorFlag()) {
266
267 m_nEventsWithAbort[index]->Fill(1);
268
269 if (m_eventLevelTrackingInfo->hasUnspecifiedTrackFindingFailure())
270 m_trackingErrorFlagsReasons[index]->Fill(0);
271 if (m_eventLevelTrackingInfo->hasVXDTF2AbortionFlag())
272 m_trackingErrorFlagsReasons[index]->Fill(1);
273 if (m_eventLevelTrackingInfo->hasSVDCKFAbortionFlag())
274 m_trackingErrorFlagsReasons[index]->Fill(2);
275 if (m_eventLevelTrackingInfo->hasPXDCKFAbortionFlag())
276 m_trackingErrorFlagsReasons[index]->Fill(3);
277 if (m_eventLevelTrackingInfo->hasSVDSpacePointCreatorAbortionFlag())
278 m_trackingErrorFlagsReasons[index]->Fill(4);
279 } else { //EventLevelTrackingInfo valid but no error
280 m_nEventsWithAbort[index]->Fill(0);
281 }
282 } else //EventLevelTrackingInfo not valid
283 m_nEventsWithAbort[index]->Fill(0);
284
285 //compute the number of ZS5 strips of L3 and L4, both sides
286 float nStripsL3UZS5 = 0;
287 float nStripsL3VZS5 = 0;
288 float nStripsL4UZS5 = 0;
289 float nStripsL4VZS5 = 0;
290 for (const SVDShaperDigit& hit : m_strips) {
291 const VxdID& sensorID = hit.getSensorID();
292 if (sensorID.getLayerNumber() > 4) continue;
293 const float noise = m_NoiseCal.getNoise(sensorID, hit.isUStrip(), hit.getCellID());
294 const float cutMinSignal = std::round(5 * noise);
295
296 if (hit.passesZS(1, cutMinSignal)) {
297 if (sensorID.getLayerNumber() == 3) {
298 if (hit.isUStrip()) nStripsL3UZS5++;
299 else nStripsL3VZS5++;
300 } else if (hit.isUStrip()) nStripsL4UZS5++;
301 else nStripsL4VZS5++;
302 }
303 }
304
305 //fill the SVD L3 v-side cluster time
306 for (const SVDCluster& hit : m_clusters) {
307 const VxdID& sensorID = hit.getSensorID();
308 if (sensorID.getLayerNumber() != 3) continue;
309 if (hit.isUCluster()) continue;
310
311 m_svdTime[index]->Fill(hit.getClsTime());
312 }
313
314 // fill the svd L3 v ZS5 occupancy, add the overflow in the last bin to make them visible in the plot
315 double tmp_L3uZS5occupancy = (double)nStripsL3UZS5 / m_nStripsL3U * 100;
316 double L3uZS5occupancy = std::min(tmp_L3uZS5occupancy, (double)100.0 / 1536.0 * 90);
317 m_svdL3uZS5Occupancy[index]->Fill(L3uZS5occupancy);
318 double L3uZS5occupancy_abort = std::min(tmp_L3uZS5occupancy, (double)100.0 / 1536.0 * 180);
319 if (m_eventLevelTrackingInfo->hasVXDTF2AbortionFlag())
320 m_svdL3uZS5Occupancy_VXDTF2aborts[index]->Fill(L3uZS5occupancy_abort);
321 if (m_eventLevelTrackingInfo->hasSVDCKFAbortionFlag())
322 m_svdL3uZS5Occupancy_toSVDCKFaborts[index]->Fill(L3uZS5occupancy_abort);
323
324 //fill the nCDCExtraHits, add the overflow in the last bin to make them visible in the plot
325 if (m_eventLevelTrackingInfo.isValid())
326 m_nCDCExtraHits[index]->Fill(std::min((int)m_eventLevelTrackingInfo->getNCDCHitsNotAssigned(), (int)4999));
327
328 //compute number of CDC hits in the inner and outer layers
329 int nCDCHitsInner = 0;
330 int nCDCHitsOuter = 0;
331 for (const CDCHit& hit : m_cdcHits) {
332 if (hit.getISuperLayer() == 0) nCDCHitsInner++;
333 else nCDCHitsOuter++;
334 }
335
336 // fill the integrated averages TH1F
337 // bin 1: nCDCHits Inner layers
338 updateBinContent(index, 1, nCDCHitsInner);
339 // bin 2: nCDCHits Outer layers
340 updateBinContent(index, 2, nCDCHitsOuter);
341 // bin 3: nStrips L3 V-side
342 updateBinContent(index, 3, nStripsL3VZS5);
343 // bin 4: nStrips L4 U-side
344 updateBinContent(index, 4, nStripsL4UZS5);
345 // bin 5: nStrips L4 V-side
346 updateBinContent(index, 5, nStripsL4VZS5);
347
348
349}
350
351void TrackingAbortDQMModule::updateBinContent(int index, int bin, float valueToBeAdded)
352{
353 float oldValue = m_integratedAverages[index]->GetBinContent(bin);
354 m_integratedAverages[index]->SetBinContent(bin, oldValue + valueToBeAdded);
355}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
@ c_B2LinkPacketCRCError
Belle2link CRC error is detected in the event.
@ c_HLTCrash
The HLT reconstruction crashed in this event or the event before.
@ c_ReconstructionAbort
The event was not reconstructed, e.g.
@ c_B2LinkEventCRCError
HSLB_COPPER CRC error is detected in the event.
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
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition SVDCluster.h:29
The SVD ShaperDigit class.
void initialize() override final
Module function initialize.
TH1F * m_svdTime[2]
L3 V-side time for all clusters.
TH1F * m_svdL3uZS5Occupancy_toSVDCKFaborts[2]
distribution of the SVD L3 V ZS5 occupancy when toSVDCKF aborts
TH1F * m_svdL3uZS5Occupancy_VXDTF2aborts[2]
distribution of the SVD L3 V ZS5 occupancy when VXDTF2 aborts
StoreObjPtr< EventLevelTrackingInfo > m_eventLevelTrackingInfo
tracking abort info
TH1D * m_integratedAverages[2]
integrated averages of additional SVD, CDC variables
SVDNoiseCalibrations m_NoiseCal
SVDNoise calibration db object.
TH1F * m_trackingErrorFlagsReasons[2]
stores the reason of the abort
void defineHisto() override final
Defines Histograms.
StoreObjPtr< TRGSummary > m_trgSummary
trg summary
TH1F * m_svdL3uZS5Occupancy[2]
distribution of the SVD L3 V ZS5 occupancy
StoreArray< SVDCluster > m_clusters
SVD clusters.
TH1F * m_nEventsWithAbort[2]
0: no abort; 1: at least one abort
TH1F * m_nCDCExtraHits[2]
distribution of the number of extra CDC hits
static constexpr int m_nStripsL3U
number of U-side L3 strips
StoreObjPtr< EventMetaData > m_eventMetaData
event meta data
void event() override final
Module function event.
StoreArray< SVDShaperDigit > m_strips
SVD strips.
void updateBinContent(int index, int bin, float valueToBeAdded)
function to update the bin content
std::string m_histogramDirectoryName
Name of the histogram directory in ROOT file.
StoreArray< CDCHit > m_cdcHits
CDCHits.
void beginRun() override final
Module function beginRun.
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
baseType getLayerNumber() const
Get the layer id.
Definition VxdID.h:95
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
Abstract base class for different kinds of events.