ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaPoolCnvSvc Class Reference

This class provides the interface between Athena and PoolSvc. More...

#include <AthenaPoolCnvSvc.h>

Inheritance diagram for AthenaPoolCnvSvc:
Collaboration diagram for AthenaPoolCnvSvc:

Public Member Functions

virtual StatusCode initialize () override
 Required of all Gaudi Services.
virtual StatusCode io_reinit () override
virtual StatusCode finalize () override
 Required of all Gaudi Services.
virtual StatusCode io_finalize () override
virtual StatusCode stop () override
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Implementation of IConversionSvc: Create the transient representation of an object from persistent state.
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Implementation of IConversionSvc: Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConversionSvc: Resolve the references of the converted object.
virtual StatusCode connectOutput (const std::string &outputConnectionSpec, const std::string &openMode) override
 Implementation of IConversionSvc: Connect to the output connection specification with open mode.
virtual StatusCode connectOutput (const std::string &outputConnectionSpec) override
 Implementation of IConversionSvc: Connect to the output connection specification with open mode.
virtual StatusCode commitOutput (const std::string &outputConnectionSpec, bool doCommit) override
 Implementation of IConversionSvc: Commit pending output.
virtual StatusCode disconnectOutput (const std::string &outputConnectionSpec) override
 Disconnect to the output connection.
virtual IPoolSvcgetPoolSvc () override
virtual TokenregisterForWrite (Placement *placement, const void *obj, const RootType &classDesc) override
virtual void setObjPtr (void *&obj, const Token *token) override
virtual bool useDetailChronoStat () const override
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.
virtual StatusCode createAddress (long svcType, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
 Create address from string form.
virtual StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress) override
 Convert address to string form.
virtual StatusCode registerCleanUp (IAthenaPoolCleanUp *cnv) override
 Implement registerCleanUp to register a IAthenaPoolCleanUp to be called during cleanUp.
virtual StatusCode cleanUp (const std::string &connection) override
 Implement cleanUp to call all registered IAthenaPoolCleanUp cleanUp() function.
virtual StatusCode setInputAttributes (const std::string &fileName) override
 Set the input file attributes, if any are requested from jobOpts.
virtual void handle (const Incident &incident) override
 Implementation of IIncidentListener: Handle for EndEvent incidence.
void flushDataHeaderForms (const std::string &streamName="*")
 Tell DataHeaderCnv to write out all DataHeaderForms for a given streamName (default is all).
 AthenaPoolCnvSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Standard Service Constructor.
virtual ~AthenaPoolCnvSvc ()=default
 Destructor.

Protected Member Functions

unsigned outputContextId (const std::string &outputConnection)

Protected Attributes

PMonUtils::BasicStopWatchResultMap_t m_chronoMap {}
 Map that holds chrono information.
Gaudi::Property< bool > m_persSvcPerOutput {this,"PersSvcPerOutput",true}
 PersSvcPerOutput, boolean property to use multiple persistency services, one per output stream.
Gaudi::Property< std::string > m_persSvcPerInputType {this,"PersSvcPerInputType",""}
 PersSvcPerInputType, string property, tree name to use multiple persistency services, one per input type.
std::mutex m_mutex
std::set< unsigned int > m_processedContextIds
 Track context IDs for which extractPoolAttributes has been called.
Gaudi::Property< bool > m_oneDataHeaderForm { this, "OneDataHeaderForm", false }
 If true, use only one DataHeaderForm per Stream.
Gaudi::Property< int > m_DHFormCacheSize { this, "maxDHFormCacheSize", 100 }
 Property for DataHeaderCnv input DHForm cache size.
Gaudi::Property< bool > m_DHFilterAliases { this, "doFilterDHAliases", true }
 Flag to control SG alias filtering when writing out DataHeader (see DataHeaderCnv_p6).
Gaudi::Property< std::string > m_defaultContainerType {this, "DefaultContainerType", "ROOTTREEINDEX"}
 Default container type.

Private Member Functions

void extractPoolAttributes (const Gaudi::Property< std::vector< std::string > > &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.
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.

Private Attributes

std::string m_lastInputFileName
 decoded storage tech requested in "StorageTechnology" property
ServiceHandle< IPoolSvcm_poolSvc {this,"PoolSvc","PoolSvc"}
ServiceHandle< IClassIDSvc > m_clidSvc {this,"ClassIDSvc","ClassIDSvc"}
Gaudi::Property< bool > m_useDetailChronoStat {this,"UseDetailChronoStat",false}
 UseDetailChronoStat, enable detailed output for time and size statistics for AthenaPOOL: default = false.
Gaudi::Property< std::string > m_containerNamingSchemeProp {this, "PoolContainerNamingScheme", "Historical"}
 POOL container naming scheme selection.
Gaudi::Property< std::vector< std::string > > m_poolAttr {this,"PoolAttributes",{},"Pool Attributes","OrderedSet<std::string>"}
 Output PoolAttributes, vector with names and values of technology specific attributes for POOL.
std::vector< std::vector< std::string > > m_domainAttr
std::vector< std::vector< std::string > > m_databaseAttr
std::vector< std::vector< std::string > > m_containerAttr
Gaudi::Property< std::vector< std::string > > m_inputPoolAttr {this,"InputPoolAttributes",{}}
 Input PoolAttributes, vector with names and values of technology specific attributes for POOL.
std::vector< std::vector< std::string > > m_inputAttr
Gaudi::Property< std::vector< std::string > > m_inputPoolAttrPerEvent {this,"PrintInputAttrPerEvt",{}}
 Print input PoolAttributes per event, vector with names of technology specific attributes for POOL to be printed each event.
std::vector< std::vector< std::string > > m_inputAttrPerEvent

Friends

class SvcFactory< AthenaPoolCnvSvc >

Detailed Description

This class provides the interface between Athena and PoolSvc.

Definition at line 39 of file AthenaPoolCnvSvc.h.

Constructor & Destructor Documentation

◆ AthenaPoolCnvSvc()

AthenaPoolCnvSvc::AthenaPoolCnvSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Standard Service Constructor.

Definition at line 449 of file AthenaPoolCnvSvc.cxx.

449 :
450 base_class(name, pSvcLocator, pool::POOL_StorageType.type()) {
451}
static const DbType POOL_StorageType
Definition DbType.h:84

◆ ~AthenaPoolCnvSvc()

virtual AthenaPoolCnvSvc::~AthenaPoolCnvSvc ( )
virtualdefault

Destructor.

Member Function Documentation

◆ cleanUp()

StatusCode AthenaPoolCnvSvc::cleanUp ( const std::string & connection)
overridevirtual

Implement cleanUp to call all registered IAthenaPoolCleanUp cleanUp() function.

Definition at line 397 of file AthenaPoolCnvSvc.cxx.

397 {
398 bool retError = false;
399 std::size_t cpos = connection.find(':');
400 std::size_t bpos = connection.find('[');
401 if (cpos == std::string::npos) {
402 cpos = 0;
403 } else {
404 cpos++;
405 }
406 if (bpos != std::string::npos) bpos = bpos - cpos;
407 const std::string conn = connection.substr(cpos, bpos);
408 ATH_MSG_VERBOSE("Cleanup for Connection='"<< conn <<"'");
409 for (auto converter : m_cnvs) {
410 if (!converter->cleanUp(conn).isSuccess()) {
411 ATH_MSG_WARNING("AthenaPoolConverter cleanUp failed.");
412 retError = true;
413 }
414 }
415 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
416}
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)

