ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaPOOL
EventSelectorAthenaPool
src
PoolCollectionConverter.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
9
10
#include "
PoolCollectionConverter.h
"
11
#include "
PoolSvc/IPoolSvc.h
"
12
#include "
PersistentDataModel/Token.h
"
13
14
// Pool
15
#include "
CollectionSvc/ICollection.h
"
16
#include "
CollectionSvc/ICollectionCursor.h
"
17
#include "
CollectionSvc/CollectionService.h
"
18
19
// Gaudi
20
#include "GaudiKernel/StatusCode.h"
21
22
#include <exception>
23
#include <format>
24
#include <mutex>
25
#include <stdexcept>
26
27
//______________________________________________________________________________
28
PoolCollectionConverter::PoolCollectionConverter
(
29
const
std::string& inputCollection,
30
unsigned
int
contextId,
31
const
IPoolSvc
* svc) :
32
m_inputCollection
(inputCollection),
33
m_contextId
(contextId),
34
m_poolSvc
(svc),
35
m_poolCollection
(nullptr) {
36
}
37
//______________________________________________________________________________
38
PoolCollectionConverter::~PoolCollectionConverter
() {
39
if
(
m_poolCollection
) {
40
m_poolCollection
->close();
41
delete
m_poolCollection
;
m_poolCollection
=
nullptr
;
42
}
43
}
44
//______________________________________________________________________________
45
StatusCode
PoolCollectionConverter::initialize
() {
46
// Check if already prefixed
47
if
(!
m_inputCollection
.starts_with(
"PFN:"
)
48
&& !
m_inputCollection
.starts_with(
"LFN:"
)
49
&& !
m_inputCollection
.starts_with(
"FID:"
)) {
50
// Prefix with PFN:
51
m_inputCollection
= std::format(
"PFN:{}"
,
m_inputCollection
);
52
}
53
StatusCode
sc
=
m_poolSvc
->connectCollection(
m_inputCollection
,
"Input"
,
m_contextId
);
54
try
{
55
m_poolCollection
=
pool::CollectionService::open
(
"Input"
,
m_inputCollection
,
m_poolSvc
->getInputContextSession(
m_contextId
));
56
m_lastError
.clear();
57
}
catch
(std::exception &e) {
58
m_lastError
= std::format(
"Failed to open collection '{}': {}"
,
m_inputCollection
, e.what());
59
}
60
if
(
sc
.isRecoverable() ||
m_poolCollection
==
nullptr
) {
61
return
m_poolSvc
->checkCollection(
m_inputCollection
,
m_contextId
,
m_poolCollection
==
nullptr
);
62
}
63
return
StatusCode::SUCCESS;
64
}
65
66
//______________________________________________________________________________
67
StatusCode
PoolCollectionConverter::disconnectDb
() {
68
if
(
m_poolCollection
==
nullptr
) {
69
return
StatusCode::SUCCESS;
70
}
71
return
m_poolSvc
->disconnectDb(
m_inputCollection
);
72
}
73
//______________________________________________________________________________
74
StatusCode
PoolCollectionConverter::isValid
()
const
{
75
return
m_poolCollection
!=
nullptr
? StatusCode::SUCCESS : StatusCode::FAILURE;
76
}
77
//______________________________________________________________________________
78
std::unique_ptr<pool::ICollectionCursor>
PoolCollectionConverter::selectAll
() {
79
if
(
m_poolCollection
==
nullptr
)[[
unlikely
]] {
80
throw
std::runtime_error(
"PoolCollectionConverter::selectAll: m_poolCollection is nullptr."
);
81
}
82
return
m_poolCollection
->cursor();
83
}
CollectionService.h
ICollectionCursor.h
ICollection.h
IPoolSvc.h
This file contains the class definition for the IPoolSvc interface class.
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
PoolCollectionConverter.h
This file contains the class definition for the PoolCollectionConverter class.
Token.h
This file contains the class definition for the Token class (migrated from POOL).
IPoolSvc
This class provides the interface to the APR persistency software.
Definition
IPoolSvc.h:35
PoolCollectionConverter::selectAll
std::unique_ptr< pool::ICollectionCursor > selectAll()
Definition
PoolCollectionConverter.cxx:78
PoolCollectionConverter::m_lastError
std::string m_lastError
Definition
PoolCollectionConverter.h:60
PoolCollectionConverter::PoolCollectionConverter
PoolCollectionConverter(const std::string &inputCollection, unsigned int contextId, const IPoolSvc *svc)
Constructor.
Definition
PoolCollectionConverter.cxx:28
PoolCollectionConverter::m_inputCollection
std::string m_inputCollection
Definition
PoolCollectionConverter.h:55
PoolCollectionConverter::disconnectDb
StatusCode disconnectDb()
Disconnect Database.
Definition
PoolCollectionConverter.cxx:67
PoolCollectionConverter::m_contextId
unsigned int m_contextId
Definition
PoolCollectionConverter.h:56
PoolCollectionConverter::m_poolCollection
pool::ICollection * m_poolCollection
Definition
PoolCollectionConverter.h:58
PoolCollectionConverter::isValid
StatusCode isValid() const
Check whether has valid pool::ICollection*.
Definition
PoolCollectionConverter.cxx:74
PoolCollectionConverter::m_poolSvc
const IPoolSvc * m_poolSvc
Definition
PoolCollectionConverter.h:57
PoolCollectionConverter::~PoolCollectionConverter
virtual ~PoolCollectionConverter()
Destructor.
Definition
PoolCollectionConverter.cxx:38
PoolCollectionConverter::initialize
StatusCode initialize()
Required by all Gaudi Services.
Definition
PoolCollectionConverter.cxx:45
pool::CollectionService::open
static ICollection * open(const std::string &name, const std::string &connection="", ISession *session=0)
Opens an existing collection for reading.
unlikely
#define unlikely(x)
Definition
pythonic_coracool.cxx:9
Generated on
for ATLAS Offline Software by
1.17.0