The Gaudi Framework  master (9f3f8895)
Loading...
Searching...
No Matches
HiveSlimEventLoopMgr Class Reference
Inheritance diagram for HiveSlimEventLoopMgr:
Collaboration diagram for HiveSlimEventLoopMgr:

Public Member Functions

 ~HiveSlimEventLoopMgr () override
StatusCode getEventRoot (IOpaqueAddress *&refpAddr)
 Create event address using event selector.
StatusCode initialize () override
 implementation of IService::initialize
StatusCode reinitialize () override
 implementation of IService::reinitialize
StatusCode stop () override
 implementation of IService::stop
StatusCode finalize () override
 implementation of IService::finalize
StatusCode nextEvent (int maxevt) override
 implementation of IService::nextEvent
EventContext createEventContext () override
 implementation of IEventProcessor::createEventContext()
StatusCode executeEvent (EventContext &&ctx) override
 implementation of IEventProcessor::executeEvent(EventContext&&)
StatusCode executeRun (int maxevt) override
 implementation of IEventProcessor::executeRun()
StatusCode stopRun () override
 implementation of IEventProcessor::stopRun()
Public Member Functions inherited from extends< Service, IEventProcessor >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
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.
StatusCode sysStart () override
 Initialize Service.
StatusCode sysStop () override
 Initialize Service.
StatusCode sysFinalize () override
 Finalize Service.
StatusCode sysReinitialize () override
 Re-initialize the Service.
StatusCode sysRestart () override
 Re-initialize the Service.
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
template<class T>
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
template<class T>
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
const std::vector< IAlgTool * > & tools () const
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 PropertyHolder ()=default
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
Gaudi::Details::PropertyBase * declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
Gaudi::Details::PropertyBase * property (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
PropertyHolder & operator= (const PropertyHolder &)=delete
Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
MsgStream & msgStream () const
 Return an uninitialized MsgStream.
MsgStream & msgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
MsgStream & always () const
 shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & fatal () const
 shortcut for the method msgStream(MSG::FATAL)
MsgStream & err () const
 shortcut for the method msgStream(MSG::ERROR)
MsgStream & error () const
 shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning () const
 shortcut for the method msgStream(MSG::WARNING)
MsgStream & info () const
 shortcut for the method msgStream(MSG::INFO)
MsgStream & debug () const
 shortcut for the method msgStream(MSG::DEBUG)
MsgStream & verbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & msg () const
 shortcut for the method msgStream(MSG::INFO)
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream

Protected Member Functions

StatusCode clearWBSlot (int evtSlot)
 Clear a slot in the WB.
StatusCode declareEventRootAddress ()
 Declare the root address of the event.
StatusCode drainScheduler (int &finishedEvents)
 Drain the scheduler from all actions that may be queued.
Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 ~Service () override
int outputLevel () const
 get the Service's output level
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const override final
 Set up local caches.
MSG::Level resetMessaging ()
 Reinitialize internal states.
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.

Protected Attributes

Gaudi::Property< std::string > m_histPersName { this, "HistogramPersistency", "", "" }
Gaudi::Property< std::string > m_evtsel { this, "EvtSel", "", "" }
Gaudi::Property< std::string > m_schedulerName
Gaudi::Property< std::vector< unsigned int > > m_eventNumberBlacklist { this, "EventNumberBlackList", {}, "" }
Gaudi::Property< bool > m_abortOnFailure { this, "AbortOnFailure", true, "Abort job on event failure" }
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
 Reference to the Event Data Service's IDataManagerSvc interface.
SmartIF< IEvtSelector > m_evtSelector
 Reference to the Event Selector.
IEvtSelector::Context * m_evtContext = nullptr
 Event Iterator.
SmartIF< IDataManagerSvc > m_histoDataMgrSvc
 Reference to the Histogram Data Service.
SmartIF< IConversionSvc > m_histoPersSvc
 Reference to the Histogram Persistency Service.
SmartIF< IHiveWhiteBoard > m_whiteboard
 Reference to the Whiteboard.
SmartIF< IAlgResourcePool > m_algResourcePool
 Reference to the Algorithm resource pool.
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
 Reference to the AlgExecStateSvc.
SmartIF< IProperty > m_appMgrProperty
 Property interface of ApplicationMgr.
bool m_endEventFired = false
 Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event).
SmartIF< IScheduler > m_schedulerSvc
 A shortcut for the scheduler.
SmartIF< IIncidentListener > m_abortEventListener
 Instance of the incident listener waiting for AbortEvent.
