ATLAS Offline Software
SGGetterImpl.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
14 #include "SGTools/DataProxy.h"
17 
18 namespace D3PD {
19 
20 
26 SGGetterImpl::SGGetterImpl (const std::string& name,
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 
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) {
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 
106 {
107  CHECK( m_clidsvc.retrieve() );
108 
110 
112 
113  return StatusCode::SUCCESS;
114 }
115 
116 
117 } // namespace D3PD
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
D3PD::SGGetterImpl::typeinfo
virtual const std::type_info & typeinfo() const
Return the type of object retrieved by this tool.
Definition: SGGetterImpl.cxx:39
D3PD::SGKeyResolver::initialize
StatusCode initialize(CLID clid, const std::string &typname)
Initialize.
Definition: SGKeyResolver.cxx:44
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::SGGetterImpl::clid
CLID clid() const
Return the class ID being read by this tool.
Definition: SGGetterImpl.cxx:54
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::nameToCLID
StatusCode nameToCLID(const std::string &name, CLID &clid, const std::string &context, ServiceHandle< IClassIDSvc > clidsvc=ServiceHandle< IClassIDSvc >("ClassIDSvc", "TypeNameConversions"))
Convert from a class name to a CLID.
Definition: TypeNameConversions.cxx:72
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::SGGetterImpl::SGGetterImpl
SGGetterImpl(const std::string &name, ServiceHandle< StoreGateSvc > &sg)
Constructor.
Definition: SGGetterImpl.cxx:26
D3PD::clidToTypeinfo
StatusCode clidToTypeinfo(CLID clid, const std::string &nmae, 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:99
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
D3PD::SGGetterImpl::m_clid
CLID m_clid
CLID for the object being retrieved.
Definition: SGGetterImpl.h:126
SG::DataProxy_cast
DATA * DataProxy_cast(DataProxy *proxy)
cast the proxy into the concrete data object it proxies
D3PD::SGKeyResolver::key
std::string key()
Return the SG key we should use.
Definition: SGKeyResolver.cxx:55
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
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
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::m_clidsvc
ServiceHandle< IClassIDSvc > m_clidsvc
Property: Instance of the ClassIDSvc to use.
Definition: SGGetterImpl.h:119
IConstAuxStore.h
Interface for const operations on an auxiliary store.
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
D3PD::SGGetterImpl::m_sg
ServiceHandle< StoreGateSvc > & m_sg
The event storage service.
Definition: SGGetterImpl.h:129
SGGetterImpl.h
Common object getter code for retrieving from StoreGate.
SG::DataProxy
Definition: DataProxy.h:44
TypeNameConversions.h
Utility functions for converting between type names, type_info, and CLIDs.
D3PD::SGGetterImpl::getUntyped
virtual const void * getUntyped(bool allowMissing=false)
Return the target object.
Definition: SGGetterImpl.cxx:68
D3PD::SGGetterImpl::initializeImpl
StatusCode initializeImpl()
Initialize this mixin class.
Definition: SGGetterImpl.cxx:105
ServiceHandle< StoreGateSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
DataProxy.h