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