bool m_scheduledStop = false
 Scheduled stop of event processing.
SmartIF< IIncidentSvc > m_incidentSvc
 Reference to the incident service.
std::vector< uint8_t > m_blackList
EventContext::ContextEvt_t m_nevt { 0 }
Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
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()" }
Gaudi::Property< bool > m_autoRetrieveTools
Gaudi::Property< bool > m_checkToolDeps
SmartIF< IAuditorSvc > m_pAuditorSvc
 Auditor Service.

Additional Inherited Members

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

Detailed Description

Definition at line 39 of file HiveSlimEventLoopMgr.cpp.

Constructor & Destructor Documentation

◆ ~HiveSlimEventLoopMgr()

HiveSlimEventLoopMgr::~HiveSlimEventLoopMgr ( )
override

Definition at line 131 of file HiveSlimEventLoopMgr.cpp.

131{ delete m_evtContext; }
IEvtSelector::Context * m_evtContext
Event Iterator.

Member Function Documentation

◆ clearWBSlot()

StatusCode HiveSlimEventLoopMgr::clearWBSlot ( int evtSlot)
protected

Clear a slot in the WB.

Definition at line 656 of file HiveSlimEventLoopMgr.cpp.

656 {
657 StatusCode sc = m_whiteboard->clearStore( evtSlot );
658 if ( !sc.isSuccess() ) warning() << "Clear of Event data store failed" << endmsg;
659 return m_whiteboard->freeStore( evtSlot );
660}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
SmartIF< IHiveWhiteBoard > m_whiteboard
Reference to the Whiteboard.
bool isSuccess() const
Definition StatusCode.h:302

◆ createEventContext()

EventContext HiveSlimEventLoopMgr::createEventContext ( )
override

implementation of IEventProcessor::createEventContext()

Definition at line 581 of file HiveSlimEventLoopMgr.cpp.

581 {
582 EventContext ctx{ m_nevt, m_whiteboard->allocateStore( m_nevt ) };
583 ++m_nevt;
584
585 StatusCode sc = m_whiteboard->selectStore( ctx.slot() );
586 if ( sc.isFailure() ) {
587 throw GaudiException( "Slot " + std::to_string( ctx.slot() ) + " could not be selected for the WhiteBoard", name(),
588 sc );
589 }
590 if ( declareEventRootAddress().isFailure() ) { // We ran out of events!
591 // invalid context terminates the loop
592 return EventContext{};
593 }
594 return ctx;
595}
EventContext::ContextEvt_t m_nevt
StatusCode declareEventRootAddress()
Declare the root address of the event.
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333
bool isFailure() const
Definition StatusCode.h:118

◆ declareEventRootAddress()

StatusCode HiveSlimEventLoopMgr::declareEventRootAddress ( )
protected

Declare the root address of the event.

Definition at line 559 of file HiveSlimEventLoopMgr.cpp.

559 {
560 StatusCode sc;
561 if ( m_evtContext ) {
562 //---This is the "event iterator" context from EventSelector
563 IOpaqueAddress* pAddr = nullptr;
564 sc = getEventRoot( pAddr );
565 if ( !sc.isSuccess() ) {
566 info() << "No more events in event selection " << endmsg;
567 return StatusCode::FAILURE;
568 }
569 sc = m_evtDataMgrSvc->setRoot( "/Event", pAddr );
570 if ( !sc.isSuccess() ) { warning() << "Error declaring event root address." << endmsg; }
571 } else {
572 //---In case of no event selector----------------
573 sc = m_evtDataMgrSvc->setRoot( "/Event", new DataObject() );
574 if ( !sc.isSuccess() ) { warning() << "Error declaring event root DataObject" << endmsg; }
575 }
576 return StatusCode::SUCCESS;
577}
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service's IDataManagerSvc interface.
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ drainScheduler()

StatusCode HiveSlimEventLoopMgr::drainScheduler ( int & finishedEvents)
protected

Drain the scheduler from all actions that may be queued.

Definition at line 599 of file HiveSlimEventLoopMgr.cpp.

