9 #include <daq/storage/modules/PartialSeqRootReader.h>
29 m_buf =
new char[1024 * 1024 * 100];
30 setDescription(
"Partial sroot file reader");
32 addParam(
"FilePath", m_path,
"File path ", std::string(
""));
33 addParam(
"FileNoMin", m_filemin,
"Minimum filenumber ", 0);
34 addParam(
"FileNoMax", m_filemax,
"Maximum filenumber ", -1);
37 B2INFO(
"PartialSeqRootReader: Constructor done.");
41 PartialSeqRootReaderModule::~PartialSeqRootReaderModule()
47 int PartialSeqRootReaderModule::openFile(
int fileno)
49 if (m_fd > 0) close(m_fd);
50 if (fileno > m_filemax)
return -1;
53 sprintf(filename,
"%s-%d", m_path.c_str(), fileno);
54 }
else if (fileno == 0) {
55 sprintf(filename,
"%s", m_path.c_str());
57 int fd = ::open(filename, O_RDONLY);
59 B2ERROR(
"file open error (" << strerror(errno) <<
"): " << filename);
62 std::cout <<
"SeqFile: " << filename <<
" opened (fd=" << m_fd <<
")" << std::endl;
63 B2INFO(
"SeqFile: " << filename <<
" opened (fd=" << m_fd <<
")");
67 int PartialSeqRootReaderModule::readFile()
69 int ret = ::read(m_fd, m_buf,
sizeof(
int));
72 }
else if (ret == 0) {
73 m_fd = openFile(m_fileno++);
74 if (m_fd <= 0)
return -1;
75 ret = ::read(m_fd, m_buf,
sizeof(
int));
77 int size = *(
int*)m_buf;
78 ret = ::read(m_fd, (
char*)(m_buf +
sizeof(
int)), size -
sizeof(
int));
87 B2INFO(
"PartialSeqRootReader: initialize() started.");
92 if (readFile() < 0)
return;
95 if (evtmsg->
type() == MSG_STREAMERINFO) {
96 B2INFO(
"Reading StreamerInfo");
104 m_fd = openFile(m_fileno++);
109 if (readFile() < 0)
return;
112 if (evtmsg->
type() == MSG_STREAMERINFO) {
113 B2INFO(
"Reading StreamerInfo");
121 B2INFO(
"PartialSeqRootReader: initialize() done.");
127 if (readFile() < 0)
return;
130 if (evtmsg->
type() == MSG_STREAMERINFO) {
131 B2INFO(
"Reading StreamerInfo");
142 B2INFO(
"PartialSeqRootReader: beginRun called.");
147 B2INFO(
"PartialSeqRootReader: endRun done.");
153 B2INFO(
"PartialSeqRootReader: terminate called");
Stream/restore DataStore objects to/from EvtMessage.
int restoreDataStore(EvtMessage *msg)
Restore DataStore objects from EvtMessage.
Class to manage streamed object.
ERecordType type() const
Get record type.
A class definition of an input module for Sequential ROOT I/O.
virtual void event()
This method is the core of the module.
virtual void initialize()
Module functions to be called from main process.
virtual void beginRun()
Module functions to be called from event process.
virtual void terminate()
This method is called at the end of the event processing.
virtual void endRun()
This method is called if the current run ends.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.