ATLAS Offline Software
ByteStreamEventStorageInputSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef BYTESTREAMEVENTSTORAGEINPUTSVC_H
6 #define BYTESTREAMEVENTSTORAGEINPUTSVC_H
7 
14 // Include files.
19 
20 // FrameWork includes
21 #include "GaudiKernel/ServiceHandle.h"
22 
23 namespace EventStorage
24 {
25  class DataReader;
26 }
27 class StoreGateSvc;
28 class DataHeaderElement;
29 
30 
35 : public ByteStreamInputSvc
36 {
37 public:
39  ByteStreamEventStorageInputSvc(const std::string& name,
40  ISvcLocator* pSvcLocator);
41 
44 
46  virtual StatusCode initialize() override;
47  virtual StatusCode stop () override;
48  virtual StatusCode finalize () override;
49 
51  virtual
52  StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override;
53 
55  virtual const RawEvent* currentEvent () const override;
56  virtual const RawEvent* nextEvent () override;
57  virtual const RawEvent* previousEvent() override;
58  virtual void setEvent (void* data, unsigned int eventStatus) override;
59 
61  virtual unsigned int currentEventStatus() const override;
62  virtual void validateEvent () override;
63 
64  virtual long positionInBlock () override;
65  virtual std::pair<long,std::string> getBlockIterator(const std::string& fileName) override;
66  virtual void closeBlockIterator(bool clearMetadata=true) override;
67  virtual bool setSequentialRead ();
68  virtual bool ready () override;
69  virtual StatusCode generateDataHeader() override;
70 
71 
72 private: // data
74 
75  struct EventCache {
76  std::unique_ptr<RawEvent> rawEvent = nullptr;
77  char* data = nullptr;
78  unsigned int eventStatus = 0;
79  long long int eventOffset = 0;
80  void releaseEvent();
81  virtual ~EventCache();
82  };
83 
85 
86  std::unique_ptr<EventStorage::DataReader> m_reader;
87 
88  std::vector<long long int> m_evtOffsets;
89  unsigned int m_evtInFile;
90  long long int m_evtFileOffset;
91  // Event back navigation info
92  std::string m_fileGUID;
93 
94 
95 
96 private: // properties
101  Gaudi::Property<bool> m_sequential;
102  Gaudi::Property<bool> m_dump;
103  Gaudi::Property<float> m_wait;
104  Gaudi::Property<bool> m_valEvent;
105  Gaudi::Property<std::string> m_eventInfoKey;
106 
107 
108 private: // internal helper functions
110  void buildFragment (EventCache* cache, uint32_t eventSize, bool validate) const;
111  bool readerReady ();
112  bool ROBFragmentCheck(const RawEvent*) const;
113  unsigned validateEvent (const RawEvent* const rawEvent) const;
114  void setEvent (const EventContext& context, void* data, unsigned int eventStatus);
115 
116  enum Advance{ PREVIOUS = -1, NEXT = 1 };
118  std::unique_ptr<DataHeaderElement> makeBSProvenance() const;
119 
120  template<typename T>
121  StatusCode deleteEntry(const std::string& key)
122  {
123  if (m_storeGate->contains<T>(key)) {
124  const T* tmp = m_storeGate->tryConstRetrieve<T>(key);
125  if (tmp != nullptr) ATH_CHECK(m_storeGate->remove<T>(tmp));
126  }
127  return StatusCode::SUCCESS;
128  }
129 
130 };
131 
132 #endif // BYTESTREAMEVENTSTORAGEINPUTSVC_H
ByteStreamEventStorageInputSvc
This class is the ByteStreamInputSvc for reading events written by EventStorage.
Definition: ByteStreamEventStorageInputSvc.h:36
ByteStreamInputSvc.h
This file contains the class definition for the ByteStreamInputSvc class.
ByteStreamEventStorageInputSvc::m_evtFileOffset
long long int m_evtFileOffset
last read in event offset within a file, can be -1
Definition: ByteStreamEventStorageInputSvc.h:90
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:75
ByteStreamEventStorageInputSvc::NEXT
@ NEXT
Definition: ByteStreamEventStorageInputSvc.h:116
ByteStreamEventStorageInputSvc::PREVIOUS
@ PREVIOUS
Definition: ByteStreamEventStorageInputSvc.h:116
ByteStreamEventStorageInputSvc::m_readerMutex
std::mutex m_readerMutex
Definition: ByteStreamEventStorageInputSvc.h:73
ByteStreamEventStorageInputSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Required of all Gaudi services: see Gaudi documentation for details.
Definition: ByteStreamEventStorageInputSvc.cxx:667
ByteStreamInputSvc
This class provides the base class to services to read bytestream data. The concrete class can provid...
Definition: ByteStreamInputSvc.h:23
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:88
ByteStreamEventStorageInputSvc::m_eventsCache
SG::SlotSpecificObj< EventCache > m_eventsCache
Definition: ByteStreamEventStorageInputSvc.h:84
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ByteStreamEventStorageInputSvc::ready
virtual bool ready() override
Definition: ByteStreamEventStorageInputSvc.cxx:513
ByteStreamEventStorageInputSvc::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to StoreGate.
Definition: ByteStreamEventStorageInputSvc.h:98
ByteStreamEventStorageInputSvc::setSequentialRead
virtual bool setSequentialRead()
Definition: ByteStreamEventStorageInputSvc.cxx:503
ByteStreamEventStorageInputSvc::validateEvent
virtual void validateEvent() override
Definition: ByteStreamEventStorageInputSvc.cxx:277
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:105
ByteStreamEventStorageInputSvc::EventCache::eventStatus
unsigned int eventStatus
check_tree() status of the current event
Definition: ByteStreamEventStorageInputSvc.h:78
ByteStreamEventStorageInputSvc::m_robProvider
ServiceHandle< IROBDataProviderSvc > m_robProvider
Definition: ByteStreamEventStorageInputSvc.h:100
ByteStreamEventStorageInputSvc::generateDataHeader
virtual StatusCode generateDataHeader() override
Definition: ByteStreamEventStorageInputSvc.cxx:391
ByteStreamEventStorageInputSvc::stop
virtual StatusCode stop() override
Definition: ByteStreamEventStorageInputSvc.cxx:85
ByteStreamEventStorageInputSvc::nextEvent
virtual const RawEvent * nextEvent() override
++, new
Definition: ByteStreamEventStorageInputSvc.cxx:197
ByteStreamEventStorageInputSvc::m_evtInFile
unsigned int m_evtInFile
Definition: ByteStreamEventStorageInputSvc.h:89
ByteStreamEventStorageInputSvc::m_dump
Gaudi::Property< bool > m_dump
Definition: ByteStreamEventStorageInputSvc.h:102
ByteStreamEventStorageInputSvc::closeBlockIterator
virtual void closeBlockIterator(bool clearMetadata=true) override
Definition: ByteStreamEventStorageInputSvc.cxx:482
ByteStreamEventStorageInputSvc::m_valEvent
Gaudi::Property< bool > m_valEvent
Definition: ByteStreamEventStorageInputSvc.h:104
ByteStreamEventStorageInputSvc::loadMetadata
StatusCode loadMetadata()
Definition: ByteStreamEventStorageInputSvc.cxx:117
ByteStreamEventStorageInputSvc::m_wait
Gaudi::Property< float > m_wait
Definition: ByteStreamEventStorageInputSvc.h:103
ByteStreamEventStorageInputSvc::ROBFragmentCheck
bool ROBFragmentCheck(const RawEvent *) const
Definition: ByteStreamEventStorageInputSvc.cxx:582
ByteStreamEventStorageInputSvc::EventCache::rawEvent
std::unique_ptr< RawEvent > rawEvent
current event
Definition: ByteStreamEventStorageInputSvc.h:76
ByteStreamEventStorageInputSvc::EventCache::eventOffset
long long int eventOffset
event offset within a file, can be -1
Definition: ByteStreamEventStorageInputSvc.h:79
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
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:109
ByteStreamEventStorageInputSvc::m_reader
std::unique_ptr< EventStorage::DataReader > m_reader
DataReader from EventStorage.
Definition: ByteStreamEventStorageInputSvc.h:86
ByteStreamEventStorageInputSvc::ByteStreamEventStorageInputSvc
ByteStreamEventStorageInputSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructors:
Definition: ByteStreamEventStorageInputSvc.cxx:37
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:70
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:116
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ByteStreamEventStorageInputSvc::readerReady
bool readerReady()
Definition: ByteStreamEventStorageInputSvc.cxx:564
ByteStreamEventStorageInputSvc::EventCache::data
char * data
take ownership of RawEvent content
Definition: ByteStreamEventStorageInputSvc.h:77
ByteStreamEventStorageInputSvc::buildFragment
void buildFragment(EventCache *cache, uint32_t eventSize, bool validate) const
Definition: ByteStreamEventStorageInputSvc.cxx:322
ByteStreamEventStorageInputSvc::EventCache::~EventCache
virtual ~EventCache()
calls releaseEvent
Definition: ByteStreamEventStorageInputSvc.cxx:474
ByteStreamEventStorageInputSvc::previousEvent
virtual const RawEvent * previousEvent() override
–, old
Definition: ByteStreamEventStorageInputSvc.cxx:130
ByteStreamEventStorageInputSvc::m_sequential
Gaudi::Property< bool > m_sequential
enable sequential reading.
Definition: ByteStreamEventStorageInputSvc.h:101
ByteStreamEventStorageInputSvc::m_inputMetadata
ServiceHandle< StoreGateSvc > m_inputMetadata
StoreGateSvc.
Definition: ByteStreamEventStorageInputSvc.h:99
LArCellBinning.step
step
Definition: LArCellBinning.py:158
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:658
EventStorage
Definition: ByteStreamEventStorageInputSvc.h:24
ByteStreamEventStorageInputSvc::currentEvent
virtual const RawEvent * currentEvent() const override
Implementation of the ByteStreamInputSvc interface methods.
Definition: ByteStreamEventStorageInputSvc.cxx:649
ByteStreamEventStorageInputSvc::deleteEntry
StatusCode deleteEntry(const std::string &key)
Definition: ByteStreamEventStorageInputSvc.h:121
ByteStreamEventStorageInputSvc::getBlockIterator
virtual std::pair< long, std::string > getBlockIterator(const std::string &fileName) override
Definition: ByteStreamEventStorageInputSvc.cxx:521
IROBDataProviderSvc.h
ByteStreamEventStorageInputSvc::makeBSProvenance
std::unique_ptr< DataHeaderElement > makeBSProvenance() const
Definition: ByteStreamEventStorageInputSvc.cxx:682
ByteStreamEventStorageInputSvc::finalize
virtual StatusCode finalize() override
Definition: ByteStreamEventStorageInputSvc.cxx:96
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
ByteStreamEventStorageInputSvc::m_fileGUID
std::string m_fileGUID
current file GUID
Definition: ByteStreamEventStorageInputSvc.h:92
ByteStreamEventStorageInputSvc::EventCache::releaseEvent
void releaseEvent()
deletes fragments and raw event
Definition: ByteStreamEventStorageInputSvc.cxx:458
ByteStreamEventStorageInputSvc::setEvent
virtual void setEvent(void *data, unsigned int eventStatus) override
Definition: ByteStreamEventStorageInputSvc.cxx:614
ServiceHandle< StoreGateSvc >
ByteStreamEventStorageInputSvc::~ByteStreamEventStorageInputSvc
virtual ~ByteStreamEventStorageInputSvc()
Destructor.
Definition: ByteStreamEventStorageInputSvc.cxx:64
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37