ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaServices
src
AthReadAlg.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3
*/
10
11
12
#include "
AthReadAlg.h
"
13
#include "
StoreGate/TypelessWriteHandle.h
"
14
15
19
StatusCode
AthReadAlg::initialize
()
20
{
21
// Initialize the output key.
22
ATH_CHECK
(
m_key
.initialize() );
23
24
// AddressRemappingSvc will rename the proxy for the original object
25
// so that it ends with _DELETED. Cache the sgkey for this proxy.
26
m_sgkey
=
evtStore
()->stringToKey (
m_key
.key() +
"_DELETED"
,
27
m_key
.clid());
28
29
std::string storename;
30
const
std::string& objkey =
m_key
.objKey();
31
std::string::size_type ppos = objkey.find (
'+'
);
32
if
(ppos != std::string::npos) {
33
storename = objkey.substr (0, ppos+1);
34
}
35
for
(
const
std::string&
a
:
m_aliases
) {
36
this->addDependency (DataObjID (
m_key
.clid(), storename +
a
),
37
Gaudi::DataHandle::Writer);
38
}
39
return
StatusCode::SUCCESS;
40
}
41
42
47
StatusCode
AthReadAlg::execute
(
const
EventContext& ctx)
const
48
{
49
// Look up the proxy for the original object.
50
SG::DataProxy
* proxy =
evtStore
()->proxy_exact (
m_sgkey
);
51
if
(!proxy) {
52
ATH_MSG_ERROR
(
"Cannot find proxy for original object: {}/{}_DELETED [{}]"
,
53
m_key
.clid(),
m_key
.key(),
m_sgkey
);
54
return
StatusCode::FAILURE;
55
}
56
57
// Read the object.
58
std::unique_ptr<DataObject> ptr (proxy->readData());
59
if
(!ptr) {
60
ATH_MSG_ERROR
(
"Object read failed: {}/{}_DELETED [{}]"
,
61
m_key
.clid(),
m_key
.key(),
m_sgkey
);
62
return
StatusCode::FAILURE;
63
}
64
65
// Record the result in the event store.
66
SG::TypelessWriteHandle
h
(
m_key
, ctx);
67
ATH_CHECK
(
h
.typelessPut (std::move (ptr) ) );
68
69
// Any extra aliases?
70
std::vector<std::string> extraAliases;
71
for
(
const
std::string&
a
:
m_aliases
) {
72
if
(!proxy->hasAlias (
a
+
"_DELETED"
)) {
73
extraAliases.push_back (
a
);
74
}
75
}
76
77
// Restore original aliases.
78
if
(!proxy->alias().empty() || !extraAliases.empty()) {
79
SG::DataProxy
* newprox =
evtStore
()->proxy (
m_key
.clid(),
m_key
.key());
80
if
(!newprox) {
81
ATH_MSG_ERROR
(
"Can't find proxy for just-recorded object {}/{}"
,
82
m_key
.clid(),
m_key
.key());
83
return
StatusCode::FAILURE;
84
}
85
SG::DataObjectSharedPtr<DataObject>
dobj (newprox->
accessData
());
86
87
for
(std::string
a
: proxy->alias()) {
88
if
(
a
.ends_with (
"_DELETED"
)) {
89
a
.erase (
a
.size() - 8, 8);
90
if
(!
evtStore
()->recordObject (dobj,
a
,
false
,
true
)) {
91
ATH_MSG_ERROR
(
"Can't make alias {} for {}/{}"
,
92
a
,
m_key
.clid(),
m_key
.key());
93
return
StatusCode::FAILURE;
94
}
95
}
96
}
97
98
for
(
const
std::string&
a
: extraAliases) {
99
if
(!
evtStore
()->recordObject (dobj,
a
,
false
,
true
)) {
100
ATH_MSG_ERROR
(
"Can't make alias {} for {}/{}"
,
101
a
,
m_key
.clid(),
m_key
.key());
102
return
StatusCode::FAILURE;
103
}
104
}
105
}
106
107
return
StatusCode::SUCCESS;
108
}
109
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
AthReadAlg.h
Generic algorithm wrapping an input conversion.
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
TypelessWriteHandle.h
Handle allowing writes to the event store with a configurable type.
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
h
Header file for AthHistogramAlgorithm.
AthReadAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Standard Algorithm execute method.
Definition
AthReadAlg.cxx:47
AthReadAlg::m_sgkey
SG::sgkey_t m_sgkey
Cache sgkey of proxy corresponding to the original object.
Definition
AthReadAlg.h:71
AthReadAlg::m_key
SG::TypelessWriteHandleKey m_key
Property: Output key.
Definition
AthReadAlg.h:65
AthReadAlg::m_aliases
Gaudi::Property< std::vector< std::string > > m_aliases
Definition
AthReadAlg.h:68
AthReadAlg::initialize
virtual StatusCode initialize() override
Standard initialize method.
Definition
AthReadAlg.cxx:19
SG::DataProxy
Definition
DataProxy.h:45
SG::DataProxy::accessData
DataObject * accessData()
Access DataObject on-demand using conversion service.
SG::TypelessWriteHandle
Handle allowing writes to the event store with a configurable type.
Definition
TypelessWriteHandle.h:35
SG::DataObjectSharedPtr
CxxUtils::RefCountedPtr< T > DataObjectSharedPtr
Definition
DataObjectSharedPtr.h:27
Generated on
for ATLAS Offline Software by
1.17.0