14 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 15 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 37 error() <<
"Unable to configure one or more sequencer members " <<
endmsg;
42 error() <<
"Unable to configure one or more branch members " <<
endmsg;
48 result = alg->sysInitialize();
50 error() <<
"Unable to initialize Algorithm " << alg->name() <<
endmsg;
57 result = alg->sysInitialize();
59 error() <<
"Unable to initialize Algorithm " << alg->name() <<
endmsg;
75 if ( alg->isEnabled() ) alg->reinitialize().
ignore();
80 if ( alg->isEnabled() ) {
81 alg->reinitialize().ignore();
107 if ( !theAlgs.empty() ) {
109 if ( lastAlgorithm == branchAlgorithm ) {
138 if ( alg->sysFinalize().isFailure() ) {
139 error() <<
"Unable to finalize Algorithm " << alg->name() <<
endmsg;
151 result = alg->sysStart();
153 error() <<
"Unable to start Algorithm " << alg->name() <<
endmsg;
160 result = alg->sysStart();
162 error() <<
"Unable to start Algorithm " << alg->name() <<
endmsg;
176 if ( alg->sysStop().isFailure() ) {
177 error() <<
"Unable to stop Algorithm " << alg->name() <<
endmsg;
182 if ( alg->sysStop().isFailure() ) {
183 error() <<
"Unable to stop Algorithm " << alg->name() <<
endmsg;
201 result = alg->sysInitialize();
203 error() <<
"Unable to initialize Algorithm " << alg->name() <<
endmsg;
206 result = alg->sysStart();
208 error() <<
"Unable to start Algorithm " << alg->name() <<
endmsg;
216 if ( !alg->isEnabled() ) {
217 alg->beginRun().ignore();
226 result = alg->sysInitialize();
228 error() <<
"Unable to initialize Algorithm " << alg->name() <<
endmsg;
231 result = alg->sysStart();
233 error() <<
"Unable to start Algorithm " << alg->name() <<
endmsg;
241 if ( !alg->isEnabled() ) {
242 alg->beginRun().ignore();
257 if ( !alg->isEnabled() ) alg->endRun().
ignore();
262 if ( !alg->isEnabled() ) alg->endRun().ignore();
344 pAlgorithm->addRef();
355 StatusCode result = theAlgMgr->createAlgorithm( type, algName, tmp );
358 pAlgorithm =
dynamic_cast<Algorithm*
>( tmp );
361 error() <<
"Unable to create Algorithm " << algName <<
endmsg;
380 for (
const auto&
n : theNames.value() ) {
398 bool isInverted =
false;
399 std::string::size_type invert = theName.
find_first_of(
":" );
401 while ( std::string::npos != invert && invert < ( theName.
size() - 1 ) && theName[invert + 1] ==
':' )
403 if ( std::string::npos != invert ) {
404 if ( theName == theType ) {
407 theType = theType.
substr( 0, invert );
409 theName = theName.
substr( 0, invert );
419 theAlgorithm =
dynamic_cast<Algorithm*
>( theIAlg.
get() );
421 warning() << theName <<
" is not an Algorithm - Failed dynamic cast" <<
endmsg;
422 theAlgorithm =
nullptr;
425 if ( theAlgorithm ) {
428 status =
append( theAlgorithm, theAlgs );
432 warning() << theName <<
" already exists - append failed!!!" <<
endmsg;
441 ON_DEBUG debug() << theName <<
" doesn't exist - created and appended to member list" <<
endmsg;
443 warning() << theName <<
" doesn't exist - creation failed!!!" <<
endmsg;
452 info() <<
"Member list: ";
453 auto ai = theAlgs.
begin();
454 auto li = theLogic.
begin();
455 for ( ; ai != theAlgs.
end(); ++ai, ++li ) {
457 if ( ai != theAlgs.
begin() )
info() <<
", ";
460 info() << alg->name();
464 if ( *li )
info() <<
":invert";
472 Algorithm*& lastAlgorithm,
unsigned int first )
480 unsigned int size = theAlgs.
size();
481 for (
unsigned int i = first; i < size; i++ ) {
482 lastAlgorithm = theAlgs[i];
489 bool isInverted = theLogic[i];
490 if ( isInverted ) passed = !passed;
497 if ( !passed )
break;
526 for (
auto& alg : theAlgs ) {
527 if ( alg->name() == algname ) {
531 info() <<
"Sequencer::remove( ) isn't implemented yet!!!!!" <<
endmsg;
541 if (theAlgs.empty())
return os <<
"CFTrue";
544 const auto algs_count = theAlgs.size();
547 while (i < algs_count) {
550 theAlgs[i]->toControlFlowExpression(os);
void resetExecuted() override
Reset the executed state of the Algorithm for the duration of the current event.
virtual bool isStopOverride() const
Has the StopOverride mode been set?
StatusCode append(Algorithm *pAlgorithm)
Append an algorithm to the sequencer.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const std::string & name() const override
The identifying name of the algorithm object.
StatusCode remove(Algorithm *pAlgorithm)
Remove the specified algorithm from the sequencer.
Implementation of property with value of concrete type.
StatusCode removeFromBranch(Algorithm *pAlgorithm)
bool isExecuted() const override
Has this algorithm been executed since the last reset?
Gaudi::Property< std::vector< std::string > > m_branchNames
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
bool isSuccess() const
Test for a status code of SUCCESS.
Sequencer(const std::string &name, ISvcLocator *svcloc)
Constructor(s)
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
virtual bool branchFilterPassed() const
additional interface methods
StatusCode stop() override
Sequencer finalization.
bool m_branchFilterPassed
StatusCode reinitialize() override
Sequencer Reinitialization.
StatusCode beginRun() override
Sequencer beginRun.
const std::vector< Algorithm * > & branchAlgorithms() const
List of branch algorithms.
StatusCode executeMember(Algorithm *theAlgorithm)
Execute member algorithm.
bool isFailure() const
Test for a status code of FAILURE.
StatusCode decodeBranchMemberNames()
Decode branch member name list.
TYPE * get() const
Get interface pointer.
virtual StatusCode setBranchFilterPassed(bool state)
Set the branch filter passed flag for the last event.
Gaudi::Property< bool > m_stopOverride
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool isEnabled() const override
Is this algorithm enabled or disabled?
Helper class to parse a string of format "type/name".
void setExecuted(bool state) override
Set the executed flag to the specified state.
StatusCode execute() override
The actions to be performed by the sequencer on an event.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode decodeMemberNames()
Decode Member Name list.
StatusCode createAndAppendToBranch(const std::string &type, const std::string &name, Algorithm *&pAlgorithm)
Create a algorithm and append it to the sequencer branch.
This class is used for returning status codes from appropriate routines.
const EventContext & getContext() const override
get the context
Gaudi::Property< std::vector< std::string > > m_names
T find_first_of(T...args)
std::ostream & toControlFlowExpression(std::ostream &os) const override
Produce string represention of the control flow expression.
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
The IAlgorithm is the interface implemented by the Algorithm base class.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Base class from which all concrete algorithm classes should be derived.
std::vector< Algorithm * > m_branchAlgs
StatusCode endRun() override
Sequencer endRun.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
std::vector< bool > m_isInverted
StatusCode createAndAppend(const std::string &type, const std::string &name, Algorithm *&pAlgorithm)
Create a algorithm and append it to the sequencer.
bool isInitialized() const override
Has the Algorithm already been initialized?
const std::string & type() const
bool filterPassed() const override
Did this algorithm pass or fail its filter criterion for the last event?
StatusCode appendToBranch(Algorithm *pAlgorithm)
Append an algorithm to the sequencer branch.
StatusCode decodeNames(Gaudi::Property< std::vector< std::string >> &theNames, std::vector< Algorithm * > &theAlgs, std::vector< bool > &theLogic)
Decode algorithm names, creating or appending algorithms as appropriate.
StatusCode finalize() override
Sequencer finalization.
StatusCode initialize() override
Initialization of a sequencer.
const std::string & name() const
std::string typeName(const std::type_info &typ)
const std::string & type() const override
The type of the algorithm object.
void setFilterPassed(bool state) override
Set the filter passed flag to the specified state.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
void resetExecuted() override
Reset the Sequencer executed state for the current event.
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
std::vector< bool > m_isBranchInverted
StatusCode start() override
Sequencer finalization.