ATLAS Offline Software
PoolCollectionConverter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "PoolSvc/IPoolSvc.h"
13 
14 // Pool
15 #include "CoralBase/AttributeList.h"
16 #include "CoralBase/Attribute.h"
17 
22 
23 // Gaudi
24 #include "GaudiKernel/StatusCode.h"
25 
26 #include <assert.h>
27 #include <exception>
28 #include <format>
29 
30 //______________________________________________________________________________
31 PoolCollectionConverter::PoolCollectionConverter(const std::string& collectionType,
32  const std::string& inputCollection,
33  unsigned int contextId,
34  const IPoolSvc* svc) :
35  m_collectionType(collectionType),
36  m_connection(),
37  m_inputCollection(inputCollection),
38  m_contextId(contextId),
39  m_poolSvc(svc),
40  m_poolCollection(nullptr),
41  m_collectionQuery(nullptr),
42  m_inputContainer() {
43 }
44 //______________________________________________________________________________
46  if (m_poolCollection) {
48  delete m_collectionQuery; m_collectionQuery = nullptr;
49  delete m_poolCollection; m_poolCollection = nullptr;
50  }
51 }
52 //______________________________________________________________________________
54  // Find out if the user specified a container
55  const std::string collectionType = m_collectionType;
56  std::string::size_type p_colon = collectionType.rfind(':');
57  if (p_colon != std::string::npos) {
58  m_inputContainer = collectionType.substr(p_colon + 1);
59  m_collectionType = collectionType.substr(0, p_colon);
60  }
61  if (m_collectionType == "ImplicitCollection") {
62  // Check if already prefixed
63  if (m_inputCollection.starts_with( "PFN:")
64  || m_inputCollection.starts_with( "LFN:")
65  || m_inputCollection.starts_with( "FID:")) {
66  // Already prefixed
68  } else {
69  // Prefix with PFN:
71  }
72  try {
74  } catch (std::exception &e) {
75  m_poolCollection = nullptr;
76  }
77  if (m_poolCollection == nullptr) {
78  // Now set where to look in the implicit file
79  m_inputCollection = std::format("{}(DataHeader)", m_inputContainer);
80  }
81  }
82  try {
83  if (m_poolCollection == nullptr) {
85  }
86  if (m_poolCollection == nullptr && m_collectionType == "ImplicitCollection") {
89  }
90  } catch (std::exception &e) {
91  return StatusCode::RECOVERABLE;
92  }
93  return StatusCode::SUCCESS;
94 }
95 //______________________________________________________________________________
97  if (m_poolCollection == nullptr) {
98  return StatusCode::SUCCESS;
99  }
100  if (m_poolCollection->description().type() == "ImplicitCollection") {
102  }
103  return StatusCode::SUCCESS;
104 }
105 //______________________________________________________________________________
107  return m_poolCollection != nullptr ? StatusCode::SUCCESS : StatusCode::FAILURE;
108 }
109 //______________________________________________________________________________
111  delete m_collectionQuery; m_collectionQuery = nullptr;
114  return m_collectionQuery->execute();
115 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
IPoolSvc
This class provides the interface to the LCG POOL persistency software.
Definition: IPoolSvc.h:35
PoolCollectionConverter::m_contextId
unsigned int m_contextId
Definition: PoolCollectionConverter.h:60
vtune_athena.format
format
Definition: vtune_athena.py:14
PoolCollectionConverter::m_connection
std::string m_connection
Definition: PoolCollectionConverter.h:58
PoolCollectionConverter.h
This file contains the class definition for the PoolCollectionConverter class.
ICollectionCursor.h
pool::ICollectionQuery::execute
virtual pool::ICollectionCursor & execute()=0
Processes the query and returns a cursor over the query result.
PoolCollectionConverter::selectAll
pool::ICollectionCursor & selectAll()
Definition: PoolCollectionConverter.cxx:110
pool::ICollection::close
virtual void close()=0
Closes the collection and terminates any database connections.
PoolCollectionConverter::m_collectionType
std::string m_collectionType
Definition: PoolCollectionConverter.h:57
pool::ICollectionDescription::type
virtual const std::string & type() const =0
Returns the storage technology type of the collection.
pool::ICollectionQuery::selectAll
virtual void selectAll()=0
Adds all Token and Attribute columns to the query select list.
PoolCollectionConverter::m_inputCollection
std::string m_inputCollection
Definition: PoolCollectionConverter.h:59
PoolCollectionConverter::m_inputContainer
std::string m_inputContainer
Definition: PoolCollectionConverter.h:64
pool::ICollection::newQuery
virtual ICollectionQuery * newQuery()=0
Returns an object used to query the collection.
PoolCollectionConverter::isValid
StatusCode isValid() const
Check whether has valid pool::ICollection*.
Definition: PoolCollectionConverter.cxx:106
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PoolCollectionConverter::m_poolSvc
const IPoolSvc * m_poolSvc
Definition: PoolCollectionConverter.h:61
calibdata.exception
exception
Definition: calibdata.py:495
ICollection.h
pool::ICollection::description
virtual const ICollectionDescription & description() const =0
Returns an object used to describe the collection properties.
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
pool::ICollectionCursor
Definition: ICollectionCursor.h:22
PoolCollectionConverter::PoolCollectionConverter
PoolCollectionConverter(const std::string &collectionType, const std::string &inputCollection, unsigned int contextId, const IPoolSvc *svc)
Constructor.
Definition: PoolCollectionConverter.cxx:31
PoolCollectionConverter::m_collectionQuery
pool::ICollectionQuery * m_collectionQuery
Definition: PoolCollectionConverter.h:63
IPoolSvc.h
This file contains the class definition for the IPoolSvc interface class.
PoolCollectionConverter::disconnectDb
StatusCode disconnectDb()
Disconnect Database.
Definition: PoolCollectionConverter.cxx:96
PoolCollectionConverter::initialize
StatusCode initialize()
Required by all Gaudi Services.
Definition: PoolCollectionConverter.cxx:53
PoolCollectionConverter::m_poolCollection
pool::ICollection * m_poolCollection
Definition: PoolCollectionConverter.h:62
IPoolSvc::disconnectDb
virtual StatusCode disconnectDb(const std::string &connection, unsigned int contextId=IPoolSvc::kInputStream) const =0
Disconnect single Database.
ICollectionQuery.h
PoolCollectionConverter::~PoolCollectionConverter
virtual ~PoolCollectionConverter()
Destructor.
Definition: PoolCollectionConverter.cxx:45
ICollectionDescription.h
Token.h
This file contains the class definition for the Token class (migrated from POOL).
IPoolSvc::createCollection
virtual pool::ICollection * createCollection(const std::string &collectionType, const std::string &connection, const std::string &collectionName, unsigned int contextId=IPoolSvc::kInputStream) const =0