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();
146 state.setFilterPassed( !
passed );
148 state.setFilterPassed(
passed );
161 ATH_MSG_INFO (
"execute of [" << theAlgorithm->name() <<
"] did NOT succeed");
170 state.setFilterPassed( !seqPass );
172 state.setFilterPassed( seqPass );
176 state.setState( AlgExecState::State::Done );
183 const EventContext& ctx)
const
189 s_abortTimer = std::make_unique<Athena::AlgorithmTimer>(0);
201 << theAlgorithm->name() <<
"> : " << remaining);
211 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
212 if (!theAlgorithm->sysStart( ).isSuccess()) {
214 << theAlgorithm->type () <<
"/"
215 << theAlgorithm->name());
216 sc = StatusCode::FAILURE;
227 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
228 if (theAlgorithm->sysStop( ).isFailure()) {
230 << theAlgorithm->type () <<
"/"
231 << theAlgorithm->name());
232 sc = StatusCode::FAILURE;
241 execState(ctx).reset();
245 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
246 theAlgorithm->execState(ctx).reset();
259 return append( pAlgorithm, subAlgorithms( ) );
264 const std::string&
name,
265 Gaudi::Algorithm*& pAlgorithm )
273 return remove (pAlgorithm->name());
301 std::vector<Gaudi::Algorithm*>* theAlgs )
303 bool all_good =
true;
306 for (Gaudi::Algorithm* theAlgorithm : *theAlgs) {
307 if ( theAlgorithm == pAlgorithm ) {
313 theAlgs->push_back( pAlgorithm );
314 pAlgorithm->addRef();
316 return all_good ? StatusCode::SUCCESS : StatusCode::FAILURE;
322 Gaudi::Algorithm*& pAlgorithm,
323 std::vector<Gaudi::Algorithm*>* theAlgs )
325 SmartIF<IAlgManager> theAlgMgr(Gaudi::svcLocator()->as<IAlgManager>());
326 IAlgorithm*
tmp =
nullptr;
329 pAlgorithm =
dynamic_cast<Gaudi::Algorithm*
>(
tmp);
330 theAlgs->push_back( pAlgorithm );
332 return StatusCode::SUCCESS;
337 std::vector<Gaudi::Algorithm*>* theAlgs )
339 SmartIF<IAlgManager> theAlgMgr(Gaudi::svcLocator()->as<IAlgManager>());
347 for (
const std::string&
name : theNames.value()) {
350 Gaudi::Utils::TypeNameString tn(
name);
354 SmartIF<IAlgorithm>& theIAlg = theAlgMgr->algorithm(tn.name(),
false);
355 Gaudi::Algorithm* theAlgorithm =
nullptr;
357 theAlgorithm =
dynamic_cast<Gaudi::Algorithm*
>(theIAlg.get());
358 if ( theAlgorithm ) {
361 if (
append(theAlgorithm, theAlgs).isSuccess( ) ) {
362 ATH_MSG_DEBUG (tn.name() <<
" already exists - appended to member list");
365 result = StatusCode::FAILURE;
369 ATH_MSG_WARNING (tn.name() <<
" is not an Algorithm - Failed dynamic cast");
370 result = StatusCode::FAILURE;
376 if (
createAndAppend(tn.type(), tn.name(), theAlgorithm, theAlgs).isSuccess( ) ) {
377 ATH_MSG_DEBUG (tn.name() <<
" doesn't exist - created and appended to member list");
380 result = StatusCode::FAILURE;
387 if (
result.isSuccess() && !theAlgs->empty() ) {
391 for (Gaudi::Algorithm*
alg : *theAlgs) {
409 std::vector<Gaudi::Algorithm*>* )
412 return StatusCode::FAILURE;