Belle II Software  release-05-02-19
SVDDataFormatCheckModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Michael De Nuccio, Giulia Casarosa *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <svd/modules/svdReconstruction/SVDDataFormatCheckModule.h>
12 
13 using namespace Belle2;
14 using namespace std;
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 REG_MODULE(SVDDataFormatCheck)
20 
21 //-----------------------------------------------------------------
22 // Implementation
23 //-----------------------------------------------------------------
24 
26 {
27  setDescription("Checks the SVD data format: ");
28  setPropertyFlags(c_ParallelProcessingCertified);
29 
30  addParam("SVDEventInfo", m_svdEventInfoName,
31  "SVDEventInfo name", string(""));
32  addParam("ShaperDigits", m_storeShaperDigitsName,
33  "ShaperDigits collection name", string("SVDShaperDigits"));
34  addParam("DAQDiagnostics", m_storeDAQName,
35  "DAQDiagnostics collection name", string("SVDDAQDiagnostics"));
36  addParam("maxProblematicEvents", m_maxProblematicEvts,
37  "maximum number of problematic events to display WARNING", int(10));
38 }
39 
40 
41 SVDDataFormatCheckModule::~SVDDataFormatCheckModule()
42 {
43 }
44 
45 
47 {
48 
49  m_evtMetaData.isRequired();
50  m_storeShaper.isRequired(m_storeShaperDigitsName);
51  m_storeSVDEvtInfo.isRequired(m_svdEventInfoName);
52 
53  if (!m_storeSVDEvtInfo.isOptional(m_svdEventInfoName)) m_svdEventInfoName = "SVDEventInfoSim";
54  m_storeSVDEvtInfo.isRequired(m_svdEventInfoName);
55 
56  //there only if reconstructing data
57  m_storeDAQ.isOptional(m_storeDAQName);
58 
59  B2DEBUG(1, " COLLECTIONS:");
60  B2DEBUG(1, " --> Digits: " << m_storeShaperDigitsName);
61  B2DEBUG(1, " --> Diagnostic: " << m_storeDAQName);
62 }
63 
65 {
66 
67  m_expNumber = m_evtMetaData->getExperiment();
68  m_runNumber = m_evtMetaData->getRun();
69 
70  m_shutUpWarnings = false;
71  m_problematicEvtsCounter = 0;
72  m_stripEvtsCounter = 0;
73  m_evtsCounter = 0;
74  m_nLocalRunEvts = 0;
75  m_nNoZSEvts = 0;
76  m_nBadTBEvts = 0;
77  m_n1samples = 0;
78  m_n3samples = 0;
79  m_n6samples = 0;
80 
81 }
82 
83 
85 {
86 
87  int evtNumber = m_evtMetaData->getEvent();
88  bool isProblematic = false;
89 
90  // If no digits, nothing to do
91  if (!m_storeShaper || !m_storeShaper.getEntries()) {
92 
93  if (m_evtsCounter < m_maxProblematicEvts)
94  B2INFO("SVDDataFormatCheck: no " << m_storeShaperDigitsName << " in event " << evtNumber << " of exp " << m_expNumber << ", run " <<
95  m_runNumber);
96  m_evtsCounter++;
97  return;
98  }
99  if (!m_storeSVDEvtInfo.isValid()) return;
100 
101  SVDModeByte modeByte = m_storeSVDEvtInfo->getModeByte();
102 
103  m_stripEvtsCounter++;
104 
105  //checking the number of acquired samples per APV
106  int daqMode = (int) modeByte.getDAQMode();
107  //0 -> 1-sample
108  //1 -> 3-sample
109  //2 -> 6-sample
110  if (daqMode == 2)
111  m_n6samples++;
112 
113  if (daqMode == 1) {
114  m_n3samples++;
115  isProblematic = true;
116  if (!m_shutUpWarnings)
117  B2WARNING("SVDDataFormatCheck: the event " << evtNumber << " of exp " << m_expNumber << ", run " << m_runNumber <<
118  " is apparently taken with 3-sample mode, this is not expected. [daqMode = " << daqMode << "]");
119  }
120 
121  if (daqMode == 0) {
122  m_n1samples++;
123  isProblematic = true;
124  if (!m_shutUpWarnings)
125  B2WARNING("SVDDataFormatCheck: the event " << evtNumber << " of exp " << m_expNumber << ", run " << m_runNumber <<
126  " is apparently taken with 1-sample mode, this is not expected. [daqMode = " << daqMode << "]");
127  }
128 
129  int evtType = (int) modeByte.getEventType();
130  //0 -> global run
131  //1 -> local run
132  if (evtType != 0) { //only global runs are expected
133  m_nLocalRunEvts++;
134  isProblematic = true;
135  if (!m_shutUpWarnings)
136  B2WARNING("SVDDataFormatCheck: the event " << evtNumber << " of exp " << m_expNumber << ", run " << m_runNumber <<
137  " is apparently taken as Local Run, this is not expected. [evtType = " << evtType << "]");
138  }
139 
140  int runType = (int) modeByte.getRunType();
141  //0 -> raw
142  //1 -> transparent
143  //2 -> zero suppressed
144  //3 -> zs + hit time
145  if (runType != 2) { //only zero suppressed events are expected
146  m_nNoZSEvts++;
147  isProblematic = true;
148  if (!m_shutUpWarnings)
149  B2WARNING("SVDDataFormatCheck: the event " << evtNumber << " of exp " << m_expNumber << ", run " << m_runNumber <<
150  " is apparently not taken as ZeroSuppressed, this is not expected. [runType = " << runType << "]");
151  }
152 
153  int triggerBin = modeByte.getTriggerBin();
154  //between 0 and 3
155  if (triggerBin < 0 || triggerBin > 3) {
156  m_nBadTBEvts++;
157  isProblematic = true;
158  if (!m_shutUpWarnings)
159  B2WARNING("SVDDataFormatCheck: the event " << evtNumber << " of exp " << m_expNumber << ", run " << m_runNumber <<
160  " is apparently not with an unexpected trigger bin = " << triggerBin);
161  }
162 
163  if (isProblematic)
164  m_problematicEvtsCounter++;
165 
166  if (m_problematicEvtsCounter > m_maxProblematicEvts)
167  m_shutUpWarnings = true;
168 
169 }
170 
171 
173 {
174 
175  B2RESULT("SVDDataFormatCheck counters:");
176  B2RESULT("total number of events with at least one strip = " << m_stripEvtsCounter);
177  B2RESULT("total number of apparently problematic events = " << m_problematicEvtsCounter);
178  if (m_nLocalRunEvts > 0)
179  B2RESULT("total number local-run strips = " << m_nLocalRunEvts);
180  if (m_nNoZSEvts > 0)
181  B2RESULT("total number of NOT zero-suppressed strips = " << m_nNoZSEvts);
182  if (m_nBadTBEvts > 0)
183  B2RESULT("total number of strips with wrong TB = " << m_nBadTBEvts);
184  if (m_n1samples > 0 || m_n3samples > 0) {
185  B2RESULT("total number of 1-sample strips = " << m_n1samples);
186  B2RESULT("total number of 3-sample strips = " << m_n3samples);
187  B2RESULT("total number of 6-sample strips = " << m_n6samples);
188  }
189 }
190 
191 
193 {
194 }
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
228 
229 
230 
Belle2::SVDModeByte::getTriggerBin
baseType getTriggerBin() const
Get the triggerBin id.
Definition: SVDModeByte.h:150
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::SVDModeByte
Class to store SVD mode information.
Definition: SVDModeByte.h:79
Belle2::SVDModeByte::getDAQMode
baseType getDAQMode() const
Get the daqMode id.
Definition: SVDModeByte.h:152
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::SVDDataFormatCheckModule
This module checks the format of the data that we are going to reconstruct checking the SVDModeByte a...
Definition: SVDDataFormatCheckModule.h:48
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SVDDataFormatCheckModule::event
virtual void event() override
This method is the core of the SVDDataFormatCheck.
Definition: SVDDataFormatCheckModule.cc:84
Belle2::SVDDataFormatCheckModule::initialize
virtual void initialize() override
Initialize the SVDDataFormatCheck.
Definition: SVDDataFormatCheckModule.cc:46
Belle2::SVDModeByte::getRunType
baseType getRunType() const
Get the runMode id.
Definition: SVDModeByte.h:156
Belle2::SVDDataFormatCheckModule::endRun
virtual void endRun() override
This method is called if the current run ends.
Definition: SVDDataFormatCheckModule.cc:172
Belle2::SVDDataFormatCheckModule::terminate
virtual void terminate() override
This method is called at the end of the event processing.
Definition: SVDDataFormatCheckModule.cc:192
Belle2::SVDModeByte::getEventType
baseType getEventType() const
Get the eventMode id.
Definition: SVDModeByte.h:154
Belle2::SVDDataFormatCheckModule::beginRun
virtual void beginRun() override
Called when entering a new run.
Definition: SVDDataFormatCheckModule.cc:64