ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDMaker
D3PDMakerUtils
src
SGGetterImpl.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
10
11
12
#include "
D3PDMakerUtils/SGGetterImpl.h
"
13
#include "
D3PDMakerUtils/TypeNameConversions.h
"
14
#include "
SGTools/DataProxy.h
"
15
#include "
AthenaKernel/errorcheck.h
"
16
#include "
AthContainersInterfaces/IConstAuxStore.h
"
17
18
namespace
D3PD
{
19
20
26
SGGetterImpl::SGGetterImpl
(
const
std::string& name,
27
ServiceHandle<StoreGateSvc>
& sg)
28
:
m_clidsvc
(
"ClassIDSvc"
, name),
29
m_resolver
(name, sg,
m_sgkey
),
30
m_clid
(CLID_NULL),
31
m_sg
(sg)
32
{
33
}
34
35
39
const
std::type_info&
SGGetterImpl::typeinfo
()
const
40
{
41
const
std::type_info* ti = 0;
42
if
(
clidToTypeinfo
(
m_clid
,
m_typename
, ti, this->name()).isSuccess())
43
return
*ti;
44
45
REPORT_MESSAGE
(MSG::ERROR) <<
"Can't find typeinfo for CLID "
46
<<
m_clid
<<
" (type "
<<
m_typename
<<
")."
;
47
return
typeid
(void);
48
}
49
50
54
CLID
SGGetterImpl::clid
()
const
55
{
56
return
m_clid
;
57
}
58
59
68
const
void
*
SGGetterImpl::getUntyped
(
bool
allowMissing
/*= false*/
)
69
{
70
std::string key =
m_resolver
.key();
71
SG::DataProxy
* proxy =
m_sg
->proxy (
m_clid
, key);
72
if
(!proxy) {
73
if
(!allowMissing) {
74
REPORT_MESSAGE
(MSG::FATAL) <<
"Can't find object in event store for "
75
<<
m_typename
<<
"("
<<
m_clid
<<
")/"
76
<< key;
77
REPORT_MESSAGE
(MSG::INFO) <<
m_sg
->dump();
78
}
79
return
0;
80
}
81
82
void
* ptr =
SG::DataProxy_cast
(proxy,
m_clid
);
83
if
(!ptr) {
84
if
(!allowMissing) {
85
REPORT_MESSAGE
(MSG::FATAL)
86
<<
"Null object retrieved for "
<<
m_typename
<<
"("
<<
m_clid
<<
")/"
87
<< key;
88
REPORT_MESSAGE
(MSG::INFO) <<
m_sg
->dump();
89
}
90
return
0;
91
}
92
93
// Try to retrieve a corresponding aux store as well.
94
m_sg
->tryConstRetrieve<SG::IConstAuxStore> (
key
+
"Aux."
);
95
96
return
ptr
;
97
}
98
99
105
StatusCode
SGGetterImpl::initializeImpl
()
106
{
107
CHECK
(
m_clidsvc
.retrieve() );
108
109
CHECK
(
nameToCLID
(
m_typename
,
m_clid
, this->name(),
m_clidsvc
) );
110
111
CHECK
(
m_resolver
.initialize (
m_clid
,
m_typename
) );
112
113
return
StatusCode::SUCCESS;
114
}
115
116
117
}
// namespace D3PD
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:365
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
DataProxy.h
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
IConstAuxStore.h
Interface for const operations on an auxiliary store.
SGGetterImpl.h
Common object getter code for retrieving from StoreGate.
TypeNameConversions.h
Utility functions for converting between type names, type_info, and CLIDs.
D3PD::SGGetterImpl::m_typename
std::string m_typename
Property: Name of the type of the object being retrieved.
Definition
SGGetterImpl.h:113
D3PD::SGGetterImpl::m_resolver
SGKeyResolver m_resolver
Helper: Resolve the SG key to use.
Definition
SGGetterImpl.h:122
D3PD::SGGetterImpl::SGGetterImpl
SGGetterImpl(const std::string &name, ServiceHandle< StoreGateSvc > &sg)
Constructor.
Definition
SGGetterImpl.cxx:26
D3PD::SGGetterImpl::initializeImpl
StatusCode initializeImpl()
Initialize this mixin class.
Definition
SGGetterImpl.cxx:105
D3PD::SGGetterImpl::m_clid
CLID m_clid
CLID for the object being retrieved.
Definition
SGGetterImpl.h:126
D3PD::SGGetterImpl::getUntyped
virtual const void * getUntyped(bool allowMissing=false)
Return the target object.
Definition
SGGetterImpl.cxx:68
D3PD::SGGetterImpl::m_sg
ServiceHandle< StoreGateSvc > & m_sg
The event storage service.
Definition
SGGetterImpl.h:129
D3PD::SGGetterImpl::m_clidsvc
ServiceHandle< IClassIDSvc > m_clidsvc
Property: Instance of the ClassIDSvc to use.
Definition
SGGetterImpl.h:119
D3PD::SGGetterImpl::clid
CLID clid() const
Return the class ID being read by this tool.
Definition
SGGetterImpl.cxx:54
D3PD::SGGetterImpl::typeinfo
virtual const std::type_info & typeinfo() const
Return the type of object retrieved by this tool.
Definition
SGGetterImpl.cxx:39
D3PD::SGGetterImpl::m_sgkey
std::string m_sgkey
Property: StoreGate key of the object being retrieved.
Definition
SGGetterImpl.h:116
SG::DataProxy
Definition
DataProxy.h:45
ServiceHandle
Definition
ClusterMakerTool.h:36
D3PD
Block filler tool for noisy FEB information.
Definition
CaloCellDetailsFillerTool.cxx:29
D3PD::nameToCLID
StatusCode nameToCLID(const std::string &name, CLID &clid, const std::string &context, const ServiceHandle< IClassIDSvc > &clidsvc=ServiceHandle< IClassIDSvc >("ClassIDSvc", "TypeNameConversions"))
Convert from a class name to a CLID.
Definition
TypeNameConversions.cxx:71
D3PD::clidToTypeinfo
StatusCode clidToTypeinfo(CLID clid, const std::string &name, std::type_info const *&ti, const std::string &context)
Convert from a CLID to a type_info; we also already know the name.
Definition
TypeNameConversions.cxx:98
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
Definition
DataProxy_cast.h:53
dbg::ptr
void * ptr(T *p)
Definition
SGImplSvc.cxx:74
mapkey::key
key
Definition
TElectronEfficiencyCorrectionTool.cxx:37
Generated on
for ATLAS Offline Software by
1.17.0