ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthViews
src_dflow
AthViews/src_dflow/DFlowAlg3.cxx
Go to the documentation of this file.
1
2
3
/*
4
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
// DFlowAlg3.cxx
8
// Implementation file for class DFlowAlg3
9
// Author: S.Binet<binet@cern.ch>
11
12
// AthExStoreGateExample includes
13
#include "
DFlowAlg3.h
"
14
15
// STL includes
16
17
// FrameWork includes
18
#include "Gaudi/Property.h"
19
#include "
StoreGate/ReadHandleKey.h
"
20
#include "
StoreGate/WriteHandleKey.h
"
21
#include "
AthenaKernel/ExtendedEventContext.h
"
22
23
namespace
AthViews
{
24
25
// Athena Algorithm's Hooks
27
StatusCode
DFlowAlg3::initialize
()
28
{
29
ATH_MSG_INFO
(
"Initializing "
<< name() <<
"..."
);
30
31
CHECK
(
m_r_int
.initialize() );
32
CHECK
(
m_r_ints
.initialize() );
33
CHECK
(
m_w_dflowDummy
.initialize() );
34
CHECK
(
m_testUpdate
.initialize() );
35
CHECK
(
m_condKeyTest
.initialize() );
36
37
return
StatusCode::SUCCESS;
38
}
39
40
StatusCode
DFlowAlg3::finalize
()
41
{
42
ATH_MSG_INFO
(
"Finalizing "
<< name() <<
"..."
);
43
44
return
StatusCode::SUCCESS;
45
}
46
47
StatusCode
DFlowAlg3::execute
(
const
EventContext& ctx)
const
48
{
49
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
"..."
);
50
51
SG::ReadHandle< int >
inputScalarHandle(
m_r_int
, ctx );
52
ATH_MSG_INFO
(
"================================"
);
53
ATH_MSG_INFO
(
"myint r-handle..."
);
54
ATH_MSG_INFO
(
"name: ["
<< inputScalarHandle.
name
() <<
"]"
);
55
ATH_MSG_INFO
(
"store ["
<< inputScalarHandle.
store
() <<
"]"
);
56
ATH_MSG_INFO
(
"clid: ["
<< inputScalarHandle.
clid
() <<
"]"
);
57
58
ATH_MSG_INFO
(
"ptr: "
<< inputScalarHandle.
cptr
());
59
if
( inputScalarHandle.
isValid
() )
60
{
61
ATH_MSG_INFO
(
"val: "
<< *( inputScalarHandle.
cptr
() ) );
62
}
63
64
SG::ReadHandle< std::vector< int >
> inputVectorHandle(
m_r_ints
, ctx );
65
ATH_MSG_INFO
(
"ints r-handle..."
);
66
ATH_MSG_INFO
(
"name: ["
<< inputVectorHandle.
name
() <<
"]"
);
67
ATH_MSG_INFO
(
"store ["
<< inputVectorHandle.
store
() <<
"]"
);
68
ATH_MSG_INFO
(
"clid: ["
<< inputVectorHandle.
clid
() <<
"]"
);
69
ATH_MSG_INFO
(
"cptr: "
<< inputVectorHandle.
cptr
());
70
71
// try to modify 'ints' via ReadHandle<>
72
// shouldn't compile
73
#ifdef TRY_COMPILATION_ERRORS
74
inputVectorHandle->push_back(666);
75
#endif
76
77
// create a temporary r-handle
78
SG::ReadHandle< std::vector<int>
> ints( inputVectorHandle.
name
() );
79
StatusCode
sc
= ints.
setProxyDict
(
Atlas::getExtendedEventContext
(ctx).proxy() );
80
if
( !
sc
.isSuccess() )
ATH_MSG_INFO
(
"Failed to load view "
);
81
ATH_MSG_INFO
(
"temporary r-handle[ints] - size: "
<< ints->size() );
82
83
// test that inexistant proxies are correctly detected
84
ATH_MSG_INFO
(
"-- testing inexistant proxies --"
);
85
{
86
SG::ReadHandle<int>
o(
"--r-not-there--"
);
87
ATH_MSG_INFO
(
"name: "
<< o.
name
());
88
ATH_MSG_INFO
(
"valid:"
<< o.
isValid
());
89
if
(o.
isValid
()) {
90
ATH_MSG_ERROR
(
"should NOT be valid ! [line "
<< __LINE__ <<
"]"
);
91
return
StatusCode::FAILURE;
92
}
93
}
94
{
95
SG::WriteHandle<int>
o(
"--w-not-there--"
);
96
ATH_MSG_INFO
(
"name: "
<< o.
name
());
97
ATH_MSG_INFO
(
"valid:"
<< o.
isValid
());
98
if
(o.
isValid
()) {
99
ATH_MSG_ERROR
(
"should NOT be valid ! [line "
<< __LINE__ <<
"]"
);
100
return
StatusCode::FAILURE;
101
}
102
}
103
104
// test WVar<T> semantics
105
ATH_MSG_INFO
(
"-- testing WVar<T> semantics..."
);
106
{
107
SG::WriteHandle<int>
o( inputScalarHandle.
name
() );
108
ATH_MSG_INFO
(
"name: "
<< o.
name
());
109
ATH_MSG_INFO
(
"valid:"
<< o.
isValid
());
110
if
(o.
isValid
()) {
111
ATH_MSG_ERROR
(
"should NOT be valid ! [line "
<< __LINE__ <<
"]"
);
112
return
StatusCode::FAILURE;
113
}
114
try
{
115
*o = 42;
116
if
(o.
isValid
()) {
117
ATH_MSG_ERROR
(
"should NOT be valid ! [line "
<< __LINE__ <<
"]"
);
118
return
StatusCode::FAILURE;
119
}
120
}
catch
(std::exception &err) {
121
ATH_MSG_INFO
(
"good, caught: ["
<< err.what() <<
"]"
);
122
}
123
ATH_MSG_INFO
(
"valid:"
<< o.
isValid
());
124
if
(o.
isValid
()) {
125
ATH_MSG_ERROR
(
"should NOT be valid ! [line "
<< __LINE__ <<
"]"
);
126
return
StatusCode::FAILURE;
127
}
128
}
129
130
//Dummy object to fix the data flow
131
SG::WriteHandle< int >
outputHandle(
m_w_dflowDummy
, ctx );
132
ATH_CHECK
( outputHandle.
record
( std::make_unique<int>(1) ) );
133
134
// Test update handles
135
SG::ReadHandle< HiveDataObj >
testUpdate(
m_testUpdate
, ctx );
136
ATH_MSG_INFO
(
"Update handle final: "
<< testUpdate->val() );
137
138
// Test conditions handles
139
SG::ReadCondHandle< CondDataObj >
testConditions(
m_condKeyTest
, ctx );
140
ATH_MSG_INFO
(
"Conditions handle test: "
<< **testConditions <<
" from key "
<< testConditions.
fullKey
() );
141
142
return
StatusCode::SUCCESS;
143
}
144
145
}
//> end namespace AthViews
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
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DFlowAlg3.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ExtendedEventContext.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
AthViews::DFlowAlg3::m_r_ints
SG::ReadHandleKey< std::vector< int > > m_r_ints
Definition
AthViews/src_dflow/DFlowAlg3.h:39
AthViews::DFlowAlg3::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
AthViews/src_dflow/DFlowAlg3.cxx:47
AthViews::DFlowAlg3::initialize
virtual StatusCode initialize() override
Definition
AthViews/src_dflow/DFlowAlg3.cxx:27
AthViews::DFlowAlg3::m_w_dflowDummy
SG::WriteHandleKey< int > m_w_dflowDummy
Definition
AthViews/src_dflow/DFlowAlg3.h:40
AthViews::DFlowAlg3::finalize
virtual StatusCode finalize() override
Definition
AthViews/src_dflow/DFlowAlg3.cxx:40
AthViews::DFlowAlg3::m_r_int
SG::ReadHandleKey< int > m_r_int
Definition
AthViews/src_dflow/DFlowAlg3.h:38
AthViews::DFlowAlg3::m_testUpdate
SG::ReadHandleKey< HiveDataObj > m_testUpdate
Definition
AthViews/src_dflow/DFlowAlg3.h:41
AthViews::DFlowAlg3::m_condKeyTest
SG::ReadCondHandleKey< CondDataObj > m_condKeyTest
Definition
AthViews/src_dflow/DFlowAlg3.h:42
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition
ReadCondHandle.h:60
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::VarHandleBase::setProxyDict
virtual StatusCode setProxyDict(IProxyDict *store)
Explicitly set the event store.
Definition
StoreGate/src/VarHandleBase.cxx:557
SG::VarHandleBase::store
std::string store() const
Return the name of the store holding the object we are proxying.
Definition
StoreGate/src/VarHandleBase.cxx:382
SG::VarHandleBase::clid
CLID clid() const
Return the class ID for the referenced object.
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition
AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
AthViews
Definition
ViewDataVerifier.cxx:18
Atlas::getExtendedEventContext
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
Definition
ExtendedEventContext.cxx:32
Generated on
for ATLAS Offline Software by
1.17.0