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 (const std::string &nam, ISvcLocator *svcLoc)
 Standard Constructor. More...
 
 ~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...
 
 ~MinimalEventLoopMgr () override=default
 Standard Destructor. 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 (Property &p)
 Top algorithm List handler. More...
 
StatusCode decodeTopAlgs ()
 decodeTopAlgNameList & topAlgNameListHandler More...
 
void outStreamHandler (Property &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...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value 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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. 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 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

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...
 
std::string m_evtsel
 Event selector. More...
 
SmartIF< IDataManagerSvcm_histoDataMgrSvc = nullptr
 Reference to the Histogram Data Service. More...
 
SmartIF< IConversionSvcm_histoPersSvc = nullptr
 Reference to the Histogram Persistency Service. More...
 
std::string m_histPersName
 Name of the Hist Pers type. 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...
 
bool m_warnings = true
 Flag to disable warning messages when using external input. More...
 
- Protected Attributes inherited from MinimalEventLoopMgr
SmartIF< IAppMgrUIm_appMgrUI
 Reference to the IAppMgrUI interface of the application manager. More...
 
SmartIF< IIncidentSvcm_incidentSvc
 Reference to the incident service. More...
 
ListAlg m_topAlgList
 List of top level algorithms. More...
 
ListAlg m_outStreamList
 List of output streams. More...
 
std::string m_outStreamType
 Out Stream type. More...
 
StringArrayProperty m_topAlgNames
 List of top level algorithms names. More...
 
StringArrayProperty m_outStreamNames
 List of output stream names. 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
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. 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 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 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 ( const std::string nam,
ISvcLocator svcLoc 
)

Standard Constructor.

Definition at line 32 of file EventLoopMgr.cpp.

33 : MinimalEventLoopMgr(nam, svcLoc)
34 {
35  // Declare properties
36  declareProperty("HistogramPersistency", m_histPersName );
37  declareProperty("EvtSel", m_evtsel );
38  declareProperty("Warnings",m_warnings=true,
39  "Set this property to false to suppress warning messages");
40 }
std::string m_histPersName
Name of the Hist Pers type.
Definition: EventLoopMgr.h:57
bool m_warnings
Flag to disable warning messages when using external input.
Definition: EventLoopMgr.h:64
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
std::string m_evtsel
Event selector.
Definition: EventLoopMgr.h:51
MinimalEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
EventLoopMgr::~EventLoopMgr ( )
override

Standard Destructor.

Definition at line 45 of file EventLoopMgr.cpp.

45  {
46  delete m_evtContext;
47 }
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:49

Member Function Documentation

StatusCode EventLoopMgr::executeEvent ( void *  par)
override

implementation of IEventProcessor::executeEvent(void* par)

Definition at line 270 of file EventLoopMgr.cpp.

270  {
271 
272  // DP Monitoring
273 
274 
275 
276  // Fire BeginEvent "Incident"
277  m_incidentSvc->fireIncident(Incident(name(),IncidentType::BeginEvent));
278  // An incident may schedule a stop, in which case is better to exit before the actual execution.
279  if ( m_scheduledStop ) {
280  always() << "Terminating event processing loop due to a stop scheduled by an incident listener" << endmsg;
281  return StatusCode::SUCCESS;
282  }
283 
284  // Execute Algorithms
285  m_incidentSvc->fireIncident(Incident(name(), IncidentType::BeginProcessing));
287  m_incidentSvc->fireIncident(Incident(name(), IncidentType::EndProcessing));
288 
289  // Check if there was an error processing current event
290  if( UNLIKELY(!sc.isSuccess()) ){
291  error() << "Terminating event processing loop due to errors" << endmsg;
292  }
293  return sc;
294 }
#define UNLIKELY(x)
Definition: Kernel.h:126
bool m_scheduledStop
Scheduled stop of event processing.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
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 204 of file EventLoopMgr.cpp.

204  {
205  StatusCode sc;
206 
207  // Finalize base class
209  if (! sc.isSuccess()) {
210  error() << "Error finalizing base class" << endmsg;
211  return sc;
212  }
213 
214  // Save Histograms Now
215  if ( m_histoPersSvc ) {
216  HistogramAgent agent;
217  sc = m_histoDataMgrSvc->traverseTree( &agent );
218  if( sc.isSuccess() ) {
219  IDataSelector* objects = agent.selectedObjects();
220  // skip /stat entry!
221  if ( objects->size() > 0 ) {
222  for ( auto& i : *objects ) {
223  IOpaqueAddress* pAddr = nullptr;
224  StatusCode iret = m_histoPersSvc->createRep(i, pAddr);
225  if ( iret.isSuccess() ) {
226  i->registry()->setAddress(pAddr);
227  }
228  else {
229  sc = iret;
230  }
231  }
232  for ( auto& i : *objects ) {
233  IRegistry* reg = i->registry();
234  StatusCode iret = m_histoPersSvc->fillRepRefs(reg->address(), i);
235  if ( !iret.isSuccess() ) sc = iret;
236  }
237  }
238  if ( sc.isSuccess() ) {
239  info() << "Histograms converted successfully according to request." << endmsg;
240  }
241  else {
242  error() << "Error while saving Histograms." << endmsg;
243  }
244  }
245  else {
246  error() << "Error while traversing Histogram data store" << endmsg;
247  }
248  }
249 
250  // Release event selector context
251  if ( m_evtSelector && m_evtContext ) {
253  m_evtContext = nullptr;
254  }
255 
256  // Release all interfaces...
257  m_histoDataMgrSvc = nullptr;
258  m_histoPersSvc = nullptr;
259 
260  m_evtSelector = nullptr;
261  m_evtDataSvc = nullptr;
262  m_evtDataMgrSvc = nullptr;
263 
264  return StatusCode::SUCCESS;
265 }
StatusCode finalize() override
implementation of IService::finalize
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
Definition: EventLoopMgr.h:55
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
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
virtual StatusCode releaseContext(Context *&) const =0
Release the Context object.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
IDataSelector * selectedObjects()
Return the set of selected DataObjects.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service's IDataManagerSvc interface.
Definition: EventLoopMgr.h:43
T size(T...args)
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:49
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: EventLoopMgr.h:47
SmartIF< IDataProviderSvc > m_evtDataSvc
Reference to the Event Data Service's IDataProviderSvc interface.
Definition: EventLoopMgr.h:45
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:108
list i
Definition: ana.py:128
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:53
StatusCode EventLoopMgr::getEventRoot ( IOpaqueAddress *&  refpAddr)

Create event address using event selector.

Definition at line 396 of file EventLoopMgr.cpp.

396  {
397  refpAddr = nullptr;
399  if ( !sc.isSuccess() ) return sc;
400  // Create root address and assign address to data service
401  sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
402  if( !sc.isSuccess() ) {
404  if ( sc.isSuccess() ) {
405  sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
406  if ( !sc.isSuccess() ) {
407  warning() << "Error creating IOpaqueAddress." << endmsg;
408  }
409  }
410  }
411  return sc;
412 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
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
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...
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:49
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: EventLoopMgr.h:47
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 52 of file EventLoopMgr.cpp.

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

implementation of IService::nextEvent

Definition at line 301 of file EventLoopMgr.cpp.

301  {
302 
303  // DP Monitoring
304  // Calculate runtime
307 
308  const float oneOver1024 = 1.f/1024.f;
309 
310 
311  static int total_nevt = 0;
312  DataObject* pObject = nullptr;
314 
315  // loop over events if the maxevt (received as input) if different from -1.
316  // if evtmax is -1 it means infinite loop
317  time_point start_time = Clock::now();
318  for( int nevt = 0; maxevt == -1 || nevt < maxevt; ++nevt, ++total_nevt) {
319 
320  if(1 == nevt) // reset after first evt
321  start_time = Clock::now();
322 
323  //always() << "Event Number = " << total_nevt
324  // << " WSS (MB) = " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1024
325  // << " Time (s) = " << secsFromStart(start_time) << endmsg;
326 
327 
328  // Check if there is a scheduled stop issued by some algorithm/service
329  if ( m_scheduledStop ) {
330  m_scheduledStop = false;
331  always() << "Terminating event processing loop due to scheduled stop" << endmsg;
332  break;
333  }
334  // Clear the event store, if used in the event loop
335  if( 0 != total_nevt ) {
336 
337  if ( ! m_endEventFired ) {
338  // Fire EndEvent "Incident" (it is considered part of the clearing of the TS)
339  m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
340  m_endEventFired = true;
341  }
343  if( !sc.isSuccess() ) {
344  DEBMSG << "Clear of Event data store failed" << endmsg;
345  }
346  }
347 
348  // Setup event in the event store
349  if( m_evtContext ) {
350  IOpaqueAddress* addr = nullptr;
351  // Only if there is a EventSelector
352  sc = getEventRoot(addr);
353  if( !sc.isSuccess() ) {
354  info() << "No more events in event selection " << endmsg;
355  break;
356  }
357  // Set root clears the event data store first
358  sc = m_evtDataMgrSvc->setRoot ("/Event", addr);
359  if( !sc.isSuccess() ) {
360  warning() << "Error declaring event root address." << endmsg;
361  continue;
362  }
363  sc = m_evtDataSvc->retrieveObject("/Event", pObject);
364  if( !sc.isSuccess() ) {
365  warning() << "Unable to retrieve Event root object" << endmsg;
366  break;
367  }
368  } else {
369  sc = m_evtDataMgrSvc->setRoot ("/Event", new DataObject());
370  if( !sc.isSuccess() ) {
371  warning() << "Error declaring event root DataObject" << endmsg;
372  }
373  }
374  // Execute event for all required algorithms
375  sc = executeEvent(nullptr);
376  m_endEventFired = false;
377  if( !sc.isSuccess() ){
378  error() << "Terminating event processing loop due to errors" << endmsg;
380  return sc;
381  }
382  }
383  time_point end_time = Clock::now();
384 
385  if (UNLIKELY(outputLevel() <= MSG::DEBUG))
386  debug() << "---> Loop Finished - "
387  << " WSS " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1024
388  << " | total time (skipping 1st evt) "
389  << std::chrono::duration_cast < std::chrono::nanoseconds > (end_time - start_time).count()
390  << " ns" << endmsg;
391 
392  return StatusCode::SUCCESS;
393 }
#define UNLIKELY(x)
Definition: Kernel.h:126
bool m_scheduledStop
Scheduled stop of event processing.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
int outputLevel() const
get the Service's output level
Definition: Service.h:316
T duration_cast(T...args)
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
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.
list nevt
Definition: ana.py:134
std::chrono::high_resolution_clock Clock
Definition: ITimelineSvc.h:11
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:50
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's IDataManagerSvc interface.
Definition: EventLoopMgr.h:43
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:59
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:49
#define DEBMSG
Clock::time_point time_point
Definition: ITimelineSvc.h:12
Base class for all Incidents (computing events).
Definition: Incident.h:17
constexpr int AlgorithmFailure
Definition: AppReturnCode.h:24
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:62
SmartIF< IDataProviderSvc > m_evtDataSvc
Reference to the Event Data Service's IDataProviderSvc interface.
Definition: EventLoopMgr.h:45
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:108
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 123 of file EventLoopMgr.cpp.

123  {
124 
125  // Initialize the base class
127  if( !sc.isSuccess() ) {
128  DEBMSG << "Error Initializing base class MinimalEventLoopMgr." << endmsg;
129  return sc;
130  }
131 
132  // Check to see whether a new Event Selector has been specified
134  if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
135  auto theSvc = serviceLocator()->service<IService>("EventSelector");
136  auto theEvtSel = theSvc.as<IEvtSelector>();
137  if( theEvtSel && ( theEvtSel.get() != m_evtSelector.get() ) ) {
138  // Setup Event Selector
139  if ( m_evtSelector.get() && m_evtContext ) {
140  // Need to release context before switching to new event selector
142  m_evtContext = nullptr;
143  }
144  m_evtSelector = theEvtSel;
145  if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
146  sc = theSvc->reinitialize();
147  if( !sc.isSuccess() ) {
148  error() << "Failure Reinitializing EventSelector "
149  << theSvc->name( ) << endmsg;
150  return sc;
151  }
152  } else {
153  sc = theSvc->sysInitialize();
154  if( !sc.isSuccess() ) {
155  error() << "Failure Initializing EventSelector "
156  << theSvc->name( ) << endmsg;
157  return sc;
158  }
159  }
161  if( !sc.isSuccess() ) {
162  error() << "Can not create Context " << theSvc->name( ) << endmsg;
163  return sc;
164  }
165  info() << "EventSelector service changed to "
166  << theSvc->name( ) << endmsg;
167  }
168  else if ( m_evtSelector ) {
169  if ( m_evtContext ) {
171  m_evtContext = nullptr;
172  }
174  if( !sc.isSuccess() ) {
175  error() << "Can not create Context " << theSvc->name( ) << endmsg;
176  return sc;
177  }
178  }
179  }
180  else if ( m_evtSelector && m_evtContext ) {
182  m_evtSelector = nullptr;
183  m_evtContext = nullptr;
184  }
185  return StatusCode::SUCCESS;
186 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
virtual StatusCode getProperty(Property *p) const =0
Get the property by 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:76
StatusCode setProperty(const Property &p) override
Definition: Service.cpp:330
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 createContext(Context *&c) const =0
Create and return a context object that will keep track of the state of selection.
virtual StatusCode releaseContext(Context *&) const =0
Release the Context object.
T length(T...args)
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: EventLoopMgr.h:59
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: EventLoopMgr.h:49
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: EventLoopMgr.h:47
#define DEBMSG
std::string m_evtsel
Event selector.
Definition: EventLoopMgr.h:51
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 192 of file EventLoopMgr.cpp.

192  {
193  if ( ! m_endEventFired ) {
194  // Fire pending EndEvent incident
195  m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
196  m_endEventFired = true;
197  }
198  return MinimalEventLoopMgr::stop();
199 }
StatusCode stop() override
implementation of IService::stop
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
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:62

Member Data Documentation

SmartIF<IProperty> EventLoopMgr::m_appMgrProperty = nullptr
protected

Property interface of ApplicationMgr.

Definition at line 59 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 62 of file EventLoopMgr.h.

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

Event Iterator.

Definition at line 49 of file EventLoopMgr.h.

SmartIF<IDataManagerSvc> EventLoopMgr::m_evtDataMgrSvc = nullptr
protected

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 43 of file EventLoopMgr.h.

SmartIF<IDataProviderSvc> EventLoopMgr::m_evtDataSvc = nullptr
protected

Reference to the Event Data Service's IDataProviderSvc interface.

Definition at line 45 of file EventLoopMgr.h.

std::string EventLoopMgr::m_evtsel
protected

Event selector.

Definition at line 51 of file EventLoopMgr.h.

SmartIF<IEvtSelector> EventLoopMgr::m_evtSelector = nullptr
protected

Reference to the Event Selector.

Definition at line 47 of file EventLoopMgr.h.

SmartIF<IDataManagerSvc> EventLoopMgr::m_histoDataMgrSvc = nullptr
protected

Reference to the Histogram Data Service.

Definition at line 53 of file EventLoopMgr.h.

SmartIF<IConversionSvc> EventLoopMgr::m_histoPersSvc = nullptr
protected

Reference to the Histogram Persistency Service.

Definition at line 55 of file EventLoopMgr.h.

std::string EventLoopMgr::m_histPersName
protected

Name of the Hist Pers type.

Definition at line 57 of file EventLoopMgr.h.

bool EventLoopMgr::m_warnings = true
protected

Flag to disable warning messages when using external input.

Definition at line 64 of file EventLoopMgr.h.


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