Belle II Software development
DummyDataSourceFile.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 <daq/rawdata/modules/DummyDataSourceFile.h>
10#include <daq/rawdata/modules/DeSerializer.h>
11#include <rawdata/dataobjects/RawCDC.h>
12
13using namespace std;
14using namespace Belle2;
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
19REG_MODULE(DummyDataSourceFile);
20
21//-----------------------------------------------------------------
22// Implementation
23//-----------------------------------------------------------------
24
26{
27}
28
29
30
31DummyDataSourceFileModule::~DummyDataSourceFileModule()
32{
33
34}
35
36
38{
39 B2INFO("DummyDataSourceFile: initialize() started.");
40
42 // m_eventMetaDataPtr.registerInDataStore();
43
44#ifdef USE_RAWDATABLOCK
45 // raw_datablkarray.registerInDataStore();
46#endif
47
48 rawcprarray.registerInDataStore();
49
50 n_basf2evt = 0;
51 m_start_flag = 0;
52
53 if (m_shmflag > 0) {
54 if (m_nodename.size() == 0 || m_nodeid < 0) {
55 m_shmflag = 0;
56 } else {
57 printf("nodename = %s\n", m_nodename.c_str());
58 RunInfoBuffer& status(DeSerializerModule::getStatus());
59 status.open(m_nodename, m_nodeid);
60 }
61 }
62
63 B2INFO("DummyDataSourceFile: initialize() done.");
64}
65
66
67
68
70{
71
72 StoreArray<RawCDC> raw_cdcarray;
73 // Make RawCOPPER array
74 if (m_start_flag == 0) {
75 m_start_flag = 1;
76 RunInfoBuffer& status(DeSerializerModule::getStatus());
77 if (status.isAvailable()) {
78 B2INFO("DeSerializerCOPPER: Waiting for Start...\n");
79 status.reportRunning();
80 }
81 }
82
83 //
84 // Fill event info (These values will be stored in RawHeader )
85 //
86 RawCOPPERPackerInfo rawcprpacker_info;
87 rawcprpacker_info.exp_num = 1;
88 rawcprpacker_info.run_subrun_num = 2; // run number : 14bits, subrun # : 8bits
89 rawcprpacker_info.eve_num = n_basf2evt;
90 rawcprpacker_info.node_id = m_nodeid;
91 rawcprpacker_info.tt_ctime = 0x7123456;
92 rawcprpacker_info.tt_utime = 0xF1234567;
93 rawcprpacker_info.b2l_ctime = 0x7654321;
94
95
96 //
97 // Prepare buffer to fill dummy data
98 //
99 RawCOPPER* raw_copper = rawcprarray.appendNew();
100
101 int* buf[4] = {0, 0, 0, 0};
102 int nwords[4] = {0, 0, 0, 0};
103
104 for (int i = 0; i < raw_cdcarray.getEntries(); i++) {
105 for (int j = 0; j < raw_cdcarray[ i ]->GetNumEntries(); j++) {
106
107 for (int k = 0; k < 4; k ++) {
108 // nwords_1st = n_basf2evt % 10;
109 nwords[ k ] = raw_cdcarray[ i ]->GetDetectorNwords(j, k);
110 buf[ k ] = raw_cdcarray[ i ]->GetDetectorBuffer(j, k);
111 // memset( buf[k], 0, nwords[k]*sizeof(int));
112 }
113
114#ifdef USE_RAWDATABLOCK
115 raw_copper->PackDetectorBuf4DummyData(buf[0], nwords[0],
116 buf[1], nwords[1],
117 buf[2], nwords[2],
118 buf[3], nwords[3],
119 rawcprpacker_info);
120#else
121 raw_copper->PackDetectorBuf(buf[0], nwords[0],
122 buf[1], nwords[1],
123 buf[2], nwords[2],
124 buf[3], nwords[3],
125 rawcprpacker_info);
126
127#endif
128
129
130#ifdef USE_RAWDATABLOCK
131 // raw_datablkarray.create();
132 RawDataBlock* raw_datablk = raw_datablkarray.appendNew();
133 raw_datablk->SetBuffer(raw_copper->GetWholeBuffer(), raw_copper->TotalBufNwords(),
134 false, 1, 1);
135#endif
136
137 }
138 }
139 //
140 // Monitor
141 //
142 if (max_nevt >= 0) {
143 if (n_basf2evt >= (unsigned int) max_nevt && max_nevt > 0) {
144 printf("[DEBUG] RunStop was detected. ( Setting: Max event # %d ) Processed Event %d \n",
146 fflush(stdout);
147 m_eventMetaDataPtr->setEndOfData();
148 }
149 }
150
151 if (n_basf2evt % 1000 == 0) {
152 printf("Dummy data : Event # %.8d\n", n_basf2evt);
153 fflush(stdout);
154 }
155
156 n_basf2evt++;
157 RunInfoBuffer& status(DeSerializerModule::getStatus());
158 if (status.isAvailable()) {
159 status.addInputNBytes(1);
160 status.setInputCount(n_basf2evt);
161 }
162 return;
163}
void initialize() override
Module functions to be called from main process.
void event() override
Module functions to be called from event process.
DummyDataSourceFileModule()
Constructor / Destructor.
A class definition of an input module for Sequential ROOT I/O.
StoreArray< RawCOPPER > rawcprarray
RawCOPPER array.
unsigned int n_basf2evt
Number of events.
std::string m_nodename
Node name.
StoreArray< RawDataBlock > raw_datablkarray
RawDataBlock array.
int m_shmflag
Use shared memory.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Event Meta Data.
int max_nevt
check data contents
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...
Definition: RawCOPPER.h:52
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.
Definition: RawCOPPER.cc:183
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)
Definition: RawCOPPER.cc:251
The RawDataBlock class Base class for rawdata handling.
Definition: RawDataBlock.h:27
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 )
Definition: RawDataBlock.cc:35
virtual int * GetWholeBuffer()
get pointer to buffer(m_buffer)
Definition: RawDataBlock.h:60
virtual int TotalBufNwords()
Get total length of m_buffer.
Definition: RawDataBlock.h:39
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
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.