18#include <FairLogger.h>
19#include <FairRootManager.h>
20#include <FairRunOnline.h>
26#include "ext_data_client.h"
29 const TString& NtupleOptions,
30 const TString& UcesbPath,
53 R3BLOG(debug1,
"R3BUcesbSource destructor.");
66 R3BLOG(debug,
"checking whether R3BEventHeader has been defined in FairRun");
67 auto run = FairRun::Instance();
68 auto eventHeader =
dynamic_cast<R3BEventHeader*
>(run->GetEventHeader());
71 R3BLOG(info,
"EventHeader. was defined properly");
76 run->SetEventHeader(eventHeader);
77 R3BLOG(warn,
"EventHeader. has been created from R3BEventHeader");
81 std::ostringstream command;
90 LOG(info) <<
"Calling ucesb with command: " << command.str();
93 fFd = popen(command.str().c_str(),
"r");
96 R3BLOG(fatal,
"popen() failed");
102 if (kFALSE == status)
104 R3BLOG(error,
"ext_data_clnt::connect() failed");
113 R3BLOG(warn,
"Input file for RunIds could not be open, it is Ok!");
128 FairRootManager* frm = FairRootManager::Instance();
129 R3BLOG_IF(fatal, !frm,
"FairRootManager no found");
131 R3BLOG(info,
"Checking the register of R3BEventHeader");
135 R3BLOG(info,
"EventHeader. was defined properly");
139 R3BLOG(error,
"EventHeader. was not defined properly!");
143 for (
int i = 0; i <
fReaders->GetEntriesFast(); ++i)
154 uint32_t struct_map_success = 0;
159 R3BLOG(error,
"ext_data_clnt::setup() failed");
169 uint32_t map_ok = EXT_DATA_ITEM_MAP_OK | EXT_DATA_ITEM_MAP_NO_DEST;
170 if (struct_map_success & ~(map_ok))
172 R3BLOG(warn,
"ext_data_clnt::setup() failed to map all items:");
173 ext_data_struct_info_print_map_success(
fStructInfo, stderr, map_ok);
180 "ext_data_clnt::setup() mapping failure may "
181 "cause unexpected analysis results due to missing "
182 "data members. Unpacker needs fixing.");
187 "ext_data_clnt::setup() mapping failure may "
188 "cause unexpected analysis results due to missing "
189 "data members. Unpacker needs fixing.");
200 for (
int i = 0; i <
fReaders->GetEntriesFast(); ++i)
209 for (
int i = 0; i <
fReaders->GetEntriesFast(); ++i)
213 R3BLOG(fatal,
"ReInit of a reader failed.");
223 std::string tempstr = wholestr;
224 tempstr.replace(0, tempstr.find(pattern) + pattern.length(),
"");
225 tempstr.replace(0, tempstr.find(
'=') + 1,
"");
226 return atoi(tempstr.c_str());
243 R3BLOG(info,
"ReadEvent()");
249 LOG(info) <<
"read from file: \"" << buffer <<
"\"";
250 if (buffer.find(
"EVENT BEGIN") == 0)
255 if (buffer.find(
"EVENT") == 0)
257 Int_t fInit = atoi(buffer.c_str());
258 buffer.erase(0, buffer.find(
' ') + 1);
261 }
while (
fInputFile && buffer.compare(
"EVENT END"));
274 LOG(info) <<
"End of input";
279 perror(
"ext_data_clnt::fetch_event()");
280 R3BLOG(error,
"ext_data_clnt::fetch_event() failed");
286 ret =
fClient.get_raw_data(&raw, &raw_words);
289 perror(
"ext_data_clnt::get_raw_data()");
290 R3BLOG(fatal,
"Failed to get raw data.");
295 for (
int r = 0; r <
fReaders->GetEntriesFast(); ++r)
299 LOG(debug1) <<
" Reading reader " << r <<
" (" << reader->GetName() <<
")";
307 const uint32_t* u =
reinterpret_cast<const uint32_t*
>(raw);
309 LOG(info) <<
" Raw data:";
310 for (w = 0; w < raw_words; w += 8)
312 printf(
" RAW%4x:", w);
313 for (j = 0; j < 8 && w + j < raw_words; j++)
314 printf(
" %08x", u[w + j]);
333 R3BLOG(fatal,
"ext_data_clnt::close() failed");
338 status = pclose(
fFd);
342 R3BLOG(fatal,
"pclose() failed");
353 for (
int i = 0; i <
fReaders->GetEntriesFast(); ++i)
372 feh->SetRunId(fRunId);
#define R3BLOG(severity, x)
#define R3BLOG_IF(severity, condition, x)
struct EXT_STR_h101_t EXT_STR_h101
virtual Bool_t R3BRead()=0
R3BUcesbSource(const TString &, const TString &, const TString &, EXT_STR_h101 *, size_t)
virtual Bool_t InitUnpackers()
virtual void SetParUnpackers()
R3BEventHeader * fEventHeader
virtual void FillEventHeader(FairEventHeader *feh)
bool fFullDataStructureValidation
virtual Bool_t ReInitUnpackers()
const TString fNtupleOptions
ext_data_struct_info fStructInfo
virtual ~R3BUcesbSource()
virtual Bool_t SpecifyRunId()
Int_t ReadIntFromString(const std::string &wholestr, const std::string &pattern)