ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ByteStreamEventStorageInputSvc Class Reference

This class is the ByteStreamInputSvc for reading events written by EventStorage. More...

#include <ByteStreamEventStorageInputSvc.h>

Inheritance diagram for ByteStreamEventStorageInputSvc:
Collaboration diagram for ByteStreamEventStorageInputSvc:

Classes

struct  EventCache
 

Public Member Functions

 ByteStreamEventStorageInputSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Constructors: More...
 
virtual ~ByteStreamEventStorageInputSvc ()
 Destructor. More...
 
virtual StatusCode initialize () override
 Required of all Gaudi Services. More...
 
virtual StatusCode stop () override
 
virtual StatusCode finalize () override
 
virtual const RawEventcurrentEvent () const override
 Implementation of the IByteStreamInputSvc interface methods. More...
 
virtual const RawEventnextEvent () override
 ++, new More...
 
virtual const RawEventpreviousEvent () override
 –, old More...
 
virtual void setEvent (void *data, unsigned int eventStatus) override
 
virtual unsigned int currentEventStatus () const override
 Return the current event status. More...
 
virtual void validateEvent () override
 
virtual long positionInBlock () override
 
virtual std::pair< long, std::string > getBlockIterator (const std::string &fileName) override
 
virtual void closeBlockIterator (bool clearMetadata=true) override
 
virtual bool setSequentialRead ()
 
virtual bool ready () override
 
virtual StatusCode generateDataHeader () override
 

Private Types

enum  Advance { PREVIOUS = -1, NEXT = 1 }
 

Private Member Functions

StatusCode loadMetadata ()
 
void buildFragment (EventCache *cache, uint32_t eventSize, bool validate) const
 
bool readerReady ()
 
bool ROBFragmentCheck (const RawEvent *) const
 
unsigned validateEvent (const RawEvent *const rawEvent) const
 
void setEvent (const EventContext &context, void *data, unsigned int eventStatus)
 
const RawEventgetEvent (Advance step)
 
std::unique_ptr< DataHeaderElementmakeBSProvenance () const
 
template<typename T >
StatusCode deleteEntry (const std::string &key)
 

Private Attributes

std::mutex m_readerMutex
 
SG::SlotSpecificObj< EventCachem_eventsCache
 
std::unique_ptr< EventStorage::DataReader > m_reader
 DataReader from EventStorage. More...
 
std::vector< long long int > m_evtOffsets
 offset for event i in that file More...
 
unsigned int m_evtInFile
 
long long int m_evtFileOffset
 last read in event offset within a file, can be -1 More...
 
std::string m_fileGUID
 current file GUID More...
 
ServiceHandle< StoreGateSvcm_storeGate
 Pointer to StoreGate. More...
 
ServiceHandle< StoreGateSvcm_inputMetadata
 StoreGateSvc. More...
 
ServiceHandle< IROBDataProviderSvcm_robProvider
 
Gaudi::Property< bool > m_sequential
 enable sequential reading. More...
 
Gaudi::Property< bool > m_dump
 
Gaudi::Property< float > m_wait
 
Gaudi::Property< bool > m_valEvent
 
Gaudi::Property< std::string > m_eventInfoKey
 

Detailed Description

This class is the ByteStreamInputSvc for reading events written by EventStorage.

Definition at line 35 of file ByteStreamEventStorageInputSvc.h.

Member Enumeration Documentation

◆ Advance

Enumerator
PREVIOUS 
NEXT 

Definition at line 113 of file ByteStreamEventStorageInputSvc.h.

113 { PREVIOUS = -1, NEXT = 1 };

Constructor & Destructor Documentation

◆ ByteStreamEventStorageInputSvc()

ByteStreamEventStorageInputSvc::ByteStreamEventStorageInputSvc ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Constructors:

Definition at line 38 of file ByteStreamEventStorageInputSvc.cxx.

40  : base_class(name, pSvcLocator)
41  , m_readerMutex()
42  , m_eventsCache()
43  , m_reader()
44  , m_evtOffsets()
45  , m_evtInFile(0)
46  , m_evtFileOffset(0)
47  , m_fileGUID("")
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")
56 {
57  assert(pSvcLocator != nullptr);
58 
59  declareProperty("EventStore", m_storeGate);
60  declareProperty("MetaDataStore", m_inputMetadata);
61 }

◆ ~ByteStreamEventStorageInputSvc()

ByteStreamEventStorageInputSvc::~ByteStreamEventStorageInputSvc ( )
virtual

Destructor.

Definition at line 65 of file ByteStreamEventStorageInputSvc.cxx.

66 {}

Member Function Documentation

◆ buildFragment()

void ByteStreamEventStorageInputSvc::buildFragment ( EventCache cache,
uint32_t  eventSize,
bool  validate 
) const
private

