Belle II Software  release-08-01-10
CheckErrorEvent.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 <rawdata/modules/CheckErrorEvent.h>
10 
11 using namespace std;
12 using namespace Belle2;
13 
14 //#define DEBUG
15 
16 //-----------------------------------------------------------------
17 // Register the Module
18 //-----------------------------------------------------------------
19 REG_MODULE(CheckErrorEvent);
20 
21 //-----------------------------------------------------------------
22 // Implementation
23 //-----------------------------------------------------------------
24 
25 CheckErrorEventModule::CheckErrorEventModule() : PrintDataTemplateModule()
26 {
27  //Set module properties
28  setDescription("Encode DataStore into RingBuffer");
29  B2INFO("CheckErrorEvent: Constructor done.");
30 
31 }
32 
33 
34 
35 CheckErrorEventModule::~CheckErrorEventModule()
36 {
37 }
38 
40 {
41  B2INFO("CheckErrorEvent: initialize() started.");
47  B2INFO("CheckErrorEvent: initialize() done.");
48 }
49 
51 {
52  for (int j = 0; j < rawcpr->GetNumEntries(); j++) {
53  int temp_packet = rawcpr->GetPacketCRCError(j);
54  int temp_event = rawcpr->GetEventCRCError(j);
55  m_packetCRCerr_cpr = + temp_packet;
56  m_eventCRCerr_cpr = + temp_event;
57  if (temp_packet) {
58  printf("Packet CRC error : block %d ent %d eve %.12u node %.8x\n", i, j,
59  rawcpr->GetEveNo(j), rawcpr->GetNodeID(j));
60  }
61  if (temp_event) {
62  printf("Packet EVE error : block %d ent %d eve %.12u node %.8x\n", i, j,
63  rawcpr->GetEveNo(j), rawcpr->GetNodeID(j));
64  }
65  }
66 }
67 
69 {
70  // printf("Packet CRC error %d CPRs %d Events\n",
71  // m_packetCRCerr_cpr,
72  // m_eventCRCerr_cpr);
73  printf("Event CRC error %d CPRs %d Events (obtained by checking each Raw*** header)\n",
76  );
77  printf("Event CRC error %d Events (obtained by checking EventMetaData. it should be equal to the above value. )\n",
79 }
80 
82 {
83 
84  //
85  // FTSW + COPPER can be combined in the array
86  //
87  StoreArray<RawDataBlock> raw_datablkarray;
88  for (int i = 0; i < raw_datablkarray.getEntries(); i++) {
89  for (int j = 0; j < raw_datablkarray[ i ]->GetNumEntries(); j++) {
90  int* temp_buf = raw_datablkarray[ i ]->GetBuffer(j);
91  int nwords = raw_datablkarray[ i ]->GetBlockNwords(j);
92  int delete_flag = 0;
93  int num_nodes = 1;
94  int num_events = 1;
95  if (raw_datablkarray[ i ]->CheckFTSWID(j)) {
96  // No operation
97  } else if (raw_datablkarray[ i ]->CheckTLUID(j)) {
98  // No operation
99  } else {
100  // COPPER data block
101  RawCOPPER temp_raw_copper;
102  temp_raw_copper.SetBuffer(temp_buf, nwords, delete_flag, num_nodes, num_events);
103  checkCRCError(&temp_raw_copper, i);
104  }
105  }
106  }
107 
108 
109  StoreArray<RawCOPPER> raw_cprarray;
110  for (int i = 0; i < raw_cprarray.getEntries(); i++) {
111  checkCRCError(raw_cprarray[ i ], i);
112  }
113 
114  StoreArray<RawSVD> raw_svdarray;
115  for (int i = 0; i < raw_svdarray.getEntries(); i++) {
116  checkCRCError(raw_svdarray[ i ], i);
117  }
118 
119  StoreArray<RawCDC> raw_cdcarray;
120  for (int i = 0; i < raw_cdcarray.getEntries(); i++) {
121  checkCRCError(raw_cdcarray[ i ], i);
122  }
123 
124  StoreArray<RawTOP> raw_toparray;
125  for (int i = 0; i < raw_toparray.getEntries(); i++) {
126  checkCRCError(raw_toparray[ i ], i);
127  }
128 
129  StoreArray<RawARICH> raw_aricharray;
130  for (int i = 0; i < raw_aricharray.getEntries(); i++) {
131  checkCRCError(raw_aricharray[ i ], i);
132  }
133 
134  StoreArray<RawKLM> raw_klmarray;
135  for (int i = 0; i < raw_klmarray.getEntries(); i++) {
136  checkCRCError(raw_klmarray[ i ], i);
137  }
138 
139  StoreArray<RawECL> raw_eclarray;
140  for (int i = 0; i < raw_eclarray.getEntries(); i++) {
141  checkCRCError(raw_eclarray[ i ], i);
142  }
143 
144  StoreArray<RawTRG> raw_trgarray;
145  for (int i = 0; i < raw_trgarray.getEntries(); i++) {
146  checkCRCError(raw_trgarray[ i ], i);
147  }
148 
149 
150 
151  StoreObjPtr<EventMetaData> evtmetadata;
152  // evtmetadata.create();
153  if (evtmetadata->getErrorFlag()) {
154  printf("EventMeta Error %.8x : exp %d run %d sub %d eve %d\n",
155  evtmetadata->getErrorFlag(),
156  evtmetadata->getExperiment(), evtmetadata->getRun(),
157  evtmetadata->getSubrun(), evtmetadata->getEvent());
159 
160  }
161 
162  // printf("loop %d\n", n_basf2evt);
163  n_basf2evt++;
164 
165 }
void checkCRCError(RawCOPPER *rawcpr, int i)
Check if a RawCOPPER object contains CRC error flag in RawCOPPER header/trailer.
virtual void initialize() override
initialization
virtual void event() override
event module
virtual void terminate() override
termination
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
Module to get data from DataStore and send it to another network node.
int n_basf2evt
No. of sent events.
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
Definition: RawCOPPER.h:52
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
Definition: RawCOPPER.cc:141
virtual int GetNumEntries()
get # of data blocks = (# of nodes)*(# of events)
Definition: RawDataBlock.h:67
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
unsigned int GetEveNo(int n)
get subrun #(8bit)
Definition: RawCOPPER.h:390
int GetEventCRCError(int n)
check CRC event Error
Definition: RawCOPPER.h:434
int GetPacketCRCError(int n)
check CRC packet Error
Definition: RawCOPPER.h:428
unsigned int GetNodeID(int n)
get node-ID from data
Definition: RawCOPPER.h:397
Abstract base class for different kinds of events.