19 #include "GaudiKernel/IAlgManager.h"
20 #include "GaudiKernel/ISvcLocator.h"
26 #include "valgrind/valgrind.h"
29 thread_local std::unique_ptr<Athena::AlgorithmTimer>
s_abortTimer{
nullptr};
36 ISvcLocator* pSvcLocator ):
38 m_clidSvc(
"ClassIDSvc/ClassIDSvc",
name),
39 m_timeoutMilliseconds(0)
55 if ( RUNNING_ON_VALGRIND ) {
56 ATH_MSG_WARNING (
"### detected running inside Valgrind, disabling algorithm timeout ###");
61 ATH_MSG_ERROR (
"Unable to configure one or more sequencer members ");
62 return StatusCode::FAILURE;
68 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
69 if (!theAlgorithm->sysInitialize( ).isSuccess()) {
71 << theAlgorithm->type() <<
"/" << theAlgorithm->name());
72 sc= StatusCode::FAILURE;
80 ATH_MSG_DEBUG(
"Allow dynamic data consumers to update their data dependencies.");
99 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
100 if ( theAlgorithm->isEnabled( ) ) {
101 if (theAlgorithm->sysReinitialize( ).isFailure()) {
103 << theAlgorithm->type () <<
"/"
104 << theAlgorithm->name());
105 sc = StatusCode::FAILURE;
121 auto& state = execState( ctx );
124 if ( isEnabled( ) && state.state() != AlgExecState::State::Done ) {
127 state.setState( AlgExecState::State::Executing );
133 const std::vector<Gaudi::Algorithm*>* subAlgms = subAlgorithms( );
134 for (
auto theAlgorithm : *subAlgms) {
135 if ( theAlgorithm->isEnabled( ) ) {
140 if (
sc.isSuccess() ) {
144 const bool passed = theAlgorithm->execState( ctx ).filterPassed();
145 state.setFilterPassed(
passed );
157 ATH_MSG_INFO (
"execute of [" << theAlgorithm->name() <<
"] did NOT succeed");
166 state.setState( AlgExecState::State::Done );
173 const EventContext& ctx)
const
179 s_abortTimer = std::make_unique<Athena::AlgorithmTimer>(0);
191 << theAlgorithm->name() <<
"> : " << remaining);
201 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
202 if (!theAlgorithm->sysStart( ).isSuccess()) {
204 << theAlgorithm->type () <<
"/"
205 << theAlgorithm->name());
206 sc = StatusCode::FAILURE;
217 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
218 if (theAlgorithm->sysStop( ).isFailure()) {
220 << theAlgorithm->type () <<
"/"
221 << theAlgorithm->name());
222 sc = StatusCode::FAILURE;
231 execState(ctx).reset();
235 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
236 theAlgorithm->execState(ctx).reset();
249 return append( pAlgorithm, subAlgorithms( ) );
254 const std::string&
name,
255 Gaudi::Algorithm*& pAlgorithm )
263 return remove (pAlgorithm->name());
291 std::vector<Gaudi::Algorithm*>* theAlgs )
293 bool all_good =
true;
296 for (Gaudi::Algorithm* theAlgorithm : *theAlgs) {
297 if ( theAlgorithm == pAlgorithm ) {
303 theAlgs->push_back( pAlgorithm );
304 pAlgorithm->addRef();
306 return all_good ? StatusCode::SUCCESS : StatusCode::FAILURE;
312 Gaudi::Algorithm*& pAlgorithm,
313 std::vector<Gaudi::Algorithm*>* theAlgs )
315 SmartIF<IAlgManager> theAlgMgr(Gaudi::svcLocator()->as<IAlgManager>());
316 IAlgorithm*
tmp =
nullptr;
319 pAlgorithm =
dynamic_cast<Gaudi::Algorithm*
>(
tmp);
320 theAlgs->push_back( pAlgorithm );
322 return StatusCode::SUCCESS;
327 std::vector<Gaudi::Algorithm*>* theAlgs )
329 SmartIF<IAlgManager> theAlgMgr(Gaudi::svcLocator()->as<IAlgManager>());
337 for (
const std::string&
name : theNames.value()) {
340 Gaudi::Utils::TypeNameString tn(
name);
344 SmartIF<IAlgorithm>& theIAlg = theAlgMgr->algorithm(tn.name(),
false);
345 Gaudi::Algorithm* theAlgorithm =
nullptr;
347 theAlgorithm =
dynamic_cast<Gaudi::Algorithm*
>(theIAlg.get());
348 if ( theAlgorithm ) {
351 if (
append(theAlgorithm, theAlgs).isSuccess( ) ) {
352 ATH_MSG_DEBUG (tn.name() <<
" already exists - appended to member list");
355 result = StatusCode::FAILURE;
359 ATH_MSG_WARNING (tn.name() <<
" is not an Algorithm - Failed dynamic cast");
360 result = StatusCode::FAILURE;
366 if (
createAndAppend(tn.type(), tn.name(), theAlgorithm, theAlgs).isSuccess( ) ) {
367 ATH_MSG_DEBUG (tn.name() <<
" doesn't exist - created and appended to member list");
370 result = StatusCode::FAILURE;
377 if (
result.isSuccess() && !theAlgs->empty() ) {
381 for (Gaudi::Algorithm*
alg : *theAlgs) {
386 if (
alg->name() == System::typeinfoName(
typeid(*
alg)))
389 msg() << System::typeinfoName(
typeid(*
alg)) <<
"/" <<
alg->name();
399 std::vector<Gaudi::Algorithm*>* )
402 return StatusCode::FAILURE;