ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
D3PDMakerUtils
src
SGKeyResolver.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
12
#include "
D3PDMakerUtils/SGKeyResolver.h
"
13
#include "
StoreGate/StoreGateSvc.h
"
14
#include "
AthenaKernel/errorcheck.h
"
15
#include "
CxxUtils/StringUtils.h
"
16
17
18
namespace
D3PD
{
19
20
27
SGKeyResolver::SGKeyResolver
(
const
std::string& name,
28
ServiceHandle<StoreGateSvc>
& sg,
29
std::string& sgkey)
30
:
m_name
(name),
31
m_sg
(sg),
32
m_clid
(CLID_NULL),
33
m_sgkey
(sgkey),
34
m_haveKey
(false)
35
{
36
}
37
38
44
StatusCode
SGKeyResolver::initialize
(
CLID
clid,
const
std::string& typname)
45
{
46
m_clid
= clid;
47
m_typname
= typname;
48
return
StatusCode::SUCCESS;
49
}
50
51
55
std::string
SGKeyResolver::key
()
56
{
57
if
(
m_haveKey
)
58
return
m_usedKey
;
59
60
// Split the requested string into individual keys.
61
std::vector<std::string> keys =
CxxUtils::tokenize
(
m_sgkey
,
" ,"
);
62
63
// First see if any existing proxies match the keys.
64
std::vector<const SG::DataProxy*> proxies =
m_sg
->proxies();
65
for
(
const
SG::DataProxy
* & p : proxies) {
66
if
(p->transientID (
m_clid
) &&
67
std::find (keys.begin(), keys.end(), p->name()) != keys.end())
68
{
69
if
(!
m_haveKey
||
70
std::find (keys.begin(), keys.end(), p->name()) <
71
std::find (keys.begin(), keys.end(),
m_usedKey
))
72
{
73
m_usedKey
= p->name();
74
m_haveKey
=
true
;
75
}
76
}
77
}
78
79
// If we haven't found one, try retrieving proxies individually.
80
// This can call to the proxy providers.
81
if
(!
m_haveKey
) {
82
for
(std::string&
key
: keys) {
83
m_usedKey
=
key
;
84
if
(
m_sg
->proxy (
m_clid
,
m_usedKey
)) {
85
m_haveKey
=
true
;
86
break
;
87
}
88
}
89
}
90
91
if
(
m_haveKey
) {
92
REPORT_MESSAGE_WITH_CONTEXT
(MSG::VERBOSE,
m_name
)
93
<<
"Using StoreGate object: "
94
<<
m_typname
<<
"("
<<
m_clid
<<
")/"
<<
m_usedKey
;
95
}
96
97
return
m_usedKey
;
98
}
99
100
101
}
// namespace D3PD
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:345
StringUtils.h
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SGKeyResolver.h
Helper to resolve the SG key to use.
StoreGateSvc.h
D3PD::SGKeyResolver::m_sg
ServiceHandle< StoreGateSvc > & m_sg
The event storage service.
Definition
SGKeyResolver.h:79
D3PD::SGKeyResolver::m_haveKey
bool m_haveKey
Flag that m_usedKey is valid.
Definition
SGKeyResolver.h:94
D3PD::SGKeyResolver::m_name
std::string m_name
The name of the tool/alg in which this is used.
Definition
SGKeyResolver.h:76
D3PD::SGKeyResolver::SGKeyResolver
SGKeyResolver(const std::string &name, ServiceHandle< StoreGateSvc > &sg, std::string &sgkey)
Constructor.
Definition
SGKeyResolver.cxx:27
D3PD::SGKeyResolver::m_clid
CLID m_clid
The CLID of the desired type.
Definition
SGKeyResolver.h:82
D3PD::SGKeyResolver::m_typname
std::string m_typname
The name of the desired type.
Definition
SGKeyResolver.h:85
D3PD::SGKeyResolver::m_usedKey
std::string m_usedKey
The actual key we'll use.
Definition
SGKeyResolver.h:91
D3PD::SGKeyResolver::m_sgkey
std::string & m_sgkey
The requested SG key.
Definition
SGKeyResolver.h:88
D3PD::SGKeyResolver::key
std::string key()
Return the SG key we should use.
Definition
SGKeyResolver.cxx:55
D3PD::SGKeyResolver::initialize
StatusCode initialize()
Initialize, from a type.
SG::DataProxy
Definition
DataProxy.h:45
ServiceHandle
Definition
ClusterMakerTool.h:36
CxxUtils::tokenize
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
Definition
Control/CxxUtils/Root/StringUtils.cxx:12
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
Generated on
for ATLAS Offline Software by
1.17.0