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>
37 setDescription(
"Encode DataStore into RingBuffer");
41 addParam(
"CompressionLevel", m_compressionLevel,
"Compression level",
46 m_compressionLevel = 0;
49 B2INFO(
"Ds2Raw: Constructor done.");
53 Ds2RawFileModule::~Ds2RawFileModule()
57 void Ds2RawFileModule::initialize()
63 m_file = open(
"file.data", O_CREAT | O_RDWR | O_TRUNC, 0644);
68 B2INFO(
"Ds2Raw initialized.");
72 void Ds2RawFileModule::beginRun()
74 B2INFO(
"Ds2Raw: beginRun called.");
78 void Ds2RawFileModule::event()
81 EvtMessage* msg = m_streamer->streamDataStore(DataStore::c_Event);
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());
132 void Ds2RawFileModule::endRun()
136 printf(
"Ds2Raw: endRun called.....\n");
137 B2INFO(
"Ds2Raw: endRun done.");
141 void Ds2RawFileModule::terminate()
147 B2INFO(
"Ds2Raw: terminate called");
Stream/restore DataStore objects to/from EvtMessage.
A class definition of an input module for Sequential ROOT I/O.
Class to manage streamed object.
char * buffer()
Get buffer address.
int size() const
Get size of message including headers.
Type-safe access to single objects in the data store.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.