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)
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()};
271 unsigned int status = 0;
274 std::vector<eformat::FragmentProblem> problems;
275 rawEvent->problems(problems);
277 if(!problems.empty()) {
278 status += 0x01000000;
282 for(
const auto& problem : problems)
283 ATH_MSG_WARNING(eformat::helper::FragmentProblemDictionary.
string(problem));
289 status += 0x02000000;
305 EventCache* cache, uint32_t eventSize,
bool validate)
const {
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;
334 eformat::old::convert(fragment, newFragment, newEventSize);
337 delete [] fragment; fragment =
nullptr;
340 fragment = newFragment;
341 cache->
data =
reinterpret_cast< char*
>(fragment);
343 }
catch (
const eformat::Issue& ex) {
351 ATH_MSG_FATAL(
"Unknown Header work in input fragment " << MSG::hex << headWord);
359 if(fragment[5] > 0) {
360 cache->
eventStatus += eformat::helper::Status(fragment[6]).specific();
361 cache->
eventStatus += (eformat::helper::Status(fragment[6]).generic() & 0x000000ff) << 16;
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>();
399 dataHeader->setProcessTag(dataHeaderElement->getKey());
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 = "
504std::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;
569 uint32_t total =
re->nchildren();
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()};
650std::unique_ptr<DataHeaderElement>
659 "StreamRAW", std::move(token));
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
This file contains the class definition for the Token class (migrated from POOL).
static void dump(const RawEvent *re)
dump fragments from FullEventFragment
This class provides a token that identifies in a unique way objects on the persistent storage.
Token & setDb(const Guid &db)
Set database name.
Token & setOid(const OID_t &oid)
Set object identifier.
Token & setTechnology(int t)
Set technology type.
const DataType * PointerType
eformat::ROBFragment< PointerType > ROBFragment
Declarations of methods for working with old eformat versions.