Belle II Software development
trgrawdataModule.h
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#ifndef TRGRAWDATAModule_h
9#define TRGRAWDATAModule_h
10
11#include <stdlib.h>
12#include <string>
13#include <iostream>
14#include <vector>
15#include <sys/uio.h>
16
17#include <rawdata/dataobjects/RawTRG.h>
18
19#include <framework/pcore/EvtMessage.h>
20
21#include <framework/datastore/StoreArray.h>
22// #include <framework/core/Module.h>
23#include <framework/core/HistoModule.h>
24#include <framework/dataobjects/EventMetaData.h>
25#include <framework/datastore/StoreObjPtr.h>
26#include <framework/database/DBObjPtr.h>
27#include <mdst/dbobjects/TRGGDLDBBadrun.h>
28#include <trg/gdl/dbobjects/TRGGDLDBUnpacker.h>
29
30#include <rawdata/dataobjects/RawDataBlock.h>
31#include <rawdata/dataobjects/RawFTSW.h>
32#include <rawdata/dataobjects/RawTLU.h>
33#include <rawdata/dataobjects/RawCOPPER.h>
34
35#include <sys/types.h>
36#include <sys/socket.h>
37#include <netinet/in.h>
38#include <netinet/tcp.h>
39#include <arpa/inet.h>
40#include <sys/resource.h>
41
42#include <TDirectory.h>
43#include <TH2I.h>
44#include <TH1I.h>
45#include <TString.h>
46
47namespace Belle2 {
53 static const int intNaN = std::numeric_limits<int>::quiet_NaN();
54
55//class TRGRAWDATAModule : public Module {
57
58 public:
62 virtual ~TRGRAWDATAModule() {}
63
64 public:
66 virtual void initialize() override;
68 virtual void beginRun() override {}
70 virtual void event() override;
72 virtual void endRun() override {}
74 virtual void terminate() override
75 {
76
77 bool m_ons[c_nModules] = {
78 m_on_2d0, m_on_2d1, m_on_2d2, m_on_2d3,
79 m_on_3d0, m_on_3d1, m_on_3d2, m_on_3d3,
80 m_on_nn0, m_on_nn1, m_on_nn2, m_on_nn3,
81 m_on_sl0, m_on_sl1, m_on_sl2, m_on_sl3,
82 m_on_sl4, m_on_sl5, m_on_sl6, m_on_sl8,
83 m_on_gdl, m_on_etf, m_on_grl, m_on_top
84 };
85 /*
86 const char* moduleNames[c_nModules] = {
87 "2D0", "2D1", "2D2", "2D3",
88 "3D0", "3D1", "3D2", "3D3",
89 "NN0", "NN1", "NN2", "NN3",
90 "SL0", "SL1", "SL2", "SL3",
91 "SL4", "SL5", "SL6", "SL8",
92 "GDL", "ETF", "GRL"
93 };
94 */
95
96 printf("-%3s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s--\n",
97 "---", "--------", "--------", "--------", "--------", "--------", "--------", "--------",
98 "--------", "--------", "--------", "--------", "--------");
99 printf(" %3s | %-8s | %-8s | %-8s | %-8s | %-8s | %-8s | %-8s | %-8s | %-8s | %-8s | %-8s | %-8s |\n",
100// printf(" %3s | %8s | %8s | %8s | %8s | %8s | %8s | %8s | %8s | %8s | %8s | %8s | %8s |\n",
101 "",
102 "a)dataOk", // cntr_nwn[i], Data event that has no problem
103 "b)hdrOk", // cntr_nw3[i], Header event that has no problem (except cc check)
104 "c)ccOk", // cntr_good_odr[i]); Data event that has good cc
105 "d)hdrTag", // cntr_nw3_badtrg[i] Header event that has bad number
106 "e)hdrL1", // cntr_nw3_badrvc[i] Header event that has L1 timing
107 "f)hdrScl", // cntr_nw3_badvet[i] Header event that should not be header event
108 "g)dataTag", // cntr_nwn_badtrg[i] Data event that has bad bad event number in data
109 "h)dataL1", // cntr_nwn_badrvc[i] Data event that has bad L1 timing
110 "i)bbbb", // cntr_nwn_badbbb[i] Data event from dummy buffer
111 "j)#wd", // cntr_bad_nwd[i], Data event that does not have expected #word
112 "k)ddsft", // cntr_bad_ddd[i], Data event that does not have expected dddd in clock cycle
113 "l)ccodr" // cntr_bad_odr[i], Data event that has bad cc cycle
114 );
115 printf("-%3s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s--\n",
116 "---", "--------", "--------", "--------", "--------", "--------", "--------", "--------",
117 "--------", "--------", "--------", "--------", "--------");
118 for (unsigned i = 0; i < c_nModules; ++i) {
119 if (m_ons[i]) {
120 printf(" %3s | %8d | %8d | %8d | %8d | %8d | %8d | %8d | %8d | %8d | %8d | %8d | %8d |\n",
121 moduleNames[i],
122 cntr_nwn[i],
123 cntr_nw3[i],
124 cntr_good_odr[i],
125 cntr_nw3_badtrg[i],
126 cntr_nw3_badrvc[i],
127 cntr_nw3_badvet[i],
128 cntr_nwn_badtrg[i],
129 cntr_nwn_badrvc[i],
130 cntr_nwn_badbbb[i],
131 cntr_bad_nwd[i],
132 cntr_bad_ddd[i],
133 cntr_bad_odr[i]
134 );
135 }
136 }
137 printf("-%3s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s---%8s--\n",
138 "---", "--------", "--------", "--------", "--------", "--------", "--------", "--------",
139 "--------", "--------", "--------", "--------", "--------");
140 printf("%-10s: %-s\n"
141 "%-10s: %-s\n"
142 "%-10s: %-s\n"
143 "%-10s: %-s\n"
144 "%-10s: %-s\n"
145 "%-10s: %-s\n"
146 "%-10s: %-s\n"
147 "%-10s: %-s\n"
148 "%-10s: %-s\n"
149 "%-10s: %-s\n"
150 "%-10s: %-s\n"
151 "%-10s: %-s\n",
152 "a)dataOk", "Data event that has no problem (except cc check)",
153 "b)hdrOk", "Header event that has no problem",
154 "c)ccOk", "Data event that has good cc cycle",
155 "d)hdrTag", "Header event that has bad event number in header",
156 "e)hdrL1", "Header event that has bad L1 timing in header",
157 "f)hdrScl", "Header event that should not be header event",
158 "g)dataTag", "Data event that has bad event number in data (can be dummy buffer)",
159 "h)dataL1", "Data event that has bad L1 timing in header",
160 "i)bbbb", "Data event from dummy buffer",
161 "j)#wd", "Data event that does not have expected #word",
162 "k)ddsft", "Data event that does not have expected dddd in clock cycle (can be dummy buffer)",
163 "l)ccodr", "Data event that has bad cc cycle");
164
165 }
166
168 virtual void defineHisto() override;
169
171 static const unsigned int c_nModules = 24;
172
173 const char* moduleNames[c_nModules] = {
174 "2D0", "2D1", "2D2", "2D3",
175 "3D0", "3D1", "3D2", "3D3",
176 "NN0", "NN1", "NN2", "NN3",
177 "SL0", "SL1", "SL2", "SL3",
178 "SL4", "SL5", "SL6", "SL8",
179 "GDL", "ETF", "GRL", "TOP"
180 };
181
182
183 enum EModuleNum {
184 e_2d0 = 0,
185 e_2d1 = 1,
186 e_2d2 = 2,
187 e_2d3 = 3,
188 e_3d0 = 4,
189 e_3d1 = 5,
190 e_3d2 = 6,
191 e_3d3 = 7,
192 e_nn0 = 8,
193 e_nn1 = 9,
194 e_nn2 = 10,
195 e_nn3 = 11,
196 e_sl0 = 12,
197 e_sl1 = 13,
198 e_sl2 = 14,
199 e_sl3 = 15,
200 e_sl4 = 16,
201 e_sl5 = 17,
202 e_sl6 = 18,
203 e_sl8 = 19,
204 e_gdl = 20,
205 e_etf = 21,
206 e_grl = 22,
207 e_top = 23
208 };
209
210 private:
211
212 int m_mydebug;
213 bool m_cc_check;
214 bool m_print_cc;
215 bool m_print_dbmap;
216 bool m_print_clkcyc_err;
217 bool m_histRecord;
218
219 int m_hdr_nwd_sl0 = intNaN;
220 int m_hdr_nwd_sl1 = intNaN;
221 int m_hdr_nwd_sl2 = intNaN;
222 int m_hdr_nwd_sl3 = intNaN;
223 int m_hdr_nwd_sl4 = intNaN;
224 int m_hdr_nwd_sl5 = intNaN;
225 int m_hdr_nwd_sl6 = intNaN;
226 //int m_hdr_nwd_sl7 = intNaN;
227 int m_hdr_nwd_sl8 = intNaN;
228 int m_hdr_nwd_2d0 = intNaN;
229 int m_hdr_nwd_2d1 = intNaN;
230 int m_hdr_nwd_2d2 = intNaN;
231 int m_hdr_nwd_2d3 = intNaN;
232 int m_hdr_nwd_3d0 = intNaN;
233 int m_hdr_nwd_3d1 = intNaN;
234 int m_hdr_nwd_3d2 = intNaN;
235 int m_hdr_nwd_3d3 = intNaN;
236 int m_hdr_nwd_nn0 = intNaN;
237 int m_hdr_nwd_nn1 = intNaN;
238 int m_hdr_nwd_nn2 = intNaN;
239 int m_hdr_nwd_nn3 = intNaN;
240 int m_hdr_nwd_gdl = intNaN;
241 int m_hdr_nwd_etf = intNaN;
242 int m_hdr_nwd_grl = intNaN;
243 int m_hdr_nwd_top = intNaN;
244
245 unsigned m_cpr_sl0 = intNaN;
246 unsigned m_cpr_sl1 = intNaN;
247 unsigned m_cpr_sl2 = intNaN;
248 unsigned m_cpr_sl3 = intNaN;
249 unsigned m_cpr_sl4 = intNaN;
250 unsigned m_cpr_sl5 = intNaN;
251 unsigned m_cpr_sl6 = intNaN;
252 int m_cpr_sl7 = intNaN;
253 unsigned m_cpr_sl8 = intNaN;
254 unsigned m_cpr_2d0 = intNaN;
255 unsigned m_cpr_2d1 = intNaN;
256 unsigned m_cpr_2d2 = intNaN;
257 unsigned m_cpr_2d3 = intNaN;
258 unsigned m_cpr_3d0 = intNaN;
259 unsigned m_cpr_3d1 = intNaN;
260 unsigned m_cpr_3d2 = intNaN;
261 unsigned m_cpr_3d3 = intNaN;
262 unsigned m_cpr_nn0 = intNaN;
263 unsigned m_cpr_nn1 = intNaN;
264 unsigned m_cpr_nn2 = intNaN;
265 unsigned m_cpr_nn3 = intNaN;
266 unsigned m_cpr_gdl = intNaN;
267 unsigned m_cpr_etf = intNaN;
268 int m_cpr_grl = intNaN;
269 unsigned m_cpr_top = intNaN;
270
271 /*
272 int m_hslb_sl0 = intNaN;
273 int m_hslb_sl1 = intNaN;
274 int m_hslb_sl2 = intNaN;
275 int m_hslb_sl3 = intNaN;
276 int m_hslb_sl4 = intNaN;
277 int m_hslb_sl5 = intNaN;
278 int m_hslb_sl6 = intNaN;
279 int m_hslb_sl7 = intNaN;
280 int m_hslb_sl8 = intNaN;
281 int m_hslb_2d0 = intNaN;
282 int m_hslb_2d1 = intNaN;
283 int m_hslb_2d2 = intNaN;
284 int m_hslb_2d3 = intNaN;
285 int m_hslb_3d0 = intNaN;
286 int m_hslb_3d1 = intNaN;
287 int m_hslb_3d2 = intNaN;
288 int m_hslb_3d3 = intNaN;
289 int m_hslb_nn0 = intNaN;
290 int m_hslb_nn1 = intNaN;
291 int m_hslb_nn2 = intNaN;
292 int m_hslb_nn3 = intNaN;
293 int m_hslb_gdl = intNaN;
294 int m_hslb_etf = intNaN;
295 int m_hslb_grl = intNaN;
296 int m_hslb_top = intNaN;
297 */
298
299 int m_fmid_sl0 = intNaN;
300 int m_fmid_sl1 = intNaN;
301 int m_fmid_sl2 = intNaN;
302 int m_fmid_sl3 = intNaN;
303 int m_fmid_sl4 = intNaN;
304 int m_fmid_sl5 = intNaN;
305 int m_fmid_sl6 = intNaN;
306 int m_fmid_sl7 = intNaN;
307 int m_fmid_sl8 = intNaN;
308 int m_fmid_2d0 = intNaN;
309 int m_fmid_2d1 = intNaN;
310 int m_fmid_2d2 = intNaN;
311 int m_fmid_2d3 = intNaN;
312 int m_fmid_3d0 = intNaN;
313 int m_fmid_3d1 = intNaN;
314 int m_fmid_3d2 = intNaN;
315 int m_fmid_3d3 = intNaN;
316 int m_fmid_nn0 = intNaN;
317 int m_fmid_nn1 = intNaN;
318 int m_fmid_nn2 = intNaN;
319 int m_fmid_nn3 = intNaN;
320 unsigned m_fmid_gdl = intNaN;
321 int m_fmid_etf = intNaN;
322 int m_fmid_grl = intNaN;
323 int m_fmid_top = intNaN;
324
325 int m_scale_sl0 = intNaN;
326 int m_scale_sl1 = intNaN;
327 int m_scale_sl2 = intNaN;
328 int m_scale_sl3 = intNaN;
329 int m_scale_sl4 = intNaN;
330 int m_scale_sl5 = intNaN;
331 int m_scale_sl6 = intNaN;
332 int m_scale_sl7 = intNaN;
333 int m_scale_sl8 = intNaN;
334 int m_scale_2ds = intNaN;
335 int m_scale_3ds = intNaN;
336 int m_scale_nns = intNaN;
337 int m_scale_gdl = intNaN;
338 int m_scale_etf = intNaN;
339 int m_scale_grl = intNaN;
340 int m_scale_top = intNaN;
341
342 bool m_on_sl0 = false;
343 bool m_on_sl1 = false;
344 bool m_on_sl2 = false;
345 bool m_on_sl3 = false;
346 bool m_on_sl4 = false;
347 bool m_on_sl5 = false;
348 bool m_on_sl6 = false;
349 bool m_on_sl7 = false;
350 bool m_on_sl8 = false;
351 bool m_on_2d0 = false;
352 bool m_on_2d1 = false;
353 bool m_on_2d2 = false;
354 bool m_on_2d3 = false;
355 bool m_on_3d0 = false;
356 bool m_on_3d1 = false;
357 bool m_on_3d2 = false;
358 bool m_on_3d3 = false;
359 bool m_on_nn0 = false;
360 bool m_on_nn1 = false;
361 bool m_on_nn2 = false;
362 bool m_on_nn3 = false;
363 bool m_on_gdl = false;
364 bool m_on_etf = false;
365 bool m_on_grl = false;
366 bool m_on_top = false;
367
368 int m_nwd_sl0 = intNaN;
369 int m_nwd_sl1 = intNaN;
370 int m_nwd_sl2 = intNaN;
371 int m_nwd_sl3 = intNaN;
372 int m_nwd_sl4 = intNaN;
373 int m_nwd_sl5 = intNaN;
374 int m_nwd_sl6 = intNaN;
375 int m_nwd_sl7 = intNaN;
376 int m_nwd_sl8 = intNaN;
377 int m_nwd_2ds = intNaN;
378 int m_nwd_3ds = intNaN;
379 int m_nwd_nns = intNaN;
380 int m_nwd_gdl = intNaN;
381 int m_nwd_etf = intNaN;
382 int m_nwd_grl = intNaN;
383 int m_nwd_top = intNaN;
384
385 int m_nclk_cdctrg = intNaN;
386 int m_nclk_sl0 = intNaN;
387 int m_nclk_sl1 = intNaN;
388 int m_nclk_sl2 = intNaN;
389 int m_nclk_sl3 = intNaN;
390 int m_nclk_sl4 = intNaN;
391 int m_nclk_sl5 = intNaN;
392 int m_nclk_sl6 = intNaN;
393 int m_nclk_sl7 = intNaN;
394 int m_nclk_sl8 = intNaN;
395 int m_nclk_2ds = intNaN;
396 int m_nclk_3ds = intNaN;
397 int m_nclk_nns = intNaN;
398 int m_nclk_gdl = intNaN;
399 int m_nclk_etf = intNaN;
400 int m_nclk_grl = intNaN;
401 int m_nclk_top = intNaN;
402
403
404 //TODO is zero default value good for these arrays
405 int cntr_good_odr[50] = {};
406 int cntr_bad_odr[50] = {};
407 int cntr_bad_ddd[50] = {};
408 int cntr_bad_nwd[50] = {};
409
410 int cntr_nw3[50] = {};
411 int cntr_nw3_badvet[50] = {};
412 int cntr_nw3_badtrg[50] = {};
413 int cntr_nw3_badrvc[50] = {};
414
415 int cntr_nwn[50] = {};
416 int cntr_nwn_badvet[50] = {};
417 int cntr_nwn_badtrg[50] = {};
418 int cntr_nwn_badrvc[50] = {};
419
420 int cntr_nwn_badbbb[50] = {};
421 int cntr_nwn_badddd[50] = {};
422
423 int cntr_nwe_badnwd[50] = {};
424
425 protected :
429 std::vector<std::vector<int>> BitMap;
430 int LeafBitMap[320] = {};
431 char LeafNames[320][100] = {};
432
433 };
434
436}
437
438#endif
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
virtual void endRun() override
End Run.
static const unsigned int c_nModules
number of modules
virtual void terminate() override
terminate
virtual void initialize() override
initialize
virtual void event() override
Event.
virtual void beginRun() override
begin Run
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Event Meta Data.
virtual ~TRGRAWDATAModule()
Destrunctor.
virtual void defineHisto() override
Define Histogram.
static const int intNaN
constant for integer NaN
Abstract base class for different kinds of events.