◆ commitOutput()

StatusCode AthenaPoolCnvSvc::commitOutput ( const std::string & outputConnectionSpec,
bool doCommit )
overridevirtual

Implementation of IConversionSvc: Commit pending output.

Parameters
doCommit[IN] boolean to force full commit

Definition at line 257 of file AthenaPoolCnvSvc.cxx.

257 {
258 // This is called after all DataObjects are converted.
259 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
260 // StopWatch listens from here until the end of this current scope
261 PMonUtils::BasicStopWatch stopWatch("commitOutput", m_chronoMap);
262 std::unique_lock<std::mutex> lock(m_mutex);
263 unsigned int contextId = outputContextId(outputConnection);
264 if (!processPoolAttributes(m_domainAttr, outputConnection, contextId).isSuccess()) {
265 ATH_MSG_DEBUG("commitOutput failed process POOL domain attributes.");
266 }
267 if (!processPoolAttributes(m_databaseAttr, outputConnection, contextId).isSuccess()) {
268 ATH_MSG_DEBUG("commitOutput failed process POOL database attributes.");
269 }
270 if (!processPoolAttributes(m_containerAttr, outputConnection, contextId).isSuccess()) {
271 ATH_MSG_DEBUG("commitOutput failed process POOL container attributes.");
272 }
273
274 // lock.unlock(); //MN: first need to make commitCache slot-specific
275 try {
276 if (doCommit) {
277 if (!m_poolSvc->commit(contextId).isSuccess()) {
278 ATH_MSG_ERROR("commitOutput FAILED to commit OutputStream.");
279 return(StatusCode::FAILURE);
280 }
281 } else {
282 if (!m_poolSvc->commitAndHold(contextId).isSuccess()) {
283 ATH_MSG_ERROR("commitOutput FAILED to commitAndHold OutputStream.");
284 return(StatusCode::FAILURE);
285 }
286 }
287 } catch (std::exception& e) {
288 ATH_MSG_ERROR("commitOutput - caught exception: " << e.what());
289 return(StatusCode::FAILURE);
290 }
291 if (!this->cleanUp(outputConnection).isSuccess()) {
292 ATH_MSG_ERROR("commitOutput FAILED to cleanup converters.");
293 return(StatusCode::FAILURE);
294 }
295
296 return(StatusCode::SUCCESS);
297}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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.
ServiceHandle< IPoolSvc > m_poolSvc
virtual StatusCode cleanUp(const std::string &connection) override
Implement cleanUp to call all registered IAthenaPoolCleanUp cleanUp() function.

◆ connectOutput() [1/2]

StatusCode AthenaPoolCnvSvc::connectOutput ( const std::string & outputConnectionSpec)
overridevirtual

Implementation of IConversionSvc: Connect to the output connection specification with open mode.

Parameters
outputConnectionSpec[IN] the name of the output connection specification as string.

Definition at line 251 of file AthenaPoolCnvSvc.cxx.

251 {
252// This is called before DataObjects are being converted.
253 return(connectOutput(outputConnectionSpec, "UPDATE"));
254}

◆ connectOutput() [2/2]

StatusCode AthenaPoolCnvSvc::connectOutput ( const std::string & outputConnectionSpec,
const std::string & openMode )
overridevirtual

Implementation of IConversionSvc: Connect to the output connection specification with open mode.

Parameters
outputConnectionSpec[IN] the name of the output connection specification as string.
openMode[IN] the open mode of the file as string.

Definition at line 223 of file AthenaPoolCnvSvc.cxx.

