9#include <daq/storage/modules/Ds2RawFileModule.h>
11#include <daq/dataobjects/SendHeader.h>
12#include <daq/dataobjects/SendTrailer.h>
13#include <framework/datastore/DataStore.h>
14#include <framework/datastore/StoreObjPtr.h>
15#include <framework/dataobjects/EventMetaData.h>
49 B2INFO(
"Ds2Raw: Constructor done.");
53Ds2RawFileModule::~Ds2RawFileModule()
63 m_file = open(
"file.data", O_CREAT | O_RDWR | O_TRUNC, 0644);
68 B2INFO(
"Ds2Raw initialized.");
74 B2INFO(
"Ds2Raw: beginRun called.");
91 int msgsize = (msg->
size() - 1) / 4 + 1;
92 int total_nwrds = msgsize + hdr.
GetHdrNwords() + trl.GetTrlNwords();
97 hdr.SetNumNodesinPacket(1);
98 hdr.SetEventNumber(evtmeta->getEvent());
101 hdr.SetRunNum(evtmeta->getRun());
102 hdr.SetExpNum(evtmeta->getExperiment());
103 hdr.SetNodeID(HLT_SUBSYS_ID);
107 int* buffer =
new int[total_nwrds];
116 memcpy(buffer + hdr.
GetHdrNwords() + msgsize, trl.GetBuffer(),
117 trl.GetTrlNwords()*
sizeof(
int));
119 write(m_file, buffer, total_nwrds * 4);
121 B2INFO(
"Ds2Raw: objs sent in buffer. Size = " << msg->
size());
136 printf(
"Ds2Raw: endRun called.....\n");
137 B2INFO(
"Ds2Raw: endRun done.");
147 B2INFO(
"Ds2Raw: terminate called");
Stream/restore DataStore objects to/from EvtMessage.
EvtMessage * streamDataStore(bool addPersistentDurability, bool streamTransientObjects=false)
Store DataStore objects in EvtMessage.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
DataStoreStreamer * m_streamer
RingBuffer ID.
void initialize() override
Module functions to be called from main process.
void event() override
This method is the core of the module.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
Ds2RawFileModule()
Constructor / Destructor.
void beginRun() override
Module functions to be called from event process.
int m_nsent
No. of sent events.
int m_compressionLevel
Compression parameter.
Class to manage streamed object.
char * buffer()
Get buffer address.
int size() const
Get size of message including headers.
void setDescription(const std::string &description)
Sets the description of the module.
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.
Abstract base class for different kinds of events.