24#include "FairFileSource.h"
25#include "FairMQLogger.h"
26#include "FairMQProgOptions.h"
27#include "FairRootManager.h"
28#include "FairRunAna.h"
30#include "TClonesArray.h"
47 using std::runtime_error::runtime_error;
54 fFileName = fConfig->GetValue<
string>(
"filename");
55 fMaxEvents = fConfig->GetValue<uint64_t>(
"max-events");
69 throw InitTaskError(
"Sending same data to more than one output channel "
70 "not implemented yet.");
78 FairRunAna* ana =
new FairRunAna();
79 ana->SetContainerStatic();
80 FairRootManager* rootman = FairRootManager::Instance();
83 LOG(info) <<
"Open the ROOT input file " <<
fFileName;
85 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
86 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
88 FairFileSource* source =
new FairFileSource(
fFileName);
89 if (!source) {
throw InitTaskError(
"Could not open input file."); }
90 rootman->SetSource(source);
91 rootman->InitSource();
97 LOG(info) << channel_name.at(0);
116 Int_t MaxAllowed = FairRootManager::Instance()->CheckMaxEventNo(
fMaxEvents);
117 if (MaxAllowed != -1) {
120 if (
static_cast<Int_t
>(
fMaxEvents) > MaxAllowed) {
121 LOG(warn) <<
"-------------------Warning---------------------------";
122 LOG(warn) <<
" File has less events than requested!!";
123 LOG(warn) <<
" File contains : " << MaxAllowed <<
" Events";
124 LOG(warn) <<
" Requested number of events = " <<
fMaxEvents <<
" Events";
125 LOG(warn) <<
" The number of events is set to " << MaxAllowed <<
" Events";
126 LOG(warn) <<
"-----------------------------------------------------";
130 LOG(info) <<
"After checking, the run will run from event 0 "
134 LOG(info) <<
"continue running without stop";
138 fTime = std::chrono::steady_clock::now();
141 LOG(error) << e.what();
147 FairRootManager* rootman)
149 if (0 == channel_name.compare(branchname)) {
150 LOG(info) <<
"Found expected data type " << branchname;
151 TClonesArray* arr =
static_cast<TClonesArray*
>(rootman->GetObject(branchname.c_str()));
153 LOG(info) <<
"Consuming device connected but no " << branchname <<
" array in input file!";
164 Int_t readEventReturn = FairRootManager::Instance()->ReadEvent(
fEventCounter);
167 if (readEventReturn != 0) {
168 LOG(warn) <<
"FairRootManager::Instance()->ReadEvent(" <<
fEventCounter <<
") returned " << readEventReturn
169 <<
". Breaking the event loop";
206 LOG(error) <<
"Problem sending data";
228 std::chrono::duration<double> run_time = std::chrono::steady_clock::now() -
fTime;
230 LOG(info) <<
"Runtime: " << run_time.count();
231 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
bool CheckChannels(FairMQDevice *device)
std::vector< int > GetComponentsToSend()
std::vector< std::vector< std::string > > GetChannelsToSend()
void ChangeState(FairMQDevice *device, cbm::mq::Transition transition)