9 #include <daq/rfarm/event/modules/Ds2RawModule.h>
10 #include <framework/datastore/StoreObjPtr.h>
11 #include <framework/dataobjects/EventMetaData.h>
12 #include <daq/dataobjects/SendHeader.h>
13 #include <daq/dataobjects/SendTrailer.h>
35 setDescription(
"Encode DataStore into RingBuffer");
37 addParam(
"RingBufferName", m_rbufname,
"Name of RingBuffer",
38 string(
"OutputRbuf"));
39 addParam(
"CompressionLevel", m_compressionLevel,
"Compression level",
44 m_compressionLevel = 0;
47 B2INFO(
"Ds2Raw: Constructor done.");
51 Ds2RawModule::~Ds2RawModule()
55 void Ds2RawModule::initialize()
65 B2INFO(
"Ds2Raw initialized.");
69 void Ds2RawModule::beginRun()
71 B2INFO(
"Ds2Raw: beginRun called.");
75 void Ds2RawModule::event()
78 EvtMessage* msg = m_streamer->streamDataStore(DataStore::c_Event);
88 int msgsize = (msg->
size() - 1) / 4 + 1;
89 int total_nwrds = msgsize + hdr.
GetHdrNwords() + trl.GetTrlNwords();
94 hdr.SetNumNodesinPacket(1);
95 hdr.SetEventNumber(evtmeta->getEvent());
97 hdr.SetSubRunNum(evtmeta->getSubrun());
98 hdr.SetRunNum(evtmeta->getRun());
99 hdr.SetExpNum(evtmeta->getExperiment());
100 hdr.SetNodeID(HLT_SUBSYS_ID);
104 int* buffer =
new int[total_nwrds];
113 memcpy(buffer + hdr.
GetHdrNwords() + msgsize, trl.GetBuffer(),
114 trl.GetTrlNwords()*
sizeof(
int));
120 int stat = m_rbuf->insq(buffer, total_nwrds);
121 if (stat >= 0)
break;
129 B2INFO(
"Ds2Raw: objs sent in buffer. Size = " << msg->
size());
140 void Ds2RawModule::endRun()
144 printf(
"Ds2Raw: endRun called.....\n");
145 B2INFO(
"Ds2Raw: endRun done.");
149 void Ds2RawModule::terminate()
155 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.
Class to manage a Ring Buffer placed in an IPC shared memory.
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.