Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EventLoopMgr Class Reference

Class definition of EventLoopMgr. More...

#include <src/ApplicationMgr/EventLoopMgr.h>

Inheritance diagram for EventLoopMgr:
Collaboration diagram for EventLoopMgr:

Public Member Functions

 ~EventLoopMgr () override
 Standard Destructor. More...
 
StatusCode getEventRoot (IOpaqueAddress *&refpAddr)
 Create event address using event selector. More...
 
StatusCode initialize () override
 implementation of IService::initialize More...
 
StatusCode reinitialize () override
 implementation of IService::reinitialize More...
 
StatusCode stop () override
 implementation of IService::stop More...
 
StatusCode finalize () override
 implementation of IService::finalize More...
 
StatusCode nextEvent (int maxevt) override
 implementation of IService::nextEvent More...
 
StatusCode executeEvent (void *par) override
 implementation of IEventProcessor::executeEvent(void* par) More...
 
- Public Member Functions inherited from MinimalEventLoopMgr
 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, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &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 Attributes

Gaudi::Property< std::stringm_histPersName {this, "HistogramPersistency", {}, "name of the Hist Pers type"}
 
Gaudi::Property< std::stringm_evtsel {this, "EvtSel", {}, "event selector"}
 
Gaudi::Property< bool > m_warnings {this, "Warnings", true, "set to false to suppress warning messages"}
 
SmartIF< IDataManagerSvcm_evtDataMgrSvc = nullptr
 Reference to the Event Data Service's IDataManagerSvc interface. More...
 
SmartIF< IDataProviderSvcm_evtDataSvc = nullptr
 Reference to the Event Data Service's IDataProviderSvc interface. More...
 
SmartIF< IEvtSelectorm_evtSelector = nullptr
 Reference to the Event Selector. More...
 
IEvtSelector::Contextm_evtContext = nullptr
 Event Iterator. More...
 
SmartIF< IDataManagerSvcm_histoDataMgrSvc = nullptr
 Reference to the Histogram Data Service. More...
 
SmartIF< IConversionSvcm_histoPersSvc = nullptr
 Reference to the Histogram Persistency Service. More...
 
SmartIF< IPropertym_appMgrProperty = nullptr
 Property interface of ApplicationMgr. More...
 
bool m_endEventFired = true
 Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event) More...
 
- Protected Attributes inherited from MinimalEventLoopMgr
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
 
Gaudi::Property< bool > m_printCFExp
 
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...
 

Additional Inherited Members

- Public Types inherited from MinimalEventLoopMgr
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...
 
- Protected Types inherited from MinimalEventLoopMgr
enum  State { OFFLINE, CONFIGURED, FINALIZED, INITIALIZED }
 
- 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

Class definition of EventLoopMgr.

This is the default processing manager of the application manager. This object handles the minimal requirements needed by the application manager. It also handles the default user configuration setup for standard event processing.

  • handling of the incidents when starting event processing
  • handling of the event loop

History:

 +---------+----------------------------------------------+---------+
 |    Date |                 Comment                      | Who     |
 +---------+----------------------------------------------+---------+
 |13/12/00 | Initial version                              | M.Frank |
 +---------+----------------------------------------------+---------+
 
Author
Markus Frank
Version
1.0

Definition at line 38 of file EventLoopMgr.h.

Constructor & Destructor Documentation

EventLoopMgr::~EventLoopMgr ( )
override

Standard Destructor.

Definition at line 32 of file EventLoopMgr.cpp.

32  {
33  delete m_evtContext;
34 }
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:55

Member Function Documentation

StatusCode EventLoopMgr::executeEvent ( void *  par)
override

implementation of IEventProcessor::executeEvent(void* par)

Definition at line 257 of file EventLoopMgr.cpp.

257  {
258 
259  // DP Monitoring
260 
261 
262 
263  // Fire BeginEvent "Incident"
264  m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginEvent));
265  // An incident may schedule a stop, in which case is better to exit before the actual execution.
266  if ( m_scheduledStop ) {
267  always() << "Terminating event processing loop due to a stop scheduled by an incident listener" << endmsg;
268  return StatusCode::SUCCESS;
269  }
270 
271  // Execute Algorithms
272  m_incidentSvc->fireIncident(Incident(name(), IncidentType::BeginProcessing));
274  m_incidentSvc->fireIncident(Incident(name(), IncidentType::EndProcessing));
275 
276  // Check if there was an error processing current event
277  if( UNLIKELY(!sc.isSuccess()) ){
278  error() << "Terminating event processing loop due to errors" << endmsg;
279  }
280  return sc;
281 }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
bool m_scheduledStop
Scheduled stop of event processing.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
#define UNLIKELY(x)
Definition: Kernel.h:126
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Base class for all Incidents (computing events).
Definition: Incident.h:17
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode executeEvent(void *par) override
implementation of IEventProcessor::executeEvent(void* par)
StatusCode EventLoopMgr::finalize ( )
override

implementation of IService::finalize

Definition at line 191 of file EventLoopMgr.cpp.

191  {
192  StatusCode sc;
193 
194  // Finalize base class
196  if (! sc.isSuccess()) {
197  error() << "Error finalizing base class" << endmsg;
198  return sc;
199  }
200 
201  // Save Histograms Now
202  if ( m_histoPersSvc ) {
203  HistogramAgent agent;
204  sc = m_histoDataMgrSvc->traverseTree( &agent );
205  if( sc.isSuccess() ) {
206  IDataSelector* objects = agent.selectedObjects();
207  // skip /stat entry!
208  if ( objects->size() > 0 ) {
209  for ( auto& i : *objects ) {
210  IOpaqueAddress* pAddr = nullptr;
211  StatusCode iret = m_histoPersSvc->createRep(i, pAddr);
212  if ( iret.isSuccess() ) {
213  i->registry()->setAddress(pAddr);
214  }
215  else {
216  sc = iret;
217  }
218  }
219  for ( auto& i : *objects ) {
220  IRegistry* reg = i->registry();
221  StatusCode iret = m_histoPersSvc->fillRepRefs(reg->address(), i);
222  if ( !iret.isSuccess() ) sc = iret;
223  }
224  }
225  if ( sc.isSuccess() ) {
226  info() << "Histograms converted successfully according to request." << endmsg;
227  }
228  else {
229  error() << "Error while saving Histograms." << endmsg;
230  }
231  }
232  else {
233  error() << "Error while traversing Histogram data store" << endmsg;
234  }
235  }
236 
237  // Release event selector context
238  if ( m_evtSelector && m_evtContext ) {
240  m_evtContext = nullptr;
241  }
242 
243  // Release all interfaces...
244  m_histoDataMgrSvc = nullptr;
245  m_histoPersSvc = nullptr;
246 
247  m_evtSelector = nullptr;
248  m_evtDataSvc = nullptr;
249  m_evtDataMgrSvc = nullptr;
250 
251  return StatusCode::SUCCESS;
252 }
StatusCode finalize() override
implementation of IService::finalize
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
Definition: EventLoopMgr.h:59
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
HistogramAgent base in charge of collecting all the refereces to DataObjects in a transient store tha...
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
virtual StatusCode releaseContext(Context *&) const =0
Release the Context object.
IDataSelector * selectedObjects()
Return the set of selected DataObjects.
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service&#39;s IDataManagerSvc interface.
Definition: EventLoopMgr.h:49
T size(T...args)
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:55
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: EventLoopMgr.h:53
SmartIF< IDataProviderSvc > m_evtDataSvc
Reference to the Event Data Service&#39;s IDataProviderSvc interface.
Definition: EventLoopMgr.h:51
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:106
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IDataManagerSvc > m_histoDataMgrSvc
Reference to the Histogram Data Service.
Definition: EventLoopMgr.h:57
StatusCode EventLoopMgr::getEventRoot ( IOpaqueAddress *&  refpAddr)

Create event address using event selector.

Definition at line 383 of file EventLoopMgr.cpp.

383  {
384  refpAddr = nullptr;
386  if ( !sc.isSuccess() ) return sc;
387  // Create root address and assign address to data service
388  sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
389  if( !sc.isSuccess() ) {
391  if ( sc.isSuccess() ) {
392  sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
393  if ( !sc.isSuccess() ) {
394  warning() << "Error creating IOpaqueAddress." << endmsg;
395  }
396  }
397  }
398  return sc;
399 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
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
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:55
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: EventLoopMgr.h:53
virtual StatusCode next(Context &c) const =0
Fetch the next event or the first event if it will be use soon after the creation of the context...
virtual StatusCode createAddress(const Context &c, IOpaqueAddress *&iop) const =0
Create an IOpaqueAddress object from the event fetched.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode EventLoopMgr::initialize ( )
override

implementation of IService::initialize

Definition at line 39 of file EventLoopMgr.cpp.

39  {
40  // Initialize the base class
42  if( !sc.isSuccess() ) {
43  DEBMSG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
44  return sc;
45  }
46 
47  // Setup access to event data services
48  m_evtDataMgrSvc = serviceLocator()->service("EventDataSvc");
49  if( !m_evtDataMgrSvc ) {
50  fatal() << "Error retrieving EventDataSvc interface IDataManagerSvc." << endmsg;
51  return StatusCode::FAILURE;
52  }
53  m_evtDataSvc = serviceLocator()->service("EventDataSvc");
54  if( !m_evtDataSvc ) {
55  fatal() << "Error retrieving EventDataSvc interface IDataProviderSvc." << endmsg;
56  return StatusCode::FAILURE;
57  }
58 
59  // Obtain the IProperty of the ApplicationMgr
61  if ( ! m_appMgrProperty ) {
62  fatal() << "IProperty interface not found in ApplicationMgr." << endmsg;
63  return StatusCode::FAILURE;
64  }
65 
66  // We do not expect a Event Selector necessarily being declared
67  setProperty(m_appMgrProperty->getProperty("EvtSel")).ignore();
68 
69  if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
70  m_evtSelector = serviceLocator()->service("EventSelector");
71  if( m_evtSelector ) {
72  // Setup Event Selector
74  if( !sc.isSuccess() ) {
75  fatal() << "Can not create the event selector Context." << endmsg;
76  return sc;
77  }
78  }
79  else {
80  fatal() << "EventSelector not found." << endmsg;
81  return sc;
82  }
83  } else {
84  m_evtSelector = nullptr;
85  m_evtContext = nullptr;
86  if ( m_warnings ) {
87  warning() << "Unable to locate service \"EventSelector\" " << endmsg;
88  warning() << "No events will be processed from external input." << endmsg;
89  }
90  }
91 
92  // Setup access to histogramming services
93  m_histoDataMgrSvc = serviceLocator()->service("HistogramDataSvc");
94  if( !m_histoDataMgrSvc ) {
95  fatal() << "Error retrieving HistogramDataSvc." << endmsg;
96  return sc;
97  }
98  // Setup histogram persistency
99  m_histoPersSvc = serviceLocator()->service("HistogramPersistencySvc");
100  if( !m_histoPersSvc ) {
101  warning() << "Histograms cannot not be saved - though required." << endmsg;
102  return sc;
103  }
104 
105  return StatusCode::SUCCESS;
106 }
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
Definition: EventLoopMgr.h:59
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
Gaudi::Property< bool > m_warnings
Definition: EventLoopMgr.h:46
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
StatusCode initialize() override
implementation of IService::initialize
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
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 & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service&#39;s IDataManagerSvc interface.
Definition: EventLoopMgr.h:49
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: EventLoopMgr.h:61
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:55
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: EventLoopMgr.h:53
#define DEBMSG
Gaudi::Property< std::string > m_evtsel
Definition: EventLoopMgr.h:45
SmartIF< IDataProviderSvc > m_evtDataSvc
Reference to the Event Data Service&#39;s IDataProviderSvc interface.
Definition: EventLoopMgr.h:51
virtual StatusCode createContext(Context *&c) const =0
Create and return a context object that will keep track of the state of selection.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
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< IDataManagerSvc > m_histoDataMgrSvc
Reference to the Histogram Data Service.
Definition: EventLoopMgr.h:57
StatusCode EventLoopMgr::nextEvent ( int  maxevt)
override

implementation of IService::nextEvent

Definition at line 288 of file EventLoopMgr.cpp.

288  {
289 
290  // DP Monitoring
291  // Calculate runtime
294 
295  const float oneOver1024 = 1.f/1024.f;
296 
297 
298  static int total_nevt = 0;
299  DataObject* pObject = nullptr;
301 
302  // loop over events if the maxevt (received as input) if different from -1.
303  // if evtmax is -1 it means infinite loop
304  time_point start_time = Clock::now();
305  for( int nevt = 0; maxevt == -1 || nevt < maxevt; ++nevt, ++total_nevt) {
306 
307  if(1 == nevt) // reset after first evt
308  start_time = Clock::now();
309 
310  //always() << "Event Number = " << total_nevt
311  // << " WSS (MB) = " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1024
312  // << " Time (s) = " << secsFromStart(start_time) << endmsg;
313 
314 
315  // Check if there is a scheduled stop issued by some algorithm/service
316  if ( m_scheduledStop ) {
317  m_scheduledStop = false;
318  always() << "Terminating event processing loop due to scheduled stop" << endmsg;
319  break;
320  }
321  // Clear the event store, if used in the event loop
322  if( 0 != total_nevt ) {
323 
324  if ( ! m_endEventFired ) {
325  // Fire EndEvent "Incident" (it is considered part of the clearing of the TS)
326  m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
327  m_endEventFired = true;
328  }
329  sc = m_evtDataMgrSvc->clearStore();
330  if( !sc.isSuccess() ) {
331  DEBMSG << "Clear of Event data store failed" << endmsg;
332  }
333  }
334 
335  // Setup event in the event store
336  if( m_evtContext ) {
337  IOpaqueAddress* addr = nullptr;
338  // Only if there is a EventSelector
339  sc = getEventRoot(addr);
340  if( !sc.isSuccess() ) {
341  info() << "No more events in event selection " << endmsg;
342  break;
343  }
344  // Set root clears the event data store first
345  sc = m_evtDataMgrSvc->setRoot ("/Event", addr);
346  if( !sc.isSuccess() ) {
347  warning() << "Error declaring event root address." << endmsg;
348  continue;
349  }
350  sc = m_evtDataSvc->retrieveObject("/Event", pObject);
351  if( !sc.isSuccess() ) {
352  warning() << "Unable to retrieve Event root object" << endmsg;
353  break;
354  }
355  } else {
356  sc = m_evtDataMgrSvc->setRoot ("/Event", new DataObject());
357  if( !sc.isSuccess() ) {
358  warning() << "Error declaring event root DataObject" << endmsg;
359  }
360  }
361  // Execute event for all required algorithms
362  sc = executeEvent(nullptr);
363  m_endEventFired = false;
364  if( !sc.isSuccess() ){
365  error() << "Terminating event processing loop due to errors" << endmsg;
367  return sc;
368  }
369  }
370  time_point end_time = Clock::now();
371 
372  if (UNLIKELY(outputLevel() <= MSG::DEBUG))
373  debug() << "---> Loop Finished - "
374  << " WSS " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1024
375  << " | total time (skipping 1st evt) "
376  << std::chrono::duration_cast < std::chrono::nanoseconds > (end_time - start_time).count()
377  << " ns" << endmsg;
378 
379  return StatusCode::SUCCESS;
380 }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
bool m_scheduledStop
Scheduled stop of event processing.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
int outputLevel() const
get the Service&#39;s output level
Definition: Service.h:196
#define UNLIKELY(x)
Definition: Kernel.h:126
T duration_cast(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
StatusCode executeEvent(void *par) override
implementation of IEventProcessor::executeEvent(void* par)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
std::chrono::high_resolution_clock Clock
Definition: ITimelineSvc.h:10
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:51
virtual StatusCode setRoot(std::string root_name, DataObject *pObject)=0
Initialize data store for new event by giving new event path.
T count(T...args)
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service&#39;s IDataManagerSvc interface.
Definition: EventLoopMgr.h:49
GAUDI_API long mappedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
Definition: Memory.cpp:180
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: EventLoopMgr.h:61
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:55
#define DEBMSG
Clock::time_point time_point
Definition: ITimelineSvc.h:11
Base class for all Incidents (computing events).
Definition: Incident.h:17
constexpr int AlgorithmFailure
Definition: AppReturnCode.h:26
virtual StatusCode clearStore()=0
Remove all data objects in the data store.
bool m_endEventFired
Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event) ...
Definition: EventLoopMgr.h:64
SmartIF< IDataProviderSvc > m_evtDataSvc
Reference to the Event Data Service&#39;s IDataProviderSvc interface.
Definition: EventLoopMgr.h:51
Opaque address interface definition.
int maxevt
Definition: Bootstrap.cpp:279
void ignore() const
Definition: StatusCode.h:106
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
StatusCode EventLoopMgr::reinitialize ( )
override

implementation of IService::reinitialize

Definition at line 110 of file EventLoopMgr.cpp.

110  {
111 
112  // Initialize the base class
114  if( !sc.isSuccess() ) {
115  DEBMSG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
116  return sc;
117  }
118 
119  // Check to see whether a new Event Selector has been specified
121  if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
122  auto theSvc = serviceLocator()->service<IService>("EventSelector");
123  auto theEvtSel = theSvc.as<IEvtSelector>();
124  if( theEvtSel && ( theEvtSel.get() != m_evtSelector.get() ) ) {
125  // Setup Event Selector
126  if ( m_evtSelector.get() && m_evtContext ) {
127  // Need to release context before switching to new event selector
129  m_evtContext = nullptr;
130  }
131  m_evtSelector = theEvtSel;
132  if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
133  sc = theSvc->reinitialize();
134  if( !sc.isSuccess() ) {
135  error() << "Failure Reinitializing EventSelector "
136  << theSvc->name( ) << endmsg;
137  return sc;
138  }
139  } else {
140  sc = theSvc->sysInitialize();
141  if( !sc.isSuccess() ) {
142  error() << "Failure Initializing EventSelector "
143  << theSvc->name( ) << endmsg;
144  return sc;
145  }
146  }
148  if( !sc.isSuccess() ) {
149  error() << "Can not create Context " << theSvc->name( ) << endmsg;
150  return sc;
151  }
152  info() << "EventSelector service changed to "
153  << theSvc->name( ) << endmsg;
154  }
155  else if ( m_evtSelector ) {
156  if ( m_evtContext ) {
158  m_evtContext = nullptr;
159  }
161  if( !sc.isSuccess() ) {
162  error() << "Can not create Context " << theSvc->name( ) << endmsg;
163  return sc;
164  }
165  }
166  }
167  else if ( m_evtSelector && m_evtContext ) {
169  m_evtSelector = nullptr;
170  m_evtContext = nullptr;
171  }
172  return StatusCode::SUCCESS;
173 }
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
The Event Selector Interface.
Definition: IEvtSelector.h:18
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
StatusCode reinitialize() override
implementation of IService::reinitialize
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
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)
General service interface definition.
Definition: IService.h:18
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode releaseContext(Context *&) const =0
Release the Context object.
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: EventLoopMgr.h:61
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:55
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: EventLoopMgr.h:53
#define DEBMSG
Gaudi::Property< std::string > m_evtsel
Definition: EventLoopMgr.h:45
virtual StatusCode createContext(Context *&c) const =0
Create and return a context object that will keep track of the state of selection.
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 EventLoopMgr::stop ( )
override

implementation of IService::stop

Definition at line 179 of file EventLoopMgr.cpp.

179  {
180  if ( ! m_endEventFired ) {
181  // Fire pending EndEvent incident
182  m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
183  m_endEventFired = true;
184  }
185  return MinimalEventLoopMgr::stop();
186 }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
StatusCode stop() override
implementation of IService::stop
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Base class for all Incidents (computing events).
Definition: Incident.h:17
bool m_endEventFired
Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event) ...
Definition: EventLoopMgr.h:64

Member Data Documentation

SmartIF<IProperty> EventLoopMgr::m_appMgrProperty = nullptr
protected

Property interface of ApplicationMgr.

Definition at line 61 of file EventLoopMgr.h.

bool EventLoopMgr::m_endEventFired = true
protected

Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event)

Definition at line 64 of file EventLoopMgr.h.

IEvtSelector::Context* EventLoopMgr::m_evtContext = nullptr
protected

Event Iterator.

Definition at line 55 of file EventLoopMgr.h.

SmartIF<IDataManagerSvc> EventLoopMgr::m_evtDataMgrSvc = nullptr
protected

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 49 of file EventLoopMgr.h.

SmartIF<IDataProviderSvc> EventLoopMgr::m_evtDataSvc = nullptr
protected

Reference to the Event Data Service's IDataProviderSvc interface.

Definition at line 51 of file EventLoopMgr.h.

Gaudi::Property<std::string> EventLoopMgr::m_evtsel {this, "EvtSel", {}, "event selector"}
protected

Definition at line 45 of file EventLoopMgr.h.

SmartIF<IEvtSelector> EventLoopMgr::m_evtSelector = nullptr
protected

Reference to the Event Selector.

Definition at line 53 of file EventLoopMgr.h.

SmartIF<IDataManagerSvc> EventLoopMgr::m_histoDataMgrSvc = nullptr
protected

Reference to the Histogram Data Service.

Definition at line 57 of file EventLoopMgr.h.

SmartIF<IConversionSvc> EventLoopMgr::m_histoPersSvc = nullptr
protected

Reference to the Histogram Persistency Service.

Definition at line 59 of file EventLoopMgr.h.

Gaudi::Property<std::string> EventLoopMgr::m_histPersName {this, "HistogramPersistency", {}, "name of the Hist Pers type"}
protected

Definition at line 44 of file EventLoopMgr.h.

Gaudi::Property<bool> EventLoopMgr::m_warnings {this, "Warnings", true, "set to false to suppress warning messages"}
protected

Definition at line 46 of file EventLoopMgr.h.


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