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 
27 #include "EventStorage/EventStorageRecords.h"
30 
31 #include "GaudiKernel/extends.h"
32 #include "GaudiKernel/IIoComponent.h"
33 #include "GaudiKernel/IIoComponentMgr.h"
34 #include "GaudiKernel/ServiceHandle.h"
35 
36 
37 class EventInfo;
38 class ByteStreamMetadata;
39 
40 
48  public extends< AthService, IByteStreamOutputSvc, IIoComponent > {
49  public:
50 
53  const std::string& name, ISvcLocator* pSvcLocator);
54 
57 
59  StatusCode initialize() override;
60  StatusCode stop() override;
61  StatusCode finalize() override;
62 
64  virtual bool putEvent(const RawEvent* re) override;
65  virtual bool putEvent(const RawEvent* re, const EventContext& ctx) override;
66 
67  // Callback method to reinitialize the internal state of the component
68  // for I/O purposes (e.g. upon @c fork(2))
69  StatusCode io_reinit() override;
70 
71  private: // properties
73  Gaudi::Property<std::string> m_inputDir{this, "OutputDirectory", "",
74  "directory for the data files"};
75 
77  Gaudi::Property<std::string> m_projectTag{this, "ProjectTag", "",
78  "part of filename"};
79 
81  Gaudi::Property<std::string> m_appName{this, "AppName", "",
82  "part of filename"};
83 
85  Gaudi::Property<std::string> m_fileTag{this, "FileTag", "",
86  "part of filename"};
87 
89  Gaudi::Property<std::string> m_streamType{this, "StreamType", "",
90  "part of filename"};
91 
93  Gaudi::Property<std::string> m_streamName{this, "StreamName", "",
94  "part of filename"};
95 
97  Gaudi::Property<std::string> m_eformatVersion{this, "EformatVersion",
98  "current", "Version of the event format data, use \"v40\" or \"run1\" "
99  "for run1, \"current\" for most current version (default)."};
100 
102  Gaudi::Property<std::string> m_eventStorageVersion{this,
103  "EventStorageVersion", "current", "Version of the ByteStream file data, "
104  "use \"v5\" or \"run1\" for run1, \"current\" for most current version "
105  "(default)."};
106 
108  Gaudi::Property<std::string> m_bsOutputStreamName{this, "BSOutputStreamName",
109  name(), "stream name for multiple output"};
110 
112  Gaudi::Property<std::string> m_simpleFileName{this, "SimpleFileName", "",
113  "for filename not from AgreedFileName"};
114 
116  Gaudi::Property<int> m_lumiBlockNumber{this, "LumiBlockNumber", 0,
117  "part of filename"};
118 
120  Gaudi::Property<int> m_run{this, "RunNumber", 0, "part of filename"};
121 
123  Gaudi::Property<bool> m_dump{this, "DumpFlag", false, "dump fragments"};
124 
126  Gaudi::Property<bool> m_writeEventless{this, "WriteEventlessFiles", true,
127  ""};
128 
130  Gaudi::Property<bool> m_compressEvents{this, "CompressEvents", false, ""};
131 
133  Gaudi::Property<unsigned int> m_maxFileMB{this, "MaxFileMB", 10000,
134  "MB per file"};
135 
137  Gaudi::Property<unsigned int> m_maxFileNE{this, "MaxFileNE", 100000,
138  "evens per file"};
139 
141  "EventInfo", "Key for EventInfo object in event store"};
142 
144  "ByteStreamMetadataKey", "MetaDataStore+ByteStreamMetadata",
145  "Key for bytestream metadata object in metadata store"};
146 
148 
149  private: // data
152 
153  bool m_isRun1{false};
154 
156  std::unique_ptr<ByteStreamDataWriter> m_dataWriter;
157 
160 
161  private: // internal helper functions
163  StatusCode reinit();
164 
166  bool initDataWriter(const EventContext* ctx = nullptr);
168  const xAOD::EventInfo*, const ByteStreamMetadata*);
170  const ByteStreamMetadata * getByteStreamMetadata(const EventContext& ctx);
171 
172  struct EventCache {
173  inline void releaseEvent() {
174  buffer.reset(nullptr);
175  size = 0;
176  }
177 
179  std::unique_ptr< uint32_t[] > buffer{nullptr};
180 
181  unsigned int size{0};
182  };
183 
186 
189 
192  const xAOD::EventInfo& evtInfo) const;
193 
196  const ByteStreamMetadata& metaData) const;
197 
198 };
199 
200 #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:117
ByteStreamEventStorageOutputSvc::m_byteStreamMetadataKey
SG::ReadHandleKey< ByteStreamMetadataContainer > m_byteStreamMetadataKey
Definition: ByteStreamEventStorageOutputSvc.h:143
ByteStreamEventStorageOutputSvc::~ByteStreamEventStorageOutputSvc
virtual ~ByteStreamEventStorageOutputSvc()
Destructor.
Definition: ByteStreamEventStorageOutputSvc.h:56
ByteStreamEventStorageOutputSvc::EventCache::size
unsigned int size
Definition: ByteStreamEventStorageOutputSvc.h:181
ByteStreamEventStorageOutputSvc::m_writeEventless
Gaudi::Property< bool > m_writeEventless
Compress events.
Definition: ByteStreamEventStorageOutputSvc.h:126
ByteStreamEventStorageOutputSvc::io_reinit
StatusCode io_reinit() override
Definition: ByteStreamEventStorageOutputSvc.cxx:251
ByteStreamEventStorageOutputSvc::m_eventCache
SG::SlotSpecificObj< EventCache > m_eventCache
Cache of event data for each slot.
Definition: ByteStreamEventStorageOutputSvc.h:185
ByteStreamEventStorageOutputSvc::m_streamType
Gaudi::Property< std::string > m_streamType
stream name
Definition: ByteStreamEventStorageOutputSvc.h:89
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:153
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:151
ByteStreamEventStorageOutputSvc::m_lumiBlockNumber
Gaudi::Property< int > m_lumiBlockNumber
run number
Definition: ByteStreamEventStorageOutputSvc.h:116
ByteStreamEventStorageOutputSvc::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ByteStreamEventStorageOutputSvc.h:140
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:137
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:93
ByteStreamEventStorageOutputSvc::m_inputDir
Gaudi::Property< std::string > m_inputDir
< directory for the data files
Definition: ByteStreamEventStorageOutputSvc.h:73
ByteStreamEventStorageOutputSvc::getByteStreamMetadata
const ByteStreamMetadata * getByteStreamMetadata()
Definition: ByteStreamEventStorageOutputSvc.cxx:289
ByteStreamEventStorageOutputSvc::EventCache::releaseEvent
void releaseEvent()
Definition: ByteStreamEventStorageOutputSvc.h:173
ByteStreamEventStorageOutputSvc::putEvent
virtual bool putEvent(const RawEvent *re) override
Implementation of the IByteStreamOutputSvc interface method putEvent.
Definition: ByteStreamEventStorageOutputSvc.cxx:170
ByteStreamEventStorageOutputSvc::reinit
StatusCode reinit()
reinitialize the service when a fork() occurred/was-issued
Definition: ByteStreamEventStorageOutputSvc.cxx:84
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:120
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:97
ByteStreamEventStorageOutputSvc::m_dataWriter
std::unique_ptr< ByteStreamDataWriter > m_dataWriter
pointer to DataWriter
Definition: ByteStreamEventStorageOutputSvc.h:156
IByteStreamOutputSvc.h
This file contains the interface for the ByteStreamOutputSvc classes.
ByteStreamEventStorageOutputSvc::m_simpleFileName
Gaudi::Property< std::string > m_simpleFileName
use this string for filename, not from the "AgreedFileName"
Definition: ByteStreamEventStorageOutputSvc.h:112
ByteStreamEventStorageOutputSvc::updateDataWriterParameters
void updateDataWriterParameters(DataWriterParameters &) const
Create DataWriter parameters from job properties.
Definition: ByteStreamEventStorageOutputSvc.cxx:322
ByteStreamEventStorageOutputSvc::m_appName
Gaudi::Property< std::string > m_appName
File Tag.
Definition: ByteStreamEventStorageOutputSvc.h:81
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:108
ByteStreamEventStorageOutputSvc
This class provides the services for writing FullEventFragment into file. This class implements the i...
Definition: ByteStreamEventStorageOutputSvc.h:48
ByteStreamEventStorageOutputSvc::m_fileTag
Gaudi::Property< std::string > m_fileTag
stream type
Definition: ByteStreamEventStorageOutputSvc.h:85
ByteStreamEventStorageOutputSvc::m_dataWriterMutex
std::mutex m_dataWriterMutex
mutex to lock data writer during initialization or writing
Definition: ByteStreamEventStorageOutputSvc.h:159
DataWriterParameters
Class containing parameters needed to initiate DataWriter.
Definition: ByteStreamDataWriter.h:153
ByteStreamEventStorageOutputSvc::m_ioMgr
ServiceHandle< IIoComponentMgr > m_ioMgr
Definition: ByteStreamEventStorageOutputSvc.h:147
ByteStreamEventStorageOutputSvc::ByteStreamEventStorageOutputSvc
ByteStreamEventStorageOutputSvc(const std::string &name, ISvcLocator *pSvcLocator)
Constructors:
Definition: ByteStreamEventStorageOutputSvc.cxx:29
ByteStreamEventStorageOutputSvc::finalize
StatusCode finalize() override
Definition: ByteStreamEventStorageOutputSvc.cxx:107
ByteStreamEventStorageOutputSvc::m_eventStorageVersion
Gaudi::Property< std::string > m_eventStorageVersion
stream name for multiple output
Definition: ByteStreamEventStorageOutputSvc.h:102
ByteStreamEventStorageOutputSvc::initialize
StatusCode initialize() override
Required of all Gaudi Services.
Definition: ByteStreamEventStorageOutputSvc.cxx:36
ByteStreamEventStorageOutputSvc::EventCache
Definition: ByteStreamEventStorageOutputSvc.h:172
ByteStreamEventStorageOutputSvc::m_dump
Gaudi::Property< bool > m_dump
Write eventless files.
Definition: ByteStreamEventStorageOutputSvc.h:123
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
ByteStreamEventStorageOutputSvc::initDataWriterContents
bool initDataWriterContents(const xAOD::EventInfo *, const ByteStreamMetadata *)
Definition: ByteStreamEventStorageOutputSvc.cxx:134
ByteStreamEventStorageOutputSvc::m_compressEvents
Gaudi::Property< bool > m_compressEvents
number of MB per file
Definition: ByteStreamEventStorageOutputSvc.h:130
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
ByteStreamEventStorageOutputSvc::stop
StatusCode stop() override
Definition: ByteStreamEventStorageOutputSvc.cxx:91
re
const boost::regex re(r_e)
ByteStreamEventStorageOutputSvc::m_maxFileMB
Gaudi::Property< unsigned int > m_maxFileMB
number of events per file
Definition: ByteStreamEventStorageOutputSvc.h:133
AthService.h
SlotSpecificObj.h
Maintain a set of objects, one per slot.
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
ByteStreamEventStorageOutputSvc::m_projectTag
Gaudi::Property< std::string > m_projectTag
Application Name.
Definition: ByteStreamEventStorageOutputSvc.h:77
ByteStreamEventStorageOutputSvc::EventCache::buffer
std::unique_ptr< uint32_t[] > buffer
Underlying data structure.
Definition: ByteStreamEventStorageOutputSvc.h:179
ServiceHandle< IIoComponentMgr >