ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaOutputStreamTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATHENAOUTPUTSTREAMTOOL_H
6#define ATHENAOUTPUTSTREAMTOOL_H
11
12#include "GaudiKernel/IConversionSvc.h"
13#include "GaudiKernel/ServiceHandle.h"
14
18
19#include <string>
20#include <map>
21#include <regex>
22
23class IClassIDSvc;
24class IDecisionSvc;
25class StoreGateSvc;
26class DataHeader;
27namespace SG {
28 class IFolder;
29}
30
34class AthenaOutputStreamTool : public extends<::AthAlgTool, IAthenaOutputStreamTool> {
35public:
37 AthenaOutputStreamTool(const std::string& type,
38 const std::string& name,
39 const IInterface* parent);
40
42 virtual StatusCode initialize() override;
43
47 StatusCode connectServices(const std::string& dataStore,
48 const std::string& cnvSvc,
49 bool extendProvenenceRecord) override;
50
54 StatusCode connectOutput(const std::string& outputName = "") override;
55
58 StatusCode commitOutput(bool doCommit = false) override;
59
62 StatusCode finalizeOutput() override;
63
67 typedef std::pair<std::string, std::string> TypeKeyPair;
68 typedef std::vector<TypeKeyPair> TypeKeyPairs;
69 virtual StatusCode streamObjects(const TypeKeyPairs& typeKeys, const std::string& outputName = "") override;
70
76 typedef std::vector<DataObject*> DataObjectVec;
77 virtual StatusCode streamObjects(const DataObjectVec& dataObjects, const std::string& outputName = "") override;
78
79 virtual StatusCode getInputItemList(SG::IFolder* m_p2BWrittenFromTool) override;
80
81private:
83 StatusCode connectServices();
85 void propagateProvenance( const DataHeader& src_dh );
86
87private:
88 StringProperty m_outputName{ this, "OutputFile", "", "name of the output db name"};
89 StringProperty m_dataHeaderKey{ this, "DataHeaderKey", "", "name of the data header key: defaults to tool name"};
90 StringProperty m_processTag{ this, "ProcessingTag", "", "tag of processing stage: defaults to SG key of DataHeader (Stream name)"};
91 StringProperty m_outputCollection{ this, "OutputCollection", "", "custom container name prefix for DataHeader: default = "" (will result in \"POOLContainer_\")"};
92 StringProperty m_containerPrefix{ this, "PoolContainerPrefix", "", "prefix for top level POOL container: default = \"CollectionTree\""};
93 StringProperty m_containerNameHint{ this, "TopLevelContainerName", "0", "naming hint policy for top level POOL container: default = \"0\""};
94 StringProperty m_metaDataOutputCollection{ this, "MetaDataOutputCollection", "", "custom container name prefix for MetaDataHeader: default = "" (will result in \"MetaDataHdr\")"};
95 StringProperty m_metaDataContainerPrefix{ this, "MetaDataPoolContainerPrefix", "", "prefix for top level MetaData container: default = "" (will result in \"MetaData\")"};
96 StringProperty m_branchNameHint{ this, "SubLevelBranchName", "0", "naming hint policy for POOL branching: default = \"0\"" };
97 BooleanProperty m_extend{ this, "SaveDecisions", false, "Set to true to add streaming decisions to an attributeList"};
98
99 std::string m_outputAttributes;
101 SG::ReadHandleKey<AthenaAttributeList> m_attrListKey{this, "AttributeListKey", "", "optional key for AttributeList to be written as part of the DataHeader: default = \"\""};
102 //SG::WriteHandleKey<AthenaAttributeList> m_attrListWrite{this, "AttributeListWrite", "", "optional key for AttributeList to be written as part of the DataHeader: default = <AttributeListKey>+\"Decisions\""};
103 std::string m_attrListWrite{""};
104
105 ServiceHandle<StoreGateSvc> m_store{ this, "Store", "StoreGateSvc/DetectorStore", "Pointer to the data store"};
107 ServiceHandle<IConversionSvc> m_conversionSvc{ this, "ConversionService", "AthenaPoolCnvSvc" };
115 bool m_connectionOpen{false};
116
124 std::map<std::string, bool> m_keepProvenanceMatch;
125
127 std::set<std::string> m_skippedItems;
128};
129
130#endif
Interface to an output stream tool.
An AttributeList represents a logical row of attributes in a metadata table.
StringProperty m_metaDataContainerPrefix
std::map< std::string, bool > m_keepProvenanceMatch
Cache provenance RegEx matching result in a map.
StatusCode finalizeOutput() override
Finalize the output stream after the last commit, e.g.
AthenaOutputStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard AlgTool Constructor.
std::set< std::string > m_skippedItems
set of skipped item keys, because of missing CLID
bool m_extendProvenanceRecord
Flag as to whether to extend provenance via the DataHeader.
DataHeader * m_dataHeader
Current DataHeader for streamed objects.
std::vector< DataObject * > DataObjectVec
Stream out a vector of objects Must convert to DataObject, e.g.
StatusCode connectOutput(const std::string &outputName="") override
Connect to the output stream Must connectOutput BEFORE streaming Only specify "outputName" if one wan...
ServiceHandle< IDecisionSvc > m_decSvc
Ref to DecisionSvc.
ServiceHandle< IClassIDSvc > m_clidSvc
Ref to ClassIDSvc to convert type name to clid.
std::vector< TypeKeyPair > TypeKeyPairs
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
virtual StatusCode streamObjects(const TypeKeyPairs &typeKeys, const std::string &outputName="") override
bool m_connectionOpen
Flag to tell whether connectOutput has been called.
ServiceHandle< IConversionSvc > m_conversionSvc
Keep reference to the data conversion service.
std::regex m_keepProvenancesRE
RegEx pattern created from m_keepProvenancesStr.
StatusCode connectServices()
Do the real connection to services.
void propagateProvenance(const DataHeader &src_dh)
copy provenance records when creating new DataHeaders
ServiceHandle< StoreGateSvc > m_store
virtual StatusCode initialize() override
AthAlgTool Interface method implementations:
virtual StatusCode getInputItemList(SG::IFolder *m_p2BWrittenFromTool) override
std::string m_keepProvenancesStr
RegEx string to match provenance tags to keep in the output DataHeader. Retrieved from an OutputStrea...
SG::ReadHandleKey< AthenaAttributeList > m_attrListKey
StatusCode commitOutput(bool doCommit=false) override
Commit the output stream after having streamed out objects Must commitOutput AFTER streaming.
StringProperty m_metaDataOutputCollection
This class provides the layout for summary information stored for data written to POOL.
Definition DataHeader.h:123
This class defines a protocol to register boolean decisions and.
a run-time configurable list of data objects
Definition SGIFolder.h:21
Property holding a SG store/key/clid from which a ReadHandle is made.
The Athena Transient Store API.
Forward declaration.