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 decodeOutputSpec (std::string &connectionSpec, int &outputTech) const override
 Extract/deduce the DB technology from the connection string/file specification.
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
Gaudi::Property< int > m_numberEventsPerWrite {this,"NumberEventsPerWrite",-1}
 To use MetadataSvc to merge data placed in a certain container When using TMemFile call Write on number of Events, respecting CollectionTree auto_flush.
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)

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::map< std::string, std::string > > m_storageTechProp {this, "StorageTechnology", {{"*","ROOTTREEINDEX"}}}
 Default Storage Tech for containers (ROOTTREE, ROOTTREEINDEX, ROOTRNTUPLE)
std::map< std::string, int > m_storageTechMap
Gaudi::Property< std::string > m_containerPrefixProp {this,"PoolContainerPrefix","Default"}
 POOL Container name prefix - will be part of or whole TTree/RNTuple name 'Default' takes the prefix from APRDefaults according to StorageTech.
Gaudi::Property< std::string > m_containerNameHintProp {this,"TopLevelContainerName",""}
 TopLevelContainerName, naming hint policy for top level POOL container: default = "<type>".
Gaudi::Property< std::string > m_branchNameHintProp {this,"SubLevelBranchName", "<type>/<key>"}
 SubLevelBranchName, naming hint policy for POOL branching: ("" = no branching)
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
std::vector< unsigned int > m_contextAttr
std::map< std::string, int > m_fileCommitCounter
std::map< std::string, int > m_fileFlushSetting
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
Gaudi::Property< std::vector< std::string > > m_maxFileSizes {this,"MaxFileSizes",{}}
 MaxFileSizes, vector with maximum file sizes for Athena POOL output files.
long long m_domainMaxFileSize =std::numeric_limits<long long>::max()
std::map< std::string, long long > m_databaseMaxFileSize
std::string m_defContainerType {}
 Default container type (from PoolSvc)

Friends

class SvcFactory< AthenaPoolCnvSvc >

Detailed Description

This class provides the interface between Athena and PoolSvc.

Definition at line 40 of file AthenaPoolCnvSvc.h.

Constructor & Destructor Documentation

◆ AthenaPoolCnvSvc()

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

Standard Service Constructor.

Definition at line 597 of file AthenaPoolCnvSvc.cxx.

597 :
598 base_class(name, pSvcLocator, pool::POOL_StorageType.type()) {
599}
static const DbType POOL_StorageType
Definition DbType.h:98

◆ ~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 546 of file AthenaPoolCnvSvc.cxx.

546 {
547 bool retError = false;
548 std::size_t cpos = connection.find(':');
549 std::size_t bpos = connection.find('[');
550 if (cpos == std::string::npos) {
551 cpos = 0;
552 } else {
553 cpos++;
554 }
555 if (bpos != std::string::npos) bpos = bpos - cpos;
556 const std::string conn = connection.substr(cpos, bpos);
557 ATH_MSG_VERBOSE("Cleanup for Connection='"<< conn <<"'");
558 for (auto converter : m_cnvs) {
559 if (!converter->cleanUp(conn).isSuccess()) {
560 ATH_MSG_WARNING("AthenaPoolConverter cleanUp failed.");
561 retError = true;
562 }
563 }
564 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
565}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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 343 of file AthenaPoolCnvSvc.cxx.

343 {
344 // This is called after all DataObjects are converted.
345 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
346 // StopWatch listens from here until the end of this current scope
347 PMonUtils::BasicStopWatch stopWatch("commitOutput", m_chronoMap);
348 std::unique_lock<std::mutex> lock(m_mutex);
349 // Extract the technology
350 int tech{0};
351 if (!decodeOutputSpec(outputConnection, tech).isSuccess()) {
352 ATH_MSG_ERROR("connectOutput FAILED extract file name and technology.");
353 return(StatusCode::FAILURE);
354 }
355 unsigned int contextId = outputContextId(outputConnection);
356 if (!processPoolAttributes(m_domainAttr, outputConnection, contextId).isSuccess()) {
357 ATH_MSG_DEBUG("commitOutput failed process POOL domain attributes.");
358 }
359 if (!processPoolAttributes(m_databaseAttr, outputConnection, contextId).isSuccess()) {
360 ATH_MSG_DEBUG("commitOutput failed process POOL database attributes.");
361 }
362 if (!processPoolAttributes(m_containerAttr, outputConnection, contextId).isSuccess()) {
363 ATH_MSG_DEBUG("commitOutput failed process POOL container attributes.");
364 }
365 std::size_t merge = outputConnection.find("?pmerge="); // Used to remove trailing TMemFile
366 const std::string baseOutputConnection = outputConnection.substr(0, merge);
367 m_fileCommitCounter[baseOutputConnection]++;
368 if (merge != std::string::npos && m_fileFlushSetting[baseOutputConnection] > 0 && m_fileCommitCounter[baseOutputConnection] % m_fileFlushSetting[baseOutputConnection] == 0) {
369 doCommit = true;
370 ATH_MSG_DEBUG("commitOutput sending data.");
371 }
372
373 // lock.unlock(); //MN: first need to make commitCache slot-specific
374 try {
375 if (doCommit) {
376 if (!m_poolSvc->commit(contextId).isSuccess()) {
377 ATH_MSG_ERROR("commitOutput FAILED to commit OutputStream.");
378 return(StatusCode::FAILURE);
379 }
380 } else {
381 if (!m_poolSvc->commitAndHold(contextId).isSuccess()) {
382 ATH_MSG_ERROR("commitOutput FAILED to commitAndHold OutputStream.");
383 return(StatusCode::FAILURE);
384 }
385 }
386 } catch (std::exception& e) {
387 ATH_MSG_ERROR("commitOutput - caught exception: " << e.what());
388 return(StatusCode::FAILURE);
389 }
390 if (!this->cleanUp(baseOutputConnection).isSuccess()) {
391 ATH_MSG_ERROR("commitOutput FAILED to cleanup converters.");
392 return(StatusCode::FAILURE);
393 }
394 // Check FileSize
395 long long int currentFileSize = m_poolSvc->getFileSize(outputConnection, tech, contextId);
396 if (m_databaseMaxFileSize.find(outputConnection) != m_databaseMaxFileSize.end()) {
397 if (currentFileSize > m_databaseMaxFileSize[outputConnection]) {
398 ATH_MSG_WARNING(std::format("FileSize {} > {} for {}", currentFileSize, m_databaseMaxFileSize[outputConnection], outputConnection));
399 return(StatusCode::RECOVERABLE);
400 }
401 } else if (currentFileSize > m_domainMaxFileSize) {
402 ATH_MSG_WARNING(std::format("FileSize {} > {} for {}", currentFileSize, m_domainMaxFileSize, outputConnection));
403 return(StatusCode::RECOVERABLE);
404 }
405 return(StatusCode::SUCCESS);
406}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::map< std::string, int > m_fileCommitCounter
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.
std::map< std::string, long long > m_databaseMaxFileSize
unsigned outputContextId(const std::string &outputConnection)
ServiceHandle< IPoolSvc > m_poolSvc
virtual StatusCode cleanUp(const std::string &connection) override
Implement cleanUp to call all registered IAthenaPoolCleanUp cleanUp() function.
merge(input_file_pattern, output_file)
Merge many input LHE files into a single output file.
Definition LHE.py:29

