35 #include <rawdata/modules/HexDataPacker.h>
54 setDescription(
"an Example to pack data to a RawCOPPER object");
55 addParam(
"inputFileName", m_fileName,
"Output binary filename",
string(
""));
56 B2INFO(
"HexDataPacker: Constructor done.");
63 HexDataPackerModule::~HexDataPackerModule()
69 void HexDataPackerModule::initialize()
71 B2INFO(
"HexDataPacker: initialize() started.");
77 m_eventMetaDataPtr.registerInDataStore();
79 m_raw_cprarray.registerInDataStore();
80 m_raw_svdarray.registerInDataStore();
81 m_raw_cdcarray.registerInDataStore();
82 m_raw_bpidarray.registerInDataStore();
83 m_raw_epidarray.registerInDataStore();
84 m_raw_eclarray.registerInDataStore();
85 m_raw_klmarray.registerInDataStore();
87 B2INFO(
"HexDataPacker: initialize() done.");
89 if (m_fileName ==
"") {
90 B2FATAL(
"HexDataPacker can't fine a filename: ");
93 m_ifs.open(m_fileName.c_str());
95 B2FATAL(
"HexDataPacker can't open a file " << m_fileName.c_str());
102 void HexDataPackerModule::event()
105 const int MAX_CPRBUF_WORDS = 5000;
106 int* evtbuf =
new int[MAX_CPRBUF_WORDS];
107 char char1[50], char2[50], char3[50], char4[50];
109 unsigned int val[10];
121 getline(m_ifs, strin);
122 sscanf(strin.c_str(),
"%49s %49s %49s %49s",
123 char1, char2, char3, char4);
124 if (strcmp(char1,
"data") == 0) {
125 if (strcmp(char4,
"Trailer") == 0) {
128 if (strcmp(char2,
"0") == 0) {
130 }
else if (strcmp(char2,
"7") == 0) {
131 sscanf(strin.c_str(),
"%49s %u %49s %x %x %x %x %x %x %x %x",
132 char1, &(val[0]), char2, &(val[1]), &(val[2]), &(val[3]), &(val[4]), &(val[5]), &(val[6]), &(val[7]), &(val[8]));
134 val[2] = val[2] | 0x00008000;
135 if (size < 0 || size > MAX_CPRBUF_WORDS) {
136 B2FATAL(
"The size of an event =(" << size <<
") is too large. Exiting...");
139 sscanf(strin.c_str(),
"%20s %u %20s %x %x %x %x %x %x %x %x",
140 char1, &(val[0]), char2, &(val[1]), &(val[2]), &(val[3]), &(val[4]), &(val[5]), &(val[6]), &(val[7]), &(val[8]));
143 B2FATAL(
"The size of an event (=" << size <<
") is too large. Exiting...");
145 for (
int i = 1; i <= 8 ; i++) {
146 if (word_count >= MAX_CPRBUF_WORDS) {
147 B2FATAL(
"The size of an event (=" << size <<
") is too large. Exiting...");
149 evtbuf[word_count] = val[i];
151 if (word_count == size) {
156 if (event_end == 1) {
break;}
162 if (size > 0 && size < MAX_CPRBUF_WORDS) {
163 for (
int i = 0; i < size; i++) {
164 printf(
"%.8x ", evtbuf[i]);
165 if (i % 8 == 7) printf(
"\n");
172 (ary.
appendNew())->SetBuffer(evtbuf, size, 1, 1, 1);
178 tempcpr.
SetBuffer(evtbuf, size,
false, 1, 1);
182 evtmetadata->setExperiment(tempcpr.
GetExpNo(0));
183 evtmetadata->setRun(tempcpr.
GetRunNo(0));
185 evtmetadata->setEvent(tempcpr.
GetEveNo(0));
191 evtmetadata->setEndOfData();
194 printf(
"Event counter %8d\n", n_basf2evt); fflush(stdout);
Module to store dummy data in RawCOPPER object.
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
bool create(bool replace=false)
Create a default object in the data store.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
int GetExpNo(int n)
get Experimental # from header
unsigned int GetEveNo(int n)
get subrun #(8bit)
int GetSubRunNo(int n)
get run # (14bit)
int GetRunNo(int n)
Exp# (10bit) run# (14bit) restart # (8bit)
Abstract base class for different kinds of events.