ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaOutputStream.h
Go to the documentation of this file.
1// Dear emacs, this is -*- C++ -*-
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef ATHENASERVICES_ATHENAOUTPUTSTREAM_H
8#define ATHENASERVICES_ATHENAOUTPUTSTREAM_H
9
10// STL include files
11#include <map>
12#include <memory>
13#include <mutex>
14#include <set>
15#include <string>
16#include <vector>
17
18// Required for inheritance
19#include "Gaudi/Property.h"
20#include "GaudiKernel/IDataSelector.h"
21#include "GaudiKernel/ServiceHandle.h"
22#include "GaudiKernel/ToolHandle.h"
23
24// Framework include files
30#include "GaudiKernel/IClassIDSvc.h"
31#include "GaudiKernel/IIncidentListener.h"
32#include "GaudiKernel/IIoComponent.h"
34
35// Local include files
36#include "CompressionInfo.h"
37#include "MetaDataSvc.h"
39#include "SelectionVetoes.h"
40
41// forward declarations
42namespace SG {
43 class DataProxy;
44 class IFolder;
45 class IAuxStoreIO;
46 class FolderItem;
47}
48
53class AthenaOutputStream : public extends<FilteredAlgorithm,
54 IIncidentListener, IIoComponent> {
55
56public:
57 typedef std::recursive_mutex mutex_t;
58
60 AthenaOutputStream(const std::string& name, ISvcLocator* pSvcLocator);
61
63 virtual ~AthenaOutputStream();
64
66
67 virtual StatusCode initialize() override;
68 virtual StatusCode finalize() override;
69 virtual StatusCode execute(const EventContext& ctx) override;
71
73 virtual StatusCode write(const EventContext& ctx);
74
76 void clearSelection();
77
79 StatusCode collectAllObjects(const EventContext& ctx);
80
82 IDataSelector* selectedObjects() {
83 return &m_objects;
84 }
85
87 virtual void handle(const Incident& incident) override;
88
90 virtual StatusCode io_reinit() override;
91 virtual StatusCode io_finalize() override;
92
93protected:
96 ServiceHandle<StoreGateSvc> m_dataStore{this, "Store", "StoreGateSvc/StoreGateSvc", "Handle to event store"};
97 ServiceHandle<StoreGateSvc> m_metadataStore{this, "MetadataStore", "StoreGateSvc/MetaDataStore", "Handle to metadata store"};
99
101 ServiceHandle<MetaDataSvc> m_metaDataSvc{this, "MetaDataSvc", "MetaDataSvc"};
102 ServiceHandle<IDictLoaderSvc> m_dictLoader{this, "AthDictLoaderSvc", "AthDictLoaderSvc"};
103 ServiceHandle<ITPCnvSvc> m_tpCnvSvc{this, "AthTPCnvSvc", "AthTPCnvSvc"};
104 ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"};
105 ServiceHandle<IClassIDSvc> m_pCLIDSvc{this, "ClassIDSvc", "ClassIDSvc"};
106 ServiceHandle<OutputStreamSequencerSvc> m_outSeqSvc{this, "OutputStreamSequencerSvc", "OutputStreamSequencerSvc"};
107
109 StringProperty m_streamName{this, "StreamName", "", "Name of the output stream"};
110
112 StringArrayProperty m_itemList{this, "ItemList", {}, "List of items to write", "OutputStreamItemList"};
113
115 StringArrayProperty m_metadataItemList{this, "MetadataItemList", {}, "List of metadata items to write","OutputStreamItemList"};
116
118 StringProperty m_keepProvenances {this, "KeepProvenanceTagsRegEx", {".*"},
119 "RegEx pattern to select processing tags for which DataHeader should retain provenances"};
120
122 StringArrayProperty m_compressionListHigh{this, "CompressionListHigh", {}, "Lossy float compression list (high)"};
123
125 StringArrayProperty m_compressionListLow{this, "CompressionListLow", {}, "Lossy float compression list (low)"};
126
128 UnsignedIntegerProperty m_compressionBitsHigh{this, "CompressionBitsHigh", 7, "Lossy float compression bits (high)"};
129
131 UnsignedIntegerProperty m_compressionBitsLow{this, "CompressionBitsLow", 15, "Lossy float compression bits (low)"};
132
135 StringArrayProperty m_transientItems{this, "TransientItems", {}, "Transient item list"};
136
138 StringProperty m_outputName{this, "OutputFile", "DidNotNameOutput.root", "Name of the output file"};
139
141 StringProperty m_persName{this, "EvtConversionSvc", "EventPersistencySvc", "Name of the persistency service writing data"};
142
144 BooleanProperty m_forceRead{this, "ForceRead", true, "Force read data objects in ItemList"};
145
148 BooleanProperty m_extendProvenanceRecord{this, "ExtendProvenanceRecord", true, "Extend provenance record"};
149
151 BooleanProperty m_itemListFromTool{this, "TakeItemsFromInput", false, "Write everything in input DataHeader to output"};
152
154 ToolHandle<SG::IFolder> m_p2BWritten;
155
157 ToolHandle<SG::IFolder> m_compressionDecoderHigh;
158
160 ToolHandle<SG::IFolder> m_compressionDecoderLow;
161
163 ToolHandle<SG::IFolder> m_transient;
164
166 IDataSelector m_objects;
167
169 IDataSelector m_altObjects;
170
174 std::vector<std::unique_ptr<DataObject> > m_ownedObjects;
175
177 ToolHandle<IAthenaOutputStreamTool> m_streamer;
178
180 ToolHandleArray<IAthenaOutputTool> m_helperTools{this, "HelperTools", {}, "List of AlgTools used by this stream"};
181
182 // flag set by MetaDataStop if OutputSequencer is used with EndEvent
184
186 std::atomic<int> m_events{0};
187
188 // ------- Event Ranges handling in MT -------
190 std::map< unsigned, std::string > m_slotRangeMap;
191
193 std::map< std::string, std::string > m_rangeIDforRangeFN;
194
196 std::map< std::string, std::unique_ptr<IAthenaOutputStreamTool> > m_streamerMap;
197
200
202 void itemListHandler(Gaudi::Details::PropertyBase& /* theProp */);
203
205 void compressionListHandlerHigh(Gaudi::Details::PropertyBase& /* theProp */);
206
208 void compressionListHandlerLow(Gaudi::Details::PropertyBase& /* theProp */);
209
210private:
215
220
223
225 StatusCode addItemObjects(const EventContext&, const SG::FolderItem&, SG::SelectionVetoes& vetoes, SG::CompressionInfo& compInfo);
226
227 void handleVariableSelection (const SG::IConstAuxStore& auxstore,
228 SG::DataProxy& itemProxy,
229 const std::string& aux_attr,
230 SG::SelectionVetoes& vetoes) const;
231
233 void writeMetaData( const EventContext& ctx, const std::string& outputFN="" );
234
236 std::set<std::string> buildCompressionSet (const ToolHandle<SG::IFolder>& handle,
237 const CLID& item_id,
238 const std::string& item_key) const;
239
240 // close an EventService substream that was writing to 'rangeFN' output
241 void finalizeRange( const EventContext& ctx, const std::string & rangeFN );
242
248 void loadDict (CLID clid);
249
251 bool simpleMatch(const std::string& pattern, const std::string& text);
252};
253
254#endif // ATHENASERVICES_OUTPUTSTREAM_H
uint32_t CLID
The Class ID type.
Interface to an output stream tool.
This file contains the class definition for the IAthenaOutputTool class.
This file contains the class definition for the MetaDataSvc class.
This file contains the class definition for the OutputStreamSequencerSvc class.
Property holding a SG store/key/clid from which a WriteHandle is made.
IDataSelector m_objects
Collection of objects being selected.
ServiceHandle< StoreGateSvc > m_metadataStore
virtual StatusCode finalize() override
StringProperty m_streamName
Stream name (defaults to algorithm name).
UnsignedIntegerProperty m_compressionBitsLow
Number of mantissa bits in the float compression.
UnsignedIntegerProperty m_compressionBitsHigh
Number of mantissa bits in the float compression.
StringArrayProperty m_transientItems
List of items that are known to be present in the transient store (and hence we can make input depend...
ToolHandle< SG::IFolder > m_compressionDecoderLow
The top-level folder with items to be compressed low.
ToolHandle< SG::IFolder > m_p2BWritten
The top-level folder with items to be written.
StringArrayProperty m_compressionListLow
Vector of item names.
ToolHandle< IAthenaOutputStreamTool > m_streamer
pointer to AthenaOutputStreamTool
ServiceHandle< MetaDataSvc > m_metaDataSvc
Handles to all the necessary services.
BooleanProperty m_itemListFromTool
Set to write out everything in input DataHeader.
StringProperty m_keepProvenances
Provenance record selection.
IDataSelector * selectedObjects()
Return the list of selected objects.
StringProperty m_outputName
Name of the output file.
virtual ~AthenaOutputStream()
Standard Destructor.
std::map< std::string, std::unique_ptr< IAthenaOutputStreamTool > > m_streamerMap
map of streamerTools handling event ranges in MT
std::map< unsigned, std::string > m_slotRangeMap
map of filenames assigned to active slots
virtual void handle(const Incident &incident) override
Incident service handle listening for MetaDataStop.
std::set< std::string > buildCompressionSet(const ToolHandle< SG::IFolder > &handle, const CLID &item_id, const std::string &item_key) const
Helper function for building the compression lists.
AthenaOutputStream(const std::string &name, ISvcLocator *pSvcLocator)
Standard algorithm Constructor.
ToolHandleArray< IAthenaOutputTool > m_helperTools
vector of AlgTools that that are executed by this stream
ToolHandle< SG::IFolder > m_compressionDecoderHigh
The top-level folder with items to be compressed high.
void clearSelection()
Clear list of selected objects.
StringArrayProperty m_itemList
Vector of item names.
ServiceHandle< IClassIDSvc > m_pCLIDSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
void handleVariableSelection(const SG::IConstAuxStore &auxstore, SG::DataProxy &itemProxy, const std::string &aux_attr, SG::SelectionVetoes &vetoes) const
Here we build the vetoed AuxIDs.
ServiceHandle< IDictLoaderSvc > m_dictLoader
StatusCode addItemObjects(const EventContext &, const SG::FolderItem &, SG::SelectionVetoes &vetoes, SG::CompressionInfo &compInfo)
Add item data objects to output streamer list.
void finalizeRange(const EventContext &ctx, const std::string &rangeFN)
IDataSelector m_altObjects
Objects overridden by `exact' handling.
void compressionListHandlerLow(Gaudi::Details::PropertyBase &)
Handler for ItemNames Property.
StringProperty m_persName
Name of the persistency service capable to write data from the store.
BooleanProperty m_forceRead
set to true to force read of data objects in item list
void loadDict(CLID clid)
Helper function to load dictionaries (both transient and persistent) for a given type.
virtual StatusCode execute(const EventContext &ctx) override
std::recursive_mutex mutex_t
ServiceHandle< ITPCnvSvc > m_tpCnvSvc
StatusCode collectAllObjects(const EventContext &ctx)
Collect data objects for output streamer list.
std::string m_outputAttributes
Output attributes.
StringArrayProperty m_compressionListHigh
Vector of item names.
ServiceHandle< StoreGateSvc > * m_currentStore
StringArrayProperty m_metadataItemList
Vector of item names.
std::vector< std::unique_ptr< DataObject > > m_ownedObjects
Collection of DataObject instances owned by this service.
ServiceHandle< OutputStreamSequencerSvc > m_outSeqSvc
std::map< std::string, std::string > m_rangeIDforRangeFN
map of RangeIDs (as used by the Sequencer) for each Range filename generated
ToolHandle< SG::IFolder > m_transient
Decoded list of transient ids.
ServiceHandle< StoreGateSvc > m_dataStore
Handle to the StoreGateSvc store where the data we want to write out resides.
virtual StatusCode initialize() override
mutex_t m_mutex
mutex for this Stream write() and handle() methods
virtual StatusCode io_reinit() override
Callback method to reinitialize the internal state of the component for I/O purposes (e....
SG::WriteHandleKey< SG::CompressionInfo > m_compInfoKey
Key used for recording lossy float compressed variable information to the event store.
bool simpleMatch(const std::string &pattern, const std::string &text)
Glob-style matcher, where the only meta-character is '*'.
void compressionListHandlerHigh(Gaudi::Details::PropertyBase &)
Handler for ItemNames Property.
SG::WriteHandleKey< SG::SelectionVetoes > m_selVetoesKey
Key used for recording selected dynamic variable information to the event store.
virtual StatusCode io_finalize() override
BooleanProperty m_extendProvenanceRecord
Set to false to omit adding the current DataHeader into the DataHeader history This will cause the in...
virtual StatusCode write(const EventContext &ctx)
Stream the data.
std::atomic< int > m_events
Number of events written to this output stream.
void writeMetaData(const EventContext &ctx, const std::string &outputFN="")
Write MetaData for this stream (by default) or for a substream outputFN (in ES mode).
void itemListHandler(Gaudi::Details::PropertyBase &)
Handler for ItemNames Property.
a Folder item (data object) is identified by the clid/key pair
Interface providing I/O for a generic auxiliary store.
Definition IAuxStoreIO.h:44
a run-time configurable list of data objects
Definition SGIFolder.h:21
Property holding a SG store/key/clid from which a WriteHandle is made.
Forward declaration.
std::unordered_map< std::string, SG::ThinningInfo::compression_map_t > CompressionInfo
Map of compressed variables and their compression levels.