◆ 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 271 of file AthenaPoolCnvSvc.cxx.

271 {
272// This is called before DataObjects are being converted.
273 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
274 // Extract the technology
275 int tech{0};
276 if (!decodeOutputSpec(outputConnection, tech).isSuccess()) {
277 ATH_MSG_ERROR("connectOutput FAILED extract file name and technology.");
278 return(StatusCode::FAILURE);
279 }
280 unsigned int contextId = outputContextId(outputConnection);
281 try {
282 if (!m_poolSvc->connect(pool::ITransaction::UPDATE, contextId).isSuccess()) {
283 ATH_MSG_ERROR("connectOutput FAILED to open an UPDATE transaction.");
284 return(StatusCode::FAILURE);
285 }
286 } catch (std::exception& e) {
287 ATH_MSG_ERROR("connectOutput - caught exception: " << e.what());
288 return(StatusCode::FAILURE);
289 }
290
291 std::unique_lock<std::mutex> lock(m_mutex);
292 if (std::find(m_contextAttr.begin(), m_contextAttr.end(), contextId) == m_contextAttr.end()) {
293 std::size_t merge = outputConnection.find("?pmerge="); // Used to remove trailing TMemFile
294 int flush = m_numberEventsPerWrite.value();
295 m_contextAttr.push_back(contextId);
296 // Setting default 'TREE_MAX_SIZE' for ROOT to 1024 GB to avoid file chains.
297 std::vector<std::string> maxFileSize;
298 maxFileSize.push_back("TREE_MAX_SIZE");
299 maxFileSize.push_back("1099511627776L");
300 m_domainAttr.emplace_back(std::move(maxFileSize));
301 // Extracting OUTPUT POOL ItechnologySpecificAttributes for Domain, Database and Container.
302 extractPoolAttributes(m_poolAttr, &m_containerAttr, &m_databaseAttr, &m_domainAttr);
303 //FIXME
304 for (auto& dbAttrEntry : m_databaseAttr) {
305 const std::string& opt = dbAttrEntry[0];
306 std::string& data = dbAttrEntry[1];
307 const std::string& file = dbAttrEntry[2];
308 const std::string& cont = dbAttrEntry[3];
309 std::size_t equal = cont.find('='); // Used to remove leading "TTree="
310 if (equal == std::string::npos) equal = 0;
311 else equal++;
312 const auto& prefix = m_containerPrefixProp.value();
313 std::size_t colon = prefix.find(':');
314 if (colon == std::string::npos) colon = 0; // Used to remove leading technology
315 else colon++;
317 const auto& strProp = (prefix == "Default") ? defaultContName : prefix;
318 if (merge != std::string::npos && opt == "TREE_AUTO_FLUSH" && 0 == outputConnection.compare(0, merge, file) &&cont.compare(equal, std::string::npos, strProp, colon) == 0 && data != "int" && data != "DbLonglong" && data != "double" && data != "string") {
319 flush = atoi(data.c_str());
320 if (flush < 0 && m_numberEventsPerWrite.value() > 0) {
322 data = std::to_string(flush);
323 } else if (flush > 0 && flush < m_numberEventsPerWrite.value()) {
324 flush = flush * (int(static_cast<float>(m_numberEventsPerWrite.value()) / flush - 0.5) + 1);
325 }
326 }
327 }
328 if (merge != std::string::npos) {
329 ATH_MSG_INFO("connectOutput setting auto write for: " << outputConnection << " to " << flush << " events");
330 m_fileFlushSetting[outputConnection.substr(0, merge)] = flush;
331 }
332 }
333 if (!processPoolAttributes(m_domainAttr, outputConnection, contextId).isSuccess()) {
334 ATH_MSG_DEBUG("connectOutput failed process POOL domain attributes.");
335 }
336 if (!processPoolAttributes(m_databaseAttr, outputConnection, contextId).isSuccess()) {
337 ATH_MSG_DEBUG("connectOutput failed process POOL database attributes.");
338 }
339 return(StatusCode::SUCCESS);
340}
#define ATH_MSG_INFO(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
std::vector< unsigned int > m_contextAttr
Gaudi::Property< std::string > m_containerPrefixProp
POOL Container name prefix - will be part of or whole TTree/RNTuple name 'Default' takes the prefix f...
std::map< std::string, int > m_fileFlushSetting
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.
Gaudi::Property< int > m_numberEventsPerWrite
To use MetadataSvc to merge data placed in a certain container When using TMemFile call Write on numb...
std::vector< std::vector< std::string > > m_domainAttr
int type() const
Access to full type.
Definition DbType.h:65
bool equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition fpcompare.h:114
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
static const DbType ROOTRNTUPLE_StorageType
Definition DbType.h:103
static constexpr const char * EventData
Definition APRDefaults.h:18
static constexpr const char * EventData
Definition APRDefaults.h:12
TFile * file