224 {
225 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
226 unsigned int contextId = outputContextId(outputConnection);
227 Io::IoFlag mode = openMode == "APPEND" ? Io::APPEND : Io::WRITE;
228 try {
229 if (!m_poolSvc->connect(mode, contextId).isSuccess()) {
230 ATH_MSG_ERROR("connectOutput FAILED to open an " << openMode << " transaction.");
231 return(StatusCode::FAILURE);
232 }
233 } catch (std::exception& e) {
234 ATH_MSG_ERROR("connectOutput - caught exception: " << e.what());
235 return(StatusCode::FAILURE);
236 }
237 std::unique_lock<std::mutex> lock(m_mutex);
238 if (m_processedContextIds.insert(contextId).second) {
239 // Extracting OUTPUT POOL ItechnologySpecificAttributes for Domain, Database and Container.
240 extractPoolAttributes(m_poolAttr, &m_containerAttr, &m_databaseAttr, &m_domainAttr);
241 }
242 if (!processPoolAttributes(m_domainAttr, outputConnection, contextId).isSuccess()) {
243 ATH_MSG_DEBUG("connectOutput failed process POOL domain attributes.");
244 }
245 if (!processPoolAttributes(m_databaseAttr, outputConnection, contextId).isSuccess()) {
246 ATH_MSG_DEBUG("connectOutput failed process POOL database attributes.");
247 }
248 return(StatusCode::SUCCESS);
249}
void extractPoolAttributes(const Gaudi::Property< std::vector< std::string > > &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.
std::set< unsigned int > m_processedContextIds
Track context IDs for which extractPoolAttributes has been called.

◆ convertAddress()

StatusCode AthenaPoolCnvSvc::convertAddress ( const IOpaqueAddress * pAddress,
std::string & refAddress )
overridevirtual

Convert address to string form.

Parameters
pAddress[IN] address to be converted.
refAddress[OUT] converted string form.

Definition at line 380 of file AthenaPoolCnvSvc.cxx.

381 {
382 assert(pAddress);
383 const TokenAddress* tokAddr = dynamic_cast<const TokenAddress*>(pAddress);
384 if (tokAddr != nullptr && tokAddr->getToken() != nullptr) {
385 refAddress = tokAddr->getToken()->toString();
386 } else {
387 refAddress = *pAddress->par();
388 }
389 return(StatusCode::SUCCESS);
390}
This class provides a Generic Transient Address for POOL tokens.
Token * getToken()
const std::string toString() const
Retrieve the string representation of the token.
Definition Token.cxx:135

◆ createAddress() [1/2]

StatusCode AthenaPoolCnvSvc::createAddress ( long svcType,
const CLID & clid,
const std::string & refAddress,
IOpaqueAddress *& refpAddress )
overridevirtual

Create address from string form.

Parameters
svcType[IN] service type of the address.
clid[IN] class id for the address.
refAddress[IN] string form to be converted.
refpAddress[OUT] converted address.

Definition at line 368 of file AthenaPoolCnvSvc.cxx.

371 {
372 if (svcType != repSvcType()) {
373 ATH_MSG_ERROR("createAddress: svcType != POOL_StorageType " << svcType << " " << repSvcType());
374 return(StatusCode::FAILURE);
375 }
376 refpAddress = new GenericAddress(repSvcType(), clid, refAddress);
377 return(StatusCode::SUCCESS);
378}

◆ createAddress() [2/2]

StatusCode AthenaPoolCnvSvc::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.

Parameters
svcType[IN] service type of the address.
clid[IN] class id for the address.
par[IN] string containing the database name.
ip[IN] object identifier.
refpAddress[OUT] converted address.

Definition at line 346 of file AthenaPoolCnvSvc.cxx.

350 {
351 if( svcType != repSvcType() ) {
352 ATH_MSG_ERROR("createAddress: svcType != POOL_StorageType " << svcType << " " << repSvcType());
353 return(StatusCode::FAILURE);
354 }
355 std::unique_ptr<Token> token;
356 Token *t = m_poolSvc->getToken(par[0], par[1], ip[0]);
357 if( t ) {
358 token = std::make_unique<Token>(t);
359 t->release();
360 }
361 if (token == nullptr) {
362 return(StatusCode::RECOVERABLE);
363 }
364 refpAddress = new TokenAddress(repSvcType(), clid, "", par[1], IPoolSvc::kInputStream, std::move(token));
365 return(StatusCode::SUCCESS);
366}
@ kInputStream
Definition IPoolSvc.h:39
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:22

◆ createObj()

StatusCode AthenaPoolCnvSvc::createObj ( IOpaqueAddress * pAddress,
DataObject *& refpObject )
overridevirtual

Implementation of IConversionSvc: Create the transient representation of an object from persistent state.

Parameters
pAddress[IN] pointer to IOpaqueAddress of the representation.
refpObject[OUT] pointer to DataObject to be created.

Definition at line 131 of file AthenaPoolCnvSvc.cxx.

131 {
132 assert(pAddress);
133 std::string objName = "ALL";
134 if (m_useDetailChronoStat.value()) {
135 if (m_clidSvc->getTypeNameOfID(pAddress->clID(), objName).isFailure()) {
136 objName = std::to_string(pAddress->clID());
137 }
138 objName += '#';
139 objName += *(pAddress->par() + 1);
140 }
141 // StopWatch listens from here until the end of this current scope
142 PMonUtils::BasicStopWatch stopWatch("cObj_" + objName, m_chronoMap);
143 if (!m_persSvcPerInputType.value().empty()) { // Use separate PersistencySvc for each input data type
144 TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(pAddress);
145 if (tokAddr != nullptr && tokAddr->getToken() != nullptr && (tokAddr->getToken()->contID().starts_with(m_persSvcPerInputType.value() + "(") || tokAddr->getToken()->contID().starts_with(m_persSvcPerInputType.value() + "_"))) {
146 const unsigned int maxContext = m_poolSvc->getInputContextMapSize();
147 const unsigned int auxContext = m_poolSvc->getInputContext(tokAddr->getToken()->classID().toString() + tokAddr->getToken()->dbID().toString(), 1);
148 if (m_poolSvc->getInputContextMapSize() > maxContext) {
149 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, auxContext, false, true, false).isSuccess()) {
150 ATH_MSG_DEBUG("setInputAttribute failed setting POOL database/container attributes.");
151 }
152 }
153 tokAddr->getToken()->setAuxString(CxxUtils::HexString<"[CTXT={}]">(auxContext));
154 }
155 }
156 // Forward to base class createObj
157 StatusCode status = ::AthCnvSvc::createObj(pAddress, refpObject);
158 return(status);
159}
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
Gaudi::Property< std::string > m_persSvcPerInputType
PersSvcPerInputType, string property, tree name to use multiple persistency services,...
constexpr void toString(std::span< char, StrLen > buf, bool uppercase=true) const noexcept
Automatic conversion to string representation.
const std::string & contID() const
Access container identifier.
Definition Token.h:70
const Guid & classID() const
Access database identifier.
Definition Token.h:74
const Guid & dbID() const
Access database identifier.
Definition Token.h:65
Token & setAuxString(std::string &&auxString)
Set auxiliary string.
Definition Token.h:94
detail::BasicHexString< FormatStr, detail::UpperHexDigits > HexString
Definition HexString.h:158
::StatusCode StatusCode
StatusCode definition for legacy code.
status
Definition merge.py:16

