11 #include "EventStorage/pickDataReader.h"
12 #include "EventStorage/DataReader.h"
14 #include "Gaudi/Property.h"
22 #include "eformat/HeaderMarker.h"
23 #include "eformat/SourceIdentifier.h"
24 #include "eformat/Issue.h"
25 #include "eformat/Problem.h"
26 #include "eformat/Version.h"
27 #include "eformat/Status.h"
39 const std::string&
name, ISvcLocator* pSvcLocator)
40 : base_class(
name, pSvcLocator)
48 , m_storeGate (
"StoreGateSvc",
name)
49 , m_inputMetadata(
"StoreGateSvc/InputMetaDataStore",
name)
50 , m_robProvider (
"ROBDataProviderSvc",
name)
51 , m_sequential (this,
"EnableSequential", false,
"")
52 , m_dump (this,
"DumpFlag", false,
"Dump fragments")
53 , m_wait (this,
"WaitSecs", 0.,
"Seconds to wait if input is in wait state")
54 , m_valEvent (this,
"ValidateEvent", true,
"switch on check_tree when reading events")
55 , m_eventInfoKey (this,
"EventInfoKey",
"EventInfo",
"Key of EventInfo in metadata store")
57 assert(pSvcLocator !=
nullptr);
79 return(StatusCode::SUCCESS);
89 return(StatusCode::SUCCESS);
101 return(StatusCode::SUCCESS);
119 auto bsmdc = std::make_unique<ByteStreamMetadataContainer>();
120 bsmdc->push_back(std::make_unique<ByteStreamMetadata>(*
m_reader));
123 return m_inputMetadata->record(std::move(bsmdc),
"ByteStreamMetadata");
132 const EventContext& context{Gaudi::Hive::currentContext()};
138 unsigned int eventSize;
145 if (DRWAIT == ecode &&
m_wait > 0) {
155 }
else if (DROK != ecode) {
162 ATH_MSG_ERROR(
"DataReader not ready. Need to getBlockIterator first");
188 ATH_MSG_DEBUG(
"switched to previous event in slot " << context);
199 const EventContext& context{ Gaudi::Hive::currentContext() };
206 unsigned int eventSize;
224 if (DRWAIT == ecode &&
m_wait > 0) {
233 }
while(
m_reader->getData(eventSize, &(cache->
data)) == DRWAIT);
234 }
else if (DROK != ecode) {
241 ATH_MSG_ERROR(
"DataReader not ready. Need to getBlockIterator first");
278 const EventContext& context{Gaudi::Hive::currentContext()};
291 std::vector<eformat::FragmentProblem> problems;
292 rawEvent->problems(problems);
294 if(!problems.empty()) {
299 for(
const auto& problem : problems)
300 ATH_MSG_WARNING(eformat::helper::FragmentProblemDictionary.
string(problem));
329 const DataType headWord = fragment[0];
330 ATH_MSG_DEBUG(
"First word of the fragment " << MSG::hex << headWord << MSG::dec);
332 const DataType formatVersion = eformat::helper::Version(fragment[3]).major_version();
333 ATH_MSG_DEBUG(
"Format version" << MSG::hex << formatVersion << MSG::dec);
335 if((formatVersion != eformat::MAJOR_DEFAULT_VERSION) &&
336 (formatVersion != eformat::MAJOR_V24_VERSION) &&
337 (formatVersion != eformat::MAJOR_V30_VERSION) &&
338 (formatVersion != eformat::MAJOR_V40_VERSION) &&
339 (formatVersion != eformat::MAJOR_V31_VERSION) ) {
341 << MSG::hex << formatVersion << MSG::dec);
344 if(eformat::FULL_EVENT == headWord || 0xcc1234cc == headWord) {
347 if(formatVersion != eformat::MAJOR_DEFAULT_VERSION) {
349 const uint32_t newEventSize = eventSize + 1000;
354 delete [] fragment; fragment =
nullptr;
357 fragment = newFragment;
358 cache->
data =
reinterpret_cast< char*
>(fragment);
368 ATH_MSG_FATAL(
"Unknown Header work in input fragment " << MSG::hex << headWord);
376 if(fragment[5] > 0) {
383 cache->
rawEvent = std::make_unique<RawEvent>(fragment);
384 ATH_MSG_DEBUG(
"Made an FullEventFragment from ES " << fragment);
404 std::string
key =
"ByteStreamDataHeader";
410 std::unique_ptr<DataHeader> dataHeader = std::make_unique<DataHeader>();
414 dataHeader->
insert(*std::move(dataHeaderElement));
422 std::unique_ptr<IOpaqueAddress> iopx = std::make_unique<ByteStreamAddress>(
427 if (ptmpx !=
nullptr) {
429 dataHeader->
insert(element);
436 std::unique_ptr<IOpaqueAddress> iopaux = std::make_unique<ByteStreamAddress>(
443 dataHeader->
insert(element);
449 "ByteStreamDataHeader",
true,
false,
true));
451 return StatusCode::SUCCESS;
486 if (!
status.isSuccess()) {
492 ATH_MSG_INFO(
"No more events in this run, high water mark for this file = "
519 std::pair<long,std::string>
525 m_reader = std::unique_ptr<EventStorage::DataReader>(pickDataReader(
fileName));
530 return std::make_pair(-1,
"END");
540 ATH_MSG_DEBUG(
"Recorded ByteStreamMetadata in InputMetaDataStore");
542 ATH_MSG_ERROR(
"Unable to record ByteStreamMetadata in InputMetaDataStore");
543 return std::make_pair(-1,
"FAIL");
551 if (!
test)
return std::make_pair(-1,
"SEQ");
575 return (!eofFlag) && moreEvent;
586 std::vector<eformat::FragmentProblem> problems;
588 for (
size_t i = 0;
i<total; ++
i) {
593 lastId =
f.source_id();
596 f.problems(problems);
597 if(!problems.empty()) {
599 for(
const auto& problem : problems) {
601 << eformat::helper::SourceIdentifier(lastId).human() <<
" : "
602 << eformat::helper::FragmentProblemDictionary.
string(problem));
615 const EventContext& context{Gaudi::Hive::currentContext()};
623 void*
data,
unsigned int eventStatus)
630 cache->
rawEvent = std::make_unique<RawEvent>(fragment);
639 if (rec_sg != StatusCode::SUCCESS) {
640 ATH_MSG_ERROR(
"Fail to record BS DataHeader in StoreGate. Skipping events?! "
650 const EventContext& context{Gaudi::Hive::currentContext()};
659 const EventContext& context{Gaudi::Hive::currentContext()};
665 std::unique_ptr<DataHeaderElement>
668 std::unique_ptr<Token> token = std::make_unique<Token>();
675 "StreamRAW", token.release());