599 {
600
601 StatusCode sc( StatusCode::SUCCESS );
602
603 // maybe we can do better
604 std::vector<EventContext*> finishedEvtContexts;
605
606 EventContext* finishedEvtContext( nullptr );
607
608 // Here we wait not to loose cpu resources
609 DEBUG_MSG << "Waiting for a context" << endmsg;
610 sc = m_schedulerSvc->popFinishedEvent( finishedEvtContext );
611
612 // We got past it: cache the pointer
613 DEBUG_MSG << "Context " << ( sc.isSuccess() ? "obtained" : "not obtained: a problem in the scheduling?" ) << endmsg;
614 finishedEvtContexts.push_back( finishedEvtContext );
615
616 // Let's see if we can pop other event contexts
617 while ( m_schedulerSvc->tryPopFinishedEvent( finishedEvtContext ).isSuccess() ) {
618 finishedEvtContexts.push_back( finishedEvtContext );
619 }
620
621 // Now we flush them
622 StatusCode finalSC;
623 for ( auto& thisFinishedEvtContext : finishedEvtContexts ) {
624 if ( !thisFinishedEvtContext ) {
625 error() << "Detected nullptr ctxt before clearing WB!" << endmsg;
626 finalSC = StatusCode::FAILURE;
627 continue;
628 }
629 if ( m_algExecStateSvc->eventStatus( *thisFinishedEvtContext ) != EventStatus::Success ) {
630 ( m_abortOnFailure ? fatal() : error() ) << "Failed event detected on " << thisFinishedEvtContext << endmsg;
631 if ( m_abortOnFailure ) finalSC = StatusCode::FAILURE;
632 }
633 // shouldn't these incidents move to the forward scheduler?
634 // If we want to consume incidents with an algorithm at the end of the graph
635 // we need to add this to forward scheduler lambda action,
636 // otherwise we have to do this serially on this thread!
637 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndProcessing, *thisFinishedEvtContext ) );
638 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndEvent, *thisFinishedEvtContext ) );
639
640 DEBUG_MSG << "Clearing slot " << thisFinishedEvtContext->slot() << " (event " << thisFinishedEvtContext->evt()
641 << ") of the whiteboard" << endmsg;
642
643 StatusCode sc = clearWBSlot( thisFinishedEvtContext->slot() );
644 if ( !sc.isSuccess() )
645 error() << "Whiteboard slot " << thisFinishedEvtContext->slot() << " could not be properly cleared";
646
647 delete thisFinishedEvtContext;
648
649 ++finishedEvts;
650 }
651 return finalSC;
652}
#define DEBUG_MSG
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
Gaudi::Property< bool > m_abortOnFailure
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
Reference to the AlgExecStateSvc.

◆ executeEvent()

StatusCode HiveSlimEventLoopMgr::executeEvent ( EventContext && ctx)
override

implementation of IEventProcessor::executeEvent(EventContext&&)

Definition at line 362 of file HiveSlimEventLoopMgr.cpp.

362 {
363
364 m_algExecStateSvc->reset( ctx );
365
366 // Check if event number is in blacklist
367 if ( !m_blackList.empty() ) { // we are processing a finite number of events, use bitset blacklist
368 if ( m_blackList.at( ctx.evt() ) ) {
369 VERBOSE_MSG << "Event " << ctx.evt() << " on black list" << endmsg;
370 m_whiteboard->freeStore( ctx.slot() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
372 }
373 } else if ( std::binary_search( m_eventNumberBlacklist.begin(), m_eventNumberBlacklist.end(), ctx.evt() ) ) {
374 VERBOSE_MSG << "Event " << ctx.evt() << " on black list" << endmsg;
375 m_whiteboard->freeStore( ctx.slot() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
377 }
378
379 VERBOSE_MSG << "Beginning to process event " << ctx.evt() << endmsg;
380
381 // An incident may schedule a stop, in which case is better to exit before the actual execution.
382 if ( m_scheduledStop ) {
383 always() << "Terminating event processing loop due to a stop scheduled by an incident listener" << endmsg;
384 return StatusCode::SUCCESS;
385 }
386
387 // Fire BeginEvent "Incident"
388 m_incidentSvc->fireIncident( std::make_unique<Incident>( name(), IncidentType::BeginEvent, ctx ) );
389
390 // Now add event to the scheduler
391 VERBOSE_MSG << "Adding event " << ctx.evt() << ", slot " << ctx.slot() << " to the scheduler" << endmsg;
392
393 m_incidentSvc->fireIncident( std::make_unique<Incident>( name(), IncidentType::BeginProcessing, ctx ) );
394
395 StatusCode addEventStatus = m_schedulerSvc->pushNewEvent( new EventContext{ std::move( ctx ) } );
396
397 // If this fails, we need to wait for something to complete
398 if ( !addEventStatus.isSuccess() ) {
399 fatal() << "An event processing slot should be now free in the scheduler, but it appears not to be the case."
400 << endmsg;
401 }
402
403 return StatusCode::SUCCESS;
404}
#define VERBOSE_MSG
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
std::vector< uint8_t > m_blackList
Gaudi::Property< std::vector< unsigned int > > m_eventNumberBlacklist
bool m_scheduledStop
Scheduled stop of event processing.
constexpr static const auto RECOVERABLE
Definition StatusCode.h:101

◆ executeRun()

StatusCode HiveSlimEventLoopMgr::executeRun ( int maxevt)
override

implementation of IEventProcessor::executeRun()

Definition at line 409 of file HiveSlimEventLoopMgr.cpp.

409 {
410 StatusCode sc;
411 bool eventfailed = false;
412
413 if ( maxevt > 0 ) { // finite number of events to process
414 const unsigned int umaxevt = static_cast<unsigned int>( maxevt );
415 m_blackList.assign( maxevt, 0 ); // all initialized to 0
416 for ( unsigned int i = 0; i < m_eventNumberBlacklist.size() && m_eventNumberBlacklist[i] < umaxevt;
417 ++i ) { // black list is sorted in init
419 }
420 }
421
422 // Call now the nextEvent(...)
423 sc = nextEvent( maxevt );
424 if ( sc.isFailure() ) eventfailed = true;
425
426 m_blackList.clear();
427
428 return eventfailed ? StatusCode::FAILURE : StatusCode::SUCCESS;
429}
StatusCode nextEvent(int maxevt) override
implementation of IService::nextEvent

◆ finalize()

StatusCode HiveSlimEventLoopMgr::finalize ( )
override

implementation of IService::finalize

Definition at line 300 of file HiveSlimEventLoopMgr.cpp.

300 {
301
302 StatusCode scRet;
303 StatusCode sc = Service::finalize();
304
305 if ( sc.isFailure() ) {
306 scRet = StatusCode::FAILURE;
307 error() << "Problems finalizing Service base class" << endmsg;
308 }
309
310 // Save Histograms Now
311 if ( m_histoPersSvc ) {
312 HistogramAgent agent;
313 sc = m_histoDataMgrSvc->traverseTree( &agent );
314 if ( sc.isSuccess() ) {
315 const IDataSelector& objects = agent.selectedObjects();
316 // skip /stat entry!
317 sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode s, const auto& i ) {
318 IOpaqueAddress* pAddr = nullptr;
319 StatusCode iret = m_histoPersSvc->createRep( i, pAddr );
320 if ( iret.isSuccess() ) i->registry()->setAddress( pAddr );
321 return s.isFailure() ? s : iret;
322 } );
323 sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode s, const auto& i ) {
324 IRegistry* reg = i->registry();
325 StatusCode iret = m_histoPersSvc->fillRepRefs( reg->address(), i );
326 return s.isFailure() ? s : iret;
327 } );
328 if ( sc.isSuccess() ) {
329 info() << "Histograms converted successfully according to request." << endmsg;
330 } else {
331 error() << "Error while saving Histograms." << endmsg;
332 }
333 } else {
334 error() << "Error while traversing Histogram data store" << endmsg;
335 }
336 }
337
338 scRet = sc;
339
340 // Release event selector context
341 if ( m_evtSelector && m_evtContext ) {
342 m_evtSelector->releaseContext( m_evtContext ).ignore();
343 m_evtContext = nullptr;
344 }
345
346 m_incidentSvc.reset();
347
348 // Release all interfaces...
349 m_histoDataMgrSvc.reset();
350 m_histoPersSvc.reset();
351
352 m_evtSelector.reset();
353 m_whiteboard.reset();
354 m_evtDataMgrSvc.reset();
355
356 return scRet;
357}
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work!
const IDataSelector & selectedObjects() const
Return the set of selected DataObjects.
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
SmartIF< IDataManagerSvc > m_histoDataMgrSvc
Reference to the Histogram Data Service.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
StatusCode finalize() override
Definition Service.cpp:223
AttribStringParser::Iterator begin(const AttribStringParser &parser)

◆ getEventRoot()

StatusCode HiveSlimEventLoopMgr::getEventRoot ( IOpaqueAddress *& refpAddr)

Create event address using event selector.

Definition at line 543 of file HiveSlimEventLoopMgr.cpp.

543 {
544 refpAddr = nullptr;
545 StatusCode sc = m_evtSelector->next( *m_evtContext );
546 if ( sc.isFailure() ) return sc;
547 // Create root address and assign address to data service
548 sc = m_evtSelector->createAddress( *m_evtContext, refpAddr );
549 if ( sc.isSuccess() ) return sc;
550 sc = m_evtSelector->next( *m_evtContext );
551 if ( sc.isFailure() ) return sc;
552 sc = m_evtSelector->createAddress( *m_evtContext, refpAddr );
553 if ( !sc.isSuccess() ) warning() << "Error creating IOpaqueAddress." << endmsg;
554 return sc;
555}

◆ initialize()

StatusCode HiveSlimEventLoopMgr::initialize ( )
override

implementation of IService::initialize

Definition at line 136 of file HiveSlimEventLoopMgr.cpp.

136 {
137 StatusCode sc = Service::initialize();
138 if ( !sc.isSuccess() ) {
139 error() << "Failed to initialize Service Base class." << endmsg;
140 return StatusCode::FAILURE;
141 }
142
143 // Get the references to the services that are needed by the ApplicationMgr itself
144 m_incidentSvc = serviceLocator()->service( "IncidentSvc" );
145 if ( !m_incidentSvc ) {
146 fatal() << "Error retrieving IncidentSvc." << endmsg;
147 return StatusCode::FAILURE;
148 }
149
150 // Setup access to event data services
151 m_evtDataMgrSvc = serviceLocator()->service( "EventDataSvc" );
152 if ( !m_evtDataMgrSvc ) {
153 fatal() << "Error retrieving EventDataSvc interface IDataManagerSvc." << endmsg;
154 return StatusCode::FAILURE;
155 }
156 m_whiteboard = serviceLocator()->service( "EventDataSvc" );
157 if ( !m_whiteboard ) {
158 fatal() << "Error retrieving EventDataSvc interface IHiveWhiteBoard." << endmsg;
159 return StatusCode::FAILURE;
160 }
162 if ( !m_schedulerSvc ) {
163 fatal() << "Error retrieving SchedulerSvc interface IScheduler." << endmsg;
164 return StatusCode::FAILURE;
165 }
166 // Obtain the IProperty of the ApplicationMgr
168 if ( !m_appMgrProperty ) {
169 fatal() << "IProperty interface not found in ApplicationMgr." << endmsg;
170 return StatusCode::FAILURE;
171 }
172
173 // We do not expect a Event Selector necessarily being declared
174 setProperty( m_appMgrProperty->getProperty( "EvtSel" ) ).ignore();
175
176 if ( m_evtsel != "NONE" || m_evtsel.length() == 0 ) {
177 m_evtSelector = serviceLocator()->service( "EventSelector" );
178 if ( m_evtSelector ) {
179 // Setup Event Selector
180 sc = m_evtSelector->createContext( m_evtContext );
181 if ( !sc.isSuccess() ) {
182 fatal() << "Can not create the event selector Context." << endmsg;
183 return sc;
184 }
185 } else {
186 fatal() << "EventSelector not found." << endmsg;
187 return sc;
188 }
189 } else {
190 m_evtSelector = 0;
191 m_evtContext = 0;
192 info() << "\"EventSelector\" disabled: no events will be processed from external input." << endmsg;
193 }
194
195 setProperty( m_appMgrProperty->getProperty( "HistogramPersistency" ) ).ignore();
196 if ( m_histPersName != "NONE" && !m_histPersName.empty() ) {
197 // Setup access to histogramming services
198 m_histoDataMgrSvc = serviceLocator()->service( "HistogramDataSvc" );
199 if ( !m_histoDataMgrSvc ) {
200 fatal() << "Error retrieving HistogramDataSvc." << endmsg;
201 return StatusCode::FAILURE;
202 }
203 // Setup histogram persistency
204 m_histoPersSvc = serviceLocator()->service( "HistogramPersistencySvc" );
205 if ( !m_histoPersSvc ) { warning() << "Histograms cannot not be saved - though required." << endmsg; }
206 }
207
208 // Setup algorithm resource pool
209 m_algResourcePool = serviceLocator()->service( "AlgResourcePool" );
210 if ( !m_algResourcePool ) {
211 fatal() << "Error retrieving AlgResourcePool" << endmsg;
212 return StatusCode::FAILURE;
213 }
214
215 m_algExecStateSvc = serviceLocator()->service( "AlgExecStateSvc" );
216 if ( !m_algExecStateSvc ) {
217 fatal() << "Error retrieving AlgExecStateSvc" << endmsg;
218 return StatusCode::FAILURE;
219 }
220
221 std::sort( m_eventNumberBlacklist.begin(), m_eventNumberBlacklist.end() );
222 info() << "Found " << m_eventNumberBlacklist.size() << " events in black list" << endmsg;
223
224 return StatusCode::SUCCESS;
225}
Gaudi::Property< std::string > m_histPersName
Gaudi::Property< std::string > m_schedulerName
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
Gaudi::Property< std::string > m_evtsel
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition Service.cpp:336
StatusCode initialize() override
Definition Service.cpp:118
void ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:128

◆ nextEvent()

StatusCode HiveSlimEventLoopMgr::nextEvent ( int maxevt)
override

implementation of IService::nextEvent

Definition at line 451 of file HiveSlimEventLoopMgr.cpp.

451 {
452
453 // Calculate runtime
454 using Clock = std::chrono::high_resolution_clock;
455
456 // Reset the application return code.
458
459 int finishedEvts = 0;
460 int createdEvts = 0;
461 int skippedEvts = 0;
462 info() << "Starting loop on events" << endmsg;
463 // Loop until the finished events did not reach the maxevt number
464 bool loop_ended = false;
465 // Run the first event before spilling more than one
466 bool newEvtAllowed = false;
467
468 constexpr double oneOver1024 = 1. / 1024.;
469
470 uint iteration = 0;
471 auto start_time = Clock::now();
472 StatusCode finalSC;
473 while ( !loop_ended && ( maxevt < 0 || ( finishedEvts + skippedEvts ) < maxevt ) ) {
474 DEBUG_MSG << "work loop iteration " << iteration++ << endmsg;
475 // if the created events did not reach maxevt, create an event
476 if ( ( newEvtAllowed || createdEvts == 0 ) && // Launch the first event alone
477 createdEvts >= 0 && // The events are not finished with an unlimited number of events
478 ( createdEvts < maxevt || maxevt < 0 ) && // The events are not finished with a limited number of events
479 m_schedulerSvc->freeSlots() > 0 && // There are still free slots in the scheduler
480 m_whiteboard->freeSlots() > 0 && // There are still free slots in the whiteboard
481 !m_scheduledStop // There is not a scheduled stop
482 ) {
483
484 if ( 1 == createdEvts ) // reset counter to count from event 1
485 start_time = Clock::now();
486
487 DEBUG_MSG << "createdEvts: " << createdEvts << ", freeslots: " << m_schedulerSvc->freeSlots() << endmsg;
488 // DP remove to remove the syscalls...
489 // if (0!=createdEvts){
490 // info() << "Event Number = " << createdEvts
491 // << " WSS (MB) = " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1024
492 // << " Time (s) = " << secsFromStart(start_time) << endmsg;
493 // }
494
495 // TODO can we adapt the interface of executeEvent for a nicer solution?
496 StatusCode sc = StatusCode::RECOVERABLE;
497 while ( !sc.isSuccess() // we haven't created an event yet
498 && ( createdEvts < maxevt || maxevt < 0 ) ) { // redunant check for maxEvts, can we do better?
499 {
500 auto ctx = createEventContext();
501 if ( !ctx.valid() ) {
502 createdEvts = -1;
503 break; // invalid context means end of loop
504 }
505 sc = executeEvent( std::move( ctx ) );
506 }
507 if ( sc.isRecoverable() ) { // we skipped an event
508 ++skippedEvts;
509 } else if ( sc.isFailure() ) { // exit immediatly
510 return sc;
511 } // else we have an success --> exit loop
512 ++createdEvts;
513 }
514
515 } // end if condition createdEvts < maxevt
516 else {
517 // all the events were created but not all finished or the slots were
518 // all busy: the scheduler should finish its job
519
520 DEBUG_MSG << "Draining the scheduler" << endmsg;
521
522 // Pull out of the scheduler the finished events
523 if ( drainScheduler( finishedEvts ).isFailure() ) {
524 loop_ended = true;
525 finalSC = StatusCode::FAILURE;
526 }
527 newEvtAllowed = true;
528 }
529 } // end main loop on finished events
530 auto end_time = Clock::now();
531
532 info() << "---> Loop Finished (skipping 1st evt) - "
533 << " WSS " << System::mappedMemory( System::MemoryUnit::kByte ) * oneOver1024 << " total time "
534 << std::chrono::duration_cast<std::chrono::nanoseconds>( end_time - start_time ).count() << endmsg;
535 info() << skippedEvts << " events were SKIPed" << endmsg;
536
537 return finalSC;
538}
StatusCode drainScheduler(int &finishedEvents)
Drain the scheduler from all actions that may be queued.
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(EventContext&&)
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
bool isRecoverable() const
Definition StatusCode.h:306
constexpr int Success
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
GAUDI_API long mappedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
Definition Memory.cpp:172
@ kByte
Definition Memory.h:50