◆ createRep()

StatusCode AthenaPoolCnvSvc::createRep ( DataObject * pObject,
IOpaqueAddress *& refpAddress )
overridevirtual

Implementation of IConversionSvc: Convert the transient object to the requested representation.

Parameters
pObject[IN] pointer to DataObject.
refpAddress[OUT] pointer to IOpaqueAddress of the representation to be created.

Definition at line 161 of file AthenaPoolCnvSvc.cxx.

161 {
162 assert(pObject);
163 std::string objName = "ALL";
164 if (m_useDetailChronoStat.value()) {
165 if (m_clidSvc->getTypeNameOfID(pObject->clID(), objName).isFailure()) {
166 objName = std::to_string(pObject->clID());
167 }
168 objName += '#';
169 objName += pObject->registry()->name();
170 }
171 // StopWatch listens from here until the end of this current scope
172 PMonUtils::BasicStopWatch stopWatch("cRep_" + objName, m_chronoMap);
173 StatusCode status = StatusCode::FAILURE;
174 if (pObject->clID() == 1) {
175 // No transient object was found use cnv to write default persistent object
176 SG::DataProxy* proxy = dynamic_cast<SG::DataProxy*>(pObject->registry());
177 if (proxy != nullptr) {
178 IConverter* cnv = converter(proxy->clID());
179 status = cnv->createRep(pObject, refpAddress);
180 }
181 } else {
182 // Forward to base class createRep
183 try {
184 status = ::AthCnvSvc::createRep(pObject, refpAddress);
185 } catch(std::runtime_error& e) {
186 ATH_MSG_FATAL(e.what());
187 }
188 }
189 return(status);
190}
#define ATH_MSG_FATAL(x,...)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.

◆ disconnectOutput()

StatusCode AthenaPoolCnvSvc::disconnectOutput ( const std::string & outputConnectionSpec)
overridevirtual

Disconnect to the output connection.

Definition at line 300 of file AthenaPoolCnvSvc.cxx.

300 {
301 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
302 unsigned int contextId = outputContextId(outputConnection);
303 StatusCode sc = m_poolSvc->disconnect(contextId);
304 return sc;
305}
static Double_t sc

◆ extractPoolAttributes()

void AthenaPoolCnvSvc::extractPoolAttributes ( const Gaudi::Property< std::vector< std::string > > & property,
std::vector< std::vector< std::string > > * contAttr,
std::vector< std::vector< std::string > > * dbAttr,
std::vector< std::vector< std::string > > * domAttr = 0 ) const
private

Extract POOL ItechnologySpecificAttributes for Domain, Database and Container from property.

Definition at line 453 of file AthenaPoolCnvSvc.cxx.

456 {
457 std::vector<std::string> opt;
458 std::string attributeName, containerName, databaseName, valueString;
459 for (const auto& propertyValue : property.value()) {
460 opt.clear();
461 attributeName.clear();
462 containerName.clear();
463 databaseName.clear();
464 valueString.clear();
465 using Gaudi::Utils::AttribStringParser;
466 for (const AttribStringParser::Attrib& attrib : AttribStringParser (propertyValue)) {
467 if (attrib.tag == "DatabaseName") {
468 databaseName = attrib.value;
469 } else if (attrib.tag == "ContainerName") {
470 if (databaseName.empty()) {
471 databaseName = "*";
472 }
473 containerName = attrib.value;
474 } else {
475 attributeName = attrib.tag;
476 valueString = attrib.value;
477 }
478 }
479 if (!attributeName.empty() && !valueString.empty()) {
480 opt.push_back(attributeName);
481 opt.push_back(valueString);
482 if (!databaseName.empty()) {
483 opt.push_back(databaseName);
484 if (!containerName.empty()) {
485 opt.push_back(containerName);
486 if (containerName.compare(0, 6, "TTree=") == 0) {
487 dbAttr->push_back(opt);
488 } else {
489 contAttr->push_back(opt);
490 }
491 } else {
492 opt.push_back("");
493 dbAttr->push_back(opt);
494 }
495 } else if (domAttr != 0) {
496 domAttr->push_back(opt);
497 } else {
498 opt.push_back("*");
499 opt.push_back("");
500 dbAttr->push_back(opt);
501 }
502 }
503 }
504}

◆ fillRepRefs()

StatusCode AthenaPoolCnvSvc::fillRepRefs ( IOpaqueAddress * pAddress,
DataObject * pObject )
overridevirtual

Implementation of IConversionSvc: Resolve the references of the converted object.

Parameters
pAddress[IN] pointer to IOpaqueAddress of the representation to be resolved.
pObject[IN] pointer to DataObject to be created.

