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-2024 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: "
<<
53
m_key
.clid() <<
"/"
<<
m_key
.key() <<
"_DELETED ["
<<
54
m_sgkey
<<
"]"
);
55
return
StatusCode::FAILURE;
56
}
57
58
// Read the object.
59
std::unique_ptr<DataObject> ptr (proxy->readData());
60
if
(!ptr) {
61
ATH_MSG_ERROR
(
"Object read failed: "
<<
62
m_key
.clid() <<
"/"
<<
m_key
.key() <<
"_DELETED ["
<<
63
m_sgkey
<<
"]"
);
64
return
StatusCode::FAILURE;
65
}
66
67
// Record the result in the event store.
68
SG::TypelessWriteHandle
h
(
m_key
, ctx);
69
ATH_CHECK
(
h
.typelessPut (std::move (ptr) ) );
70
71
// Any extra aliases?
72
std::vector<std::string> extraAliases;
73
for
(
const
std::string&
a
:
m_aliases
) {
74
if
(!proxy->hasAlias (
a
+
"_DELETED"
)) {
75
extraAliases.push_back (
a
);
76
}
77
}
78
79
// Restore original aliases.
80
if
(!proxy->alias().empty() || !extraAliases.empty()) {
81
SG::DataProxy
* newprox =
evtStore
()->proxy (
m_key
.clid(),
m_key
.key());
82
if
(!newprox) {
83
ATH_MSG_ERROR
(
"Can't find proxy for just-recorded object "
<<
84
m_key
.clid() <<
"/"
<<
m_key
.key());
85
return
StatusCode::FAILURE;
86
}
87
SG::DataObjectSharedPtr<DataObject>
dobj (newprox->
accessData
());
88
89
for
(std::string
a
: proxy->alias()) {
90
if
(
a
.ends_with (
"_DELETED"
)) {
91
a
.erase (
a
.size() - 8, 8);
92
if
(!
evtStore
()->recordObject (dobj,
a
,
false
,
true
)) {
93
ATH_MSG_ERROR
(
"Can't make alias "
<<
a
<<
" for "
<<
94
m_key
.clid() <<
"/"
<<
m_key
.key());
95
return
StatusCode::FAILURE;
96
}
97
}
98
}
99
100
for
(
const
std::string&
a
: extraAliases) {
101
if
(!
evtStore
()->recordObject (dobj,
a
,
false
,
true
)) {
102
ATH_MSG_ERROR
(
"Can't make alias "
<<
a
<<
" for "
<<
103
m_key
.clid() <<
"/"
<<
m_key
.key());
104
return
StatusCode::FAILURE;
105
}
106
}
107
}
108
109
return
StatusCode::SUCCESS;
110
}
111
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:33
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