◆ reinitialize()

StatusCode HiveSlimEventLoopMgr::reinitialize ( )
override

implementation of IService::reinitialize

Definition at line 229 of file HiveSlimEventLoopMgr.cpp.

229 {
230
231 // Check to see whether a new Event Selector has been specified
232 setProperty( m_appMgrProperty->getProperty( "EvtSel" ) ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
233 if ( m_evtsel != "NONE" || m_evtsel.empty() ) {
234 auto theSvc = serviceLocator()->service( "EventSelector" );
235 auto theEvtSel = theSvc.as<IEvtSelector>();
236 StatusCode sc;
237 if ( theEvtSel && ( theEvtSel.get() != m_evtSelector.get() ) ) {
238 // Setup Event Selector
239 if ( m_evtSelector.get() && m_evtContext ) {
240 // Need to release context before switching to new event selector
241 m_evtSelector->releaseContext( m_evtContext ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
242 m_evtContext = nullptr;
243 }
244 m_evtSelector = theEvtSel;
245 if ( theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED ) {
246 sc = theSvc->reinitialize();
247 if ( !sc.isSuccess() ) {
248 error() << "Failure Reinitializing EventSelector " << theSvc->name() << endmsg;
249 return sc;
250 }
251 } else {
252 sc = theSvc->sysInitialize();
253 if ( !sc.isSuccess() ) {
254 error() << "Failure Initializing EventSelector " << theSvc->name() << endmsg;
255 return sc;
256 }
257 }
258 sc = m_evtSelector->createContext( m_evtContext );
259 if ( !sc.isSuccess() ) {
260 error() << "Can not create Context " << theSvc->name() << endmsg;
261 return sc;
262 }
263
264 } else if ( m_evtSelector ) {
265 if ( m_evtContext ) {
266 m_evtSelector->releaseContext( m_evtContext ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
267 m_evtContext = nullptr;
268 }
269 sc = m_evtSelector->createContext( m_evtContext );
270 if ( !sc.isSuccess() ) {
271 error() << "Can not create Context " << theSvc->name() << endmsg;
272 return sc;
273 }
274 }
275 } else if ( m_evtSelector && m_evtContext ) {
276 m_evtSelector->releaseContext( m_evtContext ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
277 m_evtSelector = nullptr;
278 m_evtContext = nullptr;
279 }
280 return StatusCode::SUCCESS;
281}
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition SmartIF.h:110

◆ stop()

StatusCode HiveSlimEventLoopMgr::stop ( )
override

implementation of IService::stop

Definition at line 287 of file HiveSlimEventLoopMgr.cpp.

287 {
288 if ( !m_endEventFired ) {
289 // Fire pending EndEvent incident
290 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndEvent ) );
291 m_endEventFired = true;
292 }
293 return StatusCode::SUCCESS;
294}
bool m_endEventFired
Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event).

◆ stopRun()

StatusCode HiveSlimEventLoopMgr::stopRun ( )
override

implementation of IEventProcessor::stopRun()

Definition at line 434 of file HiveSlimEventLoopMgr.cpp.

434 {
435 // Set the application return code
436 auto appmgr = serviceLocator()->as<IProperty>();
437 if ( Gaudi::setAppReturnCode( appmgr, Gaudi::ReturnCode::ScheduledStop ).isFailure() ) {
438 error() << "Could not set return code of the application (" << Gaudi::ReturnCode::ScheduledStop << ")" << endmsg;
439 }
440 m_scheduledStop = true;
441 return StatusCode::SUCCESS;
442}
SmartIF< IFace > as()
Definition ISvcLocator.h:64
constexpr int ScheduledStop

Member Data Documentation

◆ m_abortEventListener

SmartIF<IIncidentListener> HiveSlimEventLoopMgr::m_abortEventListener
protected

Instance of the incident listener waiting for AbortEvent.

Definition at line 80 of file HiveSlimEventLoopMgr.cpp.

◆ m_abortOnFailure

Gaudi::Property<bool> HiveSlimEventLoopMgr::m_abortOnFailure { this, "AbortOnFailure", true, "Abort job on event failure" }
protected

Definition at line 48 of file HiveSlimEventLoopMgr.cpp.

48{ this, "AbortOnFailure", true, "Abort job on event failure" };

◆ m_algExecStateSvc

SmartIF<IAlgExecStateSvc> HiveSlimEventLoopMgr::m_algExecStateSvc
protected

Reference to the AlgExecStateSvc.

Definition at line 65 of file HiveSlimEventLoopMgr.cpp.

◆ m_algResourcePool

SmartIF<IAlgResourcePool> HiveSlimEventLoopMgr::m_algResourcePool
protected

Reference to the Algorithm resource pool.

Definition at line 63 of file HiveSlimEventLoopMgr.cpp.

◆ m_appMgrProperty

SmartIF<IProperty> HiveSlimEventLoopMgr::m_appMgrProperty
protected

Property interface of ApplicationMgr.

Definition at line 67 of file HiveSlimEventLoopMgr.cpp.

◆ m_blackList

std::vector<uint8_t> HiveSlimEventLoopMgr::m_blackList
protected

Definition at line 87 of file HiveSlimEventLoopMgr.cpp.

◆ m_endEventFired

bool HiveSlimEventLoopMgr::m_endEventFired = false
protected

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

Definition at line 70 of file HiveSlimEventLoopMgr.cpp.

◆ m_eventNumberBlacklist

Gaudi::Property<std::vector<unsigned int> > HiveSlimEventLoopMgr::m_eventNumberBlacklist { this, "EventNumberBlackList", {}, "" }
protected

Definition at line 47 of file HiveSlimEventLoopMgr.cpp.

47{ this, "EventNumberBlackList", {}, "" };

◆ m_evtContext

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

Event Iterator.

Definition at line 55 of file HiveSlimEventLoopMgr.cpp.

◆ m_evtDataMgrSvc

SmartIF<IDataManagerSvc> HiveSlimEventLoopMgr::m_evtDataMgrSvc
protected

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 51 of file HiveSlimEventLoopMgr.cpp.

◆ m_evtsel

Gaudi::Property<std::string> HiveSlimEventLoopMgr::m_evtsel { this, "EvtSel", "", "" }
protected

Definition at line 43 of file HiveSlimEventLoopMgr.cpp.

43{ this, "EvtSel", "", "" };

◆ m_evtSelector

SmartIF<IEvtSelector> HiveSlimEventLoopMgr::m_evtSelector
protected

Reference to the Event Selector.

Definition at line 53 of file HiveSlimEventLoopMgr.cpp.

◆ m_histoDataMgrSvc

SmartIF<IDataManagerSvc> HiveSlimEventLoopMgr::m_histoDataMgrSvc
protected

Reference to the Histogram Data Service.

Definition at line 57 of file HiveSlimEventLoopMgr.cpp.

◆ m_histoPersSvc

SmartIF<IConversionSvc> HiveSlimEventLoopMgr::m_histoPersSvc
protected

Reference to the Histogram Persistency Service.

Definition at line 59 of file HiveSlimEventLoopMgr.cpp.

◆ m_histPersName

Gaudi::Property<std::string> HiveSlimEventLoopMgr::m_histPersName { this, "HistogramPersistency", "", "" }
protected

Definition at line 42 of file HiveSlimEventLoopMgr.cpp.

42{ this, "HistogramPersistency", "", "" };

◆ m_incidentSvc

SmartIF<IIncidentSvc> HiveSlimEventLoopMgr::m_incidentSvc
protected

Reference to the incident service.

Definition at line 84 of file HiveSlimEventLoopMgr.cpp.

◆ m_nevt

EventContext::ContextEvt_t HiveSlimEventLoopMgr::m_nevt { 0 }
protected

Definition at line 89 of file HiveSlimEventLoopMgr.cpp.

89{ 0 };

◆ m_scheduledStop

bool HiveSlimEventLoopMgr::m_scheduledStop = false
protected

Scheduled stop of event processing.

Definition at line 82 of file HiveSlimEventLoopMgr.cpp.

◆ m_schedulerName

Gaudi::Property<std::string> HiveSlimEventLoopMgr::m_schedulerName
protected
Initial value:
{ this, "SchedulerName", "AvalancheSchedulerSvc",
"Name of the scheduler to be used" }

Definition at line 44 of file HiveSlimEventLoopMgr.cpp.

44 { this, "SchedulerName", "AvalancheSchedulerSvc",
45 "Name of the scheduler to be used" };

◆ m_schedulerSvc

SmartIF<IScheduler> HiveSlimEventLoopMgr::m_schedulerSvc
protected

A shortcut for the scheduler.

Definition at line 72 of file HiveSlimEventLoopMgr.cpp.

◆ m_whiteboard

SmartIF<IHiveWhiteBoard> HiveSlimEventLoopMgr::m_whiteboard
protected

Reference to the Whiteboard.

Definition at line 61 of file HiveSlimEventLoopMgr.cpp.


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