Definition at line 192 of file AthenaPoolCnvSvc.cxx.

192 {
193 assert(pObject);
194 std::string objName = "ALL";
195 if (m_useDetailChronoStat.value()) {
196 if (m_clidSvc->getTypeNameOfID(pObject->clID(), objName).isFailure()) {
197 objName = std::to_string(pObject->clID());
198 }
199 objName += '#';
200 objName += pObject->registry()->name();
201 }
202 // StopWatch listens from here until the end of this current scope
203 PMonUtils::BasicStopWatch stopWatch("fRep_" + objName, m_chronoMap);
204 StatusCode status = StatusCode::FAILURE;
205 if (pObject->clID() == 1) {
206 // No transient object was found use cnv to write default persistent object
207 SG::DataProxy* proxy = dynamic_cast<SG::DataProxy*>(pObject->registry());
208 if (proxy != nullptr) {
209 IConverter* cnv = converter(proxy->clID());
210 status = cnv->fillRepRefs(pAddress, pObject);
211 }
212 } else {
213 // Forward to base class fillRepRefs
214 try {
215 status = ::AthCnvSvc::fillRepRefs(pAddress, pObject);
216 } catch(std::runtime_error& e) {
217 ATH_MSG_FATAL(e.what());
218 }
219 }
220 return(status);
221}
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.

◆ finalize()

StatusCode AthenaPoolCnvSvc::finalize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 97 of file AthenaPoolCnvSvc.cxx.

97 {
98 ATH_MSG_VERBOSE("Finalizing...");
99 // Some algorithms write in finalize(), flush DHForms if any are left
100 flushDataHeaderForms();
101 // Release ClassIDSvc
102 if (!m_clidSvc.release().isSuccess()) {
103 ATH_MSG_WARNING("Cannot release ClassIDSvc.");
104 }
105 // Release PoolSvc
106 if (!m_poolSvc.release().isSuccess()) {
107 ATH_MSG_WARNING("Cannot release PoolSvc.");
108 }
109 // Print Performance Statistics
110 // The pattern AthenaPoolCnvSvc.*PerfStats is ignored in AtlasTest/TestTools/share/post.sh
111 const std::string msgPrefix{"PerfStats "};
112 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
113 ATH_MSG_INFO(msgPrefix << "Timing Measurements for AthenaPoolCnvSvc");
114 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
115 for(const auto& [key, value] : m_chronoMap) {
116 ATH_MSG_INFO(msgPrefix << "| " << std::left << std::setw(15) << key << " | "
117 << std::right << std::setw(15) << std::fixed << std::setprecision(0) << value << " ms |");
118 }
119 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
120
121 m_cnvs.clear();
122 m_cnvs.shrink_to_fit();
123 return(StatusCode::SUCCESS);
124}
#define ATH_MSG_INFO(x,...)

◆ flushDataHeaderForms()

void AthenaPoolCnvSvc::flushDataHeaderForms ( const std::string & streamName = "*")

Tell DataHeaderCnv to write out all DataHeaderForms for a given streamName (default is all).

Definition at line 83 of file AthenaPoolCnvSvc.cxx.

83 {
84 // Write remaining DataHeaderForms for a given streamName, "*"" means all
85 auto DHCnvListener = dynamic_cast<IIncidentListener*>( converter( ClassID_traits<DataHeader>::ID() ) );
86 FileIncident incident(name(), "WriteDataHeaderForms", streamName);
87 if( DHCnvListener ) DHCnvListener->handle(incident);
88}

◆ getPoolSvc()

IPoolSvc * AthenaPoolCnvSvc::getPoolSvc ( )
overridevirtual
Returns
pointer to PoolSvc instance.

Definition at line 314 of file AthenaPoolCnvSvc.cxx.

314 {
315 return(&*m_poolSvc);
316}

◆ handle()

void AthenaPoolCnvSvc::handle ( const Incident & incident)
overridevirtual

Implementation of IIncidentListener: Handle for EndEvent incidence.

Definition at line 440 of file AthenaPoolCnvSvc.cxx.

440 {
441 if (incident.type() == "ProcessEventAttributes") {
442 m_inputAttrPerEvent.push_back({"SET_ACTIVE_ENTRY", incident.source(), m_lastInputFileName, ""});
443 if (!processPoolAttributes(m_inputAttrPerEvent, m_lastInputFileName, IPoolSvc::kInputStream).isSuccess()) {
444 ATH_MSG_DEBUG("handle ProcessEventAttributes failed process POOL database attributes.");
445 }
446 }
447}

◆ initialize()

StatusCode AthenaPoolCnvSvc::initialize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 35 of file AthenaPoolCnvSvc.cxx.

