18#include "FairFileSource.h"
19#include "FairMQLogger.h"
20#include "FairMQProgOptions.h"
21#include "FairRootManager.h"
22#include "FairRunAna.h"
24#include <boost/archive/binary_oarchive.hpp>
35 using std::runtime_error::runtime_error;
55 fFileName = fConfig->GetValue<
string>(
"filename");
56 fMaxEvents = fConfig->GetValue<uint64_t>(
"max-events");
70 int noChannel = fChannels.size();
71 LOG(info) <<
"Number of defined output channels: " << noChannel;
72 for (
auto const& entry : fChannels) {
73 LOG(info) <<
"Channel name: " << entry.first;
77 FairRootManager* rootman = FairRootManager::Instance();
81 LOG(info) <<
"Open the ROOT input file " <<
fFileName;
83 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
84 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
86 FairFileSource* source =
new FairFileSource(
fFileName);
87 if (!source) {
throw InitTaskError(
"Could not open input file."); }
88 rootman->SetSource(source);
89 rootman->InitSource();
99 Int_t MaxAllowed = FairRootManager::Instance()->CheckMaxEventNo(
fMaxEvents);
100 if (MaxAllowed != -1) {
104 LOG(warn) <<
"-------------------Warning---------------------------";
105 LOG(warn) <<
" File has less events than requested!!";
106 LOG(warn) <<
" File contains : " << MaxAllowed <<
" Events";
107 LOG(warn) <<
" Requested number of events = " <<
fMaxEvents <<
" Events";
108 LOG(warn) <<
" The number of events is set to " << MaxAllowed <<
" Events";
109 LOG(warn) <<
"-----------------------------------------------------";
113 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();
124 LOG(error) << e.what();
132 LOG(info) <<
"Channel name " << channelName <<
" found in list of allowed channel names.";
136 LOG(info) <<
"Channel name " << channelName <<
" not found in list of allowed channel names.";
137 LOG(error) <<
"Stop device.";
146 LOG(info) <<
"Return value: " << readEventReturn;
148 if (readEventReturn != 0) {
149 LOG(warn) <<
"FairRootManager::Instance()->ReadEvent(" <<
fEventCounter <<
") returned " << readEventReturn
150 <<
". Breaking the event loop";
177 std::chrono::duration<double> run_time = std::chrono::steady_clock::now() -
fTime;
179 LOG(info) <<
"Runtime: " << run_time.count();
180 LOG(info) <<
"No more input data";
@ kSts
Silicon Tracking System.
static Int_t GetNofDigis(ECbmModuleId systemId)
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
InitStatus Init()
Initialisation.
const Digi * Get(Int_t index) const
Get a digi object.
static CbmDigiManager * Instance()
Static instance.
std::chrono::steady_clock::time_point fTime
bool IsChannelNameAllowed(std::string)
void PrintStsDigi(const CbmStsDigi *)
virtual ~CbmStsDigiSource()
virtual bool ConditionalRun()
std::vector< std::string > fInputFileList
List of input files.
std::vector< std::string > fAllowedChannels
Data class for a single-channel message in the STS.
std::string ToString() const
void ChangeState(FairMQDevice *device, cbm::mq::Transition transition)