23#include "FairFileSource.h"
24#include "FairMQLogger.h"
25#include "FairMQProgOptions.h"
26#include "FairRootManager.h"
27#include "FairRunAna.h"
29#include "TClonesArray.h"
46 using std::runtime_error::runtime_error;
53 fFileName = fConfig->GetValue<
string>(
"filename");
54 fMaxEvents = fConfig->GetValue<uint64_t>(
"max-events");
62 fChan.CheckChannels(
this);
68 throw InitTaskError(
"Sending same data to more than one output channel "
69 "not implemented yet.");
77 FairRunAna* ana =
new FairRunAna();
78 ana->SetContainerStatic();
79 FairRootManager* rootman = FairRootManager::Instance();
82 LOG(info) <<
"Open the ROOT input file " <<
fFileName;
84 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
85 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
87 FairFileSource* source =
new FairFileSource(
fFileName);
88 if (!source) {
throw InitTaskError(
"Could not open input file."); }
89 rootman->SetSource(source);
90 rootman->InitSource();
96 LOG(info) << channel_name.at(0);
114 Int_t MaxAllowed = FairRootManager::Instance()->CheckMaxEventNo(
fMaxEvents);
115 if (MaxAllowed != -1) {
119 LOG(warn) <<
"-------------------Warning---------------------------";
120 LOG(warn) <<
" File has less events than requested!!";
121 LOG(warn) <<
" File contains : " << MaxAllowed <<
" Events";
122 LOG(warn) <<
" Requested number of events = " <<
fMaxEvents <<
" Events";
123 LOG(warn) <<
" The number of events is set to " << MaxAllowed <<
" Events";
124 LOG(warn) <<
"-----------------------------------------------------";
128 LOG(info) <<
"After checking, the run will run from event 0 "
132 LOG(info) <<
"continue running without stop";
136 fTime = std::chrono::steady_clock::now();
139 LOG(error) << e.what();
145 FairRootManager* rootman)
147 if (0 == channel_name.compare(branchname)) {
148 LOG(info) <<
"Found expected data type " << branchname;
149 TClonesArray* arr =
static_cast<TClonesArray*
>(rootman->GetObject(branchname.c_str()));
151 LOG(info) <<
"Consuming device connected but no " << branchname <<
" array in input file!";
165 if (readEventReturn != 0) {
166 LOG(warn) <<
"FairRootManager::Instance()->ReadEvent(" <<
fEventCounter <<
") returned " << readEventReturn
167 <<
". Breaking the event loop";
199 LOG(error) <<
"Problem sending data";
221 std::chrono::duration<double> run_time = std::chrono::steady_clock::now() -
fTime;
223 LOG(info) <<
"Runtime: " << run_time.count();
224 LOG(info) <<
"No more input data";
virtual bool ConditionalRun()
std::chrono::steady_clock::time_point fTime
bool ConvertAndSend(TClonesArray *arr, int i)
virtual ~CbmMCPointSource()
void ConnectChannelIfNeeded(int, std::string, std::string, FairRootManager *)
std::vector< int > fComponentsToSend
std::vector< TClonesArray * > fArrays
std::vector< std::vector< std::string > > fChannelsToSend
void ChangeState(FairMQDevice *device, cbm::mq::Transition transition)