35 {
36 // Retrieve PoolSvc
37 ATH_CHECK(m_poolSvc.retrieve());
38 // Retrieve ClassIDSvc
39 ATH_CHECK(m_clidSvc.retrieve());
40 // Register this service for 'I/O' events
41 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
42 ATH_CHECK(iomgr.retrieve());
43 if (!iomgr->io_register(this).isSuccess()) {
44 ATH_MSG_FATAL("Could not register myself with the IoComponentMgr !");
45 return(StatusCode::FAILURE);
46 }
47 // Global POOL container naming scheme
48 if (auto scheme = APRDefaults::WriteConfig::parseNamingScheme(m_containerNamingSchemeProp.value())) {
50 } else {
51 ATH_MSG_ERROR(std::format("Invalid PoolContainerNamingScheme: {}, see APRDefaults.h for the full list.", m_containerNamingSchemeProp.value()));
52 return StatusCode::FAILURE;
53 }
54 // Extracting INPUT POOL ItechnologySpecificAttributes for Domain, Database and Container.
55 extractPoolAttributes(m_inputPoolAttr, &m_inputAttr, &m_inputAttr, &m_inputAttr);
56 // Extracting the INPUT POOL ItechnologySpecificAttributes which are to be printed for each event
57 extractPoolAttributes(m_inputPoolAttrPerEvent, &m_inputAttrPerEvent, &m_inputAttrPerEvent, &m_inputAttrPerEvent);
58 // Setup incident for ProcessEventAttributes to process attributes on each event
59 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
60 long int pri = 1000;
61 // Set to be listener for ProcessEventAttributes
62 incSvc->addListener(this, "ProcessEventAttributes", pri);
63 if (!processPoolAttributes(m_inputAttr, "", IPoolSvc::kInputStream, false, true, true).isSuccess()) {
64 ATH_MSG_DEBUG("setInputAttribute failed setting POOL domain attributes.");
65 }
66
67 // Load these dictionaries now, so we don't need to try to do so
68 // while multiple threads are running.
69 TClass::GetClass ("TLeafI");
70 TClass::GetClass ("TLeafL");
71 TClass::GetClass ("TLeafD");
72 TClass::GetClass ("TLeafF");
73
74 return(StatusCode::SUCCESS);
75}
#define ATH_CHECK
Evaluate an expression and check for errors.
Gaudi::Property< std::string > m_containerNamingSchemeProp
POOL container naming scheme selection.
std::optional< NamingScheme > parseNamingScheme(std::string_view name)
Definition APRDefaults.h:89
void setNamingScheme(NamingScheme scheme)
Definition APRDefaults.h:79

◆ io_finalize()

StatusCode AthenaPoolCnvSvc::io_finalize ( )
overridevirtual

Definition at line 126 of file AthenaPoolCnvSvc.cxx.

126 {
127 ATH_MSG_DEBUG("I/O finalization...");
128 return(StatusCode::SUCCESS);
129}

◆ io_reinit()

StatusCode AthenaPoolCnvSvc::io_reinit ( )
overridevirtual

Definition at line 77 of file AthenaPoolCnvSvc.cxx.

77 {
78 ATH_MSG_DEBUG("I/O reinitialization...");
79 m_processedContextIds.clear();
80 return(StatusCode::SUCCESS);
81}

◆ outputContextId()

unsigned int AthenaPoolCnvSvc::outputContextId ( const std::string & outputConnection)
protected

Definition at line 308 of file AthenaPoolCnvSvc.cxx.

308 {
309 return m_persSvcPerOutput?
310 m_poolSvc->getOutputContext(outputConnection) : (unsigned int)IPoolSvc::kOutputStream;
311}
@ kOutputStream
Definition IPoolSvc.h:39

◆ processPoolAttributes()

StatusCode AthenaPoolCnvSvc::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
private

Set/get technology dependent POOL attributes.

Definition at line 506 of file AthenaPoolCnvSvc.cxx.

511 {
512 bool retError = false;
513 for (auto& attrEntry : attr) {
514 if (attrEntry.size() == 2) {
515 const std::string& opt = attrEntry[0];
516 std::string data = attrEntry[1];
517 if (data == "int" || data == "DbLonglong" || data == "double" || data == "string") {
518 if (doGet) {
519 if (!m_poolSvc->getAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), contextId).isSuccess()) {
520 ATH_MSG_DEBUG("getAttribute failed for domain attr " << opt);
521 retError = true;
522 }
523 }
524 } else if (doSet) {
525 if (m_poolSvc->setAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), contextId).isSuccess()) {
526 ATH_MSG_DEBUG("setAttribute " << opt << " to " << data);
527 if (doClear) {
528 attrEntry.clear();
529 }
530 } else {
531 ATH_MSG_DEBUG("setAttribute failed for domain attr " << opt << " to " << data);
532 retError = true;
533 }
534 }
535 }
536 if (attrEntry.size() == 4) {
537 const std::string& opt = attrEntry[0];
538 std::string data = attrEntry[1];
539 const std::string& file = attrEntry[2];
540 const std::string& cont = attrEntry[3];
541 if (!fileName.empty() && (0 == fileName.compare(0, fileName.find('?'), file)
542 || (file[0] == '*' && file.find("," + fileName + ",") == std::string::npos))) {
543 if (data == "int" || data == "DbLonglong" || data == "double" || data == "string") {
544 if (doGet) {
545 if (!m_poolSvc->getAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
546 ATH_MSG_DEBUG("getAttribute failed for database/container attr " << opt);
547 retError = true;
548 }
549 }
550 } else if (doSet) {
551 if (m_poolSvc->setAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
552 ATH_MSG_DEBUG("setAttribute " << opt << " to " << data << " for db: " << fileName << " and cont: " << cont);
553 if (doClear) {
554 if (file[0] == '*' && !m_persSvcPerOutput) {
555 attrEntry[2] += "," + fileName + ",";
556 } else {
557 attrEntry.clear();
558 }
559 }
560 } else {
561 ATH_MSG_DEBUG("setAttribute failed for " << opt << " to " << data << " for db: " << fileName << " and cont: " << cont);
562 retError = true;
563 }
564 }
565 }
566 }
567 }
568 std::erase_if(attr, [](const auto& entry) { return entry.empty(); });
569 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
570}
int type() const
Access to full type.
Definition DbType.h:65
static const DbType ROOTTREE_StorageType
Definition DbType.h:87
std::size_t erase_if(T_container &container, T_Func pred)
TFile * file

◆ registerCleanUp()

StatusCode AthenaPoolCnvSvc::registerCleanUp ( IAthenaPoolCleanUp * cnv)
overridevirtual

Implement registerCleanUp to register a IAthenaPoolCleanUp to be called during cleanUp.

Definition at line 392 of file AthenaPoolCnvSvc.cxx.

392 {
393 m_cnvs.push_back(cnv);
394 return(StatusCode::SUCCESS);
395}

◆ registerForWrite()

Token * AthenaPoolCnvSvc::registerForWrite ( Placement * placement,
const void * obj,
const RootType & classDesc )
overridevirtual
Returns
a string token to a Data Object written to Pool
Parameters
placement[IN] pointer to the placement hint
obj[IN] pointer to the Data Object to be written to Pool
classDesc[IN] pointer to the Seal class description for the Data Object.

Definition at line 318 of file AthenaPoolCnvSvc.cxx.

318 {
319 // StopWatch listens from here until the end of this current scope
320 PMonUtils::BasicStopWatch stopWatch("cRepR_ALL", m_chronoMap);
321 Token* token = nullptr;
322 if (m_persSvcPerOutput) { // Use separate PersistencySvc for each output stream/file
323 placement->setAuxString(CxxUtils::HexString<"[CTXT={}]">(m_poolSvc->getOutputContext(placement->fileName())));
324 }
325 if(placement->technology() == 0) { // No technology specified, use the default
326 placement->setTechnology(pool::DbType::getType(m_defaultContainerType).type());
327 }
328 token = m_poolSvc->registerForWrite(placement, obj, classDesc);
329 return(token);
330}
Placement & setAuxString(std::string &&auxString)
Set auxiliary string.
Definition Placement.h:43
Placement & setTechnology(int technology)
Set technology type.
Definition Placement.h:39
const std::string & fileName() const
Access file name.
Definition Placement.h:29
int technology() const
Access technology type.
Definition Placement.h:37
static DbType getType(const std::string &name)
Access known storage type object by name.

◆ setInputAttributes()

StatusCode AthenaPoolCnvSvc::setInputAttributes ( const std::string & fileName)
overridevirtual

Set the input file attributes, if any are requested from jobOpts.

Parameters
fileName[IN] name of the input file

Definition at line 418 of file AthenaPoolCnvSvc.cxx.

418 {
419 // Set attributes for input file
420 m_lastInputFileName = fileName; // Save file name for printing attributes per event
421 if (!m_persSvcPerInputType.empty()) {
422// Loop over all extra event input contexts
423 const auto& extraInputContextMap = m_poolSvc->getInputContextMap();
424 for (const auto& [label, id]: extraInputContextMap) {
425 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, id, false, true, false).isSuccess()) {
426 ATH_MSG_DEBUG("setInputAttribute failed setting POOL database/container attributes.");
427 }
428 }
429 }
430 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, IPoolSvc::kInputStream, false, true, false).isSuccess()) {
431 ATH_MSG_DEBUG("setInputAttribute failed setting POOL database/container attributes.");
432 }
433 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, IPoolSvc::kInputStream, true, false).isSuccess()) {
434 ATH_MSG_DEBUG("setInputAttribute failed getting POOL database/container attributes.");
435 }
436 return(StatusCode::SUCCESS);
437}
std::string label(const std::string &format, int i)
Definition label.h:19

◆ setObjPtr()

void AthenaPoolCnvSvc::setObjPtr ( void *& obj,
const Token * token )
overridevirtual
Parameters
obj[OUT] pointer to the Data Object.
token[IN] string token of the Data Object for which a Pool Ref is filled.

Definition at line 332 of file AthenaPoolCnvSvc.cxx.

332 {
333 ATH_MSG_VERBOSE("Requesting object for: " << token->toString());
334 // StopWatch listens from here until the end of this current scope
335 PMonUtils::BasicStopWatch stopWatch("cObjR_ALL", m_chronoMap);
336 if (token->dbID() != Guid::null()) {
337 ATH_MSG_VERBOSE("Requesting object for: " << token->toString());
338 m_poolSvc->setObjPtr(obj, token);
339 }
340}
static const Guid & null() noexcept
NULL-Guid: static class method.
Definition Guid.cxx:14

◆ stop()

StatusCode AthenaPoolCnvSvc::stop ( )
overridevirtual

Definition at line 90 of file AthenaPoolCnvSvc.cxx.

90 {
91 ATH_MSG_VERBOSE("stop()");
92 // In case of direct writing without an OutputStream, this should be a good time to flush DHForms
93 flushDataHeaderForms();
94 return StatusCode::SUCCESS;
95}

◆ useDetailChronoStat()

bool AthenaPoolCnvSvc::useDetailChronoStat ( ) const
overridevirtual
Returns
a boolean for using detailed time and size statistics.

Definition at line 342 of file AthenaPoolCnvSvc.cxx.

342 {
343 return(m_useDetailChronoStat.value());
344}

◆ SvcFactory< AthenaPoolCnvSvc >

friend class SvcFactory< AthenaPoolCnvSvc >
friend

Definition at line 1 of file AthenaPoolCnvSvc.h.

Member Data Documentation

◆ m_chronoMap

PMonUtils::BasicStopWatchResultMap_t AthenaPoolCnvSvc::m_chronoMap {}
protected

Map that holds chrono information.

Definition at line 176 of file AthenaPoolCnvSvc.h.

176{};

◆ m_clidSvc

ServiceHandle<IClassIDSvc> AthenaPoolCnvSvc::m_clidSvc {this,"ClassIDSvc","ClassIDSvc"}
private

Definition at line 172 of file AthenaPoolCnvSvc.h.

172{this,"ClassIDSvc","ClassIDSvc"};

◆ m_containerAttr

std::vector<std::vector<std::string> > AthenaPoolCnvSvc::m_containerAttr
private

Definition at line 190 of file AthenaPoolCnvSvc.h.

◆ m_containerNamingSchemeProp

Gaudi::Property<std::string> AthenaPoolCnvSvc::m_containerNamingSchemeProp {this, "PoolContainerNamingScheme", "Historical"}
private

POOL container naming scheme selection.

Definition at line 184 of file AthenaPoolCnvSvc.h.

184{this, "PoolContainerNamingScheme", "Historical"};

◆ m_databaseAttr

std::vector<std::vector<std::string> > AthenaPoolCnvSvc::m_databaseAttr
private

Definition at line 189 of file AthenaPoolCnvSvc.h.

◆ m_defaultContainerType

Gaudi::Property<std::string> AthenaPoolCnvSvc::m_defaultContainerType {this, "DefaultContainerType", "ROOTTREEINDEX"}
protected

Default container type.

Definition at line 224 of file AthenaPoolCnvSvc.h.

224{this, "DefaultContainerType", "ROOTTREEINDEX"};

◆ m_DHFilterAliases

Gaudi::Property<bool> AthenaPoolCnvSvc::m_DHFilterAliases { this, "doFilterDHAliases", true }
protected

Flag to control SG alias filtering when writing out DataHeader (see DataHeaderCnv_p6).

Definition at line 221 of file AthenaPoolCnvSvc.h.

221{ this, "doFilterDHAliases", true };

◆ m_DHFormCacheSize

Gaudi::Property<int> AthenaPoolCnvSvc::m_DHFormCacheSize { this, "maxDHFormCacheSize", 100 }
protected

Property for DataHeaderCnv input DHForm cache size.

Definition at line 218 of file AthenaPoolCnvSvc.h.

218{ this, "maxDHFormCacheSize", 100 };

◆ m_domainAttr

std::vector<std::vector<std::string> > AthenaPoolCnvSvc::m_domainAttr
private

Definition at line 188 of file AthenaPoolCnvSvc.h.

◆ m_inputAttr

std::vector<std::vector<std::string> > AthenaPoolCnvSvc::m_inputAttr
private

Definition at line 194 of file AthenaPoolCnvSvc.h.

◆ m_inputAttrPerEvent

std::vector<std::vector<std::string> > AthenaPoolCnvSvc::m_inputAttrPerEvent
private

Definition at line 198 of file AthenaPoolCnvSvc.h.

◆ m_inputPoolAttr

Gaudi::Property<std::vector<std::string> > AthenaPoolCnvSvc::m_inputPoolAttr {this,"InputPoolAttributes",{}}
private

Input PoolAttributes, vector with names and values of technology specific attributes for POOL.

Definition at line 193 of file AthenaPoolCnvSvc.h.

193{this,"InputPoolAttributes",{}};

◆ m_inputPoolAttrPerEvent

Gaudi::Property<std::vector<std::string> > AthenaPoolCnvSvc::m_inputPoolAttrPerEvent {this,"PrintInputAttrPerEvt",{}}
private

Print input PoolAttributes per event, vector with names of technology specific attributes for POOL to be printed each event.

Definition at line 197 of file AthenaPoolCnvSvc.h.

197{this,"PrintInputAttrPerEvt",{}};

◆ m_lastInputFileName

std::string AthenaPoolCnvSvc::m_lastInputFileName
private

decoded storage tech requested in "StorageTechnology" property

Definition at line 170 of file AthenaPoolCnvSvc.h.

◆ m_mutex

std::mutex AthenaPoolCnvSvc::m_mutex
protected

Definition at line 209 of file AthenaPoolCnvSvc.h.

◆ m_oneDataHeaderForm

Gaudi::Property<bool> AthenaPoolCnvSvc::m_oneDataHeaderForm { this, "OneDataHeaderForm", false }
protected

If true, use only one DataHeaderForm per Stream.

Definition at line 215 of file AthenaPoolCnvSvc.h.

215{ this, "OneDataHeaderForm", false };

◆ m_persSvcPerInputType

Gaudi::Property<std::string> AthenaPoolCnvSvc::m_persSvcPerInputType {this,"PersSvcPerInputType",""}
protected

PersSvcPerInputType, string property, tree name to use multiple persistency services, one per input type.

default = "", no tree name results in a single persistency service.

Definition at line 208 of file AthenaPoolCnvSvc.h.

208{this,"PersSvcPerInputType",""};

◆ m_persSvcPerOutput

Gaudi::Property<bool> AthenaPoolCnvSvc::m_persSvcPerOutput {this,"PersSvcPerOutput",true}
protected

PersSvcPerOutput, boolean property to use multiple persistency services, one per output stream.

default = true.

Definition at line 203 of file AthenaPoolCnvSvc.h.

203{this,"PersSvcPerOutput",true};

◆ m_poolAttr

Gaudi::Property<std::vector<std::string> > AthenaPoolCnvSvc::m_poolAttr {this,"PoolAttributes",{},"Pool Attributes","OrderedSet<std::string>"}
private

Output PoolAttributes, vector with names and values of technology specific attributes for POOL.

Definition at line 187 of file AthenaPoolCnvSvc.h.

187{this,"PoolAttributes",{},"Pool Attributes","OrderedSet<std::string>"};

◆ m_poolSvc

ServiceHandle<IPoolSvc> AthenaPoolCnvSvc::m_poolSvc {this,"PoolSvc","PoolSvc"}
private

Definition at line 171 of file AthenaPoolCnvSvc.h.

171{this,"PoolSvc","PoolSvc"};

◆ m_processedContextIds

std::set<unsigned int> AthenaPoolCnvSvc::m_processedContextIds
protected

Track context IDs for which extractPoolAttributes has been called.

Definition at line 212 of file AthenaPoolCnvSvc.h.

◆ m_useDetailChronoStat

Gaudi::Property<bool> AthenaPoolCnvSvc::m_useDetailChronoStat {this,"UseDetailChronoStat",false}
private

UseDetailChronoStat, enable detailed output for time and size statistics for AthenaPOOL: default = false.

Definition at line 181 of file AthenaPoolCnvSvc.h.

181{this,"UseDetailChronoStat",false};

The documentation for this class was generated from the following files: