MinimalEventLoopMgr Class Reference

This is the default processing manager of the application manager. More...

#include <GaudiKernel/MinimalEventLoopMgr.h>

Inheritance diagram for MinimalEventLoopMgr:
Collaboration diagram for MinimalEventLoopMgr:

Public Types

typedef std::vector< SmartIF< IAlgorithm > > ListAlg
 
- Public Types inherited from extends< Service, IEventProcessor >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

 MinimalEventLoopMgr (const std::string &nam, ISvcLocator *svcLoc)
 Standard Constructor. More...
 
StatusCode initialize () override
 implementation of IService::initialize More...
 
StatusCode start () override
 implementation of IService::start More...
 
StatusCode stop () override
 implementation of IService::stop More...
 
StatusCode finalize () override
 implementation of IService::finalize More...
 
StatusCode reinitialize () override
 implementation of IService::reinitialize More...
 
StatusCode restart () override
 implementation of IService::restart More...
 
StatusCode nextEvent (int maxevt) override
 implementation of IEventProcessor::nextEvent More...
 
StatusCode executeEvent (void *par) override
 implementation of IEventProcessor::executeEvent(void* par) More...
 
StatusCode executeRun (int maxevt) override
 implementation of IEventProcessor::executeRun( ) More...
 
StatusCode stopRun () override
 implementation of IEventProcessor::stopRun( ) More...
 
void topAlgHandler (Gaudi::Details::PropertyBase &p)
 Top algorithm List handler. More...
 
StatusCode decodeTopAlgs ()
 decodeTopAlgNameList & topAlgNameListHandler More...
 
void outStreamHandler (Gaudi::Details::PropertyBase &p)
 Output stream List handler. More...
 
StatusCode decodeOutStreams ()
 decodeOutStreamNameList & outStreamNameListHandler More...
 
- Public Member Functions inherited from extends< Service, IEventProcessor >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< TYPE > &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ServiceHandle< TYPE > &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< TYPE > &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ServiceHandleArray< TYPE > &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandle< TYPE > &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Types

enum  State { OFFLINE, CONFIGURED, FINALIZED, INITIALIZED }
 

Protected Attributes

Gaudi::Property< std::vector< std::string > > m_topAlgNames {this, "TopAlg", {}, "list of top level algorithms names"}
 
Gaudi::Property< std::vector< std::string > > m_outStreamNames {this, "OutStream", {}, "list of output stream names"}
 
Gaudi::Property< std::stringm_outStreamType
 
SmartIF< IAppMgrUIm_appMgrUI
 Reference to the IAppMgrUI interface of the application manager. More...
 
SmartIF< IIncidentSvcm_incidentSvc
 Reference to the incident service. More...
 
SmartIF< IAlgExecStateSvcm_aess
 List of top level algorithms. More...
 
ListAlg m_topAlgList
 
ListAlg m_outStreamList
 List of output streams. More...
 
State m_state = OFFLINE
 State of the object. More...
 
bool m_scheduledStop = false
 Scheduled stop of event processing. More...
 
SmartIF< IIncidentListenerm_abortEventListener
 Instance of the incident listener waiting for AbortEvent. More...
 
bool m_abortEvent = false
 Flag signalling that the event being processedhas to be aborted (skip all following top algs). More...
 
std::string m_abortEventSource
 Source of the AbortEvent incident. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Private Member Functions

 MinimalEventLoopMgr (const MinimalEventLoopMgr &)
 Fake copy constructor (never implemented). More...
 
MinimalEventLoopMgroperator= (const MinimalEventLoopMgr &)
 Fake assignment operator (never implemented). More...
 

Private Attributes

EventContextm_eventContext
 EventContext. More...
 
size_t m_nevt {0}
 

Additional Inherited Members

- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Detailed Description

This is the default processing manager of the application manager.

This object handles the minimal requirements needed by the application manager. It also is capable of handling a bunch of algorithms and output streams. However, they list may as well be empty.

Author
Markus Frank
Version
1.0

Definition at line 27 of file MinimalEventLoopMgr.h.

Member Typedef Documentation

Member Enumeration Documentation

Constructor & Destructor Documentation

MinimalEventLoopMgr::MinimalEventLoopMgr ( const std::string nam,
ISvcLocator svcLoc 
)

Standard Constructor.

Definition at line 56 of file MinimalEventLoopMgr.cpp.

57  : base_class( nam, svcLoc ), m_appMgrUI( svcLoc )
58 {
59  m_topAlgNames.declareUpdateHandler( &MinimalEventLoopMgr::topAlgHandler, this );
60  m_outStreamNames.declareUpdateHandler( &MinimalEventLoopMgr::outStreamHandler, this );
61 }
void topAlgHandler(Gaudi::Details::PropertyBase &p)
Top algorithm List handler.
void outStreamHandler(Gaudi::Details::PropertyBase &p)
Output stream List handler.
extends base_class
Typedef to this class.
Definition: extends.h:14
Gaudi::Property< std::vector< std::string > > m_outStreamNames
Gaudi::Property< std::vector< std::string > > m_topAlgNames
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
MinimalEventLoopMgr::MinimalEventLoopMgr ( const MinimalEventLoopMgr )
private

Fake copy constructor (never implemented).

Member Function Documentation

StatusCode MinimalEventLoopMgr::decodeOutStreams ( )

decodeOutStreamNameList & outStreamNameListHandler

Definition at line 543 of file MinimalEventLoopMgr.cpp.

544 {
546  if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
547  auto algMan = serviceLocator()->as<IAlgManager>();
548  if ( algMan ) {
549  // Reset the existing Top Algorithm List
551  for ( const auto& it : m_outStreamNames.value() ) {
553  const bool CREATE = false;
554  SmartIF<IAlgorithm> os = algMan->algorithm( item, CREATE );
555  if ( os ) {
556  DEBMSG << "Output Stream " << item.name() << " already exists" << endmsg;
557  } else {
558  DEBMSG << "Creating Output Stream " << it << endmsg;
559  IAlgorithm* ios = nullptr;
560  StatusCode sc1 = algMan->createAlgorithm( item.type(), item.name(), ios );
561  if ( !sc1.isSuccess() ) {
562  error() << "Unable to create Output Stream " << it << endmsg;
563  return sc1;
564  }
565  os = ios; // manage reference counting
566  }
568  }
569  return sc;
570  }
571  sc = StatusCode::FAILURE;
572  }
573  return sc;
574 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
State m_state
State of the object.
T push_back(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Gaudi::Property< std::vector< std::string > > m_outStreamNames
Helper class to parse a string of format "type/name".
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T clear(T...args)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
ListAlg m_outStreamList
List of output streams.
#define DEBMSG
Gaudi::Property< std::string > m_outStreamType
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode MinimalEventLoopMgr::decodeTopAlgs ( )

decodeTopAlgNameList & topAlgNameListHandler

Definition at line 493 of file MinimalEventLoopMgr.cpp.

494 {
496  if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
497  auto algMan = serviceLocator()->as<IAlgManager>();
498  if ( algMan ) {
499  // Reset the existing Top Algorithm List
501  m_topAlgList.reserve( m_topAlgNames.value().size() );
502  for ( const auto& it : m_topAlgNames.value() ) {
504  // Got the type and name. Now creating the algorithm, avoiding duplicate creation.
505  std::string item_name = item.name() + getGaudiThreadIDfromName( name() );
506  const bool CREATE = false;
507  SmartIF<IAlgorithm> alg = algMan->algorithm( item_name, CREATE );
508  if ( alg ) {
509  DEBMSG << "Top Algorithm " << item_name << " already exists" << endmsg;
510  } else {
511  DEBMSG << "Creating Top Algorithm " << item.type() << " with name " << item_name << endmsg;
512  IAlgorithm* ialg = nullptr;
513  StatusCode sc1 = algMan->createAlgorithm( item.type(), item_name, ialg );
514  if ( !sc1.isSuccess() ) {
515  error() << "Unable to create Top Algorithm " << item.type() << " with name " << item_name << endmsg;
516  return sc1;
517  }
518  alg = ialg; // manage reference counting
519  }
520  m_topAlgList.push_back( alg );
521  }
522  return sc;
523  }
524  sc = StatusCode::FAILURE;
525  }
526  return sc;
527 }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
STL class.
State m_state
State of the object.
T push_back(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Helper class to parse a string of format "type/name".
Gaudi::Property< std::vector< std::string > > m_topAlgNames
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T clear(T...args)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
#define DEBMSG
GAUDI_API std::string getGaudiThreadIDfromName(const std::string &name)
helper function to extract Gaudi Thread ID from thread copy name
Definition: ThreadGaudi.cpp:26
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
T reserve(T...args)
StatusCode MinimalEventLoopMgr::executeEvent ( void *  par)
override

implementation of IEventProcessor::executeEvent(void* par)

Definition at line 384 of file MinimalEventLoopMgr.cpp.

385 {
386  bool eventfailed = false;
387 
388  // reset state of ALL "known" algorithms
389  // (before we were reseting only the topalgs)
390  m_aess->reset();
391 
392  // this should really be set from the EventSelector or the current
393  // event header in the EventStore
396 
397  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
398  const auto appmgr = serviceLocator()->as<IProperty>();
399  // Call the execute() method of all top algorithms
400  for ( auto& ita : m_topAlgList ) {
402  try {
403  if ( UNLIKELY( m_abortEvent ) ) {
404  DEBMSG << "AbortEvent incident fired by " << m_abortEventSource << endmsg;
405  m_abortEvent = false;
406  sc.ignore();
407  break;
408  }
410  sc = ita->sysExecute();
411  rcg.ignore(); // disarm the guard
412  } catch ( const GaudiException& Exception ) {
413  fatal() << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by " << ita->name() << endmsg;
414  error() << Exception << endmsg;
415  } catch ( const std::exception& Exception ) {
416  fatal() << ".executeEvent(): Standard std::exception thrown by " << ita->name() << endmsg;
417  error() << Exception.what() << endmsg;
418  } catch ( ... ) {
419  fatal() << ".executeEvent(): UNKNOWN Exception thrown by " << ita->name() << endmsg;
420  }
421 
422  m_aess->algExecState(ita).setExecuted(true);
424 
425  if ( UNLIKELY( !sc.isSuccess() ) ) {
426  warning() << "Execution of algorithm " << ita->name() << " failed" << endmsg;
427  eventfailed = true;
428  }
429  }
430 
431  m_aess->updateEventStatus(eventfailed);
432 
433  // ensure that the abortEvent flag is cleared before the next event
434  if ( UNLIKELY( m_abortEvent ) ) {
435  DEBMSG << "AbortEvent incident fired by " << m_abortEventSource << endmsg;
436  m_abortEvent = false;
437  }
438 
439  // Call the execute() method of all output streams
440  for ( auto& ito : m_outStreamList ) {
441  m_aess->algExecState(ito).setExecuted(false);
442  m_aess->algExecState(ito).setFilterPassed(true);
443  StatusCode sc;
444  sc = ito->sysExecute();
446  if ( UNLIKELY( !sc.isSuccess() ) ) {
447  warning() << "Execution of output stream " << ito->name() << " failed" << endmsg;
448  eventfailed = true;
449  }
450  }
451 
452  m_nevt++;
453 
454  // Check if there was an error processing current event
455  if ( UNLIKELY( eventfailed ) ) {
456  error() << "Error processing event loop." << endmsg;
457  std::ostringstream ost;
458  m_aess->dump(ost);
459  debug() << "Dumping AlgExecStateSvc status:\n" << ost.str() << endmsg;
460  return StatusCode( StatusCode::FAILURE, true );
461  }
462 
463  return StatusCode( StatusCode::SUCCESS, true );
464 }
Define general base for Gaudi exception.
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
void set(const ContextEvt_t &e=0, const ContextID_t &s=INVALID_CONTEXT_ID)
Definition: EventContext.h:46
SmartIF< IAlgExecStateSvc > m_aess
List of top level algorithms.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
#define UNLIKELY(x)
Definition: Kernel.h:126
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
constexpr int UnhandledException
Definition: AppReturnCode.h:29
virtual void dump(std::ostringstream &ost) const =0
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::string m_abortEventSource
Source of the AbortEvent incident.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
virtual const std::string & tag() const
name tag for the exception, or exception type
void setExecuted(bool e=true)
STL class.
GAUDI_API void setCurrentContext(const EventContext *ctx)
virtual void reset(const EventContext &ctx)=0
ListAlg m_outStreamList
List of output streams.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
#define DEBMSG
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
void setFilterPassed(bool f=true)
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
EventContext * m_eventContext
EventContext.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool m_abortEvent
Flag signalling that the event being processedhas to be aborted (skip all following top algs)...
virtual void updateEventStatus(const bool &b)=0
StatusCode MinimalEventLoopMgr::executeRun ( int  maxevt)
override

implementation of IEventProcessor::executeRun( )

Definition at line 327 of file MinimalEventLoopMgr.cpp.

328 {
329  StatusCode sc;
330  bool eventfailed = false;
331 
332  // Call the beginRun() method of all top algorithms
333  for ( auto& ita : m_topAlgList ) {
334  sc = ita->sysBeginRun();
335  if ( !sc.isSuccess() ) {
336  warning() << "beginRun() of algorithm " << ita->name() << " failed" << endmsg;
337  eventfailed = true;
338  }
339  }
340 
341  // Call now the nextEvent(...)
342  sc = nextEvent( maxevt );
343  if ( !sc.isSuccess() ) eventfailed = true;
344 
345  // Call the endRun() method of all top algorithms
346  for ( auto& ita : m_topAlgList ) {
347  sc = ita->sysEndRun();
348  if ( !sc.isSuccess() ) {
349  warning() << "endRun() of algorithm " << ita->name() << " failed" << endmsg;
350  eventfailed = true;
351  }
352  }
353 
354  return eventfailed ? StatusCode::FAILURE : StatusCode::SUCCESS;
355 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode nextEvent(int maxevt) override
implementation of IEventProcessor::nextEvent
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
int maxevt
Definition: Bootstrap.cpp:279
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode MinimalEventLoopMgr::finalize ( )
override

implementation of IService::finalize

Definition at line 265 of file MinimalEventLoopMgr.cpp.

266 {
269  // Call the finalize() method of all top algorithms
270  for ( auto& ita : m_topAlgList ) {
271  sc = ita->sysFinalize();
272  if ( !sc.isSuccess() ) {
273  scRet = StatusCode::FAILURE;
274  warning() << "Finalization of algorithm " << ita->name() << " failed" << endmsg;
275  }
276  }
277  // Call the finalize() method of all Output streams
278  for ( auto& ita : m_outStreamList ) {
279  sc = ita->sysFinalize();
280  if ( !sc.isSuccess() ) {
281  scRet = StatusCode::FAILURE;
282  warning() << "Finalization of algorithm " << ita->name() << " failed" << endmsg;
283  }
284  }
285  // release all top algorithms
286  auto algMan = serviceLocator()->as<IAlgManager>();
287  for ( auto& ita : m_topAlgList ) {
288  if ( algMan->removeAlgorithm( ita ).isFailure() ) {
289  scRet = StatusCode::FAILURE;
290  warning() << "Problems removing Algorithm " << ita->name() << endmsg;
291  }
292  }
293  m_topAlgList.clear();
294  m_outStreamList.clear();
295  if ( sc.isSuccess() ) m_state = FINALIZED;
296 
297  m_incidentSvc->removeListener( m_abortEventListener, IncidentType::AbortEvent );
299 
301  m_appMgrUI.reset();
302 
303  delete m_eventContext;
304 
305  sc = Service::finalize();
306 
307  if ( sc.isFailure() ) {
308  scRet = StatusCode::FAILURE;
309  error() << "Problems finalizing Service base class" << endmsg;
310  }
311 
312  return scRet;
313 }
StatusCode finalize() override
Definition: Service.cpp:174
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
State m_state
State of the object.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
SmartIF< IIncidentListener > m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
ListAlg m_outStreamList
List of output streams.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
virtual void removeListener(IIncidentListener *lis, const std::string &type="")=0
Remove listener.
EventContext * m_eventContext
EventContext.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
StatusCode MinimalEventLoopMgr::initialize ( )
override

implementation of IService::initialize

Definition at line 66 of file MinimalEventLoopMgr.cpp.

67 {
68 
69  if ( !m_appMgrUI ) return StatusCode::FAILURE;
70 
72  if ( !sc.isSuccess() ) {
73  error() << "Failed to initialize Service Base class." << endmsg;
74  return StatusCode::FAILURE;
75  }
76 
77  auto prpMgr = serviceLocator()->as<IProperty>();
78  if ( !prpMgr ) {
79  error() << "Error retrieving AppMgr interface IProperty." << endmsg;
80  return StatusCode::FAILURE;
81  }
82  if ( m_topAlgNames.value().empty() ) {
83  setProperty( prpMgr->getProperty( "TopAlg" ) ).ignore();
84  }
85  if ( m_outStreamNames.value().empty() ) {
86  setProperty( prpMgr->getProperty( "OutStream" ) ).ignore();
87  }
88 
89  // Get the references to the services that are needed by the ApplicationMgr itself
90  m_incidentSvc = serviceLocator()->service( "IncidentSvc" );
91  if ( !m_incidentSvc ) {
92  fatal() << "Error retrieving IncidentSvc." << endmsg;
93  return StatusCode::FAILURE;
94  }
95 
96  m_abortEventListener = new AbortEventListener( m_abortEvent, m_abortEventSource );
97  m_incidentSvc->addListener( m_abortEventListener, IncidentType::AbortEvent );
98 
99  // The state is changed at this moment to allow decodeXXXX() to do something
101 
102  // create an EventContext object
104 
105  //--------------------------------------------------------------------------------------------
106  // Create output streams. Do not initialize them yet.
107  // The state is updated temporarily in order to enable the handler, which
108  // is also triggered by a change to the "OutputStream" Property.
109  //--------------------------------------------------------------------------------------------
110  sc = decodeOutStreams();
111  if ( !sc.isSuccess() ) {
112  error() << "Failed to initialize Output streams." << endmsg;
114  return sc;
115  }
116  //--------------------------------------------------------------------------------------------
117  // Create all needed Top Algorithms. Do not initialize them yet.
118  // The state is updated temporarily in order to enable the handler, which
119  // is also triggered by a change to the "TopAlg" Property.
120  //--------------------------------------------------------------------------------------------
121  sc = decodeTopAlgs();
122  if ( !sc.isSuccess() ) {
123  error() << "Failed to initialize Top Algorithms streams." << endmsg;
125  return sc;
126  }
127 
128  // Initialize all the new TopAlgs. In fact Algorithms are protected against
129  // getting initialized twice.
130  for ( auto& ita : m_topAlgList ) {
131  ita->setContext( m_eventContext );
132  sc = ita->sysInitialize();
133  if ( !sc.isSuccess() ) {
134  error() << "Unable to initialize Algorithm: " << ita->name() << endmsg;
135  return sc;
136  }
137  }
138  for ( auto& ita : m_outStreamList ) {
139  sc = ita->sysInitialize();
140  ita->setContext( m_eventContext );
141  if( !sc.isSuccess() ) {
142  error() << "Unable to initialize Output Stream: " << ita->name() << endmsg;
143  return sc;
144  }
145  }
146 
147  // get hold of the Algorithm Execution State mgr
148  m_aess = serviceLocator()->service("AlgExecStateSvc");
149  if( !m_aess ) {
150  fatal() << "Error retrieving AlgExecStateSvc." << endmsg;
151  return StatusCode::FAILURE;
152  }
153 
154  return StatusCode::SUCCESS;
155 }
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
SmartIF< IAlgExecStateSvc > m_aess
List of top level algorithms.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
StatusCode decodeTopAlgs()
decodeTopAlgNameList & topAlgNameListHandler
This class represents an entry point to all the event specific data.
Definition: EventContext.h:25
State m_state
State of the object.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::string m_abortEventSource
Source of the AbortEvent incident.
Gaudi::Property< std::vector< std::string > > m_outStreamNames
SmartIF< IIncidentListener > m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
Gaudi::Property< std::vector< std::string > > m_topAlgNames
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
ListAlg m_outStreamList
List of output streams.
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
StatusCode decodeOutStreams()
decodeOutStreamNameList & outStreamNameListHandler
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
EventContext * m_eventContext
EventContext.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
bool m_abortEvent
Flag signalling that the event being processedhas to be aborted (skip all following top algs)...
StatusCode MinimalEventLoopMgr::nextEvent ( int  maxevt)
override

implementation of IEventProcessor::nextEvent

Definition at line 318 of file MinimalEventLoopMgr.cpp.

319 {
320  error() << "This method cannot be called on an object of type " << System::typeinfoName( typeid( *this ) ) << endmsg;
321  return StatusCode::FAILURE;
322 }
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:299
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MinimalEventLoopMgr& MinimalEventLoopMgr::operator= ( const MinimalEventLoopMgr )
private

Fake assignment operator (never implemented).

void MinimalEventLoopMgr::outStreamHandler ( Gaudi::Details::PropertyBase p)

Output stream List handler.

Definition at line 532 of file MinimalEventLoopMgr.cpp.

533 {
534  if ( !( decodeOutStreams() ).isSuccess() ) {
535  throw GaudiException( "Failed to initialize output streams.", "MinimalEventLoopMgr::outStreamHandler",
537  }
538 }
Define general base for Gaudi exception.
StatusCode decodeOutStreams()
decodeOutStreamNameList & outStreamNameListHandler
StatusCode MinimalEventLoopMgr::reinitialize ( )
override

implementation of IService::reinitialize

Definition at line 214 of file MinimalEventLoopMgr.cpp.

215 {
217 
218  // Reinitialize all the TopAlgs.
219  for ( auto& ita : m_topAlgList ) {
220  sc = ita->sysReinitialize();
221  if ( !sc.isSuccess() ) {
222  error() << "Unable to reinitialize Algorithm: " << ita->name() << endmsg;
223  return sc;
224  }
225  }
226  for ( auto& ita : m_outStreamList ) {
227  sc = ita->sysReinitialize();
228  if ( !sc.isSuccess() ) {
229  error() << "Unable to reinitialize Output Stream: " << ita->name() << endmsg;
230  return sc;
231  }
232  }
233 
234  return sc;
235 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode MinimalEventLoopMgr::restart ( )
override

implementation of IService::restart

Definition at line 239 of file MinimalEventLoopMgr.cpp.

240 {
242 
243  // Restart all the TopAlgs.
244  for ( auto& ita : m_topAlgList ) {
245  sc = ita->sysRestart();
246  if ( !sc.isSuccess() ) {
247  error() << "Unable to restart Algorithm: " << ita->name() << endmsg;
248  return sc;
249  }
250  }
251  for ( auto& ita : m_outStreamList ) {
252  sc = ita->sysRestart();
253  if ( !sc.isSuccess() ) {
254  error() << "Unable to restart Output Stream: " << ita->name() << endmsg;
255  return sc;
256  }
257  }
258 
259  return sc;
260 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode MinimalEventLoopMgr::start ( )
override

implementation of IService::start

Definition at line 159 of file MinimalEventLoopMgr.cpp.

160 {
161 
162  StatusCode sc = Service::start();
163  if ( !sc.isSuccess() ) return sc;
164 
165  // Start all the new TopAlgs. In fact Algorithms are protected against getting
166  // started twice.
167  for ( auto& ita : m_topAlgList ) {
168  sc = ita->sysStart();
169  if ( !sc.isSuccess() ) {
170  error() << "Unable to start Algorithm: " << ita->name() << endmsg;
171  return sc;
172  }
173  }
174  for ( auto& ita : m_outStreamList ) {
175  sc = ita->sysStart();
176  if ( !sc.isSuccess() ) {
177  error() << "Unable to start Output Stream: " << ita->name() << endmsg;
178  return sc;
179  }
180  }
181  return StatusCode::SUCCESS;
182 }
StatusCode start() override
Definition: Service.cpp:137
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode MinimalEventLoopMgr::stop ( )
override

implementation of IService::stop

Definition at line 186 of file MinimalEventLoopMgr.cpp.

187 {
188 
189  StatusCode sc( StatusCode::SUCCESS, true );
190 
191  // Stop all the TopAlgs. In fact Algorithms are protected against getting
192  // stopped twice.
193  for ( auto& ita : m_topAlgList ) {
194  sc = ita->sysStop();
195  if ( !sc.isSuccess() ) {
196  error() << "Unable to stop Algorithm: " << ita->name() << endmsg;
197  return sc;
198  }
199  }
200  for ( auto& ita : m_outStreamList ) {
201  sc = ita->sysStop();
202  if ( !sc.isSuccess() ) {
203  error() << "Unable to stop Output Stream: " << ita->name() << endmsg;
204  return sc;
205  }
206  }
207 
208  return Service::stop();
209 }
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode stop() override
Definition: Service.cpp:130
ListAlg m_outStreamList
List of output streams.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode MinimalEventLoopMgr::stopRun ( )
override

implementation of IEventProcessor::stopRun( )

Definition at line 468 of file MinimalEventLoopMgr.cpp.

469 {
470  // Set the application return code
471  auto appmgr = serviceLocator()->as<IProperty>();
473  error() << "Could not set return code of the application (" << Gaudi::ReturnCode::ScheduledStop << ")" << endmsg;
474  }
475  m_scheduledStop = true;
476  return StatusCode::SUCCESS;
477 }
bool m_scheduledStop
Scheduled stop of event processing.
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
constexpr int ScheduledStop
Definition: AppReturnCode.h:27
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:51
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void MinimalEventLoopMgr::topAlgHandler ( Gaudi::Details::PropertyBase p)

Top algorithm List handler.

Definition at line 482 of file MinimalEventLoopMgr.cpp.

483 {
484  if ( !( decodeTopAlgs() ).isSuccess() ) {
485  throw GaudiException( "Failed to initialize Top Algorithms streams.", "MinimalEventLoopMgr::topAlgHandler",
487  }
488 }
Define general base for Gaudi exception.
StatusCode decodeTopAlgs()
decodeTopAlgNameList & topAlgNameListHandler

Member Data Documentation

bool MinimalEventLoopMgr::m_abortEvent = false
protected

Flag signalling that the event being processedhas to be aborted (skip all following top algs).

Definition at line 58 of file MinimalEventLoopMgr.h.

SmartIF<IIncidentListener> MinimalEventLoopMgr::m_abortEventListener
protected

Instance of the incident listener waiting for AbortEvent.

Definition at line 55 of file MinimalEventLoopMgr.h.

std::string MinimalEventLoopMgr::m_abortEventSource
protected

Source of the AbortEvent incident.

Definition at line 60 of file MinimalEventLoopMgr.h.

SmartIF<IAlgExecStateSvc> MinimalEventLoopMgr::m_aess
protected

List of top level algorithms.

Definition at line 46 of file MinimalEventLoopMgr.h.

SmartIF<IAppMgrUI> MinimalEventLoopMgr::m_appMgrUI
protected

Reference to the IAppMgrUI interface of the application manager.

Definition at line 42 of file MinimalEventLoopMgr.h.

EventContext* MinimalEventLoopMgr::m_eventContext
private

EventContext.

Definition at line 117 of file MinimalEventLoopMgr.h.

SmartIF<IIncidentSvc> MinimalEventLoopMgr::m_incidentSvc
protected

Reference to the incident service.

Definition at line 44 of file MinimalEventLoopMgr.h.

size_t MinimalEventLoopMgr::m_nevt {0}
private

Definition at line 120 of file MinimalEventLoopMgr.h.

ListAlg MinimalEventLoopMgr::m_outStreamList
protected

List of output streams.

Definition at line 49 of file MinimalEventLoopMgr.h.

Gaudi::Property<std::vector<std::string> > MinimalEventLoopMgr::m_outStreamNames {this, "OutStream", {}, "list of output stream names"}
protected

Definition at line 35 of file MinimalEventLoopMgr.h.

Gaudi::Property<std::string> MinimalEventLoopMgr::m_outStreamType
protected
Initial value:
{this, "OutStreamType", "OutputStream",
"[[deprecated]] default type for OutputStream instances"}

Definition at line 36 of file MinimalEventLoopMgr.h.

bool MinimalEventLoopMgr::m_scheduledStop = false
protected

Scheduled stop of event processing.

Definition at line 53 of file MinimalEventLoopMgr.h.

State MinimalEventLoopMgr::m_state = OFFLINE
protected

State of the object.

Definition at line 51 of file MinimalEventLoopMgr.h.

ListAlg MinimalEventLoopMgr::m_topAlgList
protected

Definition at line 47 of file MinimalEventLoopMgr.h.

Gaudi::Property<std::vector<std::string> > MinimalEventLoopMgr::m_topAlgNames {this, "TopAlg", {}, "list of top level algorithms names"}
protected

Definition at line 34 of file MinimalEventLoopMgr.h.


The documentation for this class was generated from the following files: