9 #include <daq/rawdata/modules/DummyDataSource.h>
10 #include <daq/rawdata/modules/DeSerializer.h>
27 setDescription(
"an Example to pack data to a RawCOPPER object");
30 addParam(
"MaxEventNum", max_nevt,
"Maximum event number to make", -1);
33 addParam(
"NodeID", m_nodeid,
"Node ID", 0);
35 addParam(
"NodeName", m_nodename,
"Node(subsystem) name", std::string(
""));
37 addParam(
"UseShmFlag", m_shmflag,
"Use shared memory to communicate with Runcontroller", 0);
39 B2INFO(
"DummyDataSource: Constructor done.");
44 DummyDataSourceModule::~DummyDataSourceModule()
50 void DummyDataSourceModule::initialize()
52 B2INFO(
"DummyDataSource: initialize() started.");
55 m_eventMetaDataPtr.registerInDataStore();
57 #ifdef USE_RAWDATABLOCK
58 raw_datablkarray.registerInDataStore();
61 rawcprarray.registerInDataStore();
68 if (m_nodename.size() == 0 || m_nodeid < 0) {
71 printf(
"nodename = %s\n", m_nodename.c_str());
73 status.open(m_nodename, m_nodeid);
77 B2INFO(
"DummyDataSource: initialize() done.");
83 void DummyDataSourceModule::event()
87 if (m_start_flag == 0) {
90 if (status.isAvailable()) {
91 B2INFO(
"DeSerializerCOPPER: Waiting for Start...\n");
92 status.reportRunning();
102 rawcprpacker_info.
eve_num = n_basf2evt;
103 rawcprpacker_info.
node_id = m_nodeid;
104 rawcprpacker_info.
tt_ctime = 0x7123456;
105 rawcprpacker_info.
tt_utime = 0xF1234567;
112 RawCOPPER* raw_copper = rawcprarray.appendNew();
114 int* buf1, *buf2, *buf3, *buf4;
115 int nwords_1st = 0, nwords_2nd = 0, nwords_3rd = 0, nwords_4th = 0;
120 if (nwords_1st > 10000 || nwords_1st <= 0) {
121 printf(
"ERRORORRRR nword1st %d\n", nwords_1st);
124 buf1 =
new int[ nwords_1st];
126 for (
int i = 0; i < nwords_1st; i++) {
128 buf1[ i ] = 0x12345678;
130 buf1[ i ] = (i + 1) * buf1[ i - 1 ];
137 if (nwords_2nd > 10000 || nwords_2nd <= 0) {
138 printf(
"ERRORORRRR nword2nd %d\n", nwords_2nd);
142 buf2 =
new int[ nwords_2nd];
143 for (
int i = 0; i < nwords_2nd; i++) {
145 buf2[ i ] = 0x34567890;
147 buf2[ i ] = (i + 1) * buf2[ i - 1 ];
154 if (nwords_3rd > 10000 || nwords_3rd <= 0) {
155 printf(
"ERRORORRRR nword3rd %d\n", nwords_3rd);
159 buf3 =
new int[ nwords_3rd];
160 for (
int i = 0; i < nwords_3rd; i++) {
162 buf3[ i ] = 0x56789012;
164 buf3[ i ] = (i + 1) * buf3[ i - 1 ];
171 if (nwords_4th > 10000 || nwords_4th <= 0) {
172 printf(
"ERRORORRRR nwor_4th %d\n", nwords_4th);
176 buf4 =
new int[ nwords_4th];
177 for (
int i = 0; i < nwords_4th; i++) {
179 buf4[ i ] = 0x78901234;
181 buf4[ i ] = (i + 1) * buf4[ i - 1 ];
185 #ifdef USE_RAWDATABLOCK
200 #ifdef USE_RAWDATABLOCK
201 RawDataBlock* raw_datablk = raw_datablkarray.appendNew();
214 m_eventMetaDataPtr.create();
215 m_eventMetaDataPtr->setExperiment(rawcprpacker_info.
exp_num);
217 m_eventMetaDataPtr->setEvent(n_basf2evt);
224 if ((
int)n_basf2evt >= max_nevt && max_nevt > 0) {
225 printf(
"[DEBUG] RunStop was detected. ( Setting: Max event # %d ) Processed Event %d \n",
226 max_nevt, n_basf2evt);
228 m_eventMetaDataPtr->setEndOfData();
232 if (n_basf2evt % 10000 == 0) {
233 double cur_time = getTimeSec();
234 double interval = cur_time - m_prev_time;
235 double total_time = cur_time - m_start_time;
236 if (n_basf2evt == 0) {
239 printf(
"[INFO] Event %12d Rate %6.2lf[kHz] Recvd Flow %6.2lf[MB/s] RunTime %8.2lf[s] interval %8.4lf[s]\n",
240 n_basf2evt * NUM_EVT_PER_BASF2LOOP_PC,
241 (n_basf2evt - m_prev_nevt)*NUM_EVT_PER_BASF2LOOP_PC / interval / 1.e3,
242 (m_totbytes - m_prev_totbytes) / interval / 1.e6,
246 m_prev_time = cur_time;
247 m_prev_totbytes = m_totbytes;
248 m_prev_nevt = n_basf2evt;
255 if (status.isAvailable()) {
256 status.addInputNBytes(1);
257 status.setInputCount(n_basf2evt);
A class definition of an input module for Sequential ROOT I/O.
struct to contain header information used by RawCOPPERFormat::Packer()
unsigned int b2l_ctime
32bit unitx time at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user ...
unsigned int eve_num
Run # and subrun # ( 22bit )
unsigned int tt_ctime
Node ID (32bit)
unsigned int tt_utime
27bit clock ticks at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user...
unsigned int node_id
Event Number (32bit)
unsigned int run_subrun_num
Experiment number (10bit)
unsigned int exp_num
Experiment number (10bit)
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
void PackDetectorBuf(int *detector_buf_1st, int nwords_1st, int *detector_buf_2nd, int nwords_2nd, int *detector_buf_3rd, int nwords_3rd, int *detector_buf_4th, int nwords_4th, RawCOPPERPackerInfo rawcprpacker_info)
Packer for RawCOPPER class Pack data (format ver.
void PackDetectorBuf4DummyData(int *detector_buf_1st, int nwords_1st, int *detector_buf_2nd, int nwords_2nd, int *detector_buf_3rd, int nwords_3rd, int *detector_buf_4th, int nwords_4th, RawCOPPERPackerInfo rawcprpacker_info)
Pack dummy data (format ver. = -1 -> Select the latest format version)
The RawDataBlock class Base class for rawdata handling.
virtual void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes)
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
virtual int TotalBufNwords()
Get total length of m_buffer.
virtual int * GetWholeBuffer()
get pointer to buffer(m_buffer)
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.