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_robProvider(
"ROBDataProviderSvc",
name)
50 assert(pSvcLocator !=
nullptr);
68 return StatusCode::SUCCESS;
77 return StatusCode::SUCCESS;
84 return StatusCode::SUCCESS;
102 auto bsmdc = std::make_unique<ByteStreamMetadataContainer>();
103 bsmdc->push_back(std::make_unique<ByteStreamMetadata>(*
m_reader));
106 return m_inputMetadata->record(std::move(bsmdc),
"ByteStreamMetadata");
115 const EventContext& context{Gaudi::Hive::currentContext()};
121 unsigned int eventSize;
128 if (DRWAIT == ecode &&
m_wait > 0) {
138 }
else if (DROK != ecode) {
145 ATH_MSG_ERROR(
"DataReader not ready. Need to getBlockIterator first");
171 ATH_MSG_DEBUG(
"switched to previous event in slot " << context);
182 const EventContext& context{ Gaudi::Hive::currentContext() };
189 unsigned int eventSize;
207 if (DRWAIT == ecode &&
m_wait > 0) {
216 }
while(
m_reader->getData(eventSize, &(cache->
data)) == DRWAIT);
217 }
else if (DROK != ecode) {
224 ATH_MSG_ERROR(
"DataReader not ready. Need to getBlockIterator first");
261 const EventContext& context{Gaudi::Hive::currentContext()};
274 std::vector<eformat::FragmentProblem> problems;
275 rawEvent->problems(problems);
277 if(!problems.empty()) {
282 for(
const auto& problem : problems)
283 ATH_MSG_WARNING(eformat::helper::FragmentProblemDictionary.
string(problem));
312 const DataType headWord = fragment[0];
313 ATH_MSG_DEBUG(
"First word of the fragment " << MSG::hex << headWord << MSG::dec);
315 const DataType formatVersion = eformat::helper::Version(fragment[3]).major_version();
316 ATH_MSG_DEBUG(
"Format version" << MSG::hex << formatVersion << MSG::dec);
318 if((formatVersion != eformat::MAJOR_DEFAULT_VERSION) &&
319 (formatVersion != eformat::MAJOR_V24_VERSION) &&
320 (formatVersion != eformat::MAJOR_V30_VERSION) &&
321 (formatVersion != eformat::MAJOR_V40_VERSION) &&
322 (formatVersion != eformat::MAJOR_V31_VERSION) ) {
324 << MSG::hex << formatVersion << MSG::dec);
327 if(eformat::FULL_EVENT == headWord || 0xcc1234cc == headWord) {
330 if(formatVersion != eformat::MAJOR_DEFAULT_VERSION) {
332 const uint32_t newEventSize = eventSize + 1000;
337 delete [] fragment; fragment =
nullptr;
340 fragment = newFragment;
341 cache->
data =
reinterpret_cast< char*
>(fragment);
351 ATH_MSG_FATAL(
"Unknown Header work in input fragment " << MSG::hex << headWord);
359 if(fragment[5] > 0) {
366 cache->
rawEvent = std::make_unique<RawEvent>(fragment);
367 ATH_MSG_DEBUG(
"Made an FullEventFragment from ES " << fragment);
389 std::string
key =
"ByteStreamDataHeader";
395 std::unique_ptr<DataHeader> dataHeader = std::make_unique<DataHeader>();
401 dataHeader->
insert(*std::move(dataHeaderElement));
407 std::unique_ptr<IOpaqueAddress> iopx = std::make_unique<ByteStreamAddress>(
412 if (ptmpx !=
nullptr) {
414 dataHeader->
insert(element);
421 std::unique_ptr<IOpaqueAddress> iopaux = std::make_unique<ByteStreamAddress>(
428 dataHeader->
insert(element);
434 "ByteStreamDataHeader",
true,
false,
true));
436 return StatusCode::SUCCESS;
471 if (!
status.isSuccess()) {
477 ATH_MSG_INFO(
"No more events in this run, high water mark for this file = "
504 std::pair<long,std::string>
510 m_reader = std::unique_ptr<EventStorage::DataReader>(pickDataReader(
fileName));
515 return std::make_pair(-1,
"END");
525 ATH_MSG_DEBUG(
"Recorded ByteStreamMetadata in InputMetaDataStore");
527 ATH_MSG_ERROR(
"Unable to record ByteStreamMetadata in InputMetaDataStore");
528 return std::make_pair(-1,
"FAIL");
536 if (!
test)
return std::make_pair(-1,
"SEQ");
560 return (!eofFlag) && moreEvent;
571 std::vector<eformat::FragmentProblem> problems;
573 for (
size_t i = 0;
i<total; ++
i) {
578 lastId =
f.source_id();
581 f.problems(problems);
582 if(!problems.empty()) {
584 for(
const auto& problem : problems) {
586 << eformat::helper::SourceIdentifier(lastId).human() <<
" : "
587 << eformat::helper::FragmentProblemDictionary.
string(problem));
600 const EventContext& context{Gaudi::Hive::currentContext()};
608 void*
data,
unsigned int eventStatus)
615 cache->
rawEvent = std::make_unique<RawEvent>(fragment);
624 if (rec_sg != StatusCode::SUCCESS) {
625 ATH_MSG_ERROR(
"Fail to record BS DataHeader in StoreGate. Skipping events?! "
635 const EventContext& context{Gaudi::Hive::currentContext()};
644 const EventContext& context{Gaudi::Hive::currentContext()};
650 std::unique_ptr<DataHeaderElement>
659 "StreamRAW", std::move(token));