Definition at line 321 of file ByteStreamEventStorageInputSvc.cxx.

322  {
325  DataType* fragment = reinterpret_cast<DataType*>(cache->data);
326 
327  if (validate) {
328  // check fragment type
329  const DataType headWord = fragment[0];
330  ATH_MSG_DEBUG("First word of the fragment " << MSG::hex << headWord << MSG::dec);
331  // format version
332  const DataType formatVersion = eformat::helper::Version(fragment[3]).major_version();
333  ATH_MSG_DEBUG("Format version" << MSG::hex << formatVersion << MSG::dec);
334  // error message
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) ) {
340  ATH_MSG_ERROR("unsupported Format Version : "
341  << MSG::hex << formatVersion << MSG::dec);
342  }
343 
344  if(eformat::FULL_EVENT == headWord || 0xcc1234cc == headWord) { // ROS = 0xcc1234cc
345  try {
346  // convert old fragment
347  if(formatVersion != eformat::MAJOR_DEFAULT_VERSION) {
348  // 100 for increase of data-size due to header conversion
349  const uint32_t newEventSize = eventSize + 1000;
350  DataType* newFragment = new DataType[newEventSize];
351  eformat::old::convert(fragment, newFragment, newEventSize);
352 
353  // delete old fragment
354  delete [] fragment; fragment = nullptr;
355 
356  // set new pointer
357  fragment = newFragment;
358  cache->data = reinterpret_cast< char* >(fragment);
359  }
360  } catch (const eformat::Issue& ex) {
361  // bad event
362  ATH_MSG_WARNING(ex.what());
363  ATH_MSG_ERROR("Skipping bad event");
365  }
366  } else {
367  // Unknown fragment
368  ATH_MSG_FATAL("Unknown Header work in input fragment " << MSG::hex << headWord);
370  }
371  }
372 
373  // This is a FullEventFragment
374  // make a new FEFrag in memory from it
375  cache->eventStatus = 0;
376  if(fragment[5] > 0) {
377  cache->eventStatus += eformat::helper::Status(fragment[6]).specific();
378  cache->eventStatus += (eformat::helper::Status(fragment[6]).generic() & 0x000000ff) << 16;
379  }
380 
381  // This is a FullEventFragment
382  // make a new RawEvent in memory from it
383  cache->rawEvent = std::make_unique<RawEvent>(fragment);
384  ATH_MSG_DEBUG("Made an FullEventFragment from ES " << fragment);
385 }

◆ closeBlockIterator()

void ByteStreamEventStorageInputSvc::closeBlockIterator ( bool  clearMetadata = true)
overridevirtual

Definition at line 481 of file ByteStreamEventStorageInputSvc.cxx.

482 {
483  if (clearMetadata) {
484  ATH_MSG_WARNING("Clearing input metadata store");
485  StatusCode status = m_inputMetadata->clearStore();
486  if (!status.isSuccess()) {
487  ATH_MSG_WARNING("Unable to clear Input MetaData Proxies");
488  }
489  }
490 
491  if (!readerReady()) {
492  ATH_MSG_INFO("No more events in this run, high water mark for this file = "
493  << m_evtOffsets.size()-1);
494  }
495 
496  m_reader.reset();
497 }

◆ currentEvent()

const RawEvent * ByteStreamEventStorageInputSvc::currentEvent ( ) const
overridevirtual

Implementation of the IByteStreamInputSvc interface methods.

Definition at line 648 of file ByteStreamEventStorageInputSvc.cxx.

649 {
650  const EventContext& context{Gaudi::Hive::currentContext()};
651  return m_eventsCache.get(context)->rawEvent.get();
652 }

◆ currentEventStatus()

unsigned int ByteStreamEventStorageInputSvc::currentEventStatus ( ) const
overridevirtual

Return the current event status.

Definition at line 657 of file ByteStreamEventStorageInputSvc.cxx.

658 {
659  const EventContext& context{Gaudi::Hive::currentContext()};
660  return m_eventsCache.get(context)->eventStatus;
661 }

◆ deleteEntry()

template<typename T >
StatusCode ByteStreamEventStorageInputSvc::deleteEntry ( const std::string &  key)
inlineprivate

Definition at line 118 of file ByteStreamEventStorageInputSvc.h.

119  {
120  if (m_storeGate->contains<T>(key)) {
121  const T* tmp = m_storeGate->tryConstRetrieve<T>(key);
122  if (tmp != nullptr) ATH_CHECK(m_storeGate->remove<T>(tmp));
123  }
124  return StatusCode::SUCCESS;
125  }

◆ finalize()

StatusCode ByteStreamEventStorageInputSvc::finalize ( )
overridevirtual

Definition at line 95 of file ByteStreamEventStorageInputSvc.cxx.

