19#include "GaudiKernel/IAlgManager.h"
20#include "GaudiKernel/ISvcLocator.h"
28 ISvcLocator* pSvcLocator ):
45 ATH_MSG_ERROR (
"Unable to configure one or more sequencer members ");
46 return StatusCode::FAILURE;
50 StatusCode
sc(StatusCode::SUCCESS);
52 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
53 if (!theAlgorithm->sysInitialize( ).isSuccess()) {
55 << theAlgorithm->type() <<
"/" << theAlgorithm->name());
56 sc= StatusCode::FAILURE;
64 ATH_MSG_DEBUG(
"Allow dynamic data consumers to update their data dependencies.");
77 StatusCode
sc(StatusCode::SUCCESS);
83 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
84 if ( theAlgorithm->isEnabled( ) ) {
85 if (theAlgorithm->sysReinitialize( ).isFailure()) {
87 << theAlgorithm->type () <<
"/"
88 << theAlgorithm->name());
89 sc = StatusCode::FAILURE;
100 StatusCode
sc = StatusCode::SUCCESS;
105 auto state = execState( ctx );
108 if ( isEnabled( ) && state.state() != AlgExecState::State::Done ) {
111 state.setState( AlgExecState::State::Executing );
117 const std::vector<Gaudi::Algorithm*>* subAlgms = subAlgorithms( );
118 for (
auto theAlgorithm : *subAlgms) {
119 if ( theAlgorithm->isEnabled( ) ) {
120 if ( theAlgorithm->execState(ctx).state() == AlgExecState::State::None ) {
124 if (
sc.isSuccess() ) {
128 const bool passed = theAlgorithm->execState( ctx ).filterPassed();
130 state.setFilterPassed( !
passed );
132 state.setFilterPassed(
passed );
145 ATH_MSG_INFO (
"execute of [" << theAlgorithm->name() <<
"] did NOT succeed");
154 state.setFilterPassed( !seqPass );
156 state.setFilterPassed( seqPass );
160 state.setState( AlgExecState::State::Done );
167 const EventContext& ctx)
const
170 return theAlgorithm->sysExecute( ctx );
176 StatusCode
sc(StatusCode::SUCCESS);
178 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
179 if (!theAlgorithm->sysStart( ).isSuccess()) {
181 << theAlgorithm->type () <<
"/"
182 << theAlgorithm->name());
183 sc = StatusCode::FAILURE;
192 StatusCode
sc(StatusCode::SUCCESS);
194 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
195 if (theAlgorithm->sysStop( ).isFailure()) {
197 << theAlgorithm->type () <<
"/"
198 << theAlgorithm->name());
199 sc = StatusCode::FAILURE;
208 execState(ctx).reset();
212 for (Gaudi::Algorithm* theAlgorithm : *subAlgorithms()) {
213 theAlgorithm->execState(ctx).reset();
226 return append( pAlgorithm, subAlgorithms( ) );
231 const std::string& name,
232 Gaudi::Algorithm*& pAlgorithm )
240 return remove (pAlgorithm->name());
246 return remove( algname, subAlgorithms( ) );
268 std::vector<Gaudi::Algorithm*>* theAlgs )
270 bool all_good =
true;
273 for (Gaudi::Algorithm* theAlgorithm : *theAlgs) {
274 if ( theAlgorithm == pAlgorithm ) {
280 theAlgs->push_back( pAlgorithm );
281 pAlgorithm->addRef();
283 return all_good ? StatusCode::SUCCESS : StatusCode::FAILURE;
288 const std::string& algName,
289 Gaudi::Algorithm*& pAlgorithm,
290 std::vector<Gaudi::Algorithm*>* theAlgs )
292 SmartIF<IAlgManager> theAlgMgr(Gaudi::svcLocator()->as<IAlgManager>());
293 IAlgorithm* tmp =
nullptr;
295 ATH_CHECK( theAlgMgr->createAlgorithm(
type, algName, tmp ) );
296 pAlgorithm =
dynamic_cast<Gaudi::Algorithm*
>(tmp);
297 theAlgs->push_back( pAlgorithm );
299 return StatusCode::SUCCESS;
304 std::vector<Gaudi::Algorithm*>* theAlgs )
306 SmartIF<IAlgManager> theAlgMgr(Gaudi::svcLocator()->as<IAlgManager>());
313 StatusCode
result = StatusCode::SUCCESS;
314 for (
const std::string& name : theNames.value()) {
317 Gaudi::Utils::TypeNameString tn(name);
321 SmartIF<IAlgorithm>& theIAlg = theAlgMgr->algorithm(tn.name(),
false);
322 Gaudi::Algorithm* theAlgorithm =
nullptr;
324 theAlgorithm =
dynamic_cast<Gaudi::Algorithm*
>(theIAlg.get());
325 if ( theAlgorithm ) {
328 if (
append(theAlgorithm, theAlgs).isSuccess( ) ) {
329 ATH_MSG_DEBUG (tn.name() <<
" already exists - appended to member list");
332 result = StatusCode::FAILURE;
336 ATH_MSG_WARNING (tn.name() <<
" is not an Algorithm - Failed dynamic cast");
337 result = StatusCode::FAILURE;
343 if (
createAndAppend(tn.type(), tn.name(), theAlgorithm, theAlgs).isSuccess( ) ) {
344 ATH_MSG_DEBUG (tn.name() <<
" doesn't exist - created and appended to member list");
347 result = StatusCode::FAILURE;
354 if (
result.isSuccess() && !theAlgs->empty() ) {
356 msg(MSG::DEBUG) <<
"Member list: ";
358 for (Gaudi::Algorithm* alg : *theAlgs) {
363 if ( alg->name() == System::typeinfoName(
typeid(*alg)))
364 msg() << alg->name();
366 msg() << System::typeinfoName(
typeid(*alg)) <<
"/" << alg->name();
376 std::vector<Gaudi::Algorithm*>* )
379 return StatusCode::FAILURE;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
AthCommonDataStore(const std::string &name, T... args)
bool msgLvl(const MSG::Level lvl) const
virtual StatusCode initialize() override
Initialization of a sequencer.
virtual StatusCode reinitialize() override
AthSequencer Reinitialization.
virtual void resetExecuted(const EventContext &ctx) const
Reset the AthSequencer executed state for the current event.
virtual bool isStopOverride() const
Has the StopOverride mode been set?
ServiceHandle< IClassIDSvc > m_clidSvc
virtual StatusCode start() override
Start (from INITIALIZED to RUNNING).
Gaudi::Property< bool > m_invert
StatusCode decodeNames(Gaudi::Property< std::vector< std::string > > &theNames, std::vector< Gaudi::Algorithm * > *theAlgs)
Decode algorithm names, creating or appending algorithms as appropriate.
Gaudi::Property< bool > m_modeOR
StatusCode executeAlgorithm(Gaudi::Algorithm *theAlgorithm, const EventContext &ctx) const
Run one algorithm.
StatusCode remove(Gaudi::Algorithm *pAlgorithm)
Remove the specified algorithm from the sequencer.
virtual StatusCode execute(const EventContext &ctx) const override
The actions to be performed by the sequencer on an event.
void membershipHandler(Gaudi::Details::PropertyBase &theProp)
"Members" property handler
Gaudi::Property< std::vector< std::string > > m_names
virtual ~AthSequencer()
Destructor.
Gaudi::Property< bool > m_ignoreFilter
StatusCode append(Gaudi::Algorithm *pAlgorithm)
Append an algorithm to the sequencer.
Gaudi::Property< bool > m_stopOverride
AthSequencer(const std::string &name, ISvcLocator *svcloc)
Constructor(s)
const unsigned int m_maxPass
virtual StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
StatusCode createAndAppend(const std::string &type, const std::string &name, Gaudi::Algorithm *&pAlgorithm)
Create a algorithm and append it to the sequencer.
StatusCode decodeMemberNames()
Decode Member Name list.
Gaudi::Property< bool > m_runPostInitialize
Gaudi::Property< std::vector< std::string > > m_undeclaredOutputData
Helper class to gather all declared data IDs and propagate them to components which declare data depe...
StatusCode addExtraDependencies(IClassIDSvc &clid_svc, std::vector< std::string > &undeclared_output_data, MsgStream &out)
Add extra output data which is not declared by any of the gathered components.
void gatherDataHandlesAndDynamicConsumers(const std::string &parent_name, Gaudi::Algorithm *theAlgorithm)
Gather the input and output data declared by the given algorithm, its child algorithms and their tool...
void updateDataNeeds(unsigned int max_pass, MsgStream &out)
Update the data dependencies of all components which dynamically declare tehm.
=============================================================================