◆ 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 266 of file AthenaPoolCnvSvc.cxx.

267 {
268 return(connectOutput(outputConnectionSpec));
269}

◆ 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 494 of file AthenaPoolCnvSvc.cxx.

495 {
496 assert(pAddress);
497 const TokenAddress* tokAddr = dynamic_cast<const TokenAddress*>(pAddress);
498 if (tokAddr != nullptr && tokAddr->getToken() != nullptr) {
499 refAddress = tokAddr->getToken()->toString();
500 } else {
501 refAddress = *pAddress->par();
502 }
503 return(StatusCode::SUCCESS);
504}
This class provides a Generic Transient Address for POOL tokens.
Token * getToken()
virtual const std::string toString() const
Retrieve the string representation of the token.
Definition Token.cxx:134

◆ 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 482 of file AthenaPoolCnvSvc.cxx.

485 {
486 if (svcType != repSvcType()) {
487 ATH_MSG_ERROR("createAddress: svcType != POOL_StorageType " << svcType << " " << repSvcType());
488 return(StatusCode::FAILURE);
489 }
490 refpAddress = new GenericAddress(repSvcType(), clid, refAddress);
491 return(StatusCode::SUCCESS);
492}

◆ 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 456 of file AthenaPoolCnvSvc.cxx.

460 {
461 if( svcType != repSvcType() ) {
462 ATH_MSG_ERROR("createAddress: svcType != POOL_StorageType " << svcType << " " << repSvcType());
463 return(StatusCode::FAILURE);
464 }
465 std::unique_ptr<Token> token;
466 if (par[0].compare(0, 3, "SHM") == 0) {
467 token = std::make_unique<Token>();
468 token->setOid(Token::OID_t(ip[0], ip[1]));
469 token->setAuxString("[PNAME=" + par[2] + "]");
470 RootType classDesc = RootType::ByNameNoQuiet(par[2]);
471 token->setClassID(pool::DbReflex::guid(classDesc));
472 } else {
473 token.reset(m_poolSvc->getToken(par[0], par[1], ip[0]));
474 }
475 if (token == nullptr) {
476 return(StatusCode::RECOVERABLE);
477 }
478 refpAddress = new TokenAddress(repSvcType(), clid, "", par[1], IPoolSvc::kInputStream, std::move(token));
479 return(StatusCode::SUCCESS);
480}
TTypeAdapter RootType
Definition RootType.h:211
@ kInputStream
Definition IPoolSvc.h:39
static TScopeAdapter ByNameNoQuiet(const std::string &name, Bool_t load=kTRUE)
Definition RootType.cxx:586
static Guid guid(const TypeH &id)
Determine Guid (normalized string form) from reflection type.

◆ 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 170 of file AthenaPoolCnvSvc.cxx.

170 {
171 assert(pAddress);
172 std::string objName = "ALL";
173 if (m_useDetailChronoStat.value()) {
174 if (m_clidSvc->getTypeNameOfID(pAddress->clID(), objName).isFailure()) {
175 objName = std::to_string(pAddress->clID());
176 }
177 objName += '#';
178 objName += *(pAddress->par() + 1);
179 }
180 // StopWatch listens from here until the end of this current scope
181 PMonUtils::BasicStopWatch stopWatch("cObj_" + objName, m_chronoMap);
182 if (!m_persSvcPerInputType.empty()) { // Use separate PersistencySvc for each input data type
183 TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(pAddress);
184 if (tokAddr != nullptr && tokAddr->getToken() != nullptr && (tokAddr->getToken()->contID().starts_with(m_persSvcPerInputType.value() + "(") || tokAddr->getToken()->contID().starts_with(m_persSvcPerInputType.value() + "_"))) {
185 const unsigned int maxContext = m_poolSvc->getInputContextMap().size();
186 const unsigned int auxContext = m_poolSvc->getInputContext(tokAddr->getToken()->classID().toString() + tokAddr->getToken()->dbID().toString(), 1);
187 char text[32];
188 const std::string contextStr = std::format("[CTXT={:08X}]", auxContext);
189 std::strncpy(text, contextStr.c_str(), sizeof(text) - 1);
190 text[sizeof(text) - 1] = '\0';
191 if (m_poolSvc->getInputContextMap().size() > maxContext) {
192 if (m_poolSvc->setAttribute("TREE_CACHE", "0", pool::DbType(pool::ROOTTREE_StorageType).type(), "FID:" + tokAddr->getToken()->dbID().toString(), m_persSvcPerInputType.value(), auxContext).isSuccess()) {
193 ATH_MSG_DEBUG("setInputAttribute failed to switch off TTreeCache for id = " << auxContext << ".");
194 }
195 }
196 tokAddr->getToken()->setAuxString(text);
197 }
198 }
199 // Forward to base class createObj
200 StatusCode status = ::AthCnvSvc::createObj(pAddress, refpObject);
201 return(status);
202}
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.
Token & setAuxString(const std::string &auxString)
Set auxiliary string.
Definition Token.h:93
const std::string & contID() const
Access container identifier.
Definition Token.h:69
const Guid & classID() const
Access database identifier.
Definition Token.h:73
const Guid & dbID() const
Access database identifier.
Definition Token.h:64
::StatusCode StatusCode
StatusCode definition for legacy code.
status
Definition merge.py:16
static const DbType ROOTTREE_StorageType
Definition DbType.h:101

◆ 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 204 of file AthenaPoolCnvSvc.cxx.

204 {
205 assert(pObject);
206 std::string objName = "ALL";
207 if (m_useDetailChronoStat.value()) {
208 if (m_clidSvc->getTypeNameOfID(pObject->clID(), objName).isFailure()) {
209 objName = std::to_string(pObject->clID());
210 }
211 objName += '#';
212 objName += pObject->registry()->name();
213 }
214 // StopWatch listens from here until the end of this current scope
215 PMonUtils::BasicStopWatch stopWatch("cRep_" + objName, m_chronoMap);
216 StatusCode status = StatusCode::FAILURE;
217 if (pObject->clID() == 1) {
218 // No transient object was found use cnv to write default persistent object
219 SG::DataProxy* proxy = dynamic_cast<SG::DataProxy*>(pObject->registry());
220 if (proxy != nullptr) {
221 IConverter* cnv = converter(proxy->clID());
222 status = cnv->createRep(pObject, refpAddress);
223 }
224 } else {
225 // Forward to base class createRep
226 try {
227 status = ::AthCnvSvc::createRep(pObject, refpAddress);
228 } catch(std::runtime_error& e) {
229 ATH_MSG_FATAL(e.what());
230 }
231 }
232 return(status);
233}
#define ATH_MSG_FATAL(x)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.

◆ decodeOutputSpec()

StatusCode AthenaPoolCnvSvc::decodeOutputSpec ( std::string & connectionSpec,
int & outputTech ) const
overridevirtual

Extract/deduce the DB technology from the connection string/file specification.

Definition at line 506 of file AthenaPoolCnvSvc.cxx.

506 {
507 if (fileSpec.starts_with ( "ROOTKEY:")) {
508 outputTech = pool::ROOTKEY_StorageType.type();
509 fileSpec.erase(0, 8);
510 } else if (fileSpec.starts_with ( "ROOTTREE:")) {
511 outputTech = pool::ROOTTREE_StorageType.type();
512 fileSpec.erase(0, 9);
513 } else if (fileSpec.starts_with ( "ROOTTREEINDEX:")) {
515 fileSpec.erase(0, 14);
516 } else if (fileSpec.starts_with ( "ROOTRNTUPLE:")) {
517 outputTech = pool::ROOTRNTUPLE_StorageType.type();
518 fileSpec.erase(0, 12);
519 } else if (outputTech == 0) {
520 // Extract the file name
521 std::string fileName{fileSpec};
522 if (auto pos = fileSpec.find("?pmerge="); pos != std::string::npos) {
523 fileName = fileSpec.substr(0, pos);
524 }
525 // Find the appropriate event data technology for this file
526 // This will be used for event data and its data header
527 // First we look for an exact file name match
528 // If that fails, we look for a wildcard ("*") match
529 // If that also fails, we use the default value from PoolSvc
530 if (auto it = m_storageTechMap.find(fileName); it != m_storageTechMap.end()) {
531 outputTech = it->second;
532 } else if (it = m_storageTechMap.find("*"); it != m_storageTechMap.end()) {
533 outputTech = it->second;
534 } else {
535 outputTech = pool::DbType::getType(m_defContainerType).type();
536 }
537 }
538 return StatusCode::SUCCESS;
539}
std::map< std::string, int > m_storageTechMap
static DbType getType(const std::string &name)
Access known storage type object by name.
static const DbType ROOTTREEINDEX_StorageType
Definition DbType.h:102
static const DbType ROOTKEY_StorageType
Definition DbType.h:100

◆ disconnectOutput()

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

Disconnect to the output connection.

Definition at line 409 of file AthenaPoolCnvSvc.cxx.

409 {
410 std::string outputConnection = outputConnectionSpec.substr(0, outputConnectionSpec.find('['));
411 unsigned int contextId = outputContextId(outputConnection);
412 StatusCode sc = m_poolSvc->disconnect(contextId);
413 return sc;
414}
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 601 of file AthenaPoolCnvSvc.cxx.

604 {
605 std::vector<std::string> opt;
606 std::string attributeName, containerName, databaseName, valueString;
607 for (const auto& propertyValue : property.value()) {
608 opt.clear();
609 attributeName.clear();
610 containerName.clear();
611 databaseName.clear();
612 valueString.clear();
613 using Gaudi::Utils::AttribStringParser;
614 for (const AttribStringParser::Attrib& attrib : AttribStringParser (propertyValue)) {
615 if (attrib.tag == "DatabaseName") {
616 databaseName = attrib.value;
617 } else if (attrib.tag == "ContainerName") {
618 if (databaseName.empty()) {
619 databaseName = "*";
620 }
621 containerName = attrib.value;
622 } else {
623 attributeName = attrib.tag;
624 valueString = attrib.value;
625 }
626 }
627 if (!attributeName.empty() && !valueString.empty()) {
628 opt.push_back(attributeName);
629 opt.push_back(valueString);
630 if (!databaseName.empty()) {
631 opt.push_back(databaseName);
632 if (!containerName.empty()) {
633 opt.push_back(containerName);
634 if (containerName.compare(0, 6, "TTree=") == 0) {
635 dbAttr->push_back(opt);
636 } else {
637 contAttr->push_back(opt);
638 }
639 } else {
640 opt.push_back("");
641 dbAttr->push_back(opt);
642 }
643 } else if (domAttr != 0) {
644 domAttr->push_back(opt);
645 } else {
646 opt.push_back("*");
647 opt.push_back("");
648 dbAttr->push_back(opt);
649 }
650 }
651 }
652}

◆ 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 235 of file AthenaPoolCnvSvc.cxx.

235 {
236 assert(pObject);
237 std::string objName = "ALL";
238 if (m_useDetailChronoStat.value()) {
239 if (m_clidSvc->getTypeNameOfID(pObject->clID(), objName).isFailure()) {
240 objName = std::to_string(pObject->clID());
241 }
242 objName += '#';
243 objName += pObject->registry()->name();
244 }
245 // StopWatch listens from here until the end of this current scope
246 PMonUtils::BasicStopWatch stopWatch("fRep_" + objName, m_chronoMap);
247 StatusCode status = StatusCode::FAILURE;
248 if (pObject->clID() == 1) {
249 // No transient object was found use cnv to write default persistent object
250 SG::DataProxy* proxy = dynamic_cast<SG::DataProxy*>(pObject->registry());
251 if (proxy != nullptr) {
252 IConverter* cnv = converter(proxy->clID());
253 status = cnv->fillRepRefs(pAddress, pObject);
254 }
255 } else {
256 // Forward to base class fillRepRefs
257 try {
258 status = ::AthCnvSvc::fillRepRefs(pAddress, pObject);
259 } catch(std::runtime_error& e) {
260 ATH_MSG_FATAL(e.what());
261 }
262 }
263 return(status);
264}
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 136 of file AthenaPoolCnvSvc.cxx.

136 {
137 ATH_MSG_VERBOSE("Finalizing...");
138 // Some algorithms write in finalize(), flush DHForms if any are left
139 flushDataHeaderForms();
140 // Release ClassIDSvc
141 if (!m_clidSvc.release().isSuccess()) {
142 ATH_MSG_WARNING("Cannot release ClassIDSvc.");
143 }
144 // Release PoolSvc
145 if (!m_poolSvc.release().isSuccess()) {
146 ATH_MSG_WARNING("Cannot release PoolSvc.");
147 }
148 // Print Performance Statistics
149 // The pattern AthenaPoolCnvSvc.*PerfStats is ignored in AtlasTest/TestTools/share/post.sh
150 const std::string msgPrefix{"PerfStats "};
151 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
152 ATH_MSG_INFO(msgPrefix << "Timing Measurements for AthenaPoolCnvSvc");
153 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
154 for(const auto& [key, value] : m_chronoMap) {
155 ATH_MSG_INFO(msgPrefix << "| " << std::left << std::setw(15) << key << " | "
156 << std::right << std::setw(15) << std::fixed << std::setprecision(0) << value << " ms |");
157 }
158 ATH_MSG_INFO(msgPrefix << std::string(40, '-'));
159
160 m_cnvs.clear();
161 m_cnvs.shrink_to_fit();
162 return(StatusCode::SUCCESS);
163}

◆ 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 122 of file AthenaPoolCnvSvc.cxx.

122 {
123 // Write remaining DataHeaderForms for a given streamName, "*"" means all
124 auto DHCnvListener = dynamic_cast<IIncidentListener*>( converter( ClassID_traits<DataHeader>::ID() ) );
125 FileIncident incident(name(), "WriteDataHeaderForms", streamName);
126 if( DHCnvListener ) DHCnvListener->handle(incident);
127}

◆ getPoolSvc()

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

Definition at line 423 of file AthenaPoolCnvSvc.cxx.

423 {
424 return(&*m_poolSvc);
425}

◆ handle()

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

Implementation of IIncidentListener: Handle for EndEvent incidence.

Definition at line 589 of file AthenaPoolCnvSvc.cxx.

589 {
590 if (incident.type() == "EndEvent") {
591 if (!processPoolAttributes(m_inputAttrPerEvent, m_lastInputFileName, IPoolSvc::kInputStream).isSuccess()) {
592 ATH_MSG_DEBUG("handle EndEvent failed process POOL database attributes.");
593 }
594 }
595}

◆ initialize()

StatusCode AthenaPoolCnvSvc::initialize ( )
overridevirtual

Required of all Gaudi Services.

Definition at line 35 of file AthenaPoolCnvSvc.cxx.

35 {
36 // Initialize DataModelCompatSvc
37 ServiceHandle<IService> dmcsvc("DataModelCompatSvc", this->name());
38 ATH_CHECK(dmcsvc.retrieve());
39 // Retrieve PoolSvc
40 ATH_CHECK(m_poolSvc.retrieve());
41 StringProperty defContainerType("DefaultContainerType", "ROOTTREEINDEX");
42 if(IProperty* propertyServer = dynamic_cast<IProperty*>(m_poolSvc.get())) {
43 propertyServer->getProperty(&defContainerType).ignore();
44 }
45 m_defContainerType = defContainerType.value();
46 // Retrieve ClassIDSvc
47 ATH_CHECK(m_clidSvc.retrieve());
48 // Register this service for 'I/O' events
49 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
50 ATH_CHECK(iomgr.retrieve());
51 if (!iomgr->io_register(this).isSuccess()) {
52 ATH_MSG_FATAL("Could not register myself with the IoComponentMgr !");
53 return(StatusCode::FAILURE);
54 }
55 // Extracting MaxFileSizes for global default and map by Database name.
56 for (const auto& maxFileSizeSpec : m_maxFileSizes.value()) {
57 if (auto p = maxFileSizeSpec.find('='); p != std::string::npos) {
58 long long maxFileSize = 0;
59 const char* start = maxFileSizeSpec.data() + (p + 1);
60 const char* end = maxFileSizeSpec.data() + maxFileSizeSpec.size();
61 if (auto [ptr, ec] = std::from_chars(start, end, maxFileSize); ec != std::errc{}) {
62 ATH_MSG_WARNING(std::format("Invalid MaxFileSize value: {}", std::string(start, end)));
63 }
64 std::string databaseName = maxFileSizeSpec.substr(0, maxFileSizeSpec.find_first_of(" ="));
65 std::unique_lock<std::mutex> lock(m_mutex);
66 m_databaseMaxFileSize.emplace(std::move(databaseName), maxFileSize);
67 } else {
68 if (auto [ptr, ec] = std::from_chars(maxFileSizeSpec.data(), maxFileSizeSpec.data() + maxFileSizeSpec.size(), m_domainMaxFileSize); ec != std::errc{}) {
69 ATH_MSG_WARNING(std::format("Invalid MaxFileSize value: {}", maxFileSizeSpec));
70 }
71 }
72 }
73 // Validate provided event data technologies and fill the internal cache
74 for (const auto& [key, value] : m_storageTechProp.value()) {
75 try {
76 const auto dbType = pool::DbType::getType(value);
77 if (dbType == pool::TEST_StorageType) {
78 ATH_MSG_FATAL(std::format("Unknown storage type requested for file {}: {}", key, value));
79 return StatusCode::FAILURE;
80 }
81 m_storageTechMap.emplace(key, dbType.type());
82 } catch (const std::exception& e) {
83 ATH_MSG_FATAL(std::format("Exception while getting storage type for file {}: {}", key, e.what()));
84 return StatusCode::FAILURE;
85 } catch (...) {
86 ATH_MSG_FATAL(std::format("Unknown exception while getting storage type for file {}", key));
87 return StatusCode::FAILURE;
88 }
89 }
90 // Extracting INPUT POOL ItechnologySpecificAttributes for Domain, Database and Container.
91 extractPoolAttributes(m_inputPoolAttr, &m_inputAttr, &m_inputAttr, &m_inputAttr);
92 // Extracting the INPUT POOL ItechnologySpecificAttributes which are to be printed for each event
93 extractPoolAttributes(m_inputPoolAttrPerEvent, &m_inputAttrPerEvent, &m_inputAttrPerEvent, &m_inputAttrPerEvent);
94 // Setup incident for EndEvent to print out attributes each event
95 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
96 long int pri = 1000;
97 if (!m_inputPoolAttrPerEvent.value().empty()) {
98 // Set to be listener for EndEvent
99 incSvc->addListener(this, "EndEvent", pri);
100 ATH_MSG_DEBUG("Subscribed to EndEvent for printing out input file attributes.");
101 }
102 if (!processPoolAttributes(m_inputAttr, "", IPoolSvc::kInputStream, false, true, true).isSuccess()) {
103 ATH_MSG_DEBUG("setInputAttribute failed setting POOL domain attributes.");
104 }
105
106 // Load these dictionaries now, so we don't need to try to do so
107 // while multiple threads are running.
108 TClass::GetClass ("TLeafI");
109 TClass::GetClass ("TLeafL");
110 TClass::GetClass ("TLeafD");
111 TClass::GetClass ("TLeafF");
112
113 return(StatusCode::SUCCESS);
114}
#define ATH_CHECK
Evaluate an expression and check for errors.
Gaudi::Property< std::vector< std::string > > m_maxFileSizes
MaxFileSizes, vector with maximum file sizes for Athena POOL output files.
Gaudi::Property< std::map< std::string, std::string > > m_storageTechProp
Default Storage Tech for containers (ROOTTREE, ROOTTREEINDEX, ROOTRNTUPLE)
Gaudi::Property< std::vector< std::string > > m_inputPoolAttrPerEvent
Print input PoolAttributes per event, vector with names of technology specific attributes for POOL to...
static const DbType TEST_StorageType
Definition DbType.h:97

◆ io_finalize()

StatusCode AthenaPoolCnvSvc::io_finalize ( )
overridevirtual

Definition at line 165 of file AthenaPoolCnvSvc.cxx.

165 {
166 ATH_MSG_DEBUG("I/O finalization...");
167 return(StatusCode::SUCCESS);
168}

◆ io_reinit()

StatusCode AthenaPoolCnvSvc::io_reinit ( )
overridevirtual

Definition at line 116 of file AthenaPoolCnvSvc.cxx.

116 {
117 ATH_MSG_DEBUG("I/O reinitialization...");
118 m_contextAttr.clear();
119 return(StatusCode::SUCCESS);
120}

◆ outputContextId()

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

Definition at line 417 of file AthenaPoolCnvSvc.cxx.

417 {
418 return m_persSvcPerOutput?
419 m_poolSvc->getOutputContext(outputConnection) : (unsigned int)IPoolSvc::kOutputStream;
420}
@ 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 654 of file AthenaPoolCnvSvc.cxx.

659 {
660 bool retError = false;
661 for (auto& attrEntry : attr) {
662 if (attrEntry.size() == 2) {
663 const std::string& opt = attrEntry[0];
664 std::string data = attrEntry[1];
665 if (data == "int" || data == "DbLonglong" || data == "double" || data == "string") {
666 if (doGet) {
667 if (!m_poolSvc->getAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), contextId).isSuccess()) {
668 ATH_MSG_DEBUG("getAttribute failed for domain attr " << opt);
669 retError = true;
670 }
671 }
672 } else if (doSet) {
673 if (m_poolSvc->setAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), contextId).isSuccess()) {
674 ATH_MSG_DEBUG("setAttribute " << opt << " to " << data);
675 if (doClear) {
676 attrEntry.clear();
677 }
678 } else {
679 ATH_MSG_DEBUG("setAttribute failed for domain attr " << opt << " to " << data);
680 retError = true;
681 }
682 }
683 }
684 if (attrEntry.size() == 4) {
685 const std::string& opt = attrEntry[0];
686 std::string data = attrEntry[1];
687 const std::string& file = attrEntry[2];
688 const std::string& cont = attrEntry[3];
689 if (!fileName.empty() && (0 == fileName.compare(0, fileName.find('?'), file)
690 || (file[0] == '*' && file.find("," + fileName + ",") == std::string::npos))) {
691 if (data == "int" || data == "DbLonglong" || data == "double" || data == "string") {
692 if (doGet) {
693 if (!m_poolSvc->getAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
694 ATH_MSG_DEBUG("getAttribute failed for database/container attr " << opt);
695 retError = true;
696 }
697 }
698 } else if (doSet) {
699 if (m_poolSvc->setAttribute(opt, data, pool::DbType(pool::ROOTTREE_StorageType).type(), fileName, cont, contextId).isSuccess()) {
700 ATH_MSG_DEBUG("setAttribute " << opt << " to " << data << " for db: " << fileName << " and cont: " << cont);
701 if (doClear) {
702 if (file[0] == '*' && !m_persSvcPerOutput) {
703 attrEntry[2] += "," + fileName + ",";
704 } else {
705 attrEntry.clear();
706 }
707 }
708 } else {
709 ATH_MSG_DEBUG("setAttribute failed for " << opt << " to " << data << " for db: " << fileName << " and cont: " << cont);
710 retError = true;
711 }
712 }
713 }
714 }
715 }
716 std::erase_if(attr, [](const auto& entry) { return entry.empty(); });
717 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
718}
std::size_t erase_if(T_container &container, T_Func pred)

◆ registerCleanUp()

StatusCode AthenaPoolCnvSvc::registerCleanUp ( IAthenaPoolCleanUp * cnv)
overridevirtual

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

Definition at line 541 of file AthenaPoolCnvSvc.cxx.

541 {
542 m_cnvs.push_back(cnv);
543 return(StatusCode::SUCCESS);
544}

◆ 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 427 of file AthenaPoolCnvSvc.cxx.

427 {
428 // StopWatch listens from here until the end of this current scope
429 PMonUtils::BasicStopWatch stopWatch("cRepR_ALL", m_chronoMap);
430 Token* token = nullptr;
431 if (m_persSvcPerOutput) { // Use separate PersistencySvc for each output stream/file
432 char text[32];
433 const std::string contextStr = std::format("[CTXT={:08X}]", m_poolSvc->getOutputContext(placement->fileName()));
434 std::strncpy(text, contextStr.c_str(), sizeof(text) - 1);
435 text[sizeof(text) - 1] = '\0';
436 placement->setAuxString(text);
437 }
438 token = m_poolSvc->registerForWrite(placement, obj, classDesc);
439 return(token);
440}
Placement & setAuxString(const std::string &auxString)
Set auxiliary string.
Definition Placement.h:42
const std::string & fileName() const
Access file name.
Definition Placement.h:28
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition Token.h:21

◆ 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 567 of file AthenaPoolCnvSvc.cxx.

567 {
568 // Set attributes for input file
569 m_lastInputFileName = fileName; // Save file name for printing attributes per event
570 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, IPoolSvc::kInputStream, false, true, false).isSuccess()) {
571 ATH_MSG_DEBUG("setInputAttribute failed setting POOL database/container attributes.");
572 }
573 if (!processPoolAttributes(m_inputAttr, m_lastInputFileName, IPoolSvc::kInputStream, true, false).isSuccess()) {
574 ATH_MSG_DEBUG("setInputAttribute failed getting POOL database/container attributes.");
575 }
576 if (!m_persSvcPerInputType.empty()) {
577 // Loop over all extra event input contexts and switch off TTreeCache
578 const auto& extraInputContextMap = m_poolSvc->getInputContextMap();
579 for (const auto& [label, id]: extraInputContextMap) {
580 if (m_poolSvc->setAttribute("TREE_CACHE", "0", pool::DbType(pool::ROOTTREE_StorageType).type(), m_lastInputFileName, m_persSvcPerInputType.value(), id).isSuccess()) {
581 ATH_MSG_DEBUG("setInputAttribute failed to switch off TTreeCache for = " << label << ".");
582 }
583 }
584 }
585 return(StatusCode::SUCCESS);
586}
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 442 of file AthenaPoolCnvSvc.cxx.

442 {
443 ATH_MSG_VERBOSE("Requesting object for: " << token->toString());
444 // StopWatch listens from here until the end of this current scope
445 PMonUtils::BasicStopWatch stopWatch("cObjR_ALL", m_chronoMap);
446 if (token->dbID() != Guid::null()) {
447 ATH_MSG_VERBOSE("Requesting object for: " << token->toString());
448 m_poolSvc->setObjPtr(obj, token);
449 }
450}
static const Guid & null() noexcept
NULL-Guid: static class method.
Definition Guid.cxx:14

◆ stop()

StatusCode AthenaPoolCnvSvc::stop ( )
overridevirtual

Definition at line 129 of file AthenaPoolCnvSvc.cxx.

129 {
130 ATH_MSG_VERBOSE("stop()");
131 // In case of direct writing without an OutputStream, this should be a good time to flush DHForms
132 flushDataHeaderForms();
133 return StatusCode::SUCCESS;
134}

◆ useDetailChronoStat()

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

Definition at line 452 of file AthenaPoolCnvSvc.cxx.

452 {
453 return(m_useDetailChronoStat.value());
454}

◆ SvcFactory< AthenaPoolCnvSvc >

friend class SvcFactory< AthenaPoolCnvSvc >
friend

Definition at line 1 of file AthenaPoolCnvSvc.h.

Member Data Documentation

◆ m_branchNameHintProp

Gaudi::Property<std::string> AthenaPoolCnvSvc::m_branchNameHintProp {this,"SubLevelBranchName", "<type>/<key>"}
private

SubLevelBranchName, naming hint policy for POOL branching: ("" = no branching)

Definition at line 197 of file AthenaPoolCnvSvc.h.

197{this,"SubLevelBranchName", "<type>/<key>"};

◆ m_chronoMap

PMonUtils::BasicStopWatchResultMap_t AthenaPoolCnvSvc::m_chronoMap {}
protected

Map that holds chrono information.

Definition at line 181 of file AthenaPoolCnvSvc.h.

181{};

◆ m_clidSvc

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

Definition at line 177 of file AthenaPoolCnvSvc.h.

177{this,"ClassIDSvc","ClassIDSvc"};

◆ m_containerAttr

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

Definition at line 203 of file AthenaPoolCnvSvc.h.

◆ m_containerNameHintProp

Gaudi::Property<std::string> AthenaPoolCnvSvc::m_containerNameHintProp {this,"TopLevelContainerName",""}
private

TopLevelContainerName, naming hint policy for top level POOL container: default = "<type>".

Definition at line 195 of file AthenaPoolCnvSvc.h.

195{this,"TopLevelContainerName",""};

◆ m_containerPrefixProp

Gaudi::Property<std::string> AthenaPoolCnvSvc::m_containerPrefixProp {this,"PoolContainerPrefix","Default"}
private

POOL Container name prefix - will be part of or whole TTree/RNTuple name 'Default' takes the prefix from APRDefaults according to StorageTech.

Definition at line 193 of file AthenaPoolCnvSvc.h.

193{this,"PoolContainerPrefix","Default"};

◆ m_contextAttr

std::vector<unsigned int> AthenaPoolCnvSvc::m_contextAttr
private

Definition at line 204 of file AthenaPoolCnvSvc.h.

◆ m_databaseAttr

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

Definition at line 202 of file AthenaPoolCnvSvc.h.

◆ m_databaseMaxFileSize

std::map<std::string, long long> AthenaPoolCnvSvc::m_databaseMaxFileSize
private

Definition at line 218 of file AthenaPoolCnvSvc.h.

◆ m_defContainerType

std::string AthenaPoolCnvSvc::m_defContainerType {}
private

Default container type (from PoolSvc)

Definition at line 221 of file AthenaPoolCnvSvc.h.

221{};

◆ 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 243 of file AthenaPoolCnvSvc.h.

243{ 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 241 of file AthenaPoolCnvSvc.h.

241{ this, "maxDHFormCacheSize", 100 };

◆ m_domainAttr

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

Definition at line 201 of file AthenaPoolCnvSvc.h.

◆ m_domainMaxFileSize

long long AthenaPoolCnvSvc::m_domainMaxFileSize =std::numeric_limits<long long>::max()
private

Definition at line 217 of file AthenaPoolCnvSvc.h.

◆ m_fileCommitCounter

std::map<std::string, int> AthenaPoolCnvSvc::m_fileCommitCounter
private

Definition at line 205 of file AthenaPoolCnvSvc.h.

◆ m_fileFlushSetting

std::map<std::string, int> AthenaPoolCnvSvc::m_fileFlushSetting
private

Definition at line 206 of file AthenaPoolCnvSvc.h.

◆ m_inputAttr

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

Definition at line 209 of file AthenaPoolCnvSvc.h.

◆ m_inputAttrPerEvent

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

Definition at line 213 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 208 of file AthenaPoolCnvSvc.h.

208{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 212 of file AthenaPoolCnvSvc.h.

212{this,"PrintInputAttrPerEvt",{}};

◆ m_lastInputFileName

std::string AthenaPoolCnvSvc::m_lastInputFileName
private

decoded storage tech requested in "StorageTechnology" property

Definition at line 175 of file AthenaPoolCnvSvc.h.

◆ m_maxFileSizes

Gaudi::Property<std::vector<std::string> > AthenaPoolCnvSvc::m_maxFileSizes {this,"MaxFileSizes",{}}
private

MaxFileSizes, vector with maximum file sizes for Athena POOL output files.

Definition at line 216 of file AthenaPoolCnvSvc.h.

216{this,"MaxFileSizes",{}};

◆ m_mutex

std::mutex AthenaPoolCnvSvc::m_mutex
protected

Definition at line 232 of file AthenaPoolCnvSvc.h.

◆ m_numberEventsPerWrite

Gaudi::Property<int> AthenaPoolCnvSvc::m_numberEventsPerWrite {this,"NumberEventsPerWrite",-1}
protected

To use MetadataSvc to merge data placed in a certain container When using TMemFile call Write on number of Events, respecting CollectionTree auto_flush.

Definition at line 236 of file AthenaPoolCnvSvc.h.

236{this,"NumberEventsPerWrite",-1};

◆ m_oneDataHeaderForm

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

If true, use only one DataHeaderForm per Stream.

Definition at line 239 of file AthenaPoolCnvSvc.h.

239{ 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 231 of file AthenaPoolCnvSvc.h.

231{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 226 of file AthenaPoolCnvSvc.h.

226{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 200 of file AthenaPoolCnvSvc.h.

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

◆ m_poolSvc

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

Definition at line 176 of file AthenaPoolCnvSvc.h.

176{this,"PoolSvc","PoolSvc"};

◆ m_storageTechMap

std::map<std::string, int> AthenaPoolCnvSvc::m_storageTechMap
private

Definition at line 190 of file AthenaPoolCnvSvc.h.

◆ m_storageTechProp

Gaudi::Property<std::map<std::string, std::string> > AthenaPoolCnvSvc::m_storageTechProp {this, "StorageTechnology", {{"*","ROOTTREEINDEX"}}}
private

Default Storage Tech for containers (ROOTTREE, ROOTTREEINDEX, ROOTRNTUPLE)

Definition at line 189 of file AthenaPoolCnvSvc.h.

189{this, "StorageTechnology", {{"*","ROOTTREEINDEX"}}};

◆ 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 186 of file AthenaPoolCnvSvc.h.

186{this,"UseDetailChronoStat",false};

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