9#include <daq/rfarm/event/modules/rawinputModule.h>
11#include <daq/dataobjects/SendHeader.h>
12#include <daq/dataobjects/SendTrailer.h>
40 B2DEBUG(1,
"RawInput: Constructor done.");
44RawInputModule::~RawInputModule()
50 gSystem->Load(
"libdataobjects");
74 printf(
"Done. m_fd = %d\n",
m_fd);
82 B2INFO(
"RawInput: initialized.");
90 B2INFO(
"RawInput: beginRun called.");
108 char* evtbuf =
new char[MAXEVTSIZE];
110 int sstat = read(
m_fd, evtbuf,
sizeof(
int));
115 int* recsize = (
int*)evtbuf;
116 int rstat = read(
m_fd, evtbuf +
sizeof(
int), (*recsize - 1) * 4);
122 B2INFO(
"RawInput: got an event from a file, size=" << recsize <<
123 " (proc= " << (
int)getpid() <<
")");
131 if (npackedevts != 1) {
132 B2FATAL(
"Raw2DsModule::number of events in packet is not 1 " << npackedevts);
134 int ncprs = sndhdr.GetNumNodesinPacket();
135 int nwords = sndhdr.GetTotalNwords() - SendHeader::SENDHDR_NWORDS - SendTrailer::SENDTRL_NWORDS;
136 B2INFO(
"RawInput: Ncprs=" << ncprs <<
" Nwords=" << nwords);
139 int* bufbody = (
int*)evtbuf + SendHeader::SENDHDR_NWORDS;
147 tempdblk.
SetBuffer(bufbody, nwords,
false, npackedevts, ncprs);
150 for (
int cprid = 0; cprid < ncprs * npackedevts; cprid++) {
153 int* cprbuf =
new int[nwds_buf];
154 memcpy(cprbuf, tempdblk.
GetBuffer(cprid), nwds_buf * 4);
159 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
165 tempcpr.
SetBuffer(cprbuf, nwds_buf,
false, 1, 1);
173 if ((subsysid & DETECTOR_MASK) == CDC_ID) {
175 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
176 }
else if ((subsysid & DETECTOR_MASK) == SVD_ID) {
178 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
179 }
else if ((subsysid & DETECTOR_MASK) == BECL_ID) {
181 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
182 }
else if ((subsysid & DETECTOR_MASK) == EECL_ID) {
184 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
185 }
else if ((subsysid & DETECTOR_MASK) == TOP_ID) {
187 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
188 }
else if ((subsysid & DETECTOR_MASK) == ARICH_ID) {
190 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
191 }
else if ((subsysid & DETECTOR_MASK) == BKLM_ID) {
193 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
194 }
else if ((subsysid & DETECTOR_MASK) == EKLM_ID) {
196 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
197 }
else if (((subsysid & DETECTOR_MASK) & 0xF0000000) == TRGDATA_ID) {
199 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
202 (ary.
appendNew())->SetBuffer(cprbuf, nwds_buf, 1, 1, 1);
209 evtmetadata->setExperiment(sndhdr.GetExpNum());
210 evtmetadata->setRun(sndhdr.GetRunNum());
211 evtmetadata->setSubrun(sndhdr.GetSubRunNum());
212 evtmetadata->setEvent(sndhdr.GetEventNumber());
218 B2INFO(
"RawInput: DataStore Restored!!");
225 B2INFO(
"RawInput: endRun done.");
232 B2INFO(
"RawInput: terminate called");
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_Input
This module is an input module (reads data).
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 )
The RawDataBlock class Base class for rawdata handling.
virtual int * GetBuffer(int n)
get nth buffer pointer
virtual int CheckFTSWID(int n)
get FTSW ID to check whether this data block is FTSW data or not
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 )
virtual int GetBlockNwords(int n)
get size of a data block
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.
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 GetEventCRCError(int n)
check CRC event Error
unsigned int GetNodeID(int n)
get node-ID from data
Abstract base class for different kinds of events.