24#define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
25#define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
31 error() <<
"Unable to configure one or more sequencer members " <<
endmsg;
37 error() <<
"Unable to configure one or more branch members " <<
endmsg;
43 if ( !is_good )
return is_good;
48 is_good = alg->sysInitialize();
49 if ( is_good.isFailure() ) {
50 error() <<
"Unable to initialize Algorithm " << alg->name() <<
endmsg;
64 if ( alg->isEnabled() ) { alg->reinitialize().ignore(); }
82 const bool passed = state.filterPassed();
91 if ( !theAlgs.empty() ) {
93 if ( lastAlgorithm == branchAlgorithm ) {
121 if ( alg->sysFinalize().isFailure() ) {
error() <<
"Unable to finalize Algorithm " << alg->name() <<
endmsg; }
128 if ( !is_good )
return is_good;
132 is_good = alg->sysStart();
134 error() <<
"Unable to start Algorithm " << alg->name() <<
endmsg;
146 if ( alg->sysStop().isFailure() ) {
error() <<
"Unable to stop Algorithm " << alg->name() <<
endmsg; }
207 if ( std::find( std::begin( theAlgs ), std::end( theAlgs ), pAlgorithm ) != std::end( theAlgs ) ) {
210 theAlgs.push_back( pAlgorithm );
211 pAlgorithm->addRef();
221 StatusCode result = theAlgMgr->createAlgorithm(
type, algName, tmp );
225 theAlgs.push_back( pAlgorithm );
227 error() <<
"Unable to create Algorithm " << algName <<
endmsg;
236 std::vector<Gaudi::Algorithm*>& theAlgs, std::vector<bool>& theLogic ) {
245 for (
const auto& n : theNames.value() ) {
254 std::string theName = typeName.name();
255 std::string theType = typeName.type();
263 bool isInverted =
false;
264 std::string::size_type invert = theName.find_first_of(
":" );
266 while ( std::string::npos != invert && invert < ( theName.size() - 1 ) && theName[invert + 1] ==
':' )
267 invert = theName.find_first_of(
":", invert + 2 );
268 if ( std::string::npos != invert ) {
269 if ( theName == theType ) {
272 theType = theType.substr( 0, invert );
274 theName = theName.substr( 0, invert );
286 warning() << theName <<
" is not an Algorithm - Failed dynamic cast" <<
endmsg;
287 theAlgorithm =
nullptr;
290 if ( theAlgorithm ) {
293 status =
append( theAlgorithm, theAlgs );
297 warning() << theName <<
" already exists - append failed!!!" <<
endmsg;
306 ON_DEBUG debug() << theName <<
" doesn't exist - created and appended to member list" <<
endmsg;
308 warning() << theName <<
" doesn't exist - creation failed!!!" <<
endmsg;
312 if ( status.
isSuccess() ) theLogic.push_back( isInverted );
316 if ( result.
isSuccess() && theAlgs.size() != 0 ) {
317 info() <<
"Member list: ";
318 auto ai = theAlgs.begin();
319 auto li = theLogic.begin();
320 for ( ; ai != theAlgs.end(); ++ai, ++li ) {
322 if ( ai != theAlgs.begin() )
info() <<
", ";
325 info() << alg->name();
329 if ( *li )
info() <<
":invert";
338 std::size_t first )
const {
349 auto exists = [&](
const std::string_view loc ) ->
bool {
370 auto size = theAlgs.size();
371 for (
auto i = first; i < size; i++ ) {
372 lastAlgorithm = theAlgs[i];
379 bool isInverted = theLogic[i];
380 if ( isInverted ) passed = !passed;
386 if (
m_modeOR ? passed : !passed ) {
395 if (
m_invert ) state.setFilterPassed( !state.filterPassed() );
413 for (
auto& alg : theAlgs ) {
414 if ( alg->name() == algname ) {
418 info() <<
"Sequencer::remove( ) isn't implemented yet!!!!!" <<
endmsg;
430 if ( theAlgs.empty() )
return os << ( ( !
m_modeOR ) ?
"CFTrue" :
"CFFalse" );
433 if ( theAlgs.size() > 1 ) os <<
"seq(";
435 const auto algs_count = theAlgs.size();
438 while ( i < algs_count ) {
441 theAlgs[i]->toControlFlowExpression( os );
444 if ( theAlgs.size() > 1 ) os <<
')';
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
bool filterPassed() const
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
MSG::Level msgLevel() const
A DataObject is the base class of any identifiable object on any data store.
This class represents an entry point to all the event specific data.
Base class from which all concrete algorithm classes should be derived.
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
const std::string & name() const override
The identifying name of the algorithm object.
AlgExecStateRef execState(const EventContext &ctx) const override
get the AlgExecStateRef of current algorithm Actually a small wrapper around it, thus the plain objec...
const std::string & type() const override
The type of the algorithm object.
bool isEnabled() const override
Is this algorithm enabled or disabled?
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Implementation of property with value of concrete type.
StatusCode finalize() override
System finalization.
StatusCode start() override
System start.
StatusCode reinitialize() override
Reinitialization method invoked by the framework.
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
StatusCode stop() override
System stop.
StatusCode initialize() override
Initialization method invoked by the framework.
Gaudi::Property< bool > m_modeOR
std::ostream & toControlFlowExpression(std::ostream &os) const override
Produce string representation of the control flow expression.
void setBranchFilterPassed(const EventContext &ctx, bool state) const
Set the branch filter passed flag for the last event.
Gaudi::Property< std::vector< std::string > > m_branchNames
StatusCode execute(const EventContext &ctx) const override
The actions to be performed by the sequencer on an event.
StatusCode remove(Gaudi::Algorithm *pAlgorithm)
Remove the specified algorithm from the sequencer.
StatusCode decodeBranchMemberNames()
Decode branch member name list.
Gaudi::Property< std::vector< std::string > > m_names
Gaudi::Property< bool > m_shortCircuit
StatusCode finalize() override
Sequencer finalization.
StatusCode createAndAppendToBranch(const std::string &type, const std::string &name, Gaudi::Algorithm *&pAlgorithm)
Create a algorithm and append it to the sequencer branch.
StatusCode start() override
Sequencer finalization.
StatusCode decodeNames(Gaudi::Property< std::vector< std::string > > &theNames, std::vector< Gaudi::Algorithm * > &theAlgs, std::vector< bool > &theLogic)
Decode algorithm names, creating or appending algorithms as appropriate.
std::vector< bool > m_isBranchInverted
StatusCode createAndAppend(const std::string &type, const std::string &name, Gaudi::Algorithm *&pAlgorithm)
Create a algorithm and append it to the sequencer.
StatusCode reinitialize() override
Sequencer Reinitialization.
Gaudi::Property< bool > m_invert
std::mutex m_branchFilterMutex
const std::vector< Gaudi::Algorithm * > & branchAlgorithms() const
List of branch algorithms.
std::map< EventContext::ContextID_t, bool > m_branchFilterPassed
StatusCode executeMember(Gaudi::Algorithm *theAlgorithm, const EventContext &context) const
Execute member algorithm.
StatusCode initialize() override
Initialization of a sequencer.
std::vector< bool > m_isInverted
Gaudi::Property< std::vector< std::string > > m_requireObjs
std::vector< Gaudi::Algorithm * > m_branchAlgs
StatusCode append(Gaudi::Algorithm *pAlgorithm)
Append an algorithm to the sequencer.
bool branchFilterPassed(const EventContext &ctx) const
Was the branch filter passed for the last event?
StatusCode stop() override
Sequencer stop.
StatusCode decodeMemberNames()
Decode Member Name list.
StatusCode removeFromBranch(Gaudi::Algorithm *pAlgorithm)
Gaudi::Property< bool > m_ignoreFilter
StatusCode appendToBranch(Gaudi::Algorithm *pAlgorithm)
Append an algorithm to the sequencer branch.
Gaudi::Property< std::vector< std::string > > m_vetoObjs
Helper class to parse a string of format "type/name".
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
The IAlgorithm is the interface implemented by the Algorithm base class.
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Small smart pointer class with automatic reference counting for IInterface.
TYPE * get() const
Get interface pointer.
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.