95  {
96 
97  ATH_CHECK(m_storeGate.release());
98  ATH_CHECK(m_robProvider.release());
99  ATH_CHECK(m_inputMetadata.release());
100 
101  return(StatusCode::SUCCESS);
102 }

◆ generateDataHeader()

StatusCode ByteStreamEventStorageInputSvc::generateDataHeader ( )
overridevirtual

Definition at line 390 of file ByteStreamEventStorageInputSvc.cxx.

391 {
392  // get file GUID
393  m_fileGUID = m_reader->GUID();
394 
395  // reader returns -1 when end of the file is reached
396  if(m_evtFileOffset != -1) {
397  ATH_MSG_DEBUG("ByteStream File GUID: " << m_fileGUID);
398  ATH_MSG_DEBUG("ByteStream Event Position in File: " << m_evtFileOffset);
399 
400  // To accommodate for skipEvents option in EventSelector
401  // While skipping BS event Selector does not return SUCCESS code,
402  // just advances silently through events. So SG content is not refreshed
403  // Lets do refresh of the event header here
404  std::string key = "ByteStreamDataHeader";
405  ATH_CHECK(deleteEntry<DataHeader>(key));
406 
407  // Created data header element with BS provenance information
408  std::unique_ptr<DataHeaderElement> dataHeaderElement = makeBSProvenance();
409  // Create data header itself
410  std::unique_ptr<DataHeader> dataHeader = std::make_unique<DataHeader>();
411  // Declare header primary
412  dataHeader->setStatus(DataHeader::Input);
413  //add the data header element self reference to the object vector
414  dataHeader->insert(*std::move(dataHeaderElement));
415  // Set processTag
416  dataHeader->setProcessTag(dataHeaderElement->getKey());
417 
418  // Clean up EventInfo from the previous event
419  key = m_eventInfoKey.value();
420  ATH_CHECK(deleteEntry<xAOD::EventInfo>(key));
421  // Now add ref to xAOD::EventInfo
422  std::unique_ptr<IOpaqueAddress> iopx = std::make_unique<ByteStreamAddress>(
424  ATH_CHECK(m_storeGate->recordAddress(key, iopx.release()));
425  const SG::DataProxy* ptmpx = m_storeGate->transientProxy(
427  if (ptmpx != nullptr) {
428  DataHeaderElement element(ptmpx, 0, key);
429  dataHeader->insert(element);
430  }
431 
432  // Clean up auxiliary EventInfo from the previous event
433  key = m_eventInfoKey.value() + "Aux.";
434  ATH_CHECK(deleteEntry<xAOD::EventAuxInfo>(key));
435  // Now add ref to xAOD::EventAuxInfo
436  std::unique_ptr<IOpaqueAddress> iopaux = std::make_unique<ByteStreamAddress>(
438  ATH_CHECK(m_storeGate->recordAddress(key, iopaux.release()));
439  const SG::DataProxy* ptmpaux = m_storeGate->transientProxy(
441  if (ptmpaux !=0) {
442  DataHeaderElement element(ptmpaux, 0, key);
443  dataHeader->insert(element);
444  }
445 
446  // Record new data header.Boolean flags will allow it's deletion in case
447  // of skipped events.
448  ATH_CHECK(m_storeGate->record<DataHeader>(dataHeader.release(),
449  "ByteStreamDataHeader", true, false, true));
450  }
451  return StatusCode::SUCCESS;
452 }

◆ getBlockIterator()

std::pair< long, std::string > ByteStreamEventStorageInputSvc::getBlockIterator ( const std::string &  fileName)
overridevirtual

Definition at line 520 of file ByteStreamEventStorageInputSvc.cxx.

521 {
522  // open the file
523  if(m_reader != 0) closeBlockIterator();
524 
525  m_reader = std::unique_ptr<EventStorage::DataReader>(pickDataReader(fileName));
526 
527  if(m_reader == nullptr) {
528  ATH_MSG_ERROR("Failed to open file " << fileName);
530  return std::make_pair(-1,"END");
531  }
532 
533  // Initialize offset vector
534  m_evtOffsets.resize(m_reader->eventsInFile(), -1);
535  m_evtOffsets.clear();
536 
537  // Get ByteStream Metadata into Input MetaData Store
538  // (include begin Input File Incident)
539  if (loadMetadata().isSuccess()) {
540  ATH_MSG_DEBUG("Recorded ByteStreamMetadata in InputMetaDataStore");
541  } else {
542  ATH_MSG_ERROR("Unable to record ByteStreamMetadata in InputMetaDataStore");
543  return std::make_pair(-1, "FAIL");
544  }
545 
546  m_evtInFile = 0;
547 
548  // enable sequentialReading if multiple files
549  if(m_sequential) {
550  bool test = setSequentialRead();
551  if (!test) return std::make_pair(-1,"SEQ");
552  }
553 
554  ATH_MSG_INFO("Picked valid file: " << m_reader->fileName());
555  // initialize offsets and counters
556  m_evtOffsets.push_back(static_cast<long long>(m_reader->getPosition()));
557  return std::make_pair(m_reader->eventsInFile(), m_reader->GUID());
558 }

◆ getEvent()

const RawEvent* ByteStreamEventStorageInputSvc::getEvent ( Advance  step)
private

◆ initialize()

StatusCode ByteStreamEventStorageInputSvc::initialize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 71 of file ByteStreamEventStorageInputSvc.cxx.

72 {
73  ATH_MSG_INFO("Initializing");
74 
75  ATH_CHECK(m_inputMetadata.retrieve());
76  ATH_CHECK(m_storeGate.retrieve());
77  ATH_CHECK(m_robProvider.retrieve());
78 
79  return(StatusCode::SUCCESS);
80 }

◆ loadMetadata()

StatusCode ByteStreamEventStorageInputSvc::loadMetadata ( )
private

Definition at line 116 of file ByteStreamEventStorageInputSvc.cxx.

117 {
118  // default goes into ByteStreamMetadata
119  auto bsmdc = std::make_unique<ByteStreamMetadataContainer>();
120  bsmdc->push_back(std::make_unique<ByteStreamMetadata>(*m_reader));
121  ATH_MSG_DEBUG("ByteStreamMetadata:\n" << *(bsmdc->front()));
122 
123  return m_inputMetadata->record(std::move(bsmdc), "ByteStreamMetadata");
124 }

◆ makeBSProvenance()

std::unique_ptr< DataHeaderElement > ByteStreamEventStorageInputSvc::makeBSProvenance ( ) const
private

Definition at line 666 of file ByteStreamEventStorageInputSvc.cxx.

667 {
668  std::unique_ptr<Token> token = std::make_unique<Token>();
669  token->setDb(m_fileGUID);
670  token->setTechnology(0x00001000);
671  token->setOid(Token::OID_t(0LL, m_evtFileOffset));
672 
673  // note: passing ownership of token to DataHeaderElement
674  return std::make_unique<DataHeaderElement>(ClassID_traits<DataHeader>::ID(),
675  "StreamRAW", token.release());
676 }

◆ nextEvent()

const RawEvent * ByteStreamEventStorageInputSvc::nextEvent ( )
overridevirtual

++, new

Definition at line 196 of file ByteStreamEventStorageInputSvc.cxx.

196  {
197 
198  std::lock_guard<std::mutex> lock( m_readerMutex );
199  const EventContext& context{ Gaudi::Hive::currentContext() };
200  EventCache* cache = m_eventsCache.get(context);
201 
202  // initialize before building RawEvent
203  cache->releaseEvent();
204 
205  // Load data buffer from file
206  unsigned int eventSize;
207  if (readerReady()) {
208  DRError ecode;
209  // Check if have moved back from high water mark
210  m_evtInFile++; // increment iterator
211  if (m_evtInFile+1 > m_evtOffsets.size()) {
212  //get current event position (cast to long long until native tdaq implementation)
213  ATH_MSG_DEBUG("nextEvent _above_ high water mark");
214  m_evtFileOffset = static_cast<long long>(m_reader->getPosition());
215  m_evtOffsets.push_back(m_evtFileOffset);
216  ecode = m_reader->getData(eventSize, &(cache->data));
217  } else {
218  // Load from previous offset
219  ATH_MSG_DEBUG("nextEvent below high water mark");
221  ecode = m_reader->getData(eventSize, &(cache->data), m_evtFileOffset);
222  }
223 
224  if (DRWAIT == ecode && m_wait > 0) {
225  do {
226  // wait for n seconds
227  ATH_MSG_DEBUG("Waiting for input: " << m_wait << " seconds");
228  int result = usleep(static_cast<int>(m_wait * 1e6));
229  if (result != 0) {
230  ATH_MSG_ERROR("System Error while running sleep");
231  return 0;
232  }
233  } while(m_reader->getData(eventSize, &(cache->data)) == DRWAIT);
234  } else if (DROK != ecode) {
235  ATH_MSG_ERROR("Error reading next event");
237  }
238  ATH_MSG_DEBUG("Event Size " << eventSize);
239 
240  } else {
241  ATH_MSG_ERROR("DataReader not ready. Need to getBlockIterator first");
242  return 0;
243  }
244 
245  // Use buffer to build FullEventFragment
246  try {
247  buildFragment(cache, eventSize, true);
248  }
249  catch (...) {
250  // rethrow any exceptions
251  throw;
252  }
253 
254  if (cache->rawEvent == nullptr) {
255  ATH_MSG_ERROR("Failure to build fragment");
256  return nullptr;
257  }
258 
259  // Set it for the data provider
260  m_robProvider->setNextEvent(context, cache->rawEvent.get());
261  m_robProvider->setEventStatus(context, cache->eventStatus);
262 
263  //++m_totalEventCounter;
264 
265  // dump
266  if (m_dump) {
267  DumpFrags::dump(cache->rawEvent.get());
268  }
269  ATH_MSG_DEBUG("switched to next event in slot " << context);
270  return(cache->rawEvent.get());
271 }

◆ positionInBlock()

long ByteStreamEventStorageInputSvc::positionInBlock ( )
overridevirtual

Definition at line 108 of file ByteStreamEventStorageInputSvc.cxx.

109 {
110  return m_evtOffsets.size();
111 }

◆ previousEvent()

const RawEvent * ByteStreamEventStorageInputSvc::previousEvent ( )
overridevirtual

–, old

Definition at line 129 of file ByteStreamEventStorageInputSvc.cxx.

130 {
131  std::lock_guard<std::mutex> lock(m_readerMutex);
132  const EventContext& context{Gaudi::Hive::currentContext()};
133  EventCache* cache = m_eventsCache.get(context);
134  // initialize before building RawEvent
135  cache->releaseEvent();
136 
137  // Load data buffer from file
138  unsigned int eventSize;
139  if (readerReady()) {
140  //get current event position (cast to long long until native tdaq implementation)
141  m_evtInFile--;
143  DRError ecode = m_reader->getData(eventSize, &(cache->data), m_evtOffsets.at(m_evtInFile - 1));
144 
145  if (DRWAIT == ecode && m_wait > 0) {
146  do {
147  // wait for n seconds
148  ATH_MSG_DEBUG("Waiting for input: " << m_wait << " seconds");
149  int result = usleep(static_cast<int>(m_wait * 1e6));
150  if (result != 0) {
151  ATH_MSG_ERROR("System Error while running sleep");
152  return nullptr;
153  }
154  } while(m_reader->getData(eventSize, &(cache->data), m_evtFileOffset) == DRWAIT);
155  } else if (DROK != ecode) {
156  ATH_MSG_ERROR("Error reading previous event");
158  }
159  ATH_MSG_DEBUG("Event Size " << eventSize);
160  }
161  else {
162  ATH_MSG_ERROR("DataReader not ready. Need to getBlockIterator first");
163  return 0;
164  }
165 
166  // Use buffer to build FullEventFragment
167  try {
168  buildFragment(cache, eventSize, true);
169  }
170  catch (...) {
171  // rethrow any exceptions
172  throw;
173  }
174 
175  if (cache->rawEvent == nullptr) {
176  ATH_MSG_ERROR("Failure to build fragment");
177  return nullptr;
178  }
179 
180  // Set it for the data provider
181  m_robProvider->setNextEvent(context, cache->rawEvent.get());
182  m_robProvider->setEventStatus(context, cache->eventStatus);
183 
184  // dump
185  if (m_dump) {
186  DumpFrags::dump(cache->rawEvent.get());
187  }
188  ATH_MSG_DEBUG( "switched to previous event in slot " << context);
189  return(cache->rawEvent.get());
190 }

◆ readerReady()

bool ByteStreamEventStorageInputSvc::readerReady ( )
private

Definition at line 563 of file ByteStreamEventStorageInputSvc.cxx.

564 {
565  bool eofFlag(false);
566 
567  if (m_reader) eofFlag = m_reader->endOfFile();
568  else {
569  ATH_MSG_INFO("eformat reader object not initialized");
570  return false;
571  }
572 
573  bool moreEvent = m_reader->good();
574 
575  return (!eofFlag) && moreEvent;
576 }

◆ ready()

bool ByteStreamEventStorageInputSvc::ready ( )
overridevirtual

Definition at line 512 of file ByteStreamEventStorageInputSvc.cxx.

513 {
514  return readerReady();
515 }

◆ ROBFragmentCheck()

bool ByteStreamEventStorageInputSvc::ROBFragmentCheck ( const RawEvent re) const
private

Definition at line 581 of file ByteStreamEventStorageInputSvc.cxx.

582 {
583  bool allOK = true;
584  uint32_t total = re->nchildren();
585  uint32_t lastId = 0;
586  std::vector<eformat::FragmentProblem> problems;
587 
588  for (size_t i = 0; i<total; ++i) {
590  re->child(fp, i);
591 
593  lastId = f.source_id();
594 
595  problems.clear();
596  f.problems(problems);
597  if(!problems.empty()) {
598  allOK = false;
599  for(const auto& problem : problems) {
600  ATH_MSG_WARNING("Failed to create ROBFragment id = " << lastId << ", "
601  << eformat::helper::SourceIdentifier(lastId).human() << " : "
602  << eformat::helper::FragmentProblemDictionary.string(problem));
603  }
604  }
605  }
606 
607  return allOK;
608 }

◆ setEvent() [1/2]

void ByteStreamEventStorageInputSvc::setEvent ( const EventContext &  context,
void *  data,
unsigned int  eventStatus 
)
private

Definition at line 622 of file ByteStreamEventStorageInputSvc.cxx.

624 {
626  EventCache* cache = m_eventsCache.get(context);
627  cache->releaseEvent();
628 
629  DataType* fragment = reinterpret_cast<DataType*>(data);
630  cache->rawEvent = std::make_unique<RawEvent>(fragment);
631  cache->eventStatus = eventStatus;
632 
633  // Set it for the data provider
634  m_robProvider->setNextEvent(context, cache->rawEvent.get());
635  m_robProvider->setEventStatus(context, cache->eventStatus);
636 
637  // Build a DH for use by other components
638  StatusCode rec_sg = generateDataHeader();
639  if (rec_sg != StatusCode::SUCCESS) {
640  ATH_MSG_ERROR("Fail to record BS DataHeader in StoreGate. Skipping events?! "
641  << rec_sg);
642  }
643 }

◆ setEvent() [2/2]

void ByteStreamEventStorageInputSvc::setEvent ( void *  data,
unsigned int  eventStatus 
)
overridevirtual

Definition at line 613 of file ByteStreamEventStorageInputSvc.cxx.

614 {
615  const EventContext& context{Gaudi::Hive::currentContext()};
616  return setEvent(context, data, eventStatus);
617 }

◆ setSequentialRead()

bool ByteStreamEventStorageInputSvc::setSequentialRead ( )
virtual

Definition at line 502 of file ByteStreamEventStorageInputSvc.cxx.

503 {
504  // enable SequenceReading
505  m_reader->enableSequenceReading();
506  return true;
507 }

◆ stop()

StatusCode ByteStreamEventStorageInputSvc::stop ( )
overridevirtual

Definition at line 85 of file ByteStreamEventStorageInputSvc.cxx.

86 {
87  // close moved to EventSelector for explicit coupling with incident
88  //if (m_reader != 0) closeBlockIterator(false);
89  return(StatusCode::SUCCESS);
90 }

◆ validateEvent() [1/2]

void ByteStreamEventStorageInputSvc::validateEvent ( )
overridevirtual

Definition at line 276 of file ByteStreamEventStorageInputSvc.cxx.

277 {
278  const EventContext& context{Gaudi::Hive::currentContext()};
279  const RawEvent* const event = m_eventsCache.get(context)->rawEvent.get();
280  m_eventsCache.get(context)->eventStatus = validateEvent(event);
281 }

◆ validateEvent() [2/2]

unsigned ByteStreamEventStorageInputSvc::validateEvent ( const RawEvent *const  rawEvent) const
private

Definition at line 286 of file ByteStreamEventStorageInputSvc.cxx.

287 {
288  unsigned int status = 0;
289  if (m_valEvent) {
290  // check validity
291  std::vector<eformat::FragmentProblem> problems;
292  rawEvent->problems(problems);
293 
294  if(!problems.empty()) {
295  status += 0x01000000;
296 
297  // bad event
298  ATH_MSG_WARNING("Failed to create FullEventFragment");
299  for(const auto& problem : problems)
300  ATH_MSG_WARNING(eformat::helper::FragmentProblemDictionary.string(problem));
301 
303  }
304 
305  if(!ROBFragmentCheck(rawEvent)) {
306  status += 0x02000000;
307 
308  // bad event
309  ATH_MSG_ERROR("Skipping bad event");
311  }
312  } else {
313  ATH_MSG_DEBUG("Processing event without validating.");
314  }
315  return status;
316 }

Member Data Documentation

◆ m_dump

Gaudi::Property<bool> ByteStreamEventStorageInputSvc::m_dump
private

Definition at line 99 of file ByteStreamEventStorageInputSvc.h.

◆ m_eventInfoKey

Gaudi::Property<std::string> ByteStreamEventStorageInputSvc::m_eventInfoKey
private

Definition at line 102 of file ByteStreamEventStorageInputSvc.h.

◆ m_eventsCache

SG::SlotSpecificObj<EventCache> ByteStreamEventStorageInputSvc::m_eventsCache
private

Definition at line 81 of file ByteStreamEventStorageInputSvc.h.

◆ m_evtFileOffset

long long int ByteStreamEventStorageInputSvc::m_evtFileOffset
private

last read in event offset within a file, can be -1

Definition at line 87 of file ByteStreamEventStorageInputSvc.h.

◆ m_evtInFile

unsigned int ByteStreamEventStorageInputSvc::m_evtInFile
private

Definition at line 86 of file ByteStreamEventStorageInputSvc.h.

◆ m_evtOffsets

std::vector<long long int> ByteStreamEventStorageInputSvc::m_evtOffsets
private

offset for event i in that file

Definition at line 85 of file ByteStreamEventStorageInputSvc.h.

◆ m_fileGUID

std::string ByteStreamEventStorageInputSvc::m_fileGUID
private

current file GUID

Definition at line 89 of file ByteStreamEventStorageInputSvc.h.

◆ m_inputMetadata

ServiceHandle<StoreGateSvc> ByteStreamEventStorageInputSvc::m_inputMetadata
private

StoreGateSvc.

Definition at line 96 of file ByteStreamEventStorageInputSvc.h.

◆ m_reader

std::unique_ptr<EventStorage::DataReader> ByteStreamEventStorageInputSvc::m_reader
private

DataReader from EventStorage.

Definition at line 83 of file ByteStreamEventStorageInputSvc.h.

◆ m_readerMutex

std::mutex ByteStreamEventStorageInputSvc::m_readerMutex
private

Definition at line 70 of file ByteStreamEventStorageInputSvc.h.

◆ m_robProvider

ServiceHandle<IROBDataProviderSvc> ByteStreamEventStorageInputSvc::m_robProvider
private

Definition at line 97 of file ByteStreamEventStorageInputSvc.h.

◆ m_sequential

Gaudi::Property<bool> ByteStreamEventStorageInputSvc::m_sequential
private

enable sequential reading.

Definition at line 98 of file ByteStreamEventStorageInputSvc.h.

◆ m_storeGate

ServiceHandle<StoreGateSvc> ByteStreamEventStorageInputSvc::m_storeGate
private

Pointer to StoreGate.

StoreGateSvc

Definition at line 95 of file ByteStreamEventStorageInputSvc.h.

◆ m_valEvent

Gaudi::Property<bool> ByteStreamEventStorageInputSvc::m_valEvent
private

Definition at line 101 of file ByteStreamEventStorageInputSvc.h.

◆ m_wait

Gaudi::Property<float> ByteStreamEventStorageInputSvc::m_wait
private

Definition at line 100 of file ByteStreamEventStorageInputSvc.h.


The documentation for this class was generated from the following files:
ByteStreamEventStorageInputSvc::m_evtFileOffset
long long int m_evtFileOffset
last read in event offset within a file, can be -1
Definition: ByteStreamEventStorageInputSvc.h:87
DataHeader::setProcessTag
void setProcessTag(const std::string &processTag)
Set ProcessTag for DataHeader.
Definition: DataHeader.cxx:243
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
validation.validate
def validate(testSampleDir, thisSampleName, testSamplePath, weight_database, outputSamples)
Definition: validation.py:26
get_generator_info.result
result
Definition: get_generator_info.py:21
ByteStreamEventStorageInputSvc::NEXT
@ NEXT
Definition: ByteStreamEventStorageInputSvc.h:113
ByteStreamEventStorageInputSvc::PREVIOUS
@ PREVIOUS
Definition: ByteStreamEventStorageInputSvc.h:113
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
OFFLINE_FRAGMENTS_NAMESPACE::DataType
uint32_t DataType
Definition: RawEvent.h:24
ByteStreamEventStorageInputSvc::m_readerMutex
std::mutex m_readerMutex
Definition: ByteStreamEventStorageInputSvc.h:70
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
DataHeader::Input
@ Input
Definition: DataHeader.h:126
ByteStreamEventStorageInputSvc::m_evtOffsets
std::vector< long long int > m_evtOffsets
offset for event i in that file
Definition: ByteStreamEventStorageInputSvc.h:85
ByteStreamEventStorageInputSvc::m_eventsCache
SG::SlotSpecificObj< EventCache > m_eventsCache
Definition: ByteStreamEventStorageInputSvc.h:81
ByteStreamEventStorageInputSvc::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to StoreGate.
Definition: ByteStreamEventStorageInputSvc.h:95
Issue
Configuration Issue
Definition: PscIssues.h:31
ByteStreamEventStorageInputSvc::setSequentialRead
virtual bool setSequentialRead()
Definition: ByteStreamEventStorageInputSvc.cxx:502
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
ByteStreamEventStorageInputSvc::validateEvent
virtual void validateEvent() override
Definition: ByteStreamEventStorageInputSvc.cxx:276
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
ByteStreamEventStorageInputSvc::m_eventInfoKey
Gaudi::Property< std::string > m_eventInfoKey
Definition: ByteStreamEventStorageInputSvc.h:102
ByteStreamEventStorageInputSvc::m_robProvider
ServiceHandle< IROBDataProviderSvc > m_robProvider
Definition: ByteStreamEventStorageInputSvc.h:97
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
ByteStreamEventStorageInputSvc::generateDataHeader
virtual StatusCode generateDataHeader() override
Definition: ByteStreamEventStorageInputSvc.cxx:390
ByteStreamEventStorageInputSvc::m_evtInFile
unsigned int m_evtInFile
Definition: ByteStreamEventStorageInputSvc.h:86
ByteStreamEventStorageInputSvc::m_dump
Gaudi::Property< bool > m_dump
Definition: ByteStreamEventStorageInputSvc.h:99
ByteStreamEventStorageInputSvc::closeBlockIterator
virtual void closeBlockIterator(bool clearMetadata=true) override
Definition: ByteStreamEventStorageInputSvc.cxx:481
ByteStreamEventStorageInputSvc::m_valEvent
Gaudi::Property< bool > m_valEvent
Definition: ByteStreamEventStorageInputSvc.h:101
ByteStreamEventStorageInputSvc::loadMetadata
StatusCode loadMetadata()
Definition: ByteStreamEventStorageInputSvc.cxx:116
ByteStreamEventStorageInputSvc::m_wait
Gaudi::Property< float > m_wait
Definition: ByteStreamEventStorageInputSvc.h:100
ByteStreamEventStorageInputSvc::ROBFragmentCheck
bool ROBFragmentCheck(const RawEvent *) const
Definition: ByteStreamEventStorageInputSvc.cxx:581
DataHeaderElement::getKey
const std::string & getKey() const
Definition: DataHeader.cxx:127
Token::OID_t
Definition: Token.h:24
OFFLINE_FRAGMENTS_NAMESPACE::PointerType
const DataType * PointerType
Definition: RawEvent.h:25
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:36
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ByteStreamExceptions::readError
Definition: ByteStreamExceptions.h:21
ByteStreamEventStorageInputSvc::m_reader
std::unique_ptr< EventStorage::DataReader > m_reader
DataReader from EventStorage.
Definition: ByteStreamEventStorageInputSvc.h:83
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
eformat::ROBFragment
Definition: L1CaloBsDecoderUtil.h:12
DataHeader
This class provides the layout for summary information stored for data written to POOL.
Definition: DataHeader.h:124
lumiFormat.i
int i
Definition: lumiFormat.py:85
trigmenu_modify_prescale_json.fp
fp
Definition: trigmenu_modify_prescale_json.py:53
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Token::setDb
Token & setDb(const Guid &db)
Set database name.
Definition: Token.h:64
hist_file_dump.f
f
Definition: hist_file_dump.py:135
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
Token::setTechnology
Token & setTechnology(int t)
Set technology type.
Definition: Token.h:77
DataHeader::insert
void insert(const SG::TransientAddress *sgAddress, IOpaqueAddress *tokAddress=0, const std::string &pTag="")
Insert a new element into the "DataObject" vector.
Definition: DataHeader.cxx:267
ByteStreamExceptions::badFragmentData
Definition: ByteStreamExceptions.h:33
DataHeader::setStatus
void setStatus(statusFlag status)
Set StatusFlag enum for DataHeader.
Definition: DataHeader.cxx:235
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ByteStreamEventStorageInputSvc::readerReady
bool readerReady()
Definition: ByteStreamEventStorageInputSvc.cxx:563
ByteStreamEventStorageInputSvc::buildFragment
void buildFragment(EventCache *cache, uint32_t eventSize, bool validate) const
Definition: ByteStreamEventStorageInputSvc.cxx:321
Token::setOid
Token & setOid(const OID_t &oid)
Set object identifier.
Definition: Token.h:83
TMVAToMVAUtils::convert
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
Definition: TMVAToMVAUtils.h:114
ByteStreamExceptions::badFragment
Definition: ByteStreamExceptions.h:27
Athena::Status
Status
Athena specific StatusCode values.
Definition: AthStatusCode.h:22
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ByteStreamEventStorageInputSvc::m_sequential
Gaudi::Property< bool > m_sequential
enable sequential reading.
Definition: ByteStreamEventStorageInputSvc.h:98
re
const boost::regex re(r_e)
ByteStreamEventStorageInputSvc::m_inputMetadata
ServiceHandle< StoreGateSvc > m_inputMetadata
StoreGateSvc.
Definition: ByteStreamEventStorageInputSvc.h:96
merge.status
status
Definition: merge.py:17
DumpFrags::dump
static void dump(const RawEvent *re)
dump fragments from FullEventFragment
Definition: DumpFrags.h:23
SG::DataProxy
Definition: DataProxy.h:44
ByteStreamEventStorageInputSvc::makeBSProvenance
std::unique_ptr< DataHeaderElement > makeBSProvenance() const
Definition: ByteStreamEventStorageInputSvc.cxx:666
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ByteStreamEventStorageInputSvc::m_fileGUID
std::string m_fileGUID
current file GUID
Definition: ByteStreamEventStorageInputSvc.h:89
ByteStreamEventStorageInputSvc::setEvent
virtual void setEvent(void *data, unsigned int eventStatus) override
Definition: ByteStreamEventStorageInputSvc.cxx:613
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37