15 #include "FairMQLogger.h"
16 #include "FairMQProgOptions.h"
18 #include "FairFileSource.h"
19 #include "FairRootManager.h"
20 #include "FairRunAna.h"
23 #include <boost/archive/binary_oarchive.hpp>
34 using std::runtime_error::runtime_error;
51 fFileName = fConfig->GetValue<
string>(
"filename");
52 fMaxEvents = fConfig->GetValue<uint64_t>(
"max-events");
66 int noChannel = fChannels.size();
67 LOG(info) <<
"Number of defined output channels: " << noChannel;
68 for (
auto const& entry : fChannels) {
69 LOG(info) <<
"Channel name: " << entry.first;
74 FairRootManager* rootman = FairRootManager::Instance();
78 LOG(info) <<
"Open the ROOT input file " <<
fFileName;
80 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
81 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
83 FairFileSource* source =
new FairFileSource(
fFileName);
84 if (!source) {
throw InitTaskError(
"Could not open input file."); }
85 rootman->SetSource(source);
86 rootman->InitSource();
97 Int_t MaxAllowed = FairRootManager::Instance()->CheckMaxEventNo(
fMaxEvents);
98 if (MaxAllowed != -1) {
102 if (
static_cast<Int_t
>(
fMaxEvents) > MaxAllowed) {
103 LOG(warn) <<
"-------------------Warning---------------------------";
104 LOG(warn) <<
" File has less events than requested!!";
105 LOG(warn) <<
" File contains : " << MaxAllowed <<
" Events";
106 LOG(warn) <<
" Requested number of events = " <<
fMaxEvents
108 LOG(warn) <<
" The number of events is set to " << MaxAllowed
110 LOG(warn) <<
"-----------------------------------------------------";
114 LOG(info) <<
"After checking, the run will run from event 0 "
117 LOG(info) <<
"continue running without stop";
121 fTime = std::chrono::steady_clock::now();
123 LOG(error) << e.what();
131 LOG(info) <<
"Channel name " << channelName
132 <<
" found in list of allowed channel names.";
135 LOG(info) <<
"Channel name " << channelName
136 <<
" not found in list of allowed channel names.";
137 LOG(error) <<
"Stop device.";
144 Int_t readEventReturn = FairRootManager::Instance()->ReadEvent(
fEventCounter);
145 LOG(info) <<
"Return value: " << readEventReturn;
147 if (readEventReturn != 0) {
148 LOG(warn) <<
"FairRootManager::Instance()->ReadEvent(" <<
fEventCounter
149 <<
") returned " << readEventReturn
150 <<
". Breaking the event loop";
155 for (Int_t index = 0;
181 std::chrono::duration<double> run_time =
182 std::chrono::steady_clock::now() -
fTime;
184 LOG(info) <<
"Runtime: " << run_time.count();
185 LOG(info) <<
"No more input data";