Go to the documentation of this file.
29 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
30 #define DEBUG_MSG ON_DEBUG debug()
32 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
33 #define VERBOSE_MSG ON_VERBOSE verbose()
46 error() <<
"Failed to initialize Service Base class." <<
endmsg;
53 fatal() <<
"Error retrieving IncidentSvc." <<
endmsg;
60 fatal() <<
"Error retrieving EventDataSvc interface IDataManagerSvc." <<
endmsg;
65 fatal() <<
"Error retrieving EventDataSvc interface IHiveWhiteBoard." <<
endmsg;
70 fatal() <<
"Error retrieving SchedulerSvc interface IScheduler." <<
endmsg;
76 fatal() <<
"IProperty interface not found in ApplicationMgr." <<
endmsg;
89 fatal() <<
"Can not create the event selector Context." <<
endmsg;
93 fatal() <<
"EventSelector not found." <<
endmsg;
99 info() <<
"\"EventSelector\" disabled: no events will be processed from external input." <<
endmsg;
107 fatal() <<
"Error retrieving HistogramDataSvc." <<
endmsg;
112 if ( !
m_histoPersSvc ) { warning() <<
"Histograms cannot not be saved - though required." <<
endmsg; }
118 fatal() <<
"Error retrieving AlgResourcePool" <<
endmsg;
124 fatal() <<
"Error retrieving AlgExecStateSvc" <<
endmsg;
153 sc = theSvc->reinitialize();
154 if ( !sc.isSuccess() ) {
155 error() <<
"Failure Reinitializing EventSelector " << theSvc->name() <<
endmsg;
159 sc = theSvc->sysInitialize();
160 if ( !sc.isSuccess() ) {
161 error() <<
"Failure Initializing EventSelector " << theSvc->name() <<
endmsg;
166 if ( !sc.isSuccess() ) {
167 error() <<
"Can not create Context " << theSvc->name() <<
endmsg;
177 if ( !sc.isSuccess() ) {
178 error() <<
"Can not create Context " << theSvc->name() <<
endmsg;
214 error() <<
"Problems finalizing Service base class" <<
endmsg;
227 if ( iret.
isSuccess() ) i->registry()->setAddress( pAddr );
228 return s.isFailure() ?
s : iret;
233 return s.isFailure() ?
s : iret;
235 if ( sc.isSuccess() ) {
236 info() <<
"Histograms converted successfully according to request." <<
endmsg;
238 error() <<
"Error while saving Histograms." <<
endmsg;
241 error() <<
"Error while traversing Histogram data store" <<
endmsg;
290 always() <<
"Terminating event processing loop due to a stop scheduled by an incident listener" <<
endmsg;
295 m_incidentSvc->fireIncident( std::make_unique<Incident>(
name(), IncidentType::BeginEvent,
ctx ) );
300 m_incidentSvc->fireIncident( std::make_unique<Incident>(
name(), IncidentType::BeginProcessing,
ctx ) );
306 fatal() <<
"An event processing slot should be now free in the scheduler, but it appears not to be the case."
318 bool eventfailed =
false;
321 const unsigned int umaxevt =
static_cast<unsigned int>( maxevt );
322 m_blackListBS = std::make_unique<boost::dynamic_bitset<>>( maxevt );
331 if ( sc.
isFailure() ) eventfailed =
true;
361 using Clock = std::chrono::high_resolution_clock;
366 int finishedEvts = 0;
369 info() <<
"Starting loop on events" <<
endmsg;
371 bool loop_ended =
false;
373 bool newEvtAllowed =
false;
375 constexpr
double oneOver1024 = 1. / 1024.;
378 auto start_time = Clock::now();
380 while ( !loop_ended && ( maxevt < 0 || ( finishedEvts + skippedEvts ) < maxevt ) ) {
383 if ( ( newEvtAllowed || createdEvts == 0 ) &&
385 ( createdEvts < maxevt || maxevt < 0 ) &&
391 if ( 1 == createdEvts )
392 start_time = Clock::now();
405 && ( createdEvts < maxevt || maxevt < 0 ) ) {
408 if ( !
ctx.valid() ) {
434 newEvtAllowed =
true;
437 auto end_time = Clock::now();
439 info() <<
"---> Loop Finished (skipping 1st evt) - "
441 << std::chrono::duration_cast<std::chrono::nanoseconds>( end_time - start_time ).count() <<
endmsg;
442 info() << skippedEvts <<
" events were SKIPed" <<
endmsg;
460 if ( !sc.
isSuccess() ) warning() <<
"Error creating IOpaqueAddress." <<
endmsg;
473 info() <<
"No more events in event selection " <<
endmsg;
477 if ( !sc.
isSuccess() ) { warning() <<
"Error declaring event root address." <<
endmsg; }
481 if ( !sc.
isSuccess() ) { warning() <<
"Error declaring event root DataObject" <<
endmsg; }
494 throw GaudiException(
"Slot " + std::to_string(
ctx.slot() ) +
" could not be selected for the WhiteBoard",
name(),
511 std::vector<EventContext*> finishedEvtContexts;
520 DEBUG_MSG <<
"Context " << ( sc.
isSuccess() ?
"obtained" :
"not obtained: a problem in the scheduling?" ) <<
endmsg;
521 finishedEvtContexts.push_back( finishedEvtContext );
524 while (
m_schedulerSvc->tryPopFinishedEvent( finishedEvtContext ).isSuccess() ) {
525 finishedEvtContexts.push_back( finishedEvtContext );
530 for (
auto& thisFinishedEvtContext : finishedEvtContexts ) {
531 if ( !thisFinishedEvtContext ) {
532 error() <<
"Detected nullptr ctxt before clearing WB!" <<
endmsg;
537 (
m_abortOnFailure ? fatal() : error() ) <<
"Failed event detected on " << thisFinishedEvtContext <<
endmsg;
547 DEBUG_MSG <<
"Clearing slot " << thisFinishedEvtContext->slot() <<
" (event " << thisFinishedEvtContext->evt()
548 <<
") of the whiteboard" <<
endmsg;
552 error() <<
"Whiteboard slot " << thisFinishedEvtContext->slot() <<
" could not be properly cleared";
554 delete thisFinishedEvtContext;
565 if ( !sc.
isSuccess() ) warning() <<
"Clear of Event data store failed" <<
endmsg;
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Gaudi::Property< bool > m_abortOnFailure
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work!...
bool isRecoverable() const
StatusCode initialize() override
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
Gaudi::Property< std::vector< unsigned int > > m_eventNumberBlacklist
StatusCode reinitialize() override
implementation of IService::reinitialize
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
bool m_endEventFired
Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event)
Gaudi::Property< std::string > m_histPersName
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service's IDataManagerSvc interface.
StatusCode finalize() override
implementation of IService::finalize
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
EventContext::ContextEvt_t m_nevt
StatusCode stop() override
implementation of IService::stop
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
~HiveSlimEventLoopMgr() override
StatusCode finalize() override
const IDataSelector & selectedObjects() const
Return the set of selected DataObjects.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
const std::string & name() const override
Retrieve name of the service
SmartIF< IDataManagerSvc > m_histoDataMgrSvc
Reference to the Histogram Data Service.
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
StatusCode executeRun(int maxevt) override
implementation of IEventProcessor::executeRun()
constexpr int ScheduledStop
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
bool m_scheduledStop
Scheduled stop of event processing.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
StatusCode drainScheduler(int &finishedEvents)
Drain the scheduler from all actions that may be queued.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
SmartIF< IHiveWhiteBoard > m_whiteboard
Reference to the Whiteboard.
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(EventContext&&)
constexpr static const auto SUCCESS
TYPE * get() const
Get interface pointer.
std::unique_ptr< boost::dynamic_bitset<> > m_blackListBS
IEvtSelector::Context * m_evtContext
Event Iterator.
#define DECLARE_COMPONENT(type)
StatusCode nextEvent(int maxevt) override
implementation of IService::nextEvent
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
Reference to the AlgExecStateSvc.
StatusCode declareEventRootAddress()
Declare the root address of the event.
GAUDI_API long mappedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
Gaudi::Property< std::string > m_schedulerName
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
StatusCode initialize() override
implementation of IService::initialize
constexpr static const auto FAILURE
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
Gaudi::Property< std::string > m_evtsel
constexpr static const auto RECOVERABLE
void accumulate(Counter &counter, const Container &container, Fun f=Identity{})
A helper function for accumulating data from a container into a counter This is internally using buff...
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.