Belle II Software development
DeSerializer.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
9#ifndef DESERIALIZER_H
10#define DESERIALIZER_H
11
12#include <string>
13#include <stdlib.h>
14#include <sys/time.h>
15
16#include <framework/core/Module.h>
17#include <framework/datastore/StoreObjPtr.h>
18#include <framework/datastore/StoreArray.h>
19#include <framework/dataobjects/EventMetaData.h>
20
21#include <daq/slc/readout/RunInfoBuffer.h>
22#include <daq/rawdata/CprErrorMessage.h>
23#include <daq/rawdata/modules/DAQConsts.h>
24
25#include <rawdata/dataobjects/RawDataBlock.h>
26
27namespace Belle2 {
36 class DeSerializerModule : public Module {
37
38 // Public functions
39 public:
40
43 virtual ~DeSerializerModule();
44
46 void initialize() override;
47
48 void terminate() override;
49
51 void event() override;
52
54 virtual void openOutputFile();
55
57 virtual void dumpData(char* buf, int size);
58
60 virtual void printData(int* buf, int nwords);
61
63 virtual void printASCIIData(int* buf, int nwords);
64
65 protected :
66
67 // Event Meta Data
68 StoreObjPtr<EventMetaData> m_eventMetaDataPtr;
69
70 StoreArray<RawDataBlock> raw_datablkarray;
71
72
75
78
81
84
87
90
92 std::string m_dump_fname;
93
95 FILE* m_fp_dump;
96
99
101 int* m_bufary[ NUM_PREALLOC_BUF ];
102 // int* m_bufary[NUM_EVT_PER_BASF2LOOP];
103
105 virtual int* getPreAllocBuf();
106
108 virtual int* getNewBuffer(int nwords, int* delete_flag);
109
110 // For monitoring
111 timeval m_t0;
112 double m_totbytes;
113 double m_prev_totbytes;
114 int m_ncycle;
116 double cur_time;
117
118 double m_start_time;
119 double m_prev_time;
120 double time_array0[1000];
121 double time_array1[1000];
122 double time_array2[1000];
123 double time_array3[1000];
124 double time_array4[1000];
125 double time_array5[1000];
126 int prev_event;
127
129 double getTimeSec();
130
132 void recordTime(int event, double* array);
133
135 int checkData(char* buf, int prev_eve, int* cur_eve);
136
138 unsigned int calcSimpleChecksum(int* buf, int nwords);
139
141 unsigned int calcXORChecksum(int* buf, int nwords);
142
143 virtual void clearNumUsedBuf()
144 {
145 m_num_usedbuf = 0;
146 return ;
147 }
148
150 void RateMonitor(unsigned int nevt, int subrun = -1, int run = -1);
151
152
155
156
159
161 std::string m_nodename;
162
165
168
170 unsigned int m_exprunsubrun_no;
171
174
177
180
183
186
188 void shmOpen(char* path_cfg, char* path_sta);
189
191 int* shmGet(int fd, int size_words);
192
195
198
201
203 //int* m_cfg_buf;
205 //int* m_cfg_sta;
206
208
211
214
215
216#ifdef NONSTOP
218 int* m_ptr;
219
221 virtual void openRunPauseNshm();
222
224 virtual int checkRunPause();
225
227 virtual int checkRunRecovery();
228
229
231 virtual void resumeRun();
232
234 virtual void pauseRun();
235
237 virtual void waitResume();
238
240 void callCheckRunPause(std::string& err_str);
241
243 int CheckConnection(int socket);
244
245#endif
246
247 private:
248
249 public:
250 static RunInfoBuffer& getStatus()
251 {
252 return g_status;
253 }
254
255
256 };
257
259} // end namespace Belle2
260
261#endif // MODULEHELLO_H
A class definition of an input module for Sequential ROOT I/O.
Definition: DeSerializer.h:36
unsigned int calcSimpleChecksum(int *buf, int nwords)
calculate checksum
void shmOpen(char *path_cfg, char *path_sta)
open shared memory
void RateMonitor(unsigned int nevt, int subrun=-1, int run=-1)
monitor rate
unsigned int m_prev_exprunsubrun_no
run no.
Definition: DeSerializer.h:173
void initialize() override
Module functions to be called from main process.
Definition: DeSerializer.cc:89
unsigned int calcXORChecksum(int *buf, int nwords)
calculate checksum
std::string m_nodename
Node name.
Definition: DeSerializer.h:161
virtual int * getPreAllocBuf()
Getbuffer.
int * shmGet(int fd, int size_words)
Get shared memory.
void event() override
Module functions to be called from main process.
int BUF_SIZE_WORD
size of buffer for one event (word)
Definition: DeSerializer.h:83
int m_shmfd_cfg
file descripter for shm
Definition: DeSerializer.h:194
static RunInfoBuffer g_status
buffer class to communicate with NSM client
Definition: DeSerializer.h:200
int checkData(char *buf, int prev_eve, int *cur_eve)
check data
void terminate() override
This method is called at the end of the event processing.
int n_basf2evt
No. of sent events.
Definition: DeSerializer.h:86
DeSerializerModule()
Constructor / Destructor.
Definition: DeSerializer.cc:29
CprErrorMessage print_err
wrapper for B2LOG system
Definition: DeSerializer.h:213
int m_shmfd_sta
file descripter for shm
Definition: DeSerializer.h:197
virtual void dumpData(char *buf, int size)
dump binary data
virtual void printData(int *buf, int nwords)
dump error data
virtual int * getNewBuffer(int nwords, int *delete_flag)
Getbuffer.
double cur_time
for time monitoring
Definition: DeSerializer.h:116
std::string m_dump_fname
dump filename
Definition: DeSerializer.h:92
int m_shmflag
Use shared memory.
Definition: DeSerializer.h:185
int monitor_numeve
buffer for shared memory
Definition: DeSerializer.h:207
int m_prev_nevt
No. of prev sent events.
Definition: DeSerializer.h:89
void recordTime(int event, double *array)
store time info.
int m_compressionLevel
Compression Level.
Definition: DeSerializer.h:80
int * m_bufary[NUM_PREALLOC_BUF]
buffer
Definition: DeSerializer.h:101
unsigned int m_exprunsubrun_no
run no.
Definition: DeSerializer.h:170
virtual void printASCIIData(int *buf, int nwords)
dump error data
virtual void openOutputFile()
Module functions to be called from event process.
double max_seconds
time to stop a run
Definition: DeSerializer.h:77
FILE * m_fp_dump
dump file descripter
Definition: DeSerializer.h:95
int m_nodeid
Node(PC or COPPER) ID.
Definition: DeSerializer.h:158
double getTimeSec()
store time info.
Base class for Modules.
Definition: Module.h:72
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.