ATLAS Offline Software
Loading...
Searching...
No Matches
ByteStreamEventStorageInputSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef BYTESTREAMCNVSVC_BYTESTREAMEVENTSTORAGEINPUTSVC_H
6#define BYTESTREAMCNVSVC_BYTESTREAMEVENTSTORAGEINPUTSVC_H
7
13
14// Include files.
20
21// FrameWork includes
22#include "GaudiKernel/ServiceHandle.h"
23
24namespace EventStorage
25{
26 class DataReader;
27}
28class StoreGateSvc;
30
31
36 : public extends<AthService, IByteStreamInputSvc>
37{
38public:
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
69private: // data
70 std::mutex m_readerMutex;
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
93private: // properties
95 ServiceHandle<StoreGateSvc> m_storeGate{this, "EventStore", "StoreGateSvc"};
96 ServiceHandle<StoreGateSvc> m_inputMetadata{this, "MetaDataStore", "StoreGateSvc/InputMetaDataStore"};
98 Gaudi::Property<bool> m_sequential{this, "EnableSequential", false, "enable sequential reading"};
99 Gaudi::Property<bool> m_dump{this, "DumpFlag", false, "Dump fragments"};
100 Gaudi::Property<float> m_wait{this, "WaitSecs", 0.0f, "Seconds to wait if input is in wait state"};
101 Gaudi::Property<bool> m_valEvent{this, "ValidateEvent", false, "switch on check_tree when reading events"};
102 Gaudi::Property<std::string> m_eventInfoKey{this, "EventInfoKey", "EventInfo", "Key of EventInfo in metadata store"};
103
104
105private: // internal helper functions
106 StatusCode loadMetadata ();
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 };
114 const RawEvent* getEvent( Advance step );
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 // BYTESTREAMCNVSVC_BYTESTREAMEVENTSTORAGEINPUTSVC_H
#define ATH_CHECK
Evaluate an expression and check for errors.
Maintain a set of objects, one per slot.
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
This file contains the interface for the ByteStreamInputSvc classes.
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
SG::SlotSpecificObj< EventCache > m_eventsCache
virtual unsigned int currentEventStatus() const override
Return the current event status.
virtual void setEvent(void *data, unsigned int eventStatus) override
void buildFragment(EventCache *cache, uint32_t eventSize, bool validate) const
virtual const RawEvent * currentEvent() const override
Implementation of the IByteStreamInputSvc interface methods.
std::unique_ptr< DataHeaderElement > makeBSProvenance() const
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to StoreGate.
const RawEvent * getEvent(Advance step)
ByteStreamEventStorageInputSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructors:
StatusCode deleteEntry(const std::string &key)
virtual StatusCode initialize() override
Required of all Gaudi Services.
Gaudi::Property< std::string > m_eventInfoKey
virtual const RawEvent * nextEvent() override
++, new
virtual ~ByteStreamEventStorageInputSvc()
Destructor.
virtual const RawEvent * previousEvent() override
–, old
ServiceHandle< StoreGateSvc > m_inputMetadata
std::unique_ptr< EventStorage::DataReader > m_reader
DataReader from EventStorage.
ServiceHandle< IROBDataProviderSvc > m_robProvider
virtual StatusCode generateDataHeader() override
virtual std::pair< long, std::string > getBlockIterator(const std::string &fileName) override
long long int m_evtFileOffset
last read in event offset within a file, can be -1
std::vector< long long int > m_evtOffsets
offset for event i in that file
virtual void closeBlockIterator(bool clearMetadata=true) override
This class provides a persistent form for the TransientAddress.
Definition DataHeader.h:37
Maintain a set of objects, one per slot.
The Athena Transient Store API.
unsigned int eventStatus
check_tree() status of the current event
std::unique_ptr< RawEvent > rawEvent
current event
char * data
take ownership of RawEvent content
long long int eventOffset
event offset within a file, can be -1