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;
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.");
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);
202 if (!theAlgorithm->sysStart( ).isSuccess()) {
204 << theAlgorithm->type () <<
"/"
205 << theAlgorithm->name());
206 sc = StatusCode::FAILURE;
218 if (theAlgorithm->sysStop( ).isFailure()) {
220 << theAlgorithm->type () <<
"/"
221 << theAlgorithm->name());
222 sc = StatusCode::FAILURE;
231 execState(ctx).reset();
236 theAlgorithm->execState(ctx).reset();
249 return append( pAlgorithm, subAlgorithms( ) );
254 const std::string&
name,
263 return remove (pAlgorithm->name());
291 std::vector<Gaudi::Algorithm*>* theAlgs )
293 bool all_good =
true;
297 if ( theAlgorithm == pAlgorithm ) {
303 theAlgs->push_back( pAlgorithm );
304 pAlgorithm->addRef();
306 return all_good ? StatusCode::SUCCESS : StatusCode::FAILURE;
313 std::vector<Gaudi::Algorithm*>* theAlgs )
316 IAlgManager* theAlgMgr;
319 ->getService(
"ApplicationMgr",
320 IAlgManager::interfaceID(),
321 *pp_cast<IInterface>(&theAlgMgr) );
322 if (
result.isSuccess( ) ) {
325 if (
result.isSuccess( ) ) {
328 theAlgs->push_back( pAlgorithm );
331 result = StatusCode::FAILURE;
335 theAlgMgr->release();
341 std::vector<Gaudi::Algorithm*>* theAlgs )
344 IAlgManager* theAlgMgr;
346 result = serviceLocator()->getService(
"ApplicationMgr",
347 IAlgManager::interfaceID(),
348 *pp_cast<IInterface>(&theAlgMgr) );
350 if (
result.isSuccess( ) ) {
357 const std::vector<std::string>& theNameVector = theNames.value( );
358 for (
const std::string&
name : theNameVector) {
366 std::string theName =
name;
367 std::string theType =
name;
368 int slash =
name.find_first_of(
"/" );
370 theType =
name.substr( 0, slash );
371 theName =
name.substr( slash+1 );
379 if (
status.isSuccess( ) ) {
383 (theName <<
" is not an Algorithm - Failed dynamic cast");
384 status = StatusCode::FAILURE;
387 if (
status.isSuccess( ) && theAlgorithm !=
nullptr ) {
392 if (
status.isSuccess( ) ) {
394 (theName <<
" already exists - appended to member list");
397 (theName <<
" already exists - append failed!!!");
398 result = StatusCode::FAILURE;
406 if (
status.isSuccess( ) ) {
408 (theName <<
" doesn't exist - created and appended to member list");
411 (theName <<
" doesn't exist - creation failed!!!");
412 result = StatusCode::FAILURE;
420 if (
result.isSuccess() && !theAlgs->empty() ) {
429 if (
alg->name() == System::typeinfoName(
typeid(*
alg)))
432 msg() << System::typeinfoName(
typeid(*
alg)) <<
"/" <<
alg->name();
437 theAlgMgr->release();
443 std::vector<Gaudi::Algorithm*>* theAlgs )
449 if ( theAlgorithm->name( ) ==
algname ) {
453 ATH_MSG_INFO (
"AthSequencer::remove( ) isn't implemented yet!!!!!");
454 result = StatusCode::SUCCESS;