19#include "FairFileSource.h"
20#include "FairMQLogger.h"
21#include "FairMQProgOptions.h"
22#include "FairRootManager.h"
23#include "FairRunAna.h"
27#include <boost/archive/binary_oarchive.hpp>
38 using std::runtime_error::runtime_error;
58 fFileName = fConfig->GetValue<
string>(
"filename");
59 fMaxEvents = fConfig->GetValue<uint64_t>(
"max-events");
73 int noChannel = fChannels.size();
74 LOG(info) <<
"Number of defined output channels: " << noChannel;
75 for (
auto const& entry : fChannels) {
76 LOG(info) <<
"Channel name: " << entry.first;
80 FairRootManager* rootman = FairRootManager::Instance();
84 LOG(info) <<
"Open the ROOT input file " <<
fFileName;
86 FILE* inputFile = fopen(
fFileName.c_str(),
"r");
87 if (!inputFile) {
throw InitTaskError(
"Input file doesn't exist."); }
89 FairFileSource* source =
new FairFileSource(
fFileName);
90 if (!source) {
throw InitTaskError(
"Could not open input file."); }
91 rootman->SetSource(source);
92 rootman->InitSource();
102 Int_t MaxAllowed = FairRootManager::Instance()->CheckMaxEventNo(
fMaxEvents);
103 if (MaxAllowed != -1) {
106 if (
static_cast<Int_t
>(
fMaxEvents) > MaxAllowed) {
107 LOG(warn) <<
"-------------------Warning---------------------------";
108 LOG(warn) <<
" File has less events than requested!!";
109 LOG(warn) <<
" File contains : " << MaxAllowed <<
" Events";
110 LOG(warn) <<
" Requested number of events = " <<
fMaxEvents <<
" Events";
111 LOG(warn) <<
" The number of events is set to " << MaxAllowed <<
" Events";
112 LOG(warn) <<
"-----------------------------------------------------";
116 LOG(info) <<
"After checking, the run will run from event 0 "
120 LOG(info) <<
"continue running without stop";
124 fTime = std::chrono::steady_clock::now();
127 LOG(error) << e.what();
135 LOG(info) <<
"Channel name " << channelName <<
" found in list of allowed channel names.";
139 LOG(info) <<
"Channel name " << channelName <<
" not found in list of allowed channel names.";
140 LOG(error) <<
"Stop device.";
148 Int_t readEventReturn = FairRootManager::Instance()->ReadEvent(
fEventCounter);
149 LOG(info) <<
"Return value: " << readEventReturn;
151 if (readEventReturn != 0) {
152 LOG(warn) <<
"FairRootManager::Instance()->ReadEvent(" <<
fEventCounter <<
") returned " << readEventReturn
153 <<
". Breaking the event loop";
180 std::chrono::duration<double> run_time = std::chrono::steady_clock::now() -
fTime;
182 LOG(info) <<
"Runtime: " << run_time.count();
183 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 > fAllowedChannels
Data class for a single-channel message in the STS.
std::string ToString() const
void ChangeState(FairMQDevice *device, cbm::mq::Transition transition)