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-2025 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:
58 typedef std::vector<SG::DataProxy*> Items;
59 typedef std::vector<std::pair<std::string, std::string> > TypeKeyPairs;
60 typedef std::recursive_mutex mutex_t;
61
63 AthenaOutputStream(const std::string& name, ISvcLocator* pSvcLocator);
64
66 virtual ~AthenaOutputStream();
67
69
70 virtual StatusCode initialize() override;
71 virtual StatusCode finalize() override;
72 virtual StatusCode execute() override;
74
76 virtual StatusCode write();
77
79 void clearSelection();
80
82 StatusCode collectAllObjects();
83
85 IDataSelector* selectedObjects() {
86 return &m_objects;
87 }
88
90 virtual void handle(const Incident& incident) override;
91
93 virtual StatusCode io_reinit() override;
94 virtual StatusCode io_finalize() override;
95
96protected:
99 ServiceHandle<StoreGateSvc> m_dataStore{this, "Store", "StoreGateSvc/StoreGateSvc", "Handle to event store"};
100 ServiceHandle<StoreGateSvc> m_metadataStore{this, "MetadataStore", "StoreGateSvc/MetaDataStore", "Handle to metadata store"};
102
104 ServiceHandle<MetaDataSvc> m_metaDataSvc{this, "MetaDataSvc", "MetaDataSvc"};
105 ServiceHandle<IDictLoaderSvc> m_dictLoader{this, "AthDictLoaderSvc", "AthDictLoaderSvc"};
106 ServiceHandle<ITPCnvSvc> m_tpCnvSvc{this, "AthTPCnvSvc", "AthTPCnvSvc"};
107 ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"};
108 ServiceHandle<IClassIDSvc> m_pCLIDSvc{this, "ClassIDSvc", "ClassIDSvc"};
109 ServiceHandle<OutputStreamSequencerSvc> m_outSeqSvc{this, "OutputStreamSequencerSvc", "OutputStreamSequencerSvc"};
110
112 StringProperty m_streamName{this, "StreamName", "", "Name of the output stream"};
113
115 StringArrayProperty m_itemList{this, "ItemList", {}, "List of items to write", "OutputStreamItemList"};
116
118 StringArrayProperty m_metadataItemList{this, "MetadataItemList", {}, "List of metadata items to write","OutputStreamItemList"};
119
121 StringProperty m_keepProvenances {this, "KeepProvenanceTagsRegEx", {".*"},
122 "RegEx pattern to select processing tags for which DataHeader should retain provenances"};
123
125 StringArrayProperty m_compressionListHigh{this, "CompressionListHigh", {}, "Lossy float compression list (high)"};
126
128 StringArrayProperty m_compressionListLow{this, "CompressionListLow", {}, "Lossy float compression list (low)"};
129
131 UnsignedIntegerProperty m_compressionBitsHigh{this, "CompressionBitsHigh", 7, "Lossy float compression bits (high)"};
132
134 UnsignedIntegerProperty m_compressionBitsLow{this, "CompressionBitsLow", 15, "Lossy float compression bits (low)"};
135
138 StringArrayProperty m_transientItems{this, "TransientItems", {}, "Transient item list"};
139
141 StringProperty m_outputName{this, "OutputFile", "DidNotNameOutput.root", "Name of the output file"};
142
144 StringProperty m_persName{this, "EvtConversionSvc", "EventPersistencySvc", "Name of the persistency service writing data"};
145
147 BooleanProperty m_forceRead{this, "ForceRead", true, "Force read data objects in ItemList"};
148
151 BooleanProperty m_extendProvenanceRecord{this, "ExtendProvenanceRecord", true, "Extend provenance record"};
152
154 BooleanProperty m_itemListFromTool{this, "TakeItemsFromInput", false, "Write everything in input DataHeader to output"};
155
157 ToolHandle<SG::IFolder> m_p2BWritten;
158
160 ToolHandle<SG::IFolder> m_compressionDecoderHigh;
161
163 ToolHandle<SG::IFolder> m_compressionDecoderLow;
164
166 ToolHandle<SG::IFolder> m_transient;
167
169 std::multimap<CLID,std::string> m_CLIDKeyPairs;
170
172 IDataSelector m_objects;
173
175 IDataSelector m_altObjects;
176
180 std::vector<std::unique_ptr<DataObject> > m_ownedObjects;
181
183 ToolHandle<IAthenaOutputStreamTool> m_streamer;
184
186 ToolHandleArray<IAthenaOutputTool> m_helperTools{this, "HelperTools", {}, "List of AlgTools used by this stream"};
187
188 // flag set by MetaDataStop if OutputSequencer is used with EndEvent
190
192 std::atomic<int> m_events{0};
193
194 // ------- Event Ranges handling in MT -------
196 std::map< unsigned, std::string > m_slotRangeMap;
197
199 std::map< std::string, std::string > m_rangeIDforRangeFN;
200
202 std::map< std::string, std::unique_ptr<IAthenaOutputStreamTool> > m_streamerMap;
203
206
208 void itemListHandler(Gaudi::Details::PropertyBase& /* theProp */);
209
211 void excludeListHandler(Gaudi::Details::PropertyBase& /* theProp */);
212
214 void compressionListHandlerHigh(Gaudi::Details::PropertyBase& /* theProp */);
215
217 void compressionListHandlerLow(Gaudi::Details::PropertyBase& /* theProp */);
218
219private:
224
229
232
234 StatusCode addItemObjects(const SG::FolderItem&, SG::SelectionVetoes& vetoes, SG::CompressionInfo& compInfo);
235
236 void handleVariableSelection (const SG::IConstAuxStore& auxstore,
237 SG::DataProxy& itemProxy,
238 const std::string& aux_attr,
239 SG::SelectionVetoes& vetoes) const;
240
242 void writeMetaData( const std::string& outputFN="" );
243
245 std::set<std::string> buildCompressionSet (const ToolHandle<SG::IFolder>& handle,
246 const CLID& item_id,
247 const std::string& item_key) const;
248
249 // close an EventService substream that was writing to 'rangeFN' output
250 void finalizeRange( const std::string & rangeFN );
251
257 void loadDict (CLID clid);
258
260 bool simpleMatch(const std::string& pattern, const std::string& text);
261};
262
263#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.
void excludeListHandler(Gaudi::Details::PropertyBase &)
Handler for ItemNames Property.
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
std::vector< std::pair< std::string, std::string > > TypeKeyPairs
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.
std::vector< SG::DataProxy * > Items
typedefs
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
IDataSelector m_altObjects
Objects overridden by ‘exact’ handling.
void compressionListHandlerLow(Gaudi::Details::PropertyBase &)
Handler for ItemNames Property.
StatusCode addItemObjects(const SG::FolderItem &, SG::SelectionVetoes &vetoes, SG::CompressionInfo &compInfo)
Add item data objects to output streamer list.
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.
std::recursive_mutex mutex_t
ServiceHandle< ITPCnvSvc > m_tpCnvSvc
std::multimap< CLID, std::string > m_CLIDKeyPairs
Map of (clid,key) pairs to be excluded (comes from m_excludeList)
StatusCode collectAllObjects()
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 execute() override
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
virtual StatusCode write()
Stream the data.
BooleanProperty m_extendProvenanceRecord
Set to false to omit adding the current DataHeader into the DataHeader history This will cause the in...
void finalizeRange(const std::string &rangeFN)
std::atomic< int > m_events
Number of events written to this output stream.
void itemListHandler(Gaudi::Details::PropertyBase &)
Handler for ItemNames Property.
void writeMetaData(const std::string &outputFN="")
Write MetaData for this stream (by default) or for a substream outputFN (in ES mode)
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
Interface for const operations on an auxiliary store.
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::auxid_set_t > SelectionVetoes
Map of vetoed variables.
std::unordered_map< std::string, SG::ThinningInfo::compression_map_t > CompressionInfo
Map of compressed variables and their compression levels.