ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthToolSupport
AsgExampleTools
src
AsgExampleAlgorithm.cxx
Go to the documentation of this file.
1
// AsgExampleAlgorithm.cxx
2
3
#include "
AsgExampleAlgorithm.h
"
4
#include "Gaudi/Property.h"
5
#include "
AsgExampleTools/IAsgHelloTool.h
"
6
#include "
AsgTools/AsgTool.h
"
7
8
using
std::string;
9
10
//**********************************************************************
11
12
AsgExampleAlgorithm::
13
AsgExampleAlgorithm
(
const
std::string& name,
14
ISvcLocator* pSvcLocator )
15
: ::
AthAlgorithm
( name, pSvcLocator ) {
16
declareProperty
(
"Tools"
,
m_asgtools
);
17
}
18
19
//**********************************************************************
20
21
AsgExampleAlgorithm::~AsgExampleAlgorithm
() { }
22
23
//**********************************************************************
24
25
StatusCode
AsgExampleAlgorithm::initialize
() {
26
StatusCode
sc
;
27
ATH_MSG_INFO
(
"Initializing "
<< name() <<
"..."
);
28
ATH_MSG_INFO
(
"Retrieving tools..."
);
29
sc
=
m_asgtools
.retrieve();
30
if
( !
sc
.isSuccess() ) {
31
ATH_MSG_ERROR
(
"Tool retrieval failed."
);
32
}
33
ATH_MSG_INFO
(
"Tool retrieval completed."
);
34
unsigned
int
ntool =
m_asgtools
.size();
35
ATH_MSG_INFO
(
" Tool count: "
<< ntool);
36
for
(
unsigned
int
itool=0; itool<ntool; ++itool ) {
37
ATH_MSG_INFO
(
" "
<<
m_asgtools
[itool]->name());
38
m_asgtools
[itool]->print();
39
// Get the tool's message property:
40
const
asg::AsgTool
* tool =
41
dynamic_cast<
const
asg::AsgTool
*
>
(
m_asgtools
[ itool ].operator->() );
42
if
( ! tool ) {
43
ATH_MSG_ERROR
(
"The received tool is not an AsgTool?!?"
);
44
return
StatusCode::FAILURE;
45
}
46
const
std::string*
msg
= tool->getProperty< std::string >(
"Message"
);
47
if
( !
msg
) {
48
ATH_MSG_WARNING
(
"Couldn't get the \"Message\" property of tool "
49
<< tool->name() );
50
}
else
{
51
ATH_MSG_INFO
(
" Its \"Message\" property: "
<< *
msg
);
52
}
53
// Try some invalid retrievals, for fun:
54
tool->getProperty< std::string >(
"UnknownProperty"
);
55
tool->getProperty<
int
>(
"Message"
);
56
}
57
return
StatusCode::SUCCESS;
58
}
59
60
//**********************************************************************
61
62
StatusCode
AsgExampleAlgorithm::finalize
() {
63
ATH_MSG_INFO
(
"Finalizing "
<< name() <<
"..."
);
64
return
StatusCode::SUCCESS;
65
}
66
67
//**********************************************************************
68
69
StatusCode
AsgExampleAlgorithm::execute
(
const
EventContext&
/*ctx*/
) {
70
ATH_MSG_INFO
(
"Executing "
<< name() <<
"..."
);
71
// Loop over hello tools.
72
ATH_MSG_INFO
(
"Looping over ASG tools."
);
73
string
line =
"---------------------------------------------------"
;
74
ATH_MSG_INFO
(line);
75
for
( ToolHandleArray<IAsgHelloTool>::const_iterator itoo=
m_asgtools
.begin();
76
itoo!=
m_asgtools
.end(); ++itoo ) {
77
ToolHandle<IAsgHelloTool> htool = *itoo;
78
int
jstat = htool->talk();
79
if
( jstat != 0 )
ATH_MSG_INFO
(
"Tool returned error "
<< jstat);
80
ATH_MSG_INFO
(line);
81
}
82
return
StatusCode::SUCCESS;
83
}
84
85
//**********************************************************************
AsgExampleAlgorithm.h
AsgTool.h
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_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
IAsgHelloTool.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
AsgExampleAlgorithm::initialize
StatusCode initialize()
Athena algorithm's Hooks.
Definition
AsgExampleAlgorithm.cxx:25
AsgExampleAlgorithm::~AsgExampleAlgorithm
~AsgExampleAlgorithm()
Destructor:
Definition
AsgExampleAlgorithm.cxx:21
AsgExampleAlgorithm::AsgExampleAlgorithm
AsgExampleAlgorithm()
Default constructor:
AsgExampleAlgorithm::execute
StatusCode execute(const EventContext &ctx)
Execute method.
Definition
AsgExampleAlgorithm.cxx:69
AsgExampleAlgorithm::m_asgtools
ToolHandleArray< IAsgHelloTool > m_asgtools
Athena configured tools.
Definition
AsgExampleAlgorithm.h:35
AsgExampleAlgorithm::finalize
StatusCode finalize()
Definition
AsgExampleAlgorithm.cxx:62
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition
AsgTool.h:47
Generated on
for ATLAS Offline Software by
1.17.0