The Gaudi Framework master (9cc87df9)
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 657 of file HiveSlimEventLoopMgr.cpp.

657 {
658 StatusCode sc = m_whiteboard->clearStore( evtSlot );
659 if ( !sc.isSuccess() ) warning() << "Clear of Event data store failed" << endmsg;
660 return m_whiteboard->freeStore( evtSlot );
661}
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.
virtual StatusCode freeStore(size_t partitionIndex)=0
Free a store partition.
virtual StatusCode clearStore(size_t partitionIndex)=0
Clear an given 'slot'.
bool isSuccess() const
Definition StatusCode.h:302

◆ createEventContext()

EventContext HiveSlimEventLoopMgr::createEventContext ( )
override

implementation of IEventProcessor::createEventContext()

Definition at line 582 of file HiveSlimEventLoopMgr.cpp.

582 {
583 EventContext ctx{ m_nevt, m_whiteboard->allocateStore( m_nevt ) };
584 ++m_nevt;
585
586 StatusCode sc = m_whiteboard->selectStore( ctx.slot() );
587 if ( sc.isFailure() ) {
588 throw GaudiException( "Slot " + std::to_string( ctx.slot() ) + " could not be selected for the WhiteBoard", name(),
589 sc );
590 }
591 if ( declareEventRootAddress().isFailure() ) { // We ran out of events!
592 // invalid context terminates the loop
593 return EventContext{};
594 }
595 return ctx;
596}
GaudiException(std::string Message, std::string Tag, StatusCode Code)
Constructor (1).
EventContext::ContextEvt_t m_nevt
StatusCode declareEventRootAddress()
Declare the root address of the event.
virtual size_t allocateStore(int evtnumber)=0
Allocate a store partition for new event.
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given 'slot' for all subsequent calls within the same thread id.
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 560 of file HiveSlimEventLoopMgr.cpp.

560 {
561 StatusCode sc;
562 if ( m_evtContext ) {
563 //---This is the "event iterator" context from EventSelector
564 IOpaqueAddress* pAddr = nullptr;
565 sc = getEventRoot( pAddr );
566 if ( !sc.isSuccess() ) {
567 info() << "No more events in event selection " << endmsg;
568 return StatusCode::FAILURE;
569 }
570 sc = m_evtDataMgrSvc->setRoot( "/Event", pAddr );
571 if ( !sc.isSuccess() ) { warning() << "Error declaring event root address." << endmsg; }
572 } else {
573 //---In case of no event selector----------------
574 sc = m_evtDataMgrSvc->setRoot( "/Event", new DataObject() );
575 if ( !sc.isSuccess() ) { warning() << "Error declaring event root DataObject" << endmsg; }
576 }
577 return StatusCode::SUCCESS;
578}
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
DataObject()
Standard Constructor.
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
virtual StatusCode setRoot(std::string root_name, DataObject *pObject)=0
Initialize data store for new event by giving new event path.

◆ drainScheduler()

StatusCode HiveSlimEventLoopMgr::drainScheduler ( int & finishedEvents)
protected

Drain the scheduler from all actions that may be queued.

Definition at line 600 of file HiveSlimEventLoopMgr.cpp.

600 {
601
602 StatusCode sc( StatusCode::SUCCESS );
603
604 // maybe we can do better
605 std::vector<EventContext*> finishedEvtContexts;
606
607 EventContext* finishedEvtContext( nullptr );
608
609 // Here we wait not to loose cpu resources
610 DEBUG_MSG << "Waiting for a context" << endmsg;
611 sc = m_schedulerSvc->popFinishedEvent( finishedEvtContext );
612
613 // We got past it: cache the pointer
614 DEBUG_MSG << "Context " << ( sc.isSuccess() ? "obtained" : "not obtained: a problem in the scheduling?" ) << endmsg;
615 finishedEvtContexts.push_back( finishedEvtContext );
616
617 // Let's see if we can pop other event contexts
618 while ( m_schedulerSvc->tryPopFinishedEvent( finishedEvtContext ).isSuccess() ) {
619 finishedEvtContexts.push_back( finishedEvtContext );
620 }
621
622 // Now we flush them
623 StatusCode finalSC;
624 for ( auto& thisFinishedEvtContext : finishedEvtContexts ) {
625 if ( !thisFinishedEvtContext ) {
626 error() << "Detected nullptr ctxt before clearing WB!" << endmsg;
627 finalSC = StatusCode::FAILURE;
628 continue;
629 }
630 if ( m_algExecStateSvc->eventStatus( *thisFinishedEvtContext ) != EventStatus::Success ) {
631 ( m_abortOnFailure ? fatal() : error() ) << "Failed event detected on " << thisFinishedEvtContext << endmsg;
632 if ( m_abortOnFailure ) finalSC = StatusCode::FAILURE;
633 }
634 // shouldn't these incidents move to the forward scheduler?
635 // If we want to consume incidents with an algorithm at the end of the graph
636 // we need to add this to forward scheduler lambda action,
637 // otherwise we have to do this serially on this thread!
638 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndProcessing, *thisFinishedEvtContext ) );
639 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndEvent, *thisFinishedEvtContext ) );
640
641 DEBUG_MSG << "Clearing slot " << thisFinishedEvtContext->slot() << " (event " << thisFinishedEvtContext->evt()
642 << ") of the whiteboard" << endmsg;
643
644 StatusCode sc = clearWBSlot( thisFinishedEvtContext->slot() );
645 if ( !sc.isSuccess() )
646 error() << "Whiteboard slot " << thisFinishedEvtContext->slot() << " could not be properly cleared";
647
648 delete thisFinishedEvtContext;
649
650 ++finishedEvts;
651 }
652 return finalSC;
653}
#define DEBUG_MSG
constexpr void push_back(const value_type &__x)
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.
virtual const EventStatus::Status & eventStatus(const EventContext &ctx) const =0
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
virtual StatusCode popFinishedEvent(EventContext *&eventContext)=0
Retrieve a finished event from the scheduler.
virtual StatusCode tryPopFinishedEvent(EventContext *&eventContext)=0
Try to retrieve a finished event from the scheduler.
Incident(const std::string &source, const std::string &type)
Default Constructor.
Definition Incident.cpp:15

◆ 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 }
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
constexpr _OI move(_II __first, _II __last, _OI __result)
constexpr bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp &__val)
constexpr reference at(size_type __n)
constexpr bool empty() const noexcept
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
auto begin() const
Definition Property.h:282
auto end() const
Definition Property.h:287
std::vector< uint8_t > m_blackList
Gaudi::Property< std::vector< unsigned int > > m_eventNumberBlacklist
bool m_scheduledStop
Scheduled stop of event processing.
virtual void reset(const EventContext &ctx)=0
reset all states for the given EventContext
virtual StatusCode pushNewEvent(EventContext *eventContext)=0
Make an event available to the scheduler.
constexpr static const auto RECOVERABLE
Definition StatusCode.h:101
void ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:128

◆ 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
427
428 return eventfailed ? StatusCode::FAILURE : StatusCode::SUCCESS;
429}
constexpr void assign(_InputIterator __first, _InputIterator __last)
constexpr void clear() noexcept
auto size() const
Definition Property.h:262
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 ) {
343 m_evtContext = nullptr;
344 }
345
347
348 // Release all interfaces...
351
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!
constexpr _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
constexpr auto begin(_Container &__cont) -> decltype(__cont.begin())
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 StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
virtual StatusCode releaseContext(Context *&) const =0
Release the Context object.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
StatusCode finalize() override
Definition Service.cpp:223
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition SmartIF.h:88
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.

◆ getEventRoot()

StatusCode HiveSlimEventLoopMgr::getEventRoot ( IOpaqueAddress *& refpAddr)

Create event address using event selector.

Definition at line 544 of file HiveSlimEventLoopMgr.cpp.

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

◆ 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
175
176 if ( m_evtsel != "NONE" || m_evtsel.length() == 0 ) {
177 m_evtSelector = serviceLocator()->service( "EventSelector" );
178 if ( m_evtSelector ) {
179 // Setup Event Selector
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
222 info() << "Found " << m_eventNumberBlacklist.size() << " events in black list" << endmsg;
223
224 return StatusCode::SUCCESS;
225}
constexpr void sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
auto length() const
Definition Property.h:267
auto empty() const
Definition Property.h:272
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 StatusCode createContext(Context *&c) const =0
Create and return a context object that will keep track of the state of selection.
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
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

◆ nextEvent()

StatusCode HiveSlimEventLoopMgr::nextEvent ( int maxevt)
override

implementation of IService::nextEvent

Definition at line 451 of file HiveSlimEventLoopMgr.cpp.

451 {
452
453 // Calculate runtime
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 finalSC.isSuccess() && // Stop submitting events after a failure
482 !m_scheduledStop // There is not a scheduled stop
483 ) {
484
485 if ( 1 == createdEvts ) // reset counter to count from event 1
486 start_time = Clock::now();
487
488 DEBUG_MSG << "createdEvts: " << createdEvts << ", freeslots: " << m_schedulerSvc->freeSlots() << endmsg;
489 // DP remove to remove the syscalls...
490 // if (0!=createdEvts){
491 // info() << "Event Number = " << createdEvts
492 // << " WSS (MB) = " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1024
493 // << " Time (s) = " << secsFromStart(start_time) << endmsg;
494 // }
495
496 // TODO can we adapt the interface of executeEvent for a nicer solution?
497 StatusCode sc = StatusCode::RECOVERABLE;
498 while ( !sc.isSuccess() // we haven't created an event yet
499 && ( createdEvts < maxevt || maxevt < 0 ) ) { // redunant check for maxEvts, can we do better?
500 {
501 auto ctx = createEventContext();
502 if ( !ctx.valid() ) {
503 createdEvts = -1;
504 break; // invalid context means end of loop
505 }
506 sc = executeEvent( std::move( ctx ) );
507 }
508 if ( sc.isRecoverable() ) { // we skipped an event
509 ++skippedEvts;
510 } else if ( sc.isFailure() ) { // exit immediatly
511 return sc;
512 } // else we have an success --> exit loop
513 ++createdEvts;
514 }
515
516 } // end if condition createdEvts < maxevt
517 else {
518 // all the events were created but not all finished or the slots were
519 // all busy: the scheduler should finish its job
520
521 DEBUG_MSG << "Draining the scheduler" << endmsg;
522
523 // Pull out of the scheduler the finished events
524 if ( drainScheduler( finishedEvts ).isFailure() ) { finalSC = StatusCode::FAILURE; }
525 // Keep algorithms and event services alive until all submitted events have finished,
526 // including after an event failure has stopped submission of new events.
527 loop_ended = finalSC.isFailure() && m_schedulerSvc->freeSlots() == m_whiteboard->getNumberOfStores();
528 newEvtAllowed = true;
529 }
530 } // end main loop on finished events
531 auto end_time = Clock::now();
532
533 info() << "---> Loop Finished (skipping 1st evt) - "
534 << " WSS " << System::mappedMemory( System::MemoryUnit::kByte ) * oneOver1024 << " total time "
535 << std::chrono::duration_cast<std::chrono::nanoseconds>( end_time - start_time ).count() << endmsg;
536 info() << skippedEvts << " events were SKIPed" << endmsg;
537
538 return finalSC;
539}
system_clock high_resolution_clock
constexpr __enable_if_is_duration< _ToDur > duration_cast(const duration< _Rep, _Period > &__d)
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()
virtual size_t freeSlots()=0
Get free slots number.
virtual size_t getNumberOfStores() const =0
Get the number of 'slots'.
virtual unsigned int freeSlots()=0
Get the free event processing slots.
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 }
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 }
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}
TYPE * get() const
Get interface pointer.
Definition SmartIF.h:82
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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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: