35#include <rawdata/modules/HexDataPacker.h>
56 B2INFO(
"HexDataPacker: Constructor done.");
71 B2INFO(
"HexDataPacker: initialize() started.");
87 B2INFO(
"HexDataPacker: initialize() done.");
90 B2FATAL(
"HexDataPacker can't fine a filename: ");
95 B2FATAL(
"HexDataPacker can't open a file " <<
m_fileName.c_str());
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 is too large." <<
LogVar(
"size", size) <<
"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);
StoreArray< RawSVD > m_raw_svdarray
RawSVD array.
StoreArray< RawCDC > m_raw_cdcarray
RawCDC array.
StoreArray< RawARICH > m_raw_epidarray
RawARICH array.
virtual void initialize() override
initialization
virtual void event() override
event module
StoreArray< RawKLM > m_raw_klmarray
RawKLM array.
int n_basf2evt
event counter
std::string m_fileName
input-file name
StoreArray< RawCOPPER > m_raw_cprarray
RawCOPPER array.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Event Meta Data.
HexDataPackerModule()
Constructor.
virtual ~HexDataPackerModule()
Destructor.
std::ifstream m_ifs
input-file stream
StoreArray< RawECL > m_raw_eclarray
RawECL array.
StoreArray< RawTOP > m_raw_bpidarray
RawTOP array.
void setDescription(const std::string &description)
Sets the description of the module.
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.
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#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.