Belle II Software development
DummyDataPacker.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/DummyDataPacker.h>
10
11using namespace std;
12using namespace Belle2;
13
14#define USE_PCIE40
15
16//-----------------------------------------------------------------
17// Register the Module
18//-----------------------------------------------------------------
19REG_MODULE(DummyDataPacker);
20
21//-----------------------------------------------------------------
22// Implementation
23//-----------------------------------------------------------------
24
26{
28 setDescription("an Example to pack data to a RawCOPPER object");
29
31 addParam("MaxEventNum", max_nevt, "Maximum event number to make", -1);
32
34 // addParam("NodeID", m_nodeid, "Node ID", 0);
35
36 B2INFO("DummyDataPacker: Constructor done.");
37
38 // initialize event #
39 n_basf2evt = 0;
40
41
42}
43
44
45
46DummyDataPackerModule::~DummyDataPackerModule()
47{
48
49}
50
51
53{
54 B2INFO("DummyDataPacker: initialize() started.");
55
56 // Open message handler
57 // m_msghandler = new MsgHandler(m_compressionLevel);
58
60 m_eventMetaDataPtr.registerInDataStore();
61
62 raw_cprarray.registerInDataStore();
63 raw_svdarray.registerInDataStore();
64 raw_cdcarray.registerInDataStore();
65 raw_bpidarray.registerInDataStore();
66 raw_epidarray.registerInDataStore();
67 raw_eclarray.registerInDataStore();
68 raw_klmarray.registerInDataStore();
69 B2INFO("DummyDataPacker: initialize() done.");
70}
71
72
73
74
76{
77 //
78 // To Make RawCOPPER array
79 //
80
81// raw_cprarray.create();
82
83 //
84 // To make RawDetector array use the following objects
85 //
86
87// raw_cdcarray.create();
88// raw_bpidarray.create();
89// raw_epidarray.create();
90// raw_klmarray.create();
91// raw_eclarray.create();
92
93
94 RawCOPPERPackerInfo rawcprpacker_info;
95
96 int num_coppers = 48; // In SVD case
97 for (int i = 0 ; i < num_coppers; i++) {
98
99 //
100 // Example of event info (These values will be stored in RawHeader )
101 //
102 rawcprpacker_info.exp_num = 1;
103 rawcprpacker_info.run_subrun_num = 2; // run number : 14bits, subrun # : 8bits
104 rawcprpacker_info.eve_num = n_basf2evt;
105 // rawcprpacker_info.node_id = m_nodeid;
106 rawcprpacker_info.node_id = SVD_ID + 1000 + (i + 1); //cpr1001...cpr1048
107 rawcprpacker_info.tt_ctime = 0x7123456;
108 rawcprpacker_info.tt_utime = 0xF1234567;
109 rawcprpacker_info.b2l_ctime = 0x7654321;
110
111 //
112 // Prepare buffer to fill dummy data
113 //
114// RawCOPPER* raw_copper = raw_cprarray.appendNew();
115 RawSVD* raw_svd = raw_svdarray.appendNew();
116// RawCDC* raw_cdc = raw_cdcarray.appendNew();
117// RawTOP* raw_bpid = raw_bpidarray.appendNew();
118// RawARICH* raw_epid = raw_epidarray.appendNew();
119// RawECL* raw_ecl = raw_eclarray.appendNew();
120// RawKLM* raw_klm = raw_klmarray.appendNew();
121// RawTRG* raw_trg = raw_trgarray.appendNew();
122
123#ifdef USE_PCIE40
124 int* buf_pcie40[MAX_PCIE40_CH];
125 int nwords_ch[MAX_PCIE40_CH];
126
127 for (int j = 0; j < MAX_PCIE40_CH; j++) {
128 nwords_ch[j] = n_basf2evt % 10 + 1;
129 buf_pcie40[j] = new int[ nwords_ch[j]];
130 for (int k = 0; k < nwords_ch[j]; k++) {
131 buf_pcie40[j][k] = i + j + k;
132 }
133 }
134 raw_svd->PackDetectorBuf(buf_pcie40, nwords_ch, rawcprpacker_info);
135
136 for (int j = 0; j < MAX_PCIE40_CH; j++) {
137 delete [] buf_pcie40[j];
138 }
139#else
140 int* buf_hslb1, *buf_hslb2, *buf_hslb3, *buf_hslb4;
141 int nwords_1st_hslb = 0, nwords_2nd_hslb = 0, nwords_3rd_hslb = 0, nwords_4th_hslb = 0;
142
143 nwords_1st_hslb = n_basf2evt % 10 + 1;
144 buf_hslb1 = new int[ nwords_1st_hslb];
145 for (int j = 0; j < nwords_1st_hslb; j++) {
146 buf_hslb1[ j ] = i + j;
147 }
148
149 nwords_2nd_hslb = (n_basf2evt + 1) % 10 + 1;
150 buf_hslb2 = new int[ nwords_2nd_hslb];
151 for (int j = 0; j < nwords_2nd_hslb; j++) {
152 buf_hslb2[ j ] = i + j + 1;
153 }
154
155 nwords_3rd_hslb = 3 * (n_basf2evt + 2) % 10 + 1;
156 buf_hslb3 = new int[ nwords_3rd_hslb];
157 for (int j = 0; j < nwords_3rd_hslb; j++) {
158 buf_hslb3[ j ] = i + j + 2;
159 }
160
161 nwords_4th_hslb = 4 * (n_basf2evt + 3) % 10 + 1;
162 buf_hslb4 = new int[ nwords_4th_hslb];
163 for (int j = 0; j < nwords_4th_hslb; j++) {
164 buf_hslb4[ j ] = i + j + 3;
165 }
166
167 raw_svd->PackDetectorBuf(buf_hslb1, nwords_1st_hslb,
168 buf_hslb2, nwords_2nd_hslb,
169 buf_hslb3, nwords_3rd_hslb,
170 buf_hslb4, nwords_4th_hslb,
171 rawcprpacker_info);
172
173
174 delete [] buf_hslb1;
175 delete [] buf_hslb2;
176 delete [] buf_hslb3;
177 delete [] buf_hslb4;
178#endif
179
180 }
181
182
183 //
184 // Update EventMetaData :
185 //
186 m_eventMetaDataPtr.create();
187 m_eventMetaDataPtr->setExperiment(rawcprpacker_info.exp_num);
188 m_eventMetaDataPtr->setRun(rawcprpacker_info.run_subrun_num);
190
191 B2DEBUG(0, "Event # " << n_basf2evt << endl);
192 fflush(stdout);
193
194 //
195 // Monitor
196 //
197 if (max_nevt >= 0) {
198 if (n_basf2evt >= max_nevt && max_nevt > 0) {
199 B2DEBUG(0, "[DEBUG] RunStop was detected. ( Setting: Max event #" << max_nevt << ") Processed Event" << n_basf2evt << endl);
200 fflush(stdout);
201 m_eventMetaDataPtr->setEndOfData();
202 }
203 }
204
205 n_basf2evt++;
206 return;
207}
StoreArray< RawKLM > raw_klmarray
RawKLM array.
virtual void initialize() override
initialization
virtual void event() override
event module
StoreArray< RawARICH > raw_epidarray
RawARICH array.
StoreArray< RawSVD > raw_svdarray
RawSVD array.
StoreArray< RawTOP > raw_bpidarray
RawTOP array.
StoreArray< RawCOPPER > raw_cprarray
RawCOPPER array.
DummyDataPackerModule()
Constructor / Destructor.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Messaage handler.
StoreArray< RawCDC > raw_cdcarray
RawCDC array.
int max_nevt
check data contents
StoreArray< RawECL > raw_eclarray
RawECL array.
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
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)
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
The Raw SVD class Class for RawCOPPER class data taken by SVD Currently, this class is almost same as...
Definition: RawSVD.h:26
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#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.