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