9#include <daq/storage/modules/StorageSerializer.h>
11#include <framework/datastore/DataStore.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/dataobjects/EventMetaData.h>
39 addParam(
"OutputBufferSize", m_obuf_size,
"Output buffer size", 10);
40 addParam(
"NodeID", m_nodeid,
"Node(subsystem) ID", 0);
41 B2DEBUG(100,
"StorageSerializer: Constructor done.");
45StorageSerializerModule::~StorageSerializerModule() { }
52 m_expno = m_runno = -1;
57 B2FATAL(
"Failed to load arguments for shared buffer (" <<
60 std::cout <<
"[DEBUG] StorageSerializer: initialized." << std::endl;
66 B2INFO(
"StorageSerializer: beginRun called.");
69int StorageSerializerModule::writeStreamerInfos()
75 const TClass* entryClass = iter->second.objClass;
76 std::cout <<
"Recording StreamerInfo : durability " << durability
77 <<
" : Class Name " << entryClass->GetName() << std::endl;
78 TVirtualStreamerInfo* vinfo = entryClass->GetStreamerInfo();
79 if (!minilist) minilist =
new TList();
80 minilist->Add(
reinterpret_cast<TObject*
>(vinfo));
85 EvtMessage* msg =
m_msghandler->encode_msg(MSG_STREAMERINFO);
86 (msg->
header())->nObjects = 1;
87 (msg->
header())->nArrays = 0;
88 int nword = (msg->
size() - 1) / 4 + 1;
89 m_obuf.write(
reinterpret_cast<int*
>(msg->
buffer()), nword,
false, 0,
true);
90 int size = msg->
size();
91 B2INFO(
"Wrote StreamerInfo to a file : " << size <<
"bytes");
96 B2WARNING(
"No StreamerInfo in memory");
104 unsigned int expno = evtmetadata->getExperiment();
105 unsigned int runno = evtmetadata->getRun();
114 if (header->runno < runno || header->expno < expno) {
115 unsigned int subno = 0;
117 B2INFO(
"New run detected: expno = " << expno <<
" runno = "
118 << runno <<
" subno = " << subno);
119 header->expno = expno;
120 header->runno = runno;
121 header->subno = subno;
123 hd.type = MSG_STREAMERINFO;
126 m_obuf.write(
reinterpret_cast<int*
>(&hd), hd.nword,
false, 0,
true);
127 m_nbyte = writeStreamerInfos();
133 m_obuf.write(
reinterpret_cast<int*
>(&hd), hd.nword,
false, 0,
true);
135 int nword = (msg->
size() - 1) / 4 + 1;
136 m_obuf.write(
reinterpret_cast<int*
>(msg->
buffer()), nword,
false, 0,
true);
138 m_nbyte += msg->
size();
144 std::cout <<
"[DEBUG] Storage count = " <<
m_count <<
" nword = " << nword << std::endl;
151 std::cout <<
"[DEBUG] StorageSerializer : endRun called" << std::endl;
157 std::cout <<
"[DEBUG] terminate called" << std::endl;
Stream/restore DataStore objects to/from EvtMessage.
StoreEntryMap::iterator StoreEntryIter
Iterator for a StoreEntry map.
StoreEntryMap & getStoreEntryMap(EDurability durability)
Get a reference to the object/array map.
static const int c_NDurabilityTypes
Number of Durability Types.
EDurability
Durability types.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
static DataStore & Instance()
Instance of singleton Store.
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
Class to manage streamed object.
EvtHeader * header()
Get pointer to EvtHeader.
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.
A class to encode/decode an EvtMessage.
DataStoreStreamer * m_streamer
DataStoreStreamer.
std::string m_obuf_name
Ring Buffer to dump sampled output stream.
void initialize() override
Module functions to be called from main process.
unsigned int m_count
Exp number, Run number.
StorageSerializerModule()
Constructor / Destructor.
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.
MsgHandler * m_msghandler
Messaage handler.
void beginRun() override
Module functions to be called from event process.
int m_compressionLevel
Compression level.
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.