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