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);
75 StatusCode write(const EventContext& ctx, StoreGateSvc& store);
76
78 void clearSelection();
79
81 StatusCode collectAllObjects(const EventContext& ctx, StoreGateSvc& store);
82
84 IDataSelector* selectedObjects() {
85 return &m_objects;
86 }
87
89 virtual void handle(const Incident& incident) override;
90
92 virtual StatusCode io_reinit() override;
93 virtual StatusCode io_finalize() override;
94
95protected:
98 ServiceHandle<StoreGateSvc> m_dataStore{this, "Store", "StoreGateSvc/StoreGateSvc", "Handle to event store"};
99 ServiceHandle<StoreGateSvc> m_metadataStore{this, "MetadataStore", "StoreGateSvc/MetaDataStore", "Handle to metadata store"};
100
102 ServiceHandle<MetaDataSvc> m_metaDataSvc{this, "MetaDataSvc", "MetaDataSvc"};
103 ServiceHandle<IDictLoaderSvc> m_dictLoader{this, "AthDictLoaderSvc", "AthDictLoaderSvc"};
104 ServiceHandle<ITPCnvSvc> m_tpCnvSvc{this, "AthTPCnvSvc", "AthTPCnvSvc"};
105 ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"};
106 ServiceHandle<IClassIDSvc> m_pCLIDSvc{this, "ClassIDSvc", "ClassIDSvc"};
107 ServiceHandle<OutputStreamSequencerSvc> m_outSeqSvc{this, "OutputStreamSequencerSvc", "OutputStreamSequencerSvc"};
108
110 StringProperty m_streamName{this, "StreamName", "", "Name of the output stream"};
111
113 StringArrayProperty m_itemList{this, "ItemList", {}, "List of items to write", "OutputStreamItemList"};
114
116 StringArrayProperty m_metadataItemList{this, "MetadataItemList", {}, "List of metadata items to write","OutputStreamItemList"};
117
119 StringProperty m_keepProvenances {this, "KeepProvenanceTagsRegEx", {".*"},
120 "RegEx pattern to select processing tags for which DataHeader should retain provenances"};
121
123 StringArrayProperty m_compressionListHigh{this, "CompressionListHigh", {}, "Lossy float compression list (high)"};
124
126 StringArrayProperty m_compressionListLow{this, "CompressionListLow", {}, "Lossy float compression list (low)"};
127
129 UnsignedIntegerProperty m_compressionBitsHigh{this, "CompressionBitsHigh", 7, "Lossy float compression bits (high)"};
130
132 UnsignedIntegerProperty m_compressionBitsLow{this, "CompressionBitsLow", 15, "Lossy float compression bits (low)"};
133
136 StringArrayProperty m_transientItems{this, "TransientItems", {}, "Transient item list"};
137
139 StringProperty m_outputName{this, "OutputFile", "DidNotNameOutput.root", "Name of the output file"};
140
142 StringProperty m_persName{this, "EvtConversionSvc", "EventPersistencySvc", "Name of the persistency service writing data"};
143
145 BooleanProperty m_forceRead{this, "ForceRead", true, "Force read data objects in ItemList"};
146
149 BooleanProperty m_extendProvenanceRecord{this, "ExtendProvenanceRecord", true, "Extend provenance record"};
150
152 BooleanProperty m_itemListFromTool{this, "TakeItemsFromInput", false, "Write everything in input DataHeader to output"};
153
155 ToolHandle<SG::IFolder> m_p2BWritten;
156
158 ToolHandle<SG::IFolder> m_compressionDecoderHigh;
159
161 ToolHandle<SG::IFolder> m_compressionDecoderLow;
162
164 ToolHandle<SG::IFolder> m_transient;
165
167 IDataSelector m_objects;
168
170 IDataSelector m_altObjects;
171
175 std::vector<std::unique_ptr<DataObject> > m_ownedObjects;
176
178 ToolHandle<IAthenaOutputStreamTool> m_streamer;
179
181 ToolHandleArray<IAthenaOutputTool> m_helperTools{this, "HelperTools", {}, "List of AlgTools used by this stream"};
182
183 // flag set by MetaDataStop if OutputSequencer is used with EndEvent
185
187 std::atomic<int> m_events{0};
188
189 // ------- Event Ranges handling in MT -------
191 std::map< unsigned, std::string > m_slotRangeMap;
192
194 std::map< std::string, std::string > m_rangeIDforRangeFN;
195
197 std::map< std::string, std::unique_ptr<IAthenaOutputStreamTool> > m_streamerMap;
198
201
203 void itemListHandler(Gaudi::Details::PropertyBase& /* theProp */);
204
206 void compressionListHandlerHigh(Gaudi::Details::PropertyBase& /* theProp */);
207
209 void compressionListHandlerLow(Gaudi::Details::PropertyBase& /* theProp */);
210
211private:
216
221
224
226 StatusCode addItemObjects(const EventContext&, StoreGateSvc& store, const SG::FolderItem&, SG::SelectionVetoes& vetoes, SG::CompressionInfo& compInfo);
227
228 void handleVariableSelection (const SG::IConstAuxStore& auxstore,
229 SG::DataProxy& itemProxy,
230 const std::string& aux_attr,
231 SG::SelectionVetoes& vetoes) const;
232
234 void writeMetaData( const EventContext& ctx, const std::string& outputFN="" );
235
237 std::set<std::string> buildCompressionSet (const ToolHandle<SG::IFolder>& handle,
238 const CLID& item_id,
239 const std::string& item_key) const;
240
241 // close an EventService substream that was writing to 'rangeFN' output
242 void finalizeRange( const EventContext& ctx, const std::string & rangeFN );
243
249 void loadDict (CLID clid);
250
252 bool simpleMatch(const std::string& pattern, const std::string& text);
253};
254
255#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
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
std::string m_outputAttributes
Output attributes.
StringArrayProperty m_compressionListHigh
Vector of item names.
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...
StatusCode addItemObjects(const EventContext &, StoreGateSvc &store, const SG::FolderItem &, SG::SelectionVetoes &vetoes, SG::CompressionInfo &compInfo)
Add item data objects to output streamer list.
virtual StatusCode write(const EventContext &ctx)
Stream the data from the event store.
StatusCode collectAllObjects(const EventContext &ctx, StoreGateSvc &store)
Collect data objects for output streamer list.
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.
The Athena Transient Store API.
Forward declaration.
std::unordered_map< std::string, SG::ThinningInfo::compression_map_t > CompressionInfo
Map of compressed variables and their compression levels.