23 #include <FairMQLogger.h>
25 #include <TClonesArray.h>
34 , fOutputChannelName(
"data-out")
49 fFileNames = fConfig->GetValue<std::vector<std::string>>(
"file-name");
50 fMaxIndex = fConfig->GetValue<int64_t>(
"max-index");
51 fBranchNames = fConfig->GetValue<std::vector<std::string>>(
"branch-name");
52 fOutputChannelName = fConfig->GetValue<std::string>(
"out-channel");
53 fAckChannelName = fConfig->GetValue<std::string>(
"ack-channel");
56 if (fFileNames.size() > 0) {
58 for (
unsigned int ifile = 1; ifile < fFileNames.size(); ifile++)
59 fSource->
AddFile(fFileNames.at(ifile));
62 LOG(info) <<
"Going to request " << fBranchNames.size() <<
" branches:";
63 for (
unsigned int ibrn = 0; ibrn < fBranchNames.size(); ibrn++) {
64 LOG(info) <<
" requesting branch \"" << fBranchNames[ibrn] <<
"\"";
65 int branchStat = fSource->
ActivateObject((TObject**)&fInputObjects[fNObjects],
66 fBranchNames[ibrn].c_str());
67 if (fInputObjects[fNObjects]) {
68 LOG(info) <<
"Activated object \"" << fInputObjects[fNObjects] <<
"\" with name \"" << fBranchNames[ibrn]
69 <<
"\" (" << branchStat <<
")";
75 LOG(info) <<
"Input source has " << fMaxIndex <<
" events.";
80 LOG(info) <<
"FairMQPixelSampler::PreRun() started!";
87 if (fEventCounter == fMaxIndex)
90 int readEventReturn = 0;
91 readEventReturn = fSource->
ReadEvent(fEventCounter);
93 if (readEventReturn != 0)
98 for (
int iobj = 0; iobj < fNObjects; iobj++) {
99 if (strcmp(fInputObjects[iobj]->GetName(),
"EventHeader.") == 0) {
104 FairMQMessagePtr msgHeader(
108 parts.AddPart(std::move(msgHeader));
112 Int_t nofEntries = ((TClonesArray*)fInputObjects[iobj])->GetEntries();
115 FairMQMessagePtr msgTCA(NewMessage(digisSize));
119 for (
int idigi = 0; idigi < nofEntries; idigi++) {
120 PixelDigi* digi =
static_cast<PixelDigi*
>(((TClonesArray*)fInputObjects[iobj])->At(idigi));
132 parts.AddPart(std::move(msgTCA));
137 Send(parts, fOutputChannelName);
146 if (fAckChannelName !=
"") {
150 LOG(info) <<
"PostRun() finished!";
155 if (fAckChannelName !=
"") {
156 Long64_t numAcks = 0;
158 FairMQMessagePtr ack(NewMessage());
159 if (Receive(ack, fAckChannelName) >= 0) {
162 }
while (numAcks < fMaxIndex);
164 LOG(info) <<
"Acknowledged " << numAcks <<
" messages.";
void AddFile(TString FileName)
virtual Int_t CheckMaxEventNo(Int_t EvtEnd=0)
Int_t ReadEvent(UInt_t i=0)
virtual bool ConditionalRun()
virtual Bool_t ActivateObject(TObject **obj, const char *BrName)
virtual ~FairMQPixelSamplerBin()