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)
52 assert(pSvcLocator !=
nullptr);
74 return(StatusCode::SUCCESS);
84 return(StatusCode::SUCCESS);
96 return(StatusCode::SUCCESS);
114 auto bsmdc = std::make_unique<ByteStreamMetadataContainer>();
115 bsmdc->push_back(std::make_unique<ByteStreamMetadata>(*
m_reader));
118 return m_inputMetadata->record(std::move(bsmdc),
"ByteStreamMetadata");
127 const EventContext& context{Gaudi::Hive::currentContext()};
133 unsigned int eventSize;
140 if (DRWAIT == ecode &&
m_wait > 0) {
150 }
else if (DROK != ecode) {
157 ATH_MSG_ERROR(
"DataReader not ready. Need to getBlockIterator first");
183 ATH_MSG_DEBUG(
"switched to previous event in slot " << context);
194 const EventContext& context{ Gaudi::Hive::currentContext() };
201 unsigned int eventSize;
219 if (DRWAIT == ecode &&
m_wait > 0) {
228 }
while(
m_reader->getData(eventSize, &(cache->
data)) == DRWAIT);
229 }
else if (DROK != ecode) {
236 ATH_MSG_ERROR(
"DataReader not ready. Need to getBlockIterator first");
273 const EventContext& context{Gaudi::Hive::currentContext()};
286 std::vector<eformat::FragmentProblem> problems;
287 rawEvent->problems(problems);
289 if(!problems.empty()) {
294 for(
const auto& problem : problems)
295 ATH_MSG_WARNING(eformat::helper::FragmentProblemDictionary.
string(problem));
324 const DataType headWord = fragment[0];
325 ATH_MSG_DEBUG(
"First word of the fragment " << MSG::hex << headWord << MSG::dec);
327 const DataType formatVersion = eformat::helper::Version(fragment[3]).major_version();
328 ATH_MSG_DEBUG(
"Format version" << MSG::hex << formatVersion << MSG::dec);
330 if((formatVersion != eformat::MAJOR_DEFAULT_VERSION) &&
331 (formatVersion != eformat::MAJOR_V24_VERSION) &&
332 (formatVersion != eformat::MAJOR_V30_VERSION) &&
333 (formatVersion != eformat::MAJOR_V40_VERSION) &&
334 (formatVersion != eformat::MAJOR_V31_VERSION) ) {
336 << MSG::hex << formatVersion << MSG::dec);
339 if(eformat::FULL_EVENT == headWord || 0xcc1234cc == headWord) {
342 if(formatVersion != eformat::MAJOR_DEFAULT_VERSION) {
344 const uint32_t newEventSize = eventSize + 1000;
349 delete [] fragment; fragment =
nullptr;
352 fragment = newFragment;
353 cache->
data =
reinterpret_cast< char*
>(fragment);
363 ATH_MSG_FATAL(
"Unknown Header work in input fragment " << MSG::hex << headWord);
371 if(fragment[5] > 0) {
378 cache->
rawEvent = std::make_unique<RawEvent>(fragment);
379 ATH_MSG_DEBUG(
"Made an FullEventFragment from ES " << fragment);
401 std::string
key =
"ByteStreamDataHeader";
407 std::unique_ptr<DataHeader> dataHeader = std::make_unique<DataHeader>();
413 dataHeader->
insert(*std::move(dataHeaderElement));
419 std::unique_ptr<IOpaqueAddress> iopx = std::make_unique<ByteStreamAddress>(
424 if (ptmpx !=
nullptr) {
426 dataHeader->
insert(element);
433 std::unique_ptr<IOpaqueAddress> iopaux = std::make_unique<ByteStreamAddress>(
440 dataHeader->
insert(element);
446 "ByteStreamDataHeader",
true,
false,
true));
448 return StatusCode::SUCCESS;
483 if (!
status.isSuccess()) {
489 ATH_MSG_INFO(
"No more events in this run, high water mark for this file = "
516 std::pair<long,std::string>
522 m_reader = std::unique_ptr<EventStorage::DataReader>(pickDataReader(
fileName));
527 return std::make_pair(-1,
"END");
537 ATH_MSG_DEBUG(
"Recorded ByteStreamMetadata in InputMetaDataStore");
539 ATH_MSG_ERROR(
"Unable to record ByteStreamMetadata in InputMetaDataStore");
540 return std::make_pair(-1,
"FAIL");
548 if (!
test)
return std::make_pair(-1,
"SEQ");
572 return (!eofFlag) && moreEvent;
583 std::vector<eformat::FragmentProblem> problems;
585 for (
size_t i = 0;
i<total; ++
i) {
590 lastId =
f.source_id();
593 f.problems(problems);
594 if(!problems.empty()) {
596 for(
const auto& problem : problems) {
598 << eformat::helper::SourceIdentifier(lastId).human() <<
" : "
599 << eformat::helper::FragmentProblemDictionary.
string(problem));
612 const EventContext& context{Gaudi::Hive::currentContext()};
620 void*
data,
unsigned int eventStatus)
627 cache->
rawEvent = std::make_unique<RawEvent>(fragment);
636 if (rec_sg != StatusCode::SUCCESS) {
637 ATH_MSG_ERROR(
"Fail to record BS DataHeader in StoreGate. Skipping events?! "
647 const EventContext& context{Gaudi::Hive::currentContext()};
656 const EventContext& context{Gaudi::Hive::currentContext()};
662 std::unique_ptr<DataHeaderElement>
671 "StreamRAW", std::move(token));