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;
99 info() <<
"\"EventSelector\" disabled: no events will be processed from external input." <<
endmsg;
107 fatal() <<
"Error retrieving HistogramDataSvc." <<
endmsg;
118 fatal() <<
"Error retrieving AlgResourcePool" <<
endmsg;
124 fatal() <<
"Error retrieving AlgExecStateSvc" <<
endmsg;
144 if ( theEvtSel && ( theEvtSel.get() !=
m_evtSelector.get() ) ) {
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;
224 sc = std::accumulate( begin( objects ), end( objects ), sc, [&](
StatusCode s,
const auto& i ) {
227 if ( iret.
isSuccess() ) i->registry()->setAddress( pAddr );
228 return s.isFailure() ? s : iret;
230 sc = std::accumulate( begin( objects ), end( objects ), sc, [&](
StatusCode s,
const auto& i ) {
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 ) );
298 VERBOSE_MSG <<
"Adding event " << ctx.evt() <<
", slot " << ctx.slot() <<
" to the scheduler" <<
endmsg;
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;
473 info() <<
"No more events in event selection " <<
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;
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;
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work!
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
A DataObject is the base class of any identifiable object on any data store.
This class represents an entry point to all the event specific data.
Define general base for Gaudi exception.
HistogramAgent base in charge of collecting all the references to DataObjects in a transient store th...
const IDataSelector & selectedObjects() const
Return the set of selected DataObjects.
EventContext::ContextEvt_t m_nevt
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
Gaudi::Property< bool > m_abortOnFailure
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
Gaudi::Property< std::string > m_histPersName
StatusCode executeRun(int maxevt) override
implementation of IEventProcessor::executeRun()
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service's IDataManagerSvc interface.
StatusCode stop() override
implementation of IService::stop
StatusCode initialize() override
implementation of IService::initialize
StatusCode drainScheduler(int &finishedEvents)
Drain the scheduler from all actions that may be queued.
StatusCode nextEvent(int maxevt) override
implementation of IService::nextEvent
StatusCode reinitialize() override
implementation of IService::reinitialize
StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(EventContext&&)
std::unique_ptr< boost::dynamic_bitset<> > m_blackListBS
Gaudi::Property< std::string > m_schedulerName
~HiveSlimEventLoopMgr() override
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
bool m_endEventFired
Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event)
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
Gaudi::Property< std::vector< unsigned int > > m_eventNumberBlacklist
SmartIF< IHiveWhiteBoard > m_whiteboard
Reference to the Whiteboard.
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
StatusCode declareEventRootAddress()
Declare the root address of the event.
SmartIF< IDataManagerSvc > m_histoDataMgrSvc
Reference to the Histogram Data Service.
IEvtSelector::Context * m_evtContext
Event Iterator.
bool m_scheduledStop
Scheduled stop of event processing.
StatusCode finalize() override
implementation of IService::finalize
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
Reference to the AlgExecStateSvc.
Gaudi::Property< std::string > m_evtsel
EventContext createEventContext() override
implementation of IEventProcessor::createEventContext()
The Event Selector Interface.
Opaque address interface definition.
The IProperty is the basic interface for all components which have properties that can be set or get.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Base class for all Incidents (computing events).
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode finalize() override
const std::string & name() const override
Retrieve name of the service.
StatusCode initialize() override
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
This class is used for returning status codes from appropriate routines.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto RECOVERABLE
bool isRecoverable() const
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
constexpr int ScheduledStop
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.