Belle II Software  release-08-01-10
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: ");
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();
50 
51  if (!m_storeSVDEvtInfo.isOptional(m_svdEventInfoName)) m_svdEventInfoName = "SVDEventInfoSim";
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;
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 
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 
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 (triggerBin < 0 is always false)
153  if (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)
163 
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
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
int m_n1samples
counter of 1-sample events
int m_n6samples
counter of 6-sample events
bool m_shutUpWarnings
if true shut up warnings
virtual void initialize() override
Initialize the SVDDataFormatCheck.
SVDDataFormatCheckModule()
Constructor defining the parameters.
std::string m_storeShaperDigitsName
max number of strips in one with at least a warning
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.
StoreArray< SVDDAQDiagnostic > m_storeDAQ
Diagnostic store array.
virtual void terminate() override
This method is called at the end of the event processing.
int m_maxProblematicEvts
max number of events with at least one strip with a warning
int m_nBadTBEvts
counter of bad TB events
int m_nLocalRunEvts
counter of local-run events
StoreObjPtr< EventMetaData > m_evtMetaData
event meta data store array
virtual void beginRun() override
Called when entering a new run.
int m_n3samples
counter of 3-sample events
StoreArray< SVDShaperDigit > m_storeShaper
ShaperDigit store array.
std::string m_svdEventInfoName
Name of the SVDEventInfo object.
std::string m_storeDAQName
Name of the collection to use for the SVDDAQDiagnostic.
int m_stripEvtsCounter
couter of events with at least one strip
int m_nNoZSEvts
counter of non zero-suppressed events
StoreObjPtr< SVDEventInfo > m_storeSVDEvtInfo
storage for SVDEventInfo object
int m_problematicEvtsCounter
couter of events with at least one strip with a warning
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
REG_MODULE(arichBtest)
Register the Module.
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:560
Abstract base class for different kinds of events.