ATLAS Offline Software
AthenaPoolCnvSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENAPOOLCNVSVC_ATHENAPOOLCNVSVC_H
6 #define ATHENAPOOLCNVSVC_ATHENAPOOLCNVSVC_H
7 
14 
15 #include "GaudiKernel/IClassIDSvc.h"
16 #include "GaudiKernel/IIncidentListener.h"
17 #include "GaudiKernel/IIoComponent.h"
18 #include "GaudiKernel/ServiceHandle.h"
19 #include "GaudiKernel/ToolHandle.h"
20 
21 #include "StorageSvc/DbType.h"
25 #include "PoolSvc/IPoolSvc.h"
26 
27 #include <vector>
28 #include <map>
29 #include <mutex>
30 #include <limits>
31 
32 // Forward declarations
33 class Guid;
34 
35 template <class TYPE> class SvcFactory;
36 
40 class AthenaPoolCnvSvc : public extends<AthCnvSvc,
41  IAthenaPoolCnvSvc,
42  IIncidentListener,
43  IIoComponent> {
44  // Allow the factory class access to the constructor
45  friend class SvcFactory<AthenaPoolCnvSvc>;
46 
47 public:
48 
50  virtual StatusCode initialize() override;
51  virtual StatusCode io_reinit() override;
53  virtual StatusCode finalize() override;
54  virtual StatusCode io_finalize() override;
55  virtual StatusCode stop() override;
56 
60  virtual StatusCode createObj(IOpaqueAddress* pAddress, DataObject*& refpObject) override;
61 
65  virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress) override;
66 
70  virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
71 
75  virtual StatusCode connectOutput(const std::string& outputConnectionSpec,
76  const std::string& openMode) override;
77 
81  virtual StatusCode connectOutput(const std::string& outputConnectionSpec) override;
82 
85  virtual StatusCode commitOutput(const std::string& outputConnectionSpec, bool doCommit) override;
86 
88  virtual StatusCode disconnectOutput(const std::string& outputConnectionSpec) override;
89 
91  virtual IPoolSvc* getPoolSvc() override;
92 
97  virtual Token* registerForWrite(Placement* placement, const void* obj, const RootType& classDesc) override;
98 
101  virtual void setObjPtr(void*& obj, const Token* token) override;
102 
104  virtual bool useDetailChronoStat() const override;
105 
112  StatusCode createAddress(long svcType,
113  const CLID& clid,
114  const std::string* par,
115  const unsigned long* ip,
116  IOpaqueAddress*& refpAddress) override;
117 
123  virtual StatusCode createAddress(long svcType,
124  const CLID& clid,
125  const std::string& refAddress,
126  IOpaqueAddress*& refpAddress) override;
127 
131  virtual StatusCode convertAddress(const IOpaqueAddress* pAddress, std::string& refAddress) override;
132 
135  virtual StatusCode decodeOutputSpec(std::string& connectionSpec, int& outputTech) const override;
136 
138  virtual StatusCode registerCleanUp(IAthenaPoolCleanUp* cnv) override;
139 
141  virtual StatusCode cleanUp(const std::string& connection) override;
142 
145  virtual StatusCode setInputAttributes(const std::string& fileName) override;
146 
148  virtual void handle(const Incident& incident) override;
149 
151  void flushDataHeaderForms(const std::string& streamName = "*");
152 
154  AthenaPoolCnvSvc(const std::string& name, ISvcLocator* pSvcLocator);
156  virtual ~AthenaPoolCnvSvc() = default;
157 
158 private: // member functions
160  void extractPoolAttributes(const StringArrayProperty& property,
161  std::vector<std::vector<std::string> >* contAttr,
162  std::vector<std::vector<std::string> >* dbAttr,
163  std::vector<std::vector<std::string> >* domAttr = 0) const;
164 
166  StatusCode processPoolAttributes(std::vector<std::vector<std::string> >& attr,
167  const std::string& fileName,
168  unsigned long contextId,
169  bool doGet = true,
170  bool doSet = true,
171  bool doClear = true) const;
172 
173 private: // data
176  std::string m_lastInputFileName;
177  ServiceHandle<IPoolSvc> m_poolSvc{this,"PoolSvc","PoolSvc"};
178  ServiceHandle<IClassIDSvc> m_clidSvc{this,"ClassIDSvc","ClassIDSvc"};
179 
180 protected: // shared with derived services
183 
184 private: // properties
187  BooleanProperty m_useDetailChronoStat{this,"UseDetailChronoStat",false};
188 
190  StringProperty m_storageTechProp{this,"StorageTechnology", "ROOTTREEINDEX"};
193  StringProperty m_containerPrefixProp{this,"PoolContainerPrefix","Default"};
195  StringProperty m_containerNameHintProp{this,"TopLevelContainerName",""};
197  StringProperty m_branchNameHintProp{this,"SubLevelBranchName", "<type>/<key>"};
198 
200  StringArrayProperty m_poolAttr{this,"PoolAttributes",{},"Pool Attributes","OrderedSet<std::string>"};
201  std::vector<std::vector<std::string> > m_domainAttr;
202  std::vector<std::vector<std::string> > m_databaseAttr;
203  std::vector<std::vector<std::string> > m_containerAttr;
204  std::vector<unsigned int> m_contextAttr;
205  std::map<std::string, int> m_fileCommitCounter;
206  std::map<std::string, int> m_fileFlushSetting;
208  StringArrayProperty m_inputPoolAttr{this,"InputPoolAttributes",{}};
209  std::vector<std::vector<std::string> > m_inputAttr;
212  StringArrayProperty m_inputPoolAttrPerEvent{this,"PrintInputAttrPerEvt",{}};
213  std::vector<std::vector<std::string> > m_inputAttrPerEvent;
214 
216  StringArrayProperty m_maxFileSizes{this,"MaxFileSizes",{}};
218  std::map<std::string, long long> m_databaseMaxFileSize;
219 
220 protected: // properties
223  BooleanProperty m_persSvcPerOutput{this,"PersSvcPerOutput",true};
224  unsigned outputContextId(const std::string& outputConnection);
225 
228  StringProperty m_persSvcPerInputType{this,"PersSvcPerInputType",""};
230 
233  IntegerProperty m_numberEventsPerWrite{this,"NumberEventsPerWrite",-1};
234 
236  BooleanProperty m_oneDataHeaderForm { this, "OneDataHeaderForm", false };
238  IntegerProperty m_DHFormCacheSize { this, "maxDHFormCacheSize", 100 };
240  BooleanProperty m_DHFilterAliases { this, "doFilterDHAliases", true };
241 
242 };
243 
244 #endif
AthenaPoolCnvSvc::m_poolSvc
ServiceHandle< IPoolSvc > m_poolSvc
Definition: AthenaPoolCnvSvc.h:177
AthenaPoolCnvSvc::m_contextAttr
std::vector< unsigned int > m_contextAttr
Definition: AthenaPoolCnvSvc.h:204
AthenaPoolCnvSvc::registerCleanUp
virtual StatusCode registerCleanUp(IAthenaPoolCleanUp *cnv) override
Implement registerCleanUp to register a IAthenaPoolCleanUp to be called during cleanUp.
Definition: AthenaPoolCnvSvc.cxx:511
AthenaPoolCnvSvc::createAddress
StatusCode createAddress(long svcType, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
Create a Generic address using explicit arguments to identify a single object.
Definition: AthenaPoolCnvSvc.cxx:440
AthenaPoolCnvSvc::cleanUp
virtual StatusCode cleanUp(const std::string &connection) override
Implement cleanUp to call all registered IAthenaPoolCleanUp cleanUp() function.
Definition: AthenaPoolCnvSvc.cxx:516
Placement
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition: Placement.h:19
IPoolSvc
This class provides the interface to the LCG POOL persistency software.
Definition: IPoolSvc.h:35
IAthenaPoolCnvSvc.h
This file contains the class definition for the IAthenaPoolCnvSvc interface class.
AthenaPoolCnvSvc::initialize
virtual StatusCode initialize() override
Required of all Gaudi Services.
Definition: AthenaPoolCnvSvc.cxx:33
AthenaPoolCnvSvc::outputContextId
unsigned outputContextId(const std::string &outputConnection)
Definition: AthenaPoolCnvSvc.cxx:403
PMonUtils::BasicStopWatchResultMap_t
tbb::concurrent_hash_map< std::string, double > BasicStopWatchResultMap_t
Definition: BasicStopWatch.h:15
AthenaPoolCnvSvc::m_clidSvc
ServiceHandle< IClassIDSvc > m_clidSvc
Definition: AthenaPoolCnvSvc.h:178
AthenaPoolCnvSvc::m_useDetailChronoStat
BooleanProperty m_useDetailChronoStat
UseDetailChronoStat, enable detailed output for time and size statistics for AthenaPOOL: default = fa...
Definition: AthenaPoolCnvSvc.h:187
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
SvcFactory
Definition: AthCnvSvc.h:28
AthenaPoolCnvSvc::m_domainMaxFileSize
long long m_domainMaxFileSize
Definition: AthenaPoolCnvSvc.h:217
AthenaPoolCnvSvc::m_inputAttrPerEvent
std::vector< std::vector< std::string > > m_inputAttrPerEvent
Definition: AthenaPoolCnvSvc.h:213
AthenaPoolCnvSvc::decodeOutputSpec
virtual StatusCode decodeOutputSpec(std::string &connectionSpec, int &outputTech) const override
Extract/deduce the DB technology from the connection string/file specification.
Definition: AthenaPoolCnvSvc.cxx:490
IAthenaPoolCleanUp
This class provides the interface for the AthenaPoolCleanUp which is used to clean up AthenaPoolConve...
Definition: IAthenaPoolCleanUp.h:19
AthCnvSvc.h
AthenaPoolCnvSvc::m_databaseAttr
std::vector< std::vector< std::string > > m_databaseAttr
Definition: AthenaPoolCnvSvc.h:202
AthenaPoolCnvSvc::m_chronoMap
PMonUtils::BasicStopWatchResultMap_t m_chronoMap
Map that holds chrono information.
Definition: AthenaPoolCnvSvc.h:182
AthenaPoolCnvSvc::fillRepRefs
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConversionSvc: Resolve the references of the converted object.
Definition: AthenaPoolCnvSvc.cxx:218
AthenaPoolCnvSvc::m_dbType
pool::DbType m_dbType
decoded storage tech requested in "StorageTechnology" property
Definition: AthenaPoolCnvSvc.h:175
AthenaPoolCnvSvc::useDetailChronoStat
virtual bool useDetailChronoStat() const override
Definition: AthenaPoolCnvSvc.cxx:436
AthenaPoolCnvSvc::m_mutex
std::mutex m_mutex
Definition: AthenaPoolCnvSvc.h:229
DbType.h
AthenaPoolCnvSvc::setObjPtr
virtual void setObjPtr(void *&obj, const Token *token) override
Definition: AthenaPoolCnvSvc.cxx:426
AthenaPoolCnvSvc::AthenaPoolCnvSvc
AthenaPoolCnvSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition: AthenaPoolCnvSvc.cxx:567
AthenaPoolCnvSvc::getPoolSvc
virtual IPoolSvc * getPoolSvc() override
Definition: AthenaPoolCnvSvc.cxx:409
AthenaPoolCnvSvc::processPoolAttributes
StatusCode processPoolAttributes(std::vector< std::vector< std::string > > &attr, const std::string &fileName, unsigned long contextId, bool doGet=true, bool doSet=true, bool doClear=true) const
Set/get technology dependent POOL attributes.
Definition: AthenaPoolCnvSvc.cxx:627
AthenaPoolCnvSvc::flushDataHeaderForms
void flushDataHeaderForms(const std::string &streamName="*")
Tell DataHeaderCnv to write out all DataHeaderForms for a given streamName (default is all)
Definition: AthenaPoolCnvSvc.cxx:103
AthenaPoolCnvSvc::m_fileFlushSetting
std::map< std::string, int > m_fileFlushSetting
Definition: AthenaPoolCnvSvc.h:206
AthenaPoolCnvSvc::m_oneDataHeaderForm
BooleanProperty m_oneDataHeaderForm
If true, use only one DataHeaderForm per Stream.
Definition: AthenaPoolCnvSvc.h:236
AthenaPoolCnvSvc::io_reinit
virtual StatusCode io_reinit() override
Definition: AthenaPoolCnvSvc.cxx:97
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
AthenaPoolCnvSvc::registerForWrite
virtual Token * registerForWrite(Placement *placement, const void *obj, const RootType &classDesc) override
Definition: AthenaPoolCnvSvc.cxx:413
AthenaPoolCnvSvc::m_persSvcPerInputType
StringProperty m_persSvcPerInputType
PersSvcPerInputType, string property, tree name to use multiple persistency services,...
Definition: AthenaPoolCnvSvc.h:228
AthenaPoolCnvSvc::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConversionSvc: Create the transient representation of an object from persistent st...
Definition: AthenaPoolCnvSvc.cxx:151
AthenaPoolCnvSvc::m_storageTechProp
StringProperty m_storageTechProp
Default Storage Tech for containers (ROOTTREE, ROOTTREEINDEX, ROOTRNTUPLE)
Definition: AthenaPoolCnvSvc.h:190
AthenaPoolCnvSvc::extractPoolAttributes
void extractPoolAttributes(const StringArrayProperty &property, std::vector< std::vector< std::string > > *contAttr, std::vector< std::vector< std::string > > *dbAttr, std::vector< std::vector< std::string > > *domAttr=0) const
Extract POOL ItechnologySpecificAttributes for Domain, Database and Container from property.
Definition: AthenaPoolCnvSvc.cxx:571
AthenaPoolCnvSvc::handle
virtual void handle(const Incident &incident) override
Implementation of IIncidentListener: Handle for EndEvent incidence.
Definition: AthenaPoolCnvSvc.cxx:559
AthenaPoolCnvSvc::~AthenaPoolCnvSvc
virtual ~AthenaPoolCnvSvc()=default
Destructor.
BasicStopWatch.h
pool::DbType
Definition: DbType.h:31
AthenaPoolCnvSvc::setInputAttributes
virtual StatusCode setInputAttributes(const std::string &fileName) override
Set the input file attributes, if any are requested from jobOpts.
Definition: AthenaPoolCnvSvc.cxx:537
AthenaPoolCnvSvc::finalize
virtual StatusCode finalize() override
Required of all Gaudi Services.
Definition: AthenaPoolCnvSvc.cxx:117
AthenaPoolCnvSvc::m_maxFileSizes
StringArrayProperty m_maxFileSizes
MaxFileSizes, vector with maximum file sizes for Athena POOL output files.
Definition: AthenaPoolCnvSvc.h:216
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthenaPoolCnvSvc::m_DHFilterAliases
BooleanProperty m_DHFilterAliases
Flag to control SG alias filtering when writing out DataHeader (see DataHeaderCnv_p6)
Definition: AthenaPoolCnvSvc.h:240
AthenaPoolCnvSvc::m_inputAttr
std::vector< std::vector< std::string > > m_inputAttr
Definition: AthenaPoolCnvSvc.h:209
AthenaPoolCnvSvc::m_databaseMaxFileSize
std::map< std::string, long long > m_databaseMaxFileSize
Definition: AthenaPoolCnvSvc.h:218
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
AthenaPoolCnvSvc::io_finalize
virtual StatusCode io_finalize() override
Definition: AthenaPoolCnvSvc.cxx:146
AthenaPoolCnvSvc::m_numberEventsPerWrite
IntegerProperty m_numberEventsPerWrite
To use MetadataSvc to merge data placed in a certain container When using TMemFile call Write on numb...
Definition: AthenaPoolCnvSvc.h:233
AthenaPoolCnvSvc::convertAddress
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert address to string form.
Definition: AthenaPoolCnvSvc.cxx:478
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
AthenaPoolCnvSvc::disconnectOutput
virtual StatusCode disconnectOutput(const std::string &outputConnectionSpec) override
Disconnect to the output connection.
Definition: AthenaPoolCnvSvc.cxx:395
AthenaPoolCnvSvc::m_containerAttr
std::vector< std::vector< std::string > > m_containerAttr
Definition: AthenaPoolCnvSvc.h:203
AthenaPoolCnvSvc::commitOutput
virtual StatusCode commitOutput(const std::string &outputConnectionSpec, bool doCommit) override
Implementation of IConversionSvc: Commit pending output.
Definition: AthenaPoolCnvSvc.cxx:329
WriteHiveWithMetaData.streamName
string streamName
Definition: WriteHiveWithMetaData.py:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:28
AthenaPoolCnvSvc::m_persSvcPerOutput
BooleanProperty m_persSvcPerOutput
PersSvcPerOutput, boolean property to use multiple persistency services, one per output stream.
Definition: AthenaPoolCnvSvc.h:223
AthenaPoolCnvSvc::createRep
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConversionSvc: Convert the transient object to the requested representation.
Definition: AthenaPoolCnvSvc.cxx:185
AthenaPoolCnvSvc::m_inputPoolAttr
StringArrayProperty m_inputPoolAttr
Input PoolAttributes, vector with names and values of technology specific attributes for POOL.
Definition: AthenaPoolCnvSvc.h:208
IPoolSvc.h
This file contains the class definition for the IPoolSvc interface class.
AthenaPoolCnvSvc::m_domainAttr
std::vector< std::vector< std::string > > m_domainAttr
Definition: AthenaPoolCnvSvc.h:201
AthenaPoolCnvSvc::m_fileCommitCounter
std::map< std::string, int > m_fileCommitCounter
Definition: AthenaPoolCnvSvc.h:205
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
AthenaPoolCnvSvc::m_branchNameHintProp
StringProperty m_branchNameHintProp
SubLevelBranchName, naming hint policy for POOL branching: ("" = no branching)
Definition: AthenaPoolCnvSvc.h:197
AthenaPoolCnvSvc::connectOutput
virtual StatusCode connectOutput(const std::string &outputConnectionSpec, const std::string &openMode) override
Implementation of IConversionSvc: Connect to the output connection specification with open mode.
Definition: AthenaPoolCnvSvc.cxx:251
AthenaPoolCnvSvc::m_containerNameHintProp
StringProperty m_containerNameHintProp
TopLevelContainerName, naming hint policy for top level POOL container: default = "<type>".
Definition: AthenaPoolCnvSvc.h:195
AthenaPoolCnvSvc::m_poolAttr
StringArrayProperty m_poolAttr
Output PoolAttributes, vector with names and values of technology specific attributes for POOL.
Definition: AthenaPoolCnvSvc.h:200
AthenaPoolCnvSvc::m_inputPoolAttrPerEvent
StringArrayProperty m_inputPoolAttrPerEvent
Print input PoolAttributes per event, vector with names of technology specific attributes for POOL to...
Definition: AthenaPoolCnvSvc.h:212
AthenaPoolCnvSvc::m_DHFormCacheSize
IntegerProperty m_DHFormCacheSize
Property for DataHeaderCnv input DHForm cache size.
Definition: AthenaPoolCnvSvc.h:238
AthenaPoolCnvSvc::stop
virtual StatusCode stop() override
Definition: AthenaPoolCnvSvc.cxx:110
jobOptions.fileName
fileName
Definition: jobOptions.SuperChic_ALP2.py:39
AthenaPoolCnvSvc::m_containerPrefixProp
StringProperty m_containerPrefixProp
POOL Container name prefix - will be part of or whole TTree/RNTuple name 'Default' takes the prefix f...
Definition: AthenaPoolCnvSvc.h:193
python.PyAthena.obj
obj
Definition: PyAthena.py:132
AthenaPoolCnvSvc::m_lastInputFileName
std::string m_lastInputFileName
Definition: AthenaPoolCnvSvc.h:176
IAthenaIPCTool.h
ServiceHandle< IPoolSvc >
TScopeAdapter
Definition: RootType.h:119
AthenaPoolCnvSvc
Definition: Database/AthenaPOOL/AthenaPoolCnvSvc/AthenaPoolCnvSvc/debug.h:26