9 #include <framework/modules/rootio/SeqRootInputModule.h> 
   11 #include <framework/core/Environment.h> 
   12 #include <framework/datastore/DataStore.h> 
   13 #include <framework/datastore/StoreObjPtr.h> 
   14 #include <framework/dataobjects/FileMetaData.h> 
   15 #include <framework/io/RootIOUtilities.h> 
   16 #include <framework/database/Configuration.h> 
   33 SeqRootInputModule::SeqRootInputModule() : 
Module()
 
   41            "Input file name. Can also be a gzip-compressed file (with suffix .gz). " 
   42            "Parameter can be overridden using the -i argument to basf2.",
 
   47            "filename as a boost::format pattern instead of the standard where " 
   48            "subsequent files are named .sroot-N. For example 'myfile-f%08d.sroot'",
 
   50   addParam(
"declareRealData", 
m_realData, 
"Declare the input to be real, not generated data", 
false);
 
   53 SeqRootInputModule::~SeqRootInputModule() = 
default;
 
   59     B2FATAL(
"Cannot specify both 'inputFileName' and 'inputFileNames'");
 
   62   if (!inputFiles.empty()) {  
 
   63     if (inputFiles.size() > 1) {
 
   86     B2FATAL(
"SeqRootInput : Error in opening input file : " << 
m_inputFileName);
 
   98       if (evtmsg->
type() == MSG_STREAMERINFO) {
 
  100         B2INFO(
"Reading StreamerInfo");
 
  101         if (info_cnt != 0) B2FATAL(
"SeqRootInput : Reading StreamerInfos twice");
 
  113       B2FATAL(
"SeqRootInput : Error in reading first event");
 
  122     fileMetaData->declareRealData();
 
  132   gettimeofday(&
m_t0, 
nullptr);
 
  136   B2INFO(
"SeqRootInput: beginRun called.");
 
  145   if (++
m_nevt == 0) 
return;
 
  152     B2ERROR(
"SeqRootInput : file read error");
 
  158   } 
else if (size == 0) {
 
  159     B2INFO(
"SeqRootInput : EOF detected");
 
  173       B2FATAL(
"SeqRootInput : Error in opening input file : " << 
m_inputFileName);
 
  179       B2FATAL(
"SeqRootInput : Error in reading file. error code = " << is);
 
  184       B2FATAL(
"SeqRootInput : Error in reading file. error code = " << is);
 
  192   double dsize = (double)size / 1000.0;
 
  196   if (evtmsg->
type() == MSG_STREAMERINFO) {
 
  197     B2WARNING(
"SeqRootInput : StreamerInfo is found in the middle of *.sroot-* files. Skip record");
 
  200       B2FATAL(
"SeqRootInput : Error in reading file. error code = " << is);
 
  218   gettimeofday(&
m_tend, 
nullptr);
 
  219   auto etime = (double)((
m_tend.tv_sec - 
m_t0.tv_sec) * 1000000 +
 
  225   double flowmb = 
m_size / etime * 1000.0;
 
  226   double evrate = (double)
m_nevt / (etime / 1000.0);
 
  229   double sigma2 = avesize2 - avesize * avesize;
 
  230   double sigma = sqrt(sigma2);
 
  234   B2INFO(
"SeqRootInput :  " << 
m_nevt << 
" events read with total bytes of " << 
m_size << 
" kB");
 
  235   B2INFO(
"SeqRootInput : event rate = " << evrate << 
" (KHz)");
 
  236   B2INFO(
"SeqRootInput : flow rate = " << flowmb << 
" (MB/s)");
 
  237   B2INFO(
"SeqRootInput : event size = " << avesize << 
" +- " << sigma << 
" (kB)");
 
  239   B2INFO(
"SeqRootInput: endRun done.");
 
  247   B2INFO(
"SeqRootInput: terminate called");
 
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
void setInputGlobaltags(const std::vector< std::string > &inputTags)
To be called by input modules with the tags to be added from input files.
Stream/restore DataStore objects to/from EvtMessage.
int restoreDataStore(EvtMessage *msg)
Restore DataStore objects from EvtMessage.
@ c_Persistent
Object is available during entire execution time.
const std::vector< std::string > & getInputFilesOverride() const
Return overriden input file names, or empty vector if none were set.
static Environment & Instance()
Static method to get a reference to the Environment instance.
Class to manage streamed object.
ERecordType type() const
Get record type.
static const unsigned int c_MaxEventSize
maximal EvtMessage size, in bytes (200MB).
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_Input
This module is an input module (reads data).
A class to manage I/O for a chain of blocked files.
int status() const
Returns status after constructor call.
int read(char *buf, int max)
Read a record from a file.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
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.