2 #include "GaudiKernel/SmartIF.h"
3 #include "GaudiKernel/Incident.h"
4 #include "GaudiKernel/MsgStream.h"
5 #include "GaudiKernel/SvcFactory.h"
6 #include "GaudiKernel/DataObject.h"
7 #include "GaudiKernel/IAlgManager.h"
8 #include "GaudiKernel/IIncidentSvc.h"
9 #include "GaudiKernel/IEvtSelector.h"
10 #include "GaudiKernel/IDataManagerSvc.h"
11 #include "GaudiKernel/IDataProviderSvc.h"
12 #include "GaudiKernel/IConversionSvc.h"
13 #include "GaudiKernel/AppReturnCode.h"
14 #include "GaudiKernel/DataSvc.h"
15 #include "GaudiKernel/IChronoStatSvc.h"
16 #include "GaudiKernel/IIncidentListener.h"
23 #include "GaudiKernel/EventContext.h"
24 #include "GaudiKernel/Algorithm.h"
26 #include <GaudiKernel/GaudiException.h>
28 #include <GaudiKernel/IScheduler.h>
38 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
39 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
41 #define DEBMSG ON_DEBUG debug()
42 #define VERMSG ON_VERBOSE verbose()
60 declareProperty(
"EvtSel",
m_evtsel );
62 "Set this property to false to suppress warning messages");
64 "Name of the scheduler to be used");
94 error() <<
"Failed to initialize Service Base class." <<
endmsg;
101 fatal() <<
"Error retrieving IncidentSvc." <<
endmsg;
108 fatal() <<
"Error retrieving EventDataSvc interface IDataManagerSvc." <<
endmsg;
111 m_whiteboard = serviceLocator()->service(
"EventDataSvc");
113 fatal() <<
"Error retrieving EventDataSvc interface IHiveWhiteBoard." <<
endmsg;
118 fatal() <<
"Error retrieving SchedulerSvc interface ISchedulerSvc." <<
endmsg;
124 fatal() <<
"IProperty interface not found in ApplicationMgr." <<
endmsg;
137 fatal() <<
"Can not create the event selector Context." <<
endmsg;
142 fatal() <<
"EventSelector not found." <<
endmsg;
150 warning() <<
"Unable to locate service \"EventSelector\" " <<
endmsg;
151 warning() <<
"No events will be processed from external input." <<
endmsg;
158 fatal() <<
"Error retrieving HistogramDataSvc." <<
endmsg;
162 m_histoPersSvc = serviceLocator()->service(
"HistogramPersistencySvc");
164 warning() <<
"Histograms cannot not be saved - though required." <<
endmsg;
171 fatal() <<
"Error retrieving AlgResourcePool" <<
endmsg;
201 sc = theSvc->reinitialize();
203 error() <<
"Failure Reinitializing EventSelector "
204 << theSvc->name( ) <<
endmsg;
211 error() <<
"Failure Initializing EventSelector "
212 << theSvc->name( ) <<
endmsg;
218 error() <<
"Can not create Context " << theSvc->name( ) <<
endmsg;
230 error() <<
"Can not create Context " << theSvc->name( ) <<
endmsg;
267 error() <<
"Problems finalizing Service base class" <<
endmsg;
277 if ( objects->size() > 0 ) {
278 IDataSelector::iterator
i;
279 for ( i = objects->begin(); i != objects->end(); i++ ) {
283 (*i)->registry()->setAddress(pAddr);
289 for ( i = objects->begin(); i != objects->end(); i++ ) {
298 info() <<
"Histograms converted successfully according to request." <<
endmsg;
301 error() <<
"Error while saving Histograms." <<
endmsg;
305 error() <<
"Error while traversing Histogram data store" <<
endmsg;
337 int& createdEvts = *((
int*)createdEvts_IntPtr);
344 verbose() <<
"Event " << createdEvts <<
" on black list" <<
endmsg;
349 verbose() <<
"Event " << createdEvts <<
" on black list" <<
endmsg;
354 fatal() <<
"Impossible to create event context" <<
endmsg;
358 verbose() <<
"Beginning to process event " << createdEvts <<
endmsg;
378 verbose() <<
"Adding event " << evtContext->
evt()
379 <<
", slot " << evtContext->
slot()
380 <<
" to the scheduler" <<
endmsg;
388 fatal() <<
"An event processing slot should be now free in the scheduler, but it appears not to be the case." <<
endmsg;
401 bool eventfailed =
false;
404 const unsigned int umaxevt =
static_cast<unsigned int>(maxevt);
440 error() <<
"Could not set return code of the application ("
453 #include "GaudiKernel/Memory.h"
457 typedef std::chrono::high_resolution_clock
Clock;
466 info() <<
"Starting loop on events" <<
endmsg;
468 bool loop_ended =
false;
470 bool newEvtAllowed = false ;
472 constexpr
double oneOver1204 = 1./1024.;
475 time_point start_time = Clock::now();
476 while ( !loop_ended and (maxevt < 0 or (finishedEvts+skippedEvts) < maxevt)){
477 debug() <<
"work loop iteration " << iteration++ <<
endmsg;
479 if ((newEvtAllowed or createdEvts == 0 ) &&
481 (createdEvts < maxevt or maxevt<0) &&
485 start_time = Clock::now();
498 && (createdEvts < maxevt or maxevt<0)){
521 debug() <<
"Draining the scheduler" <<
endmsg;
527 newEvtAllowed =
true;
530 time_point end_time = Clock::now();
532 info() <<
"---> Loop Finished (skipping 1st evt) - "
534 <<
" total time " << std::chrono::duration_cast < std::chrono::nanoseconds > (end_time - start_time).count() <<
endmsg;
535 info() << skippedEvts <<
" events were SKIPed" <<
endmsg;
557 warning() <<
"Error creating IOpaqueAddress." <<
endmsg;
574 info() <<
"No more events in event selection " <<
endmsg;
579 warning() <<
"Error declaring event root address." <<
endmsg;
586 warning() <<
"Error declaring event root DataObject" <<
endmsg;
601 warning() <<
"Slot " << evtContext->
slot()
602 <<
" could not be selected for the WhiteBoard" <<
endmsg;
614 std::vector<EventContext*> finishedEvtContexts;
619 debug() <<
"Waiting for a context" <<
endmsg;
624 debug() <<
"Context obtained" <<
endmsg;
627 debug() <<
"Context not obtained: a problem in the scheduling?" <<
endmsg;
630 finishedEvtContexts.push_back(finishedEvtContext);
634 finishedEvtContexts.push_back(finishedEvtContext);
639 for (
auto& thisFinishedEvtContext : finishedEvtContexts){
640 if (
nullptr == thisFinishedEvtContext){
641 error() <<
"Detected nullptr ctxt before clearing WB!"<<
endmsg;
645 if (thisFinishedEvtContext->evtFail()){
646 fatal() <<
"Failed event detected"<<
endmsg;
653 debug() <<
"Clearing slot " << thisFinishedEvtContext->slot()
654 <<
" (event " << thisFinishedEvtContext->evt()
655 <<
") of the whiteboard" <<
endmsg;
659 error() <<
"Whiteboard slot " << thisFinishedEvtContext->slot()
660 <<
" could not be properly cleared";
663 delete thisFinishedEvtContext;
676 warning() <<
"Clear of Event data store failed" <<
endmsg;
virtual StatusCode finalize()
implementation of IService::finalize
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
StatusCode initialize() override
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
void set(const long int &e=0, const ID_type &s=0, const bool f=false)
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service's IDataManagerSvc interface.
virtual StatusCode executeEvent(void *par)
implementation of IEventProcessor::executeEvent(void* par)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
StatusCode declareEventRootAddress()
Declare the root address of the event.
virtual StatusCode getProperty(Property *p) const =0
Get the property by property.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode stopRun()
implementation of IEventProcessor::stopRun()
StatusCode finalize() override
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
HiveSlimEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
StatusCode drainScheduler(int &finishedEvents)
Drain the scheduler from all actions that may be queued.
bool isSuccess() const
Test for a status code of SUCCESS.
HistogramAgent base in charge of collecting all the refereces to DataObjects in a transient store tha...
SmartIF< IHiveWhiteBoard > m_whiteboard
Reference to the Whiteboard.
Clock::time_point time_point
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
bool m_scheduledStop
Scheduled stop of event processing.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
This class represents an entry point to all the event specific data.
std::string m_histPersName
Name of the Hist Pers type.
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
bool isFailure() const
Test for a status code of FAILURE.
std::vector< unsigned int > m_eventNumberBlacklist
List of events to be skipped. The number is the number in the job.
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work! M...
GAUDI_API long mappedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
constexpr int ScheduledStop
TYPE * get() const
Get interface pointer.
virtual StatusCode sysInitialize()=0
Initialize Service.
std::string m_evtsel
Event selector.
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given 'slot' for all subsequent calls within the same thread id.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
virtual StatusCode clearStore(size_t partitionIndex)=0
Clear an given 'slot'.
virtual StatusCode executeRun(int maxevt)
implementation of IEventProcessor::executeRun()
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
virtual StatusCode endRun()=0
End Run.
This class is used for returning status codes from appropriate routines.
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 createContext(Context *&c) const =0
Create and return a context object that will keep track of the state of selection.
StatusCode createEventContext(EventContext *&eventContext, int createdEvents)
Create event context.
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
virtual StatusCode releaseContext(Context *&) const =0
Release the Context object.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
#define DECLARE_SERVICE_FACTORY(x)
virtual StatusCode pushNewEvent(EventContext *eventContext)=0
Make an event available to the scheduler.
virtual ~HiveSlimEventLoopMgr()
Standard Destructor.
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
bool isRecoverable() const
IDataSelector * selectedObjects()
Return the set of selected DataObjects.
virtual StatusCode initialize()
implementation of IService::initialize
virtual StatusCode reinitialize()
implementation of IService::reinitialize
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual StatusCode setRoot(std::string root_name, DataObject *pObject)=0
Initialize data store for new event by giving new event path.
virtual StatusCode nextEvent(int maxevt)
implementation of IService::nextEvent
virtual StatusCode stop()
implementation of IService::stop
bool m_warnings
Flag to disable warning messages when using external input.
virtual StatusCode beginRun()=0
Begin Run.
virtual unsigned long release()=0
Release Interface instance.
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
virtual size_t allocateStore(int evtnumber)=0
Allocate a store partition for new event.
bool isValid() const
Allow for check if smart pointer is valid.
Base class used to extend a class implementing other interfaces.
virtual StatusCode tryPopFinishedEvent(EventContext *&eventContext)=0
Try to retrieve a finished event from the scheduler.
Base class for all Incidents (computing events).
SmartIF< IDataManagerSvc > m_histoDataMgrSvc
Reference to the Histogram Data Service.
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
virtual StatusCode freeStore(size_t partitionIndex)=0
Free a store partition.
std::string m_schedulerName
Name of the scheduler to be used.
std::chrono::high_resolution_clock Clock
Opaque address interface definition.
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
virtual StatusCode createAddress(const Context &c, IOpaqueAddress *&iop) const =0
Create an IOpaqueAddress object from the event fetched.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
virtual unsigned int freeSlots()=0
Get the free event processing slots.
virtual StatusCode popFinishedEvent(EventContext *&eventContext)=0
Retrieve a finished event from the scheduler.
bool m_endEventFired
Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event) ...
boost::dynamic_bitset * m_blackListBS
IEvtSelector::Context * m_evtContext
Event Iterator.