ATLAS Offline Software
ByteStreamEventStorageInputSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef BYTESTREAMEVENTSTORAGEINPUTSVC_H
6 #define BYTESTREAMEVENTSTORAGEINPUTSVC_H
7 
14 // Include files.
20 
21 // FrameWork includes
22 #include "GaudiKernel/ServiceHandle.h"
23 
24 namespace EventStorage
25 {
26  class DataReader;
27 }
28 class StoreGateSvc;
29 class DataHeaderElement;
30 
31 
36  : public extends<AthService, IByteStreamInputSvc>
37 {
38 public:
40  ByteStreamEventStorageInputSvc(const std::string& name,
41  ISvcLocator* pSvcLocator);
42 
45 
47  virtual StatusCode initialize() override;
48  virtual StatusCode stop () override;
49  virtual StatusCode finalize () override;
50 
52  virtual const RawEvent* currentEvent () const override;
53  virtual const RawEvent* nextEvent () override;
54  virtual const RawEvent* previousEvent() override;
55  virtual void setEvent (void* data, unsigned int eventStatus) override;
56 
58  virtual unsigned int currentEventStatus() const override;
59  virtual void validateEvent () override;
60 
61  virtual long positionInBlock () override;
62  virtual std::pair<long,std::string> getBlockIterator(const std::string& fileName) override;
63  virtual void closeBlockIterator(bool clearMetadata=true) override;
64  virtual bool setSequentialRead ();
65  virtual bool ready () override;
66  virtual StatusCode generateDataHeader() override;
67 
68 
69 private: // data
71 
72  struct EventCache {
73  std::unique_ptr<RawEvent> rawEvent = nullptr;
74  char* data = nullptr;
75  unsigned int eventStatus = 0;
76  long long int eventOffset = 0;
77  void releaseEvent();
78  virtual ~EventCache();
79  };
80 
82 
83  std::unique_ptr<EventStorage::DataReader> m_reader;
84 
85  std::vector<long long int> m_evtOffsets;
86  unsigned int m_evtInFile;
87  long long int m_evtFileOffset;
88  // Event back navigation info
89  std::string m_fileGUID;
90 
91 
92 
93 private: // properties
98  Gaudi::Property<bool> m_sequential;
99  Gaudi::Property<bool> m_dump;
100  Gaudi::Property<float> m_wait;
101  Gaudi::Property<bool> m_valEvent;
102  Gaudi::Property<std::string> m_eventInfoKey;
103 
104 
105 private: // internal helper functions
107  void buildFragment (EventCache* cache, uint32_t eventSize, bool validate) const;
108  bool readerReady ();
109  bool ROBFragmentCheck(const RawEvent*) const;
110  unsigned validateEvent (const RawEvent* const rawEvent) const;
111  void setEvent (const EventContext& context, void* data, unsigned int eventStatus);
112 
113  enum Advance{ PREVIOUS = -1, NEXT = 1 };
115  std::unique_ptr<DataHeaderElement> makeBSProvenance() const;
116 
117  template<typename T>
118  StatusCode deleteEntry(const std::string& key)
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  }
126 
127 };
128 
129 #endif // BYTESTREAMEVENTSTORAGEINPUTSVC_H
ByteStreamEventStorageInputSvc
This class is the ByteStreamInputSvc for reading events written by EventStorage.
Definition: ByteStreamEventStorageInputSvc.h:37
ByteStreamEventStorageInputSvc::m_evtFileOffset
long long int m_evtFileOffset
last read in event offset within a file, can be -1
Definition: ByteStreamEventStorageInputSvc.h:87
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
validation.validate
def validate(testSampleDir, thisSampleName, testSamplePath, weight_database, outputSamples)
Definition: validation.py:26
ByteStreamEventStorageInputSvc::EventCache
Definition: ByteStreamEventStorageInputSvc.h:72
ByteStreamEventStorageInputSvc::NEXT
@ NEXT
Definition: ByteStreamEventStorageInputSvc.h:113
ByteStreamEventStorageInputSvc::PREVIOUS
@ PREVIOUS
Definition: ByteStreamEventStorageInputSvc.h:113
ByteStreamEventStorageInputSvc::m_readerMutex
std::mutex m_readerMutex
Definition: ByteStreamEventStorageInputSvc.h:70
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
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
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ByteStreamEventStorageInputSvc::ready
virtual bool ready() override
Definition: ByteStreamEventStorageInputSvc.cxx:512
ByteStreamEventStorageInputSvc::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to StoreGate.
Definition: ByteStreamEventStorageInputSvc.h:95
ByteStreamEventStorageInputSvc::setSequentialRead
virtual bool setSequentialRead()
Definition: ByteStreamEventStorageInputSvc.cxx:502
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::EventCache::eventStatus
unsigned int eventStatus
check_tree() status of the current event
Definition: ByteStreamEventStorageInputSvc.h:75
ByteStreamEventStorageInputSvc::m_robProvider
ServiceHandle< IROBDataProviderSvc > m_robProvider
Definition: ByteStreamEventStorageInputSvc.h:97
ByteStreamEventStorageInputSvc::generateDataHeader
virtual StatusCode generateDataHeader() override
Definition: ByteStreamEventStorageInputSvc.cxx:390
ByteStreamEventStorageInputSvc::stop
virtual StatusCode stop() override
Definition: ByteStreamEventStorageInputSvc.cxx:85
ByteStreamEventStorageInputSvc::nextEvent
virtual const RawEvent * nextEvent() override
++, new
Definition: ByteStreamEventStorageInputSvc.cxx:196
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
ByteStreamEventStorageInputSvc::EventCache::rawEvent
std::unique_ptr< RawEvent > rawEvent
current event
Definition: ByteStreamEventStorageInputSvc.h:73
ByteStreamEventStorageInputSvc::EventCache::eventOffset
long long int eventOffset
event offset within a file, can be -1
Definition: ByteStreamEventStorageInputSvc.h:76
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
DataHeaderElement
This class provides a persistent form for the TransientAddress.
Definition: DataHeader.h:36
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ByteStreamEventStorageInputSvc::positionInBlock
virtual long positionInBlock() override
Definition: ByteStreamEventStorageInputSvc.cxx:108
ByteStreamEventStorageInputSvc::m_reader
std::unique_ptr< EventStorage::DataReader > m_reader
DataReader from EventStorage.
Definition: ByteStreamEventStorageInputSvc.h:83
ByteStreamEventStorageInputSvc::ByteStreamEventStorageInputSvc
ByteStreamEventStorageInputSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructors:
Definition: ByteStreamEventStorageInputSvc.cxx:38
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ByteStreamEventStorageInputSvc::initialize
virtual StatusCode initialize() override
Required of all Gaudi Services.
Definition: ByteStreamEventStorageInputSvc.cxx:71
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ByteStreamEventStorageInputSvc::getEvent
const RawEvent * getEvent(Advance step)
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
ByteStreamEventStorageInputSvc::Advance
Advance
Definition: ByteStreamEventStorageInputSvc.h:113
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
IByteStreamInputSvc.h
This file contains the interface for the ByteStreamInputSvc classes.
ByteStreamEventStorageInputSvc::readerReady
bool readerReady()
Definition: ByteStreamEventStorageInputSvc.cxx:563
ByteStreamEventStorageInputSvc::EventCache::data
char * data
take ownership of RawEvent content
Definition: ByteStreamEventStorageInputSvc.h:74
ByteStreamEventStorageInputSvc::buildFragment
void buildFragment(EventCache *cache, uint32_t eventSize, bool validate) const
Definition: ByteStreamEventStorageInputSvc.cxx:321
ByteStreamEventStorageInputSvc::EventCache::~EventCache
virtual ~EventCache()
calls releaseEvent
Definition: ByteStreamEventStorageInputSvc.cxx:473
ByteStreamEventStorageInputSvc::previousEvent
virtual const RawEvent * previousEvent() override
–, old
Definition: ByteStreamEventStorageInputSvc.cxx:129
ByteStreamEventStorageInputSvc::m_sequential
Gaudi::Property< bool > m_sequential
enable sequential reading.
Definition: ByteStreamEventStorageInputSvc.h:98
ByteStreamEventStorageInputSvc::m_inputMetadata
ServiceHandle< StoreGateSvc > m_inputMetadata
StoreGateSvc.
Definition: ByteStreamEventStorageInputSvc.h:96
LArCellBinning.step
step
Definition: LArCellBinning.py:158
AthService.h
SlotSpecificObj.h
Maintain a set of objects, one per slot.
ByteStreamEventStorageInputSvc::currentEventStatus
virtual unsigned int currentEventStatus() const override
Return the current event status.
Definition: ByteStreamEventStorageInputSvc.cxx:657
EventStorage
Definition: ByteStreamEventStorageInputSvc.h:25
ByteStreamEventStorageInputSvc::currentEvent
virtual const RawEvent * currentEvent() const override
Implementation of the IByteStreamInputSvc interface methods.
Definition: ByteStreamEventStorageInputSvc.cxx:648
ByteStreamEventStorageInputSvc::deleteEntry
StatusCode deleteEntry(const std::string &key)
Definition: ByteStreamEventStorageInputSvc.h:118
ByteStreamEventStorageInputSvc::getBlockIterator
virtual std::pair< long, std::string > getBlockIterator(const std::string &fileName) override
Definition: ByteStreamEventStorageInputSvc.cxx:520
IROBDataProviderSvc.h
ByteStreamEventStorageInputSvc::makeBSProvenance
std::unique_ptr< DataHeaderElement > makeBSProvenance() const
Definition: ByteStreamEventStorageInputSvc.cxx:666
ByteStreamEventStorageInputSvc::finalize
virtual StatusCode finalize() override
Definition: ByteStreamEventStorageInputSvc.cxx:95
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::EventCache::releaseEvent
void releaseEvent()
deletes fragments and raw event
Definition: ByteStreamEventStorageInputSvc.cxx:457
ByteStreamEventStorageInputSvc::setEvent
virtual void setEvent(void *data, unsigned int eventStatus) override
Definition: ByteStreamEventStorageInputSvc.cxx:613
ServiceHandle< StoreGateSvc >
ByteStreamEventStorageInputSvc::~ByteStreamEventStorageInputSvc
virtual ~ByteStreamEventStorageInputSvc()
Destructor.
Definition: ByteStreamEventStorageInputSvc.cxx:65
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37