The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
HiveSlimEventLoopMgr Class Reference

#include </builds/gaudi/Gaudi/GaudiHive/src/HiveSlimEventLoopMgr.h>

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::PropertyBasedeclareProperty (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::PropertyBasedeclareProperty (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::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
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
 
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 Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
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::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
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
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

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
 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< IDataManagerSvcm_evtDataMgrSvc
 Reference to the Event Data Service's IDataManagerSvc interface.
 
SmartIF< IEvtSelectorm_evtSelector
 Reference to the Event Selector.
 
IEvtSelector::Contextm_evtContext = nullptr
 Event Iterator.
 
SmartIF< IDataManagerSvcm_histoDataMgrSvc
 Reference to the Histogram Data Service.
 
SmartIF< IConversionSvcm_histoPersSvc
 Reference to the Histogram Persistency Service.
 
SmartIF< IHiveWhiteBoardm_whiteboard
 Reference to the Whiteboard.
 
SmartIF< IAlgResourcePoolm_algResourcePool
 Reference to the Algorithm resource pool.
 
SmartIF< IAlgExecStateSvcm_algExecStateSvc
 Reference to the AlgExecStateSvc.
 
SmartIF< IPropertym_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< ISchedulerm_schedulerSvc
 A shortcut for the scheduler.
 
SmartIF< IIncidentListenerm_abortEventListener
 Instance of the incident listener waiting for AbortEvent.
 
bool m_scheduledStop = false
 Scheduled stop of event processing.
 
SmartIF< IIncidentSvcm_incidentSvc
 Reference to the incident service.
 
std::unique_ptr< boost::dynamic_bitset<> > m_blackListBS
 
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< IAuditorSvcm_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 31 of file HiveSlimEventLoopMgr.h.

Constructor & Destructor Documentation

◆ ~HiveSlimEventLoopMgr()

HiveSlimEventLoopMgr::~HiveSlimEventLoopMgr ( )
override

Definition at line 38 of file HiveSlimEventLoopMgr.cpp.

38{ 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 563 of file HiveSlimEventLoopMgr.cpp.

563 {
564 StatusCode sc = m_whiteboard->clearStore( evtSlot );
565 if ( !sc.isSuccess() ) warning() << "Clear of Event data store failed" << endmsg;
566 return m_whiteboard->freeStore( evtSlot );
567}
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:314

◆ createEventContext()

EventContext HiveSlimEventLoopMgr::createEventContext ( )
override

implementation of IEventProcessor::createEventContext()

Definition at line 488 of file HiveSlimEventLoopMgr.cpp.

488 {
489 EventContext ctx{ m_nevt, m_whiteboard->allocateStore( m_nevt ) };
490 ++m_nevt;
491
492 StatusCode sc = m_whiteboard->selectStore( ctx.slot() );
493 if ( sc.isFailure() ) {
494 throw GaudiException( "Slot " + std::to_string( ctx.slot() ) + " could not be selected for the WhiteBoard", name(),
495 sc );
496 }
497 if ( declareEventRootAddress().isFailure() ) { // We ran out of events!
498 // invalid context terminates the loop
499 return EventContext{};
500 }
501 return ctx;
502}
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:129

◆ declareEventRootAddress()

StatusCode HiveSlimEventLoopMgr::declareEventRootAddress ( )
protected

Declare the root address of the event.

Definition at line 466 of file HiveSlimEventLoopMgr.cpp.

466 {
467 StatusCode sc;
468 if ( m_evtContext ) {
469 //---This is the "event iterator" context from EventSelector
470 IOpaqueAddress* pAddr = nullptr;
471 sc = getEventRoot( pAddr );
472 if ( !sc.isSuccess() ) {
473 info() << "No more events in event selection " << endmsg;
474 return StatusCode::FAILURE;
475 }
476 sc = m_evtDataMgrSvc->setRoot( "/Event", pAddr );
477 if ( !sc.isSuccess() ) { warning() << "Error declaring event root address." << endmsg; }
478 } else {
479 //---In case of no event selector----------------
480 sc = m_evtDataMgrSvc->setRoot( "/Event", new DataObject() );
481 if ( !sc.isSuccess() ) { warning() << "Error declaring event root DataObject" << endmsg; }
482 }
483 return StatusCode::SUCCESS;
484}
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 506 of file HiveSlimEventLoopMgr.cpp.

506 {
507
508 StatusCode sc( StatusCode::SUCCESS );
509
510 // maybe we can do better
511 std::vector<EventContext*> finishedEvtContexts;
512
513 EventContext* finishedEvtContext( nullptr );
514
515 // Here we wait not to loose cpu resources
516 DEBUG_MSG << "Waiting for a context" << endmsg;
517 sc = m_schedulerSvc->popFinishedEvent( finishedEvtContext );
518
519 // We got past it: cache the pointer
520 DEBUG_MSG << "Context " << ( sc.isSuccess() ? "obtained" : "not obtained: a problem in the scheduling?" ) << endmsg;
521 finishedEvtContexts.push_back( finishedEvtContext );
522
523 // Let's see if we can pop other event contexts
524 while ( m_schedulerSvc->tryPopFinishedEvent( finishedEvtContext ).isSuccess() ) {
525 finishedEvtContexts.push_back( finishedEvtContext );
526 }
527
528 // Now we flush them
529 StatusCode finalSC;
530 for ( auto& thisFinishedEvtContext : finishedEvtContexts ) {
531 if ( !thisFinishedEvtContext ) {
532 error() << "Detected nullptr ctxt before clearing WB!" << endmsg;
533 finalSC = StatusCode::FAILURE;
534 continue;
535 }
536 if ( m_algExecStateSvc->eventStatus( *thisFinishedEvtContext ) != EventStatus::Success ) {
537 ( m_abortOnFailure ? fatal() : error() ) << "Failed event detected on " << thisFinishedEvtContext << endmsg;
538 if ( m_abortOnFailure ) finalSC = StatusCode::FAILURE;
539 }
540 // shouldn't these incidents move to the forward scheduler?
541 // If we want to consume incidents with an algorithm at the end of the graph
542 // we need to add this to forward scheduler lambda action,
543 // otherwise we have to do this serially on this thread!
544 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndProcessing, *thisFinishedEvtContext ) );
545 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndEvent, *thisFinishedEvtContext ) );
546
547 DEBUG_MSG << "Clearing slot " << thisFinishedEvtContext->slot() << " (event " << thisFinishedEvtContext->evt()
548 << ") of the whiteboard" << endmsg;
549
550 StatusCode sc = clearWBSlot( thisFinishedEvtContext->slot() );
551 if ( !sc.isSuccess() )
552 error() << "Whiteboard slot " << thisFinishedEvtContext->slot() << " could not be properly cleared";
553
554 delete thisFinishedEvtContext;
555
556 ++finishedEvts;
557 }
558 return finalSC;
559}
#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 269 of file HiveSlimEventLoopMgr.cpp.

269 {
270
271 m_algExecStateSvc->reset( ctx );
272
273 // Check if event number is in blacklist
274 if ( m_blackListBS != nullptr ) { // we are processing a finite number of events, use bitset blacklist
275 if ( m_blackListBS->test( ctx.evt() ) ) {
276 VERBOSE_MSG << "Event " << ctx.evt() << " on black list" << endmsg;
277 m_whiteboard->freeStore( ctx.slot() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
279 }
280 } else if ( std::binary_search( m_eventNumberBlacklist.begin(), m_eventNumberBlacklist.end(), ctx.evt() ) ) {
281 VERBOSE_MSG << "Event " << ctx.evt() << " on black list" << endmsg;
282 m_whiteboard->freeStore( ctx.slot() ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
284 }
285
286 VERBOSE_MSG << "Beginning to process event " << ctx.evt() << endmsg;
287
288 // An incident may schedule a stop, in which case is better to exit before the actual execution.
289 if ( m_scheduledStop ) {
290 always() << "Terminating event processing loop due to a stop scheduled by an incident listener" << endmsg;
291 return StatusCode::SUCCESS;
292 }
293
294 // Fire BeginEvent "Incident"
295 m_incidentSvc->fireIncident( std::make_unique<Incident>( name(), IncidentType::BeginEvent, ctx ) );
296
297 // Now add event to the scheduler
298 VERBOSE_MSG << "Adding event " << ctx.evt() << ", slot " << ctx.slot() << " to the scheduler" << endmsg;
299
300 m_incidentSvc->fireIncident( std::make_unique<Incident>( name(), IncidentType::BeginProcessing, ctx ) );
301
302 StatusCode addEventStatus = m_schedulerSvc->pushNewEvent( new EventContext{ std::move( ctx ) } );
303
304 // If this fails, we need to wait for something to complete
305 if ( !addEventStatus.isSuccess() ) {
306 fatal() << "An event processing slot should be now free in the scheduler, but it appears not to be the case."
307 << endmsg;
308 }
309
310 return StatusCode::SUCCESS;
311}
#define VERBOSE_MSG
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
std::unique_ptr< boost::dynamic_bitset<> > m_blackListBS
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 316 of file HiveSlimEventLoopMgr.cpp.

316 {
317 StatusCode sc;
318 bool eventfailed = false;
319
320 if ( maxevt > 0 ) { // finite number of events to process
321 const unsigned int umaxevt = static_cast<unsigned int>( maxevt );
322 m_blackListBS = std::make_unique<boost::dynamic_bitset<>>( maxevt ); // all initialized to zero
323 for ( unsigned int i = 0; i < m_eventNumberBlacklist.size() && m_eventNumberBlacklist[i] <= umaxevt;
324 ++i ) { // black list is sorted in init
325 m_blackListBS->set( m_eventNumberBlacklist[i], true );
326 }
327 }
328
329 // Call now the nextEvent(...)
330 sc = nextEvent( maxevt );
331 if ( sc.isFailure() ) eventfailed = true;
332
333 m_blackListBS.reset( nullptr );
334
335 return eventfailed ? StatusCode::FAILURE : StatusCode::SUCCESS;
336}
StatusCode nextEvent(int maxevt) override
implementation of IService::nextEvent

◆ finalize()

StatusCode HiveSlimEventLoopMgr::finalize ( )
override

implementation of IService::finalize

Definition at line 207 of file HiveSlimEventLoopMgr.cpp.

207 {
208
209 StatusCode scRet;
210 StatusCode sc = Service::finalize();
211
212 if ( sc.isFailure() ) {
213 scRet = StatusCode::FAILURE;
214 error() << "Problems finalizing Service base class" << endmsg;
215 }
216
217 // Save Histograms Now
218 if ( m_histoPersSvc ) {
219 HistogramAgent agent;
220 sc = m_histoDataMgrSvc->traverseTree( &agent );
221 if ( sc.isSuccess() ) {
222 const IDataSelector& objects = agent.selectedObjects();
223 // skip /stat entry!
224 sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode s, const auto& i ) {
225 IOpaqueAddress* pAddr = nullptr;
226 StatusCode iret = m_histoPersSvc->createRep( i, pAddr );
227 if ( iret.isSuccess() ) i->registry()->setAddress( pAddr );
228 return s.isFailure() ? s : iret;
229 } );
230 sc = std::accumulate( begin( objects ), end( objects ), sc, [&]( StatusCode s, const auto& i ) {
231 IRegistry* reg = i->registry();
232 StatusCode iret = m_histoPersSvc->fillRepRefs( reg->address(), i );
233 return s.isFailure() ? s : iret;
234 } );
235 if ( sc.isSuccess() ) {
236 info() << "Histograms converted successfully according to request." << endmsg;
237 } else {
238 error() << "Error while saving Histograms." << endmsg;
239 }
240 } else {
241 error() << "Error while traversing Histogram data store" << endmsg;
242 }
243 }
244
245 scRet = sc;
246
247 // Release event selector context
248 if ( m_evtSelector && m_evtContext ) {
249 m_evtSelector->releaseContext( m_evtContext ).ignore();
250 m_evtContext = nullptr;
251 }
252
253 m_incidentSvc.reset();
254
255 // Release all interfaces...
256 m_histoDataMgrSvc.reset();
257 m_histoPersSvc.reset();
258
259 m_evtSelector.reset();
260 m_whiteboard.reset();
261 m_evtDataMgrSvc.reset();
262
263 return scRet;
264}
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 450 of file HiveSlimEventLoopMgr.cpp.

450 {
451 refpAddr = nullptr;
452 StatusCode sc = m_evtSelector->next( *m_evtContext );
453 if ( sc.isFailure() ) return sc;
454 // Create root address and assign address to data service
455 sc = m_evtSelector->createAddress( *m_evtContext, refpAddr );
456 if ( sc.isSuccess() ) return sc;
457 sc = m_evtSelector->next( *m_evtContext );
458 if ( sc.isFailure() ) return sc;
459 sc = m_evtSelector->createAddress( *m_evtContext, refpAddr );
460 if ( !sc.isSuccess() ) warning() << "Error creating IOpaqueAddress." << endmsg;
461 return sc;
462}

◆ initialize()

StatusCode HiveSlimEventLoopMgr::initialize ( )
override

implementation of IService::initialize

Definition at line 43 of file HiveSlimEventLoopMgr.cpp.

43 {
44 StatusCode sc = Service::initialize();
45 if ( !sc.isSuccess() ) {
46 error() << "Failed to initialize Service Base class." << endmsg;
48 }
49
50 // Get the references to the services that are needed by the ApplicationMgr itself
51 m_incidentSvc = serviceLocator()->service( "IncidentSvc" );
52 if ( !m_incidentSvc ) {
53 fatal() << "Error retrieving IncidentSvc." << endmsg;
55 }
56
57 // Setup access to event data services
58 m_evtDataMgrSvc = serviceLocator()->service( "EventDataSvc" );
59 if ( !m_evtDataMgrSvc ) {
60 fatal() << "Error retrieving EventDataSvc interface IDataManagerSvc." << endmsg;
62 }
63 m_whiteboard = serviceLocator()->service( "EventDataSvc" );
64 if ( !m_whiteboard ) {
65 fatal() << "Error retrieving EventDataSvc interface IHiveWhiteBoard." << endmsg;
67 }
69 if ( !m_schedulerSvc ) {
70 fatal() << "Error retrieving SchedulerSvc interface IScheduler." << endmsg;
72 }
73 // Obtain the IProperty of the ApplicationMgr
75 if ( !m_appMgrProperty ) {
76 fatal() << "IProperty interface not found in ApplicationMgr." << endmsg;
78 }
79
80 // We do not expect a Event Selector necessarily being declared
81 setProperty( m_appMgrProperty->getProperty( "EvtSel" ) ).ignore();
82
83 if ( m_evtsel != "NONE" || m_evtsel.length() == 0 ) {
84 m_evtSelector = serviceLocator()->service( "EventSelector" );
85 if ( m_evtSelector ) {
86 // Setup Event Selector
87 sc = m_evtSelector->createContext( m_evtContext );
88 if ( !sc.isSuccess() ) {
89 fatal() << "Can not create the event selector Context." << endmsg;
90 return sc;
91 }
92 } else {
93 fatal() << "EventSelector not found." << endmsg;
94 return sc;
95 }
96 } else {
97 m_evtSelector = 0;
98 m_evtContext = 0;
99 info() << "\"EventSelector\" disabled: no events will be processed from external input." << endmsg;
100 }
101
102 setProperty( m_appMgrProperty->getProperty( "HistogramPersistency" ) ).ignore();
103 if ( m_histPersName != "NONE" && !m_histPersName.empty() ) {
104 // Setup access to histogramming services
105 m_histoDataMgrSvc = serviceLocator()->service( "HistogramDataSvc" );
106 if ( !m_histoDataMgrSvc ) {
107 fatal() << "Error retrieving HistogramDataSvc." << endmsg;
108 return StatusCode::FAILURE;
109 }
110 // Setup histogram persistency
111 m_histoPersSvc = serviceLocator()->service( "HistogramPersistencySvc" );
112 if ( !m_histoPersSvc ) { warning() << "Histograms cannot not be saved - though required." << endmsg; }
113 }
114
115 // Setup algorithm resource pool
116 m_algResourcePool = serviceLocator()->service( "AlgResourcePool" );
117 if ( !m_algResourcePool ) {
118 fatal() << "Error retrieving AlgResourcePool" << endmsg;
119 return StatusCode::FAILURE;
120 }
121
122 m_algExecStateSvc = serviceLocator()->service( "AlgExecStateSvc" );
123 if ( !m_algExecStateSvc ) {
124 fatal() << "Error retrieving AlgExecStateSvc" << endmsg;
125 return StatusCode::FAILURE;
126 }
127
128 std::sort( m_eventNumberBlacklist.begin(), m_eventNumberBlacklist.end() );
129 info() << "Found " << m_eventNumberBlacklist.size() << " events in black list" << endmsg;
130
131 return StatusCode::SUCCESS;
132}
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
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139

◆ nextEvent()

StatusCode HiveSlimEventLoopMgr::nextEvent ( int maxevt)
override

implementation of IService::nextEvent

Definition at line 358 of file HiveSlimEventLoopMgr.cpp.

358 {
359
360 // Calculate runtime
361 using Clock = std::chrono::high_resolution_clock;
362
363 // Reset the application return code.
365
366 int finishedEvts = 0;
367 int createdEvts = 0;
368 int skippedEvts = 0;
369 info() << "Starting loop on events" << endmsg;
370 // Loop until the finished events did not reach the maxevt number
371 bool loop_ended = false;
372 // Run the first event before spilling more than one
373 bool newEvtAllowed = false;
374
375 constexpr double oneOver1024 = 1. / 1024.;
376
377 uint iteration = 0;
378 auto start_time = Clock::now();
379 StatusCode finalSC;
380 while ( !loop_ended && ( maxevt < 0 || ( finishedEvts + skippedEvts ) < maxevt ) ) {
381 DEBUG_MSG << "work loop iteration " << iteration++ << endmsg;
382 // if the created events did not reach maxevt, create an event
383 if ( ( newEvtAllowed || createdEvts == 0 ) && // Launch the first event alone
384 createdEvts >= 0 && // The events are not finished with an unlimited number of events
385 ( createdEvts < maxevt || maxevt < 0 ) && // The events are not finished with a limited number of events
386 m_schedulerSvc->freeSlots() > 0 && // There are still free slots in the scheduler
387 m_whiteboard->freeSlots() > 0 && // There are still free slots in the whiteboard
388 !m_scheduledStop // There is not a scheduled stop
389 ) {
390
391 if ( 1 == createdEvts ) // reset counter to count from event 1
392 start_time = Clock::now();
393
394 DEBUG_MSG << "createdEvts: " << createdEvts << ", freeslots: " << m_schedulerSvc->freeSlots() << endmsg;
395 // DP remove to remove the syscalls...
396 // if (0!=createdEvts){
397 // info() << "Event Number = " << createdEvts
398 // << " WSS (MB) = " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1024
399 // << " Time (s) = " << secsFromStart(start_time) << endmsg;
400 // }
401
402 // TODO can we adapt the interface of executeEvent for a nicer solution?
403 StatusCode sc = StatusCode::RECOVERABLE;
404 while ( !sc.isSuccess() // we haven't created an event yet
405 && ( createdEvts < maxevt || maxevt < 0 ) ) { // redunant check for maxEvts, can we do better?
406 {
407 auto ctx = createEventContext();
408 if ( !ctx.valid() ) {
409 createdEvts = -1;
410 break; // invalid context means end of loop
411 }
412 sc = executeEvent( std::move( ctx ) );
413 }
414 if ( sc.isRecoverable() ) { // we skipped an event
415 ++skippedEvts;
416 } else if ( sc.isFailure() ) { // exit immediatly
417 return sc;
418 } // else we have an success --> exit loop
419 ++createdEvts;
420 }
421
422 } // end if condition createdEvts < maxevt
423 else {
424 // all the events were created but not all finished or the slots were
425 // all busy: the scheduler should finish its job
426
427 DEBUG_MSG << "Draining the scheduler" << endmsg;
428
429 // Pull out of the scheduler the finished events
430 if ( drainScheduler( finishedEvts ).isFailure() ) {
431 loop_ended = true;
432 finalSC = StatusCode::FAILURE;
433 }
434 newEvtAllowed = true;
435 }
436 } // end main loop on finished events
437 auto end_time = Clock::now();
438
439 info() << "---> Loop Finished (skipping 1st evt) - "
440 << " WSS " << System::mappedMemory( System::MemoryUnit::kByte ) * oneOver1024 << " total time "
441 << std::chrono::duration_cast<std::chrono::nanoseconds>( end_time - start_time ).count() << endmsg;
442 info() << skippedEvts << " events were SKIPed" << endmsg;
443
444 return finalSC;
445}
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:318
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 136 of file HiveSlimEventLoopMgr.cpp.

136 {
137
138 // Check to see whether a new Event Selector has been specified
139 setProperty( m_appMgrProperty->getProperty( "EvtSel" ) ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
140 if ( m_evtsel != "NONE" || m_evtsel.empty() ) {
141 auto theSvc = serviceLocator()->service( "EventSelector" );
142 auto theEvtSel = theSvc.as<IEvtSelector>();
143 StatusCode sc;
144 if ( theEvtSel && ( theEvtSel.get() != m_evtSelector.get() ) ) {
145 // Setup Event Selector
146 if ( m_evtSelector.get() && m_evtContext ) {
147 // Need to release context before switching to new event selector
148 m_evtSelector->releaseContext( m_evtContext ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
149 m_evtContext = nullptr;
150 }
151 m_evtSelector = theEvtSel;
152 if ( theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED ) {
153 sc = theSvc->reinitialize();
154 if ( !sc.isSuccess() ) {
155 error() << "Failure Reinitializing EventSelector " << theSvc->name() << endmsg;
156 return sc;
157 }
158 } else {
159 sc = theSvc->sysInitialize();
160 if ( !sc.isSuccess() ) {
161 error() << "Failure Initializing EventSelector " << theSvc->name() << endmsg;
162 return sc;
163 }
164 }
165 sc = m_evtSelector->createContext( m_evtContext );
166 if ( !sc.isSuccess() ) {
167 error() << "Can not create Context " << theSvc->name() << endmsg;
168 return sc;
169 }
170
171 } else if ( m_evtSelector ) {
172 if ( m_evtContext ) {
173 m_evtSelector->releaseContext( m_evtContext ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
174 m_evtContext = nullptr;
175 }
176 sc = m_evtSelector->createContext( m_evtContext );
177 if ( !sc.isSuccess() ) {
178 error() << "Can not create Context " << theSvc->name() << endmsg;
179 return sc;
180 }
181 }
182 } else if ( m_evtSelector && m_evtContext ) {
183 m_evtSelector->releaseContext( m_evtContext ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
184 m_evtSelector = nullptr;
185 m_evtContext = nullptr;
186 }
187 return StatusCode::SUCCESS;
188}
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 194 of file HiveSlimEventLoopMgr.cpp.

194 {
195 if ( !m_endEventFired ) {
196 // Fire pending EndEvent incident
197 m_incidentSvc->fireIncident( Incident( name(), IncidentType::EndEvent ) );
198 m_endEventFired = true;
199 }
200 return StatusCode::SUCCESS;
201}
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 341 of file HiveSlimEventLoopMgr.cpp.

341 {
342 // Set the application return code
343 auto appmgr = serviceLocator()->as<IProperty>();
344 if ( Gaudi::setAppReturnCode( appmgr, Gaudi::ReturnCode::ScheduledStop ).isFailure() ) {
345 error() << "Could not set return code of the application (" << Gaudi::ReturnCode::ScheduledStop << ")" << endmsg;
346 }
347 m_scheduledStop = true;
348 return StatusCode::SUCCESS;
349}
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 72 of file HiveSlimEventLoopMgr.h.

◆ m_abortOnFailure

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

Definition at line 40 of file HiveSlimEventLoopMgr.h.

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

◆ m_algExecStateSvc

SmartIF<IAlgExecStateSvc> HiveSlimEventLoopMgr::m_algExecStateSvc
protected

Reference to the AlgExecStateSvc.

Definition at line 57 of file HiveSlimEventLoopMgr.h.

◆ m_algResourcePool

SmartIF<IAlgResourcePool> HiveSlimEventLoopMgr::m_algResourcePool
protected

Reference to the Algorithm resource pool.

Definition at line 55 of file HiveSlimEventLoopMgr.h.

◆ m_appMgrProperty

SmartIF<IProperty> HiveSlimEventLoopMgr::m_appMgrProperty
protected

Property interface of ApplicationMgr.

Definition at line 59 of file HiveSlimEventLoopMgr.h.

◆ m_blackListBS

std::unique_ptr<boost::dynamic_bitset<> > HiveSlimEventLoopMgr::m_blackListBS
protected

Definition at line 79 of file HiveSlimEventLoopMgr.h.

◆ 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 62 of file HiveSlimEventLoopMgr.h.

◆ m_eventNumberBlacklist

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

Definition at line 39 of file HiveSlimEventLoopMgr.h.

39{ this, "EventNumberBlackList", {}, "" };

◆ m_evtContext

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

Event Iterator.

Definition at line 47 of file HiveSlimEventLoopMgr.h.

◆ m_evtDataMgrSvc

SmartIF<IDataManagerSvc> HiveSlimEventLoopMgr::m_evtDataMgrSvc
protected

Reference to the Event Data Service's IDataManagerSvc interface.

Definition at line 43 of file HiveSlimEventLoopMgr.h.

◆ m_evtsel

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

Definition at line 35 of file HiveSlimEventLoopMgr.h.

35{ this, "EvtSel", "", "" };

◆ m_evtSelector

SmartIF<IEvtSelector> HiveSlimEventLoopMgr::m_evtSelector
protected

Reference to the Event Selector.

Definition at line 45 of file HiveSlimEventLoopMgr.h.

◆ m_histoDataMgrSvc

SmartIF<IDataManagerSvc> HiveSlimEventLoopMgr::m_histoDataMgrSvc
protected

Reference to the Histogram Data Service.

Definition at line 49 of file HiveSlimEventLoopMgr.h.

◆ m_histoPersSvc

SmartIF<IConversionSvc> HiveSlimEventLoopMgr::m_histoPersSvc
protected

Reference to the Histogram Persistency Service.

Definition at line 51 of file HiveSlimEventLoopMgr.h.

◆ m_histPersName

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

Definition at line 34 of file HiveSlimEventLoopMgr.h.

34{ this, "HistogramPersistency", "", "" };

◆ m_incidentSvc

SmartIF<IIncidentSvc> HiveSlimEventLoopMgr::m_incidentSvc
protected

Reference to the incident service.

Definition at line 76 of file HiveSlimEventLoopMgr.h.

◆ m_nevt

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

Definition at line 81 of file HiveSlimEventLoopMgr.h.

81{ 0 };

◆ m_scheduledStop

bool HiveSlimEventLoopMgr::m_scheduledStop = false
protected

Scheduled stop of event processing.

Definition at line 74 of file HiveSlimEventLoopMgr.h.

◆ 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 36 of file HiveSlimEventLoopMgr.h.

36 { this, "SchedulerName", "AvalancheSchedulerSvc",
37 "Name of the scheduler to be used" };

◆ m_schedulerSvc

SmartIF<IScheduler> HiveSlimEventLoopMgr::m_schedulerSvc
protected

A shortcut for the scheduler.

Definition at line 64 of file HiveSlimEventLoopMgr.h.

◆ m_whiteboard

SmartIF<IHiveWhiteBoard> HiveSlimEventLoopMgr::m_whiteboard
protected

Reference to the Whiteboard.

Definition at line 53 of file HiveSlimEventLoopMgr.h.


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