ATLAS Offline Software
ByteStreamEventStorageOutputSvc.h
Go to the documentation of this file.
1 /* Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */
2 
3 #ifndef EVENT_BYTESTREAMCNVSVC_SRC_BYTESTREAMEVENTSTORAGEOUTPUTSVC_H_
4 #define EVENT_BYTESTREAMCNVSVC_SRC_BYTESTREAMEVENTSTORAGEOUTPUTSVC_H_
5 
16 #include <memory>
17 #include <mutex>
18 #include <string>
19 
20 #include "ByteStreamDataWriter.h"
22 
26 #include "EventStorage/EventStorageRecords.h"
29 
30 #include "GaudiKernel/extends.h"
31 #include "GaudiKernel/IIoComponent.h"
32 #include "GaudiKernel/IIoComponentMgr.h"
33 #include "GaudiKernel/ServiceHandle.h"
34 
35 
36 class EventInfo;
37 class ByteStreamMetadata;
38 
39 
47  public extends< ByteStreamOutputSvc, IIoComponent > {
48  public:
49  using extends::extends;
50 
53  const std::string& name, ISvcLocator* pSvcLocator);
54 
57 
59  StatusCode initialize() override;
60  StatusCode stop() override;
61  StatusCode finalize() override;
63  queryInterface(const InterfaceID& riid, void** ppvInterface) override;
64 
65 
67  virtual bool putEvent(const RawEvent* re) override;
68  virtual bool putEvent(const RawEvent* re, const EventContext& ctx) override;
69 
70  // Callback method to reinitialize the internal state of the component
71  // for I/O purposes (e.g. upon @c fork(2))
72  StatusCode io_reinit() override;
73 
74  private: // properties
76  Gaudi::Property<std::string> m_inputDir{this, "OutputDirectory", "",
77  "directory for the data files"};
78 
80  Gaudi::Property<std::string> m_projectTag{this, "ProjectTag", "",
81  "part of filename"};
82 
84  Gaudi::Property<std::string> m_appName{this, "AppName", "",
85  "part of filename"};
86 
88  Gaudi::Property<std::string> m_fileTag{this, "FileTag", "",
89  "part of filename"};
90 
92  Gaudi::Property<std::string> m_streamType{this, "StreamType", "",
93  "part of filename"};
94 
96  Gaudi::Property<std::string> m_streamName{this, "StreamName", "",
97  "part of filename"};
98 
100  Gaudi::Property<std::string> m_eformatVersion{this, "EformatVersion",
101  "current", "Version of the event format data, use \"v40\" or \"run1\" "
102  "for run1, \"current\" for most current version (default)."};
103 
105  Gaudi::Property<std::string> m_eventStorageVersion{this,
106  "EventStorageVersion", "current", "Version of the ByteStream file data, "
107  "use \"v5\" or \"run1\" for run1, \"current\" for most current version "
108  "(default)."};
109 
111  Gaudi::Property<std::string> m_bsOutputStreamName{this, "BSOutputStreamName",
112  name(), "stream name for multiple output"};
113 
115  Gaudi::Property<std::string> m_simpleFileName{this, "SimpleFileName", "",
116  "for filename not from AgreedFileName"};
117 
119  Gaudi::Property<int> m_lumiBlockNumber{this, "LumiBlockNumber", 0,
120  "part of filename"};
121 
123  Gaudi::Property<int> m_run{this, "RunNumber", 0, "part of filename"};
124 
126  Gaudi::Property<bool> m_dump{this, "DumpFlag", false, "dump fragments"};
127 
129  Gaudi::Property<bool> m_writeEventless{this, "WriteEventlessFiles", true,
130  ""};
131 
133  Gaudi::Property<bool> m_compressEvents{this, "CompressEvents", false, ""};
134 
136  Gaudi::Property<unsigned int> m_maxFileMB{this, "MaxFileMB", 10000,
137  "MB per file"};
138 
140  Gaudi::Property<unsigned int> m_maxFileNE{this, "MaxFileNE", 100000,
141  "evens per file"};
142 
144  "EventInfo", "Key for EventInfo object in event store"};
145 
147  "ByteStreamMetadataKey", "MetaDataStore+ByteStreamMetadata",
148  "Key for bytestream metadata object in metadata store"};
149 
151 
152  private: // data
155 
156  bool m_isRun1{false};
157 
159  std::unique_ptr<ByteStreamDataWriter> m_dataWriter;
160 
163 
164  private: // internal helper functions
166  StatusCode reinit();
167 
169  bool initDataWriter(const EventContext* ctx = nullptr);
171  const xAOD::EventInfo*, const ByteStreamMetadata*);
173  const ByteStreamMetadata * getByteStreamMetadata(const EventContext& ctx);
174 
175  struct EventCache {
176  inline void releaseEvent() {
177  buffer.reset(nullptr);
178  size = 0;
179  }
180 
182  std::unique_ptr< uint32_t[] > buffer{nullptr};
183 
184  unsigned int size{0};
185  };
186 
189 
192 
195  const xAOD::EventInfo& evtInfo) const;
196 
199  const ByteStreamMetadata& metaData) const;
200 
201 };
202 
203 #endif // EVENT_BYTESTREAMCNVSVC_SRC_BYTESTREAMEVENTSTORAGEOUTPUTSVC_H_
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
ByteStreamEventStorageOutputSvc::initDataWriter
bool initDataWriter(const EventContext *ctx=nullptr)
initialize EventStorage's DataWriter
Definition: ByteStreamEventStorageOutputSvc.cxx:119
ByteStreamEventStorageOutputSvc::m_byteStreamMetadataKey
SG::ReadHandleKey< ByteStreamMetadataContainer > m_byteStreamMetadataKey
Definition: ByteStreamEventStorageOutputSvc.h:146
ByteStreamOutputSvc.h
This file contains the class definition for the ByteStreamOutputSvc class.
ByteStreamEventStorageOutputSvc::~ByteStreamEventStorageOutputSvc
virtual ~ByteStreamEventStorageOutputSvc()
Destructor.
Definition: ByteStreamEventStorageOutputSvc.h:56
ByteStreamEventStorageOutputSvc::EventCache::size
unsigned int size
Definition: ByteStreamEventStorageOutputSvc.h:184
ByteStreamEventStorageOutputSvc::m_writeEventless
Gaudi::Property< bool > m_writeEventless
Compress events.
Definition: ByteStreamEventStorageOutputSvc.h:129
ByteStreamEventStorageOutputSvc::io_reinit
StatusCode io_reinit() override
Definition: ByteStreamEventStorageOutputSvc.cxx:253
ByteStreamEventStorageOutputSvc::m_eventCache
SG::SlotSpecificObj< EventCache > m_eventCache
Cache of event data for each slot.
Definition: ByteStreamEventStorageOutputSvc.h:188
ByteStreamEventStorageOutputSvc::m_streamType
Gaudi::Property< std::string > m_streamType
stream name
Definition: ByteStreamEventStorageOutputSvc.h:92
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
ByteStreamEventStorageOutputSvc::m_isRun1
bool m_isRun1
Definition: ByteStreamEventStorageOutputSvc.h:156
ByteStreamMetadataContainer.h
This file contains the class definition for the ByteStreamMetadataContainer class.
ByteStreamEventStorageOutputSvc::m_totalEventCounter
int m_totalEventCounter
number of event counter
Definition: ByteStreamEventStorageOutputSvc.h:154
ByteStreamEventStorageOutputSvc::m_lumiBlockNumber
Gaudi::Property< int > m_lumiBlockNumber
run number
Definition: ByteStreamEventStorageOutputSvc.h:119
ByteStreamEventStorageOutputSvc::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ByteStreamEventStorageOutputSvc.h:143
ByteStreamMetadata
This class is the StoreGate data object for bytestream metadata.
Definition: ByteStreamMetadata.h:25
ByteStreamEventStorageOutputSvc::m_maxFileNE
Gaudi::Property< unsigned int > m_maxFileNE
Definition: ByteStreamEventStorageOutputSvc.h:140
SG::ReadHandleKey< xAOD::EventInfo >
ByteStreamEventStorageOutputSvc::m_streamName
Gaudi::Property< std::string > m_streamName
eformat event version to produce, "v40" for run1, or "current"
Definition: ByteStreamEventStorageOutputSvc.h:96
ByteStreamEventStorageOutputSvc::m_inputDir
Gaudi::Property< std::string > m_inputDir
< directory for the data files
Definition: ByteStreamEventStorageOutputSvc.h:76
ByteStreamEventStorageOutputSvc::getByteStreamMetadata
const ByteStreamMetadata * getByteStreamMetadata()
Definition: ByteStreamEventStorageOutputSvc.cxx:291
ByteStreamEventStorageOutputSvc::EventCache::releaseEvent
void releaseEvent()
Definition: ByteStreamEventStorageOutputSvc.h:176
ByteStreamEventStorageOutputSvc::putEvent
virtual bool putEvent(const RawEvent *re) override
Implementation of the ByteStreamOutputSvc interface method putEvent.
Definition: ByteStreamEventStorageOutputSvc.cxx:172
ByteStreamEventStorageOutputSvc::reinit
StatusCode reinit()
reinitialize the service when a fork() occurred/was-issued
Definition: ByteStreamEventStorageOutputSvc.cxx:86
ByteStreamDataWriter.h
This file contains the class definition for the ByteStreamDataWriter class.
ByteStreamEventStorageOutputSvc::m_run
Gaudi::Property< int > m_run
Dump fragments.
Definition: ByteStreamEventStorageOutputSvc.h:123
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
ByteStreamEventStorageOutputSvc::m_eformatVersion
Gaudi::Property< std::string > m_eformatVersion
EventStorage BS version to produce, "v5" for run1, or "current".
Definition: ByteStreamEventStorageOutputSvc.h:100
ByteStreamEventStorageOutputSvc::m_dataWriter
std::unique_ptr< ByteStreamDataWriter > m_dataWriter
pointer to DataWriter
Definition: ByteStreamEventStorageOutputSvc.h:159
ByteStreamEventStorageOutputSvc::m_simpleFileName
Gaudi::Property< std::string > m_simpleFileName
use this string for filename, not from the "AgreedFileName"
Definition: ByteStreamEventStorageOutputSvc.h:115
ByteStreamEventStorageOutputSvc::updateDataWriterParameters
void updateDataWriterParameters(DataWriterParameters &) const
Create DataWriter parameters from job properties.
Definition: ByteStreamEventStorageOutputSvc.cxx:324
ByteStreamEventStorageOutputSvc::m_appName
Gaudi::Property< std::string > m_appName
File Tag.
Definition: ByteStreamEventStorageOutputSvc.h:84
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ByteStreamEventStorageOutputSvc::m_bsOutputStreamName
Gaudi::Property< std::string > m_bsOutputStreamName
Definition: ByteStreamEventStorageOutputSvc.h:111
ByteStreamEventStorageOutputSvc
This class provides the services for writing FullEventFragment into file. This class implements the i...
Definition: ByteStreamEventStorageOutputSvc.h:47
ByteStreamEventStorageOutputSvc::m_fileTag
Gaudi::Property< std::string > m_fileTag
stream type
Definition: ByteStreamEventStorageOutputSvc.h:88
ByteStreamEventStorageOutputSvc::m_dataWriterMutex
std::mutex m_dataWriterMutex
mutex to lock data writer during initialization or writing
Definition: ByteStreamEventStorageOutputSvc.h:162
DataWriterParameters
Class containing parameters needed to initiate DataWriter.
Definition: ByteStreamDataWriter.h:153
ByteStreamEventStorageOutputSvc::m_ioMgr
ServiceHandle< IIoComponentMgr > m_ioMgr
Definition: ByteStreamEventStorageOutputSvc.h:150
ByteStreamEventStorageOutputSvc::ByteStreamEventStorageOutputSvc
ByteStreamEventStorageOutputSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructors:
Definition: ByteStreamEventStorageOutputSvc.cxx:29
ByteStreamEventStorageOutputSvc::finalize
StatusCode finalize() override
Definition: ByteStreamEventStorageOutputSvc.cxx:109
ByteStreamEventStorageOutputSvc::m_eventStorageVersion
Gaudi::Property< std::string > m_eventStorageVersion
stream name for multiple output
Definition: ByteStreamEventStorageOutputSvc.h:105
ByteStreamEventStorageOutputSvc::initialize
StatusCode initialize() override
Required of all Gaudi Services.
Definition: ByteStreamEventStorageOutputSvc.cxx:36
ByteStreamEventStorageOutputSvc::EventCache
Definition: ByteStreamEventStorageOutputSvc.h:175
ByteStreamEventStorageOutputSvc::m_dump
Gaudi::Property< bool > m_dump
Write eventless files.
Definition: ByteStreamEventStorageOutputSvc.h:126
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:42
ByteStreamEventStorageOutputSvc::initDataWriterContents
bool initDataWriterContents(const xAOD::EventInfo *, const ByteStreamMetadata *)
Definition: ByteStreamEventStorageOutputSvc.cxx:136
ByteStreamEventStorageOutputSvc::m_compressEvents
Gaudi::Property< bool > m_compressEvents
number of MB per file
Definition: ByteStreamEventStorageOutputSvc.h:133
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
ByteStreamEventStorageOutputSvc::stop
StatusCode stop() override
Definition: ByteStreamEventStorageOutputSvc.cxx:93
re
const boost::regex re(r_e)
ByteStreamEventStorageOutputSvc::m_maxFileMB
Gaudi::Property< unsigned int > m_maxFileMB
number of events per file
Definition: ByteStreamEventStorageOutputSvc.h:136
SlotSpecificObj.h
Maintain a set of objects, one per slot.
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
ByteStreamEventStorageOutputSvc::queryInterface
StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Definition: ByteStreamEventStorageOutputSvc.cxx:459
ByteStreamEventStorageOutputSvc::m_projectTag
Gaudi::Property< std::string > m_projectTag
Application Name.
Definition: ByteStreamEventStorageOutputSvc.h:80
ByteStreamEventStorageOutputSvc::EventCache::buffer
std::unique_ptr< uint32_t[] > buffer
Underlying data structure.
Definition: ByteStreamEventStorageOutputSvc.h:182
ServiceHandle< IIoComponentMgr >