2 #include <initializer_list> 19 template <
typename Container>
20 bool veto(
const Container* props,
const char*
name ) {
25 template <
typename F,
typename... Args>
26 void for_each_arg( F&& f, Args&&...
args ) {
35 class populate_JobOptionsSvc_t {
40 template <
typename Properties,
typename Key,
typename Value>
42 const auto& key = std::get<0>( arg );
43 const auto& value = std::get<1>( arg );
44 if ( isDefault( value ) || veto( props, key ) )
return;
50 template <
typename... Args>
55 std::forward<Args>(
args )... );
57 ~populate_JobOptionsSvc_t() {
77 auto status = decodeNames();
78 if ( !status.isSuccess() )
return status;
80 m_timerTool = tool<ISequencerTimerTool>(
"SequencerTimerTool" );
82 if ( m_timerTool->globalTiming() ) m_measureTime =
true;
84 if ( m_measureTime ) {
85 m_timer = m_timerTool->addTimer(
name() );
86 m_timerTool->increaseIndent();
88 release( m_timerTool );
89 m_timerTool =
nullptr;
93 for (
auto& entry : m_entries ) {
94 if ( m_measureTime ) { entry.setTimer( m_timerTool->addTimer( entry.algorithm()->name() ) ); }
96 status = entry.algorithm()->sysInitialize();
97 if ( !status.isSuccess() ) {
return Error(
"Can not initialize " + entry.algorithm()->name(), status ); }
99 if ( m_measureTime ) m_timerTool->decreaseIndent();
109 if ( m_measureTime ) m_timerTool->start( m_timer );
115 bool seqPass = !m_modeOR;
119 for (
auto& entry : m_entries ) {
122 if ( myAlg->
execState( ctx ).
state() != AlgExecState::State::Done ) {
124 if ( m_measureTime ) m_timerTool->
start( entry.timer() );
126 if ( m_measureTime ) m_timerTool->stop( entry.timer() );
130 if ( !m_ignoreFilter ) {
133 verbose() <<
"Algorithm " << myAlg->
name() <<
" returned filter passed " << ( passed ?
"true" :
"false" )
135 if ( entry.reverse() ) passed = !passed;
152 if ( m_modeOR ? passed : !passed ) {
155 if ( m_shortCircuit )
break;
160 auto&
state = execState( ctx );
161 if ( !m_ignoreFilter && !m_entries.empty() )
state.setFilterPassed( m_invert ? !seqPass : seqPass );
162 state.setState( AlgExecState::State::Done );
164 if ( m_measureTime ) m_timerTool->stop( m_timer );
177 auto jos = service<IJobOptionsSvc>(
"JobOptionsSvc" );
180 auto appMgr = service<IAlgManager>(
"ApplicationMgr" );
181 for (
const auto& item : m_names.value() ) {
196 result = createSubAlgorithm( theType, theName, myAlg );
201 subAlgorithms()->push_back( myAlg );
228 m_entries.emplace_back( myAlg );
229 if ( msgLevel(
MSG::DEBUG ) ) debug() <<
"Added algorithm " << theName <<
endmsg;
231 warning() << theName <<
" is not a Gaudi::Algorithm - failed dynamic_cast" <<
endmsg;
235 warning() <<
"Unable to find or create " << theName <<
endmsg;
242 if ( m_modeOR ) msg <<
"OR ";
243 msg <<
"Member list: ";
249 if ( alg->
name() != typ ) os <<
"/" << alg->
name();
252 if ( !isDefault( context() ) ) msg <<
", with context '" << context() <<
"'";
253 if ( !isDefault( rootInTES() ) ) msg <<
", with rootInTES '" << rootInTES() <<
"'";
266 decodeNames().ignore();
268 if ( !m_measureTime )
return;
272 if ( !m_timerTool ) { m_timerTool = tool<ISequencerTimerTool>(
"SequencerTimerTool" ); }
274 if ( m_timerTool->globalTiming() ) m_measureTime =
true;
276 m_timer = m_timerTool->addTimer(
name() );
277 m_timerTool->increaseIndent();
279 for (
auto& entry : m_entries ) { entry.setTimer( m_timerTool->addTimer( entry.algorithm()->name() ) ); }
281 m_timerTool->decreaseIndent();
285 if ( m_invert ) os <<
"~";
287 if ( m_entries.empty() )
return os << ( ( !m_modeOR ) ?
"CFTrue" :
"CFFalse" );
290 if ( m_entries.size() > 1 ) os <<
"seq(";
292 const auto op = m_modeOR ?
" | " :
" & ";
293 const auto last =
end( m_entries );
294 const auto first =
begin( m_entries );
295 for (
auto iterator = first; iterator != last; ++iterator ) {
296 if ( iterator != first ) os << op;
297 if ( iterator->reverse() ) os <<
"~";
298 iterator->algorithm()->toControlFlowExpression( os );
301 if ( m_entries.size() > 1 ) os <<
")";
310 if ( registerContext() ) { algCtx = contextSvc(); }
315 const auto it = find_if(
begin( m_vetoObjs ),
end( m_vetoObjs ),
316 [&](
const std::string& loc ) {
return this->exist<DataObject>( evtSvc(), loc ); } );
317 if ( it !=
end( m_vetoObjs ) ) {
318 if ( msgLevel(
MSG::DEBUG ) ) debug() << *it <<
" found, skipping event " <<
endmsg;
324 bool doIt = m_requireObjs.empty() ||
325 any_of(
begin( m_requireObjs ),
end( m_requireObjs ),
326 [&](
const std::string& loc ) {
return this->exist<DataObject>( evtSvc(), loc ); } );
bool isEnabled() const override
Is this algorithm enabled or disabled?
Definition of the MsgStream class used to transmit messages.
Gaudi::Algorithm * algorithm() const
T forward_as_tuple(T...args)
Helper "sentry" class to automatize the safe register/unregister the algorithm's context.
Implementation of property with value of concrete type.
virtual StatusCode sysStart()=0
Startup method invoked by the framework.
StatusCode start() override
the default (empty) implementation of IStateful::start() method
StatusCode initialize() override
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
const std::string & name() const override
The identifying name of the algorithm object.
bool PyHelper() addPropertyToCatalogue(IInterface *p, char *comp, char *name, char *value)
constexpr static const auto SUCCESS
class MergingTransformer< Out(const vector_of_const_< In > void
This class represents an entry point to all the event specific data.
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
std::ostream & toControlFlowExpression(std::ostream &os) const override
Produce string represention of the control flow expression.
virtual StatusCode addPropertyToCatalogue(const std::string &client, const Gaudi::Details::PropertyBase &property)=0
Add a property into the JobOptions catalog.
AlgExecState & execState(const EventContext &ctx) const override
reference to AlgExecState of Alg
TYPE * get() const
Get interface pointer.
StatusCode sysExecute(const EventContext &ctx) override
Helper class to parse a string of format "type/name".
Main interface for the JobOptions service.
This class is used for returning status codes from appropriate routines.
StatusCode execute(const EventContext &ctx) const override
virtual const std::vector< const Gaudi::Details::PropertyBase * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
StatusCode decodeNames()
Decode a vector of string.
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
void membershipHandler()
for asynchronous changes in the list of algorithms
const std::string & type() const
virtual StatusCode removePropertyFromCatalogue(const std::string &client, const std::string &name)=0
Remove a property from the JobOptions catalog.
const StatusCode & ignore() const
Ignore/check StatusCode.
Base class from which all concrete algorithm classes should be derived.
constexpr static const auto FAILURE
An abstract interface for Algorithm Context Service.
bool filterPassed() const
AttribStringParser::Iterator begin(const AttribStringParser &parser)
const std::string & name() const
std::string typeName(const std::type_info &typ)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.