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