ATLAS Offline Software
AthenaHiveEventLoopMgr.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef ATHENASERVICES_ATHENAHIVEEVENTLOOPMGR_H
8 #define ATHENASERVICES_ATHENAHIVEEVENTLOOPMGR_H
9 
14 // Base class headers
17 #include "GaudiKernel/IIncidentListener.h"
18 #include "AthenaKernel/Timeout.h"
19 #include "GaudiKernel/MinimalEventLoopMgr.h"
20 
21 // Athena headers
25 #ifndef EVENTINFO_EVENTID_H
26 # include "EventInfo/EventID.h" /* number_type */
27 #endif
28 
29 
30 // Gaudi headers
31 #include "Gaudi/Property.h"
32 #include "GaudiKernel/ServiceHandle.h"
33 #include "GaudiKernel/ToolHandle.h"
34 #include "GaudiKernel/IAlgResourcePool.h"
35 #include "GaudiKernel/IEvtSelector.h"
36 #include "GaudiKernel/IHiveWhiteBoard.h"
37 #include "GaudiKernel/IScheduler.h"
38 #include "GaudiKernel/IAlgExecStateSvc.h"
39 
40 // Standard includes
41 #include <functional>
42 #include <string>
43 #include <vector>
44 
45 // External Libraries
46 #include "tbb/concurrent_queue.h"
48 
49 // Forward declarations
50 class IConversionSvc;
51 struct IDataManagerSvc;
52 class IDataProviderSvc;
53 class IIncidentSvc;
54 class StoreGateSvc;
55 class ISvcLocator;
56 class IEvtIdModifierSvc;
57 
69  : virtual public IEventSeek,
70  virtual public ICollectionSize,
71  virtual public IIncidentListener,
72  public MinimalEventLoopMgr,
73  public Athena::TimeoutMaster,
74  public AthMessaging
75 {
76 public:
77  typedef IEvtSelector::Context EvtContext;
78 
79 protected:
83 
87 
89  IEvtSelector* m_evtSelector;
93  StringProperty m_evtsel;
94 
98 
102 
106 
108  StringProperty m_histPersName;
109 
114 
116  IntegerProperty m_failureMode;
117 
119  UnsignedIntegerProperty m_eventPrintoutInterval;
120 
123  typedef ToolHandleArray< tool_type > tool_store;
124  typedef tool_store::const_iterator tool_iterator;
125  typedef std::vector<unsigned int> tool_stats;
126  typedef tool_stats::const_iterator tool_stats_iterator;
127 
132 
134  void setupPreSelectTools(Gaudi::Details::PropertyBase&);
135 
138 
141 
143  virtual StatusCode writeHistograms(bool force=false);
144 
146  virtual StatusCode executeAlgorithms();
147 
150 
151 
152  //***********************************************************//
153  // for Hive
154 protected:
155 
157  SmartIF<IHiveWhiteBoard> m_whiteboard;
158 
160  SmartIF<IAlgResourcePool> m_algResourcePool;
161 
163  SmartIF<IAlgExecStateSvc> m_aess;
164 
166  SmartIF<IProperty> m_appMgrProperty;
167 
169  SmartIF<IScheduler> m_schedulerSvc;
171  StatusCode clearWBSlot(int evtSlot);
173  int declareEventRootAddress(EventContext&);
175  virtual EventContext createEventContext() override;
177  int drainScheduler(int& finishedEvents);
179  SmartIF< IIncidentListener > m_abortEventListener;
181  std::string m_schedulerName;
183  std::string m_whiteboardName;
186 
187 
188 
189 public:
191  StatusCode getEventRoot(IOpaqueAddress*& refpAddr);
192 
193 
194 
195 //***********************************************************//
196 
197 public:
199  AthenaHiveEventLoopMgr(const std::string& nam, ISvcLocator* svcLoc);
201  virtual ~AthenaHiveEventLoopMgr();
203  virtual StatusCode initialize() override;
205  virtual StatusCode finalize() override;
207  virtual StatusCode nextEvent(int maxevt) override;
209  virtual StatusCode executeEvent( EventContext&& ctx ) override;
211  virtual StatusCode executeRun(int maxevt) override;
213  virtual StatusCode stopRun() override;
215  virtual StatusCode stop() override;
216 
217 
219  virtual StatusCode seek(int evt) override;
221  virtual int curEvent() const override;
223  virtual int size() override;
225  virtual void handle(const Incident& inc) override;
226 
228  virtual StatusCode queryInterface( const InterfaceID& riid,
229  void** ppvInterface ) override;
230 
231  using AthMessaging::msg;
232  using AthMessaging::msgLvl;
233 
234  //FIXME hack to workaround pylcgdict problem...
235  virtual const std::string& name() const override { return Service::name(); } //FIXME
236 
237  virtual void modifyEventContext(EventContext& ctx, const EventID& eID, bool consume_modifier_stream);
238 
239 private:
243 
244  unsigned int m_nevt;
245  unsigned int m_timeStamp { 0 };
247  UnsignedIntegerProperty m_writeInterval;
249 
250  bool m_terminateLoop { false };
251 
253  unsigned int m_nev;
254  unsigned int m_proc;
258 
259  unsigned int m_flmbi, m_timeStampInt;
260 
261  // from MinimalEventLoopMgr
262 public:
263  typedef std::list<SmartIF<IAlgorithm> > ListAlg;
264  // typedef std::list<IAlgorithm*> ListAlgPtrs;
265  // typedef std::list<std::string> ListName;
266  // typedef std::vector<std::string> VectorName;
267 
268 private:
269  StoreGateSvc* eventStore() const;
270 
272 
273  // Save a copy of the last event context to use
274  // at the end of event processing.
275  EventContext m_lastEventContext;
276 };
277 
278 #endif // ATHENASERVICES_ATHENAHIVEEVENTLOOPMGR_H
AthenaHiveEventLoopMgr::m_toolReject
tool_stats m_toolReject
tool returns StatusCode::FAILURE counter
Definition: AthenaHiveEventLoopMgr.h:129
AthenaHiveEventLoopMgr::m_nevt
unsigned int m_nevt
Definition: AthenaHiveEventLoopMgr.h:244
AthenaHiveEventLoopMgr::handle
virtual void handle(const Incident &inc) override
IIncidentListenet interfaces.
Definition: AthenaHiveEventLoopMgr.cxx:858
AthenaHiveEventLoopMgr::size
virtual int size() override
Return the size of the collection.
Definition: AthenaHiveEventLoopMgr.cxx:836
AthenaHiveEventLoopMgr::m_evtSelector
IEvtSelector * m_evtSelector
Reference to the Event Selector.
Definition: AthenaHiveEventLoopMgr.h:89
AthenaHiveEventLoopMgr::m_schedulerName
std::string m_schedulerName
Name of the scheduler to be used.
Definition: AthenaHiveEventLoopMgr.h:181
AthenaHiveEventLoopMgr::m_useSecondaryEventNumber
bool m_useSecondaryEventNumber
read event number from secondary input
Definition: AthenaHiveEventLoopMgr.h:140
IConditionsCleanerSvc.h
Interface for doing garbage collection of conditions objects.
AthenaHiveEventLoopMgr::executeAlgorithms
virtual StatusCode executeAlgorithms()
Run the algorithms for the current event.
Definition: AthenaHiveEventLoopMgr.cxx:495
AthenaHiveEventLoopMgr::tool_stats
std::vector< unsigned int > tool_stats
Definition: AthenaHiveEventLoopMgr.h:125
calibdata.force
bool force
Definition: calibdata.py:19
IEventSeek.h
Abstract interface for seeking within an event stream.
AthenaHiveEventLoopMgr::m_tools
tool_store m_tools
internal tool store
Definition: AthenaHiveEventLoopMgr.h:131
AthenaHiveEventLoopMgr::m_incidentSvc
IIncidentSvc_t m_incidentSvc
Reference to the incident service.
Definition: AthenaHiveEventLoopMgr.h:82
AthenaHiveEventLoopMgr::initializeAlgorithms
StatusCode initializeAlgorithms()
Initialize all algorithms and output streams.
Definition: AthenaHiveEventLoopMgr.cxx:487
IAthenaEvtLoopPreSelectTool
This class provides the interface for AthenaEvtLoopPreSelectTool classes used by AthenaEventLoopMgr.
Definition: IAthenaEvtLoopPreSelectTool.h:22
AthenaHiveEventLoopMgr
The default ATLAS batch event loop manager.
Definition: AthenaHiveEventLoopMgr.h:75
AthenaHiveEventLoopMgr::IConversionSvc_t
ServiceHandle< IConversionSvc > IConversionSvc_t
Definition: AthenaHiveEventLoopMgr.h:99
AthenaHiveEventLoopMgr::m_histPersName
StringProperty m_histPersName
Definition: AthenaHiveEventLoopMgr.h:108
ICollectionSize.h
Abstract interface for finding the size of an event collection.
AthenaHiveEventLoopMgr::name
virtual const std::string & name() const override
Definition: AthenaHiveEventLoopMgr.h:235
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
AthenaHiveEventLoopMgr::m_abortEventListener
SmartIF< IIncidentListener > m_abortEventListener
Instance of the incident listener waiting for AbortEvent.
Definition: AthenaHiveEventLoopMgr.h:179
AthenaHiveEventLoopMgr::IEvtIdModifierSvc_t
ServiceHandle< IEvtIdModifierSvc > IEvtIdModifierSvc_t
Definition: AthenaHiveEventLoopMgr.h:103
AthenaHiveEventLoopMgr::IDataManagerSvc_t
ServiceHandle< IDataManagerSvc > IDataManagerSvc_t
Definition: AthenaHiveEventLoopMgr.h:95
IEvtIdModifierSvc
Definition: IEvtIdModifierSvc.h:37
AthenaHiveEventLoopMgr::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
interface dispatcher
Definition: AthenaHiveEventLoopMgr.cxx:936
AthenaHiveEventLoopMgr::operator=
AthenaHiveEventLoopMgr & operator=(const AthenaHiveEventLoopMgr &)=delete
AthenaHiveEventLoopMgr::m_eventStore
StoreGateSvc_t m_eventStore
Reference to StoreGateSvc;.
Definition: AthenaHiveEventLoopMgr.h:86
AthenaHiveEventLoopMgr::m_failureMode
IntegerProperty m_failureMode
Definition: AthenaHiveEventLoopMgr.h:116
AthenaHiveEventLoopMgr::m_timeStampInt
unsigned int m_timeStampInt
Definition: AthenaHiveEventLoopMgr.h:259
AthenaHiveEventLoopMgr::m_eventPrintoutInterval
UnsignedIntegerProperty m_eventPrintoutInterval
Definition: AthenaHiveEventLoopMgr.h:119
AthenaHiveEventLoopMgr::m_whiteboardName
std::string m_whiteboardName
Name of the Whiteboard to be used.
Definition: AthenaHiveEventLoopMgr.h:183
AthenaHiveEventLoopMgr::m_schedulerSvc
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
Definition: AthenaHiveEventLoopMgr.h:169
AthenaHiveEventLoopMgr::ListAlg
std::list< SmartIF< IAlgorithm > > ListAlg
Definition: AthenaHiveEventLoopMgr.h:263
AthenaHiveEventLoopMgr::m_proc
unsigned int m_proc
Definition: AthenaHiveEventLoopMgr.h:254
AthenaHiveEventLoopMgr::tool_type
IAthenaEvtLoopPreSelectTool tool_type
Definition: AthenaHiveEventLoopMgr.h:122
AthenaHiveEventLoopMgr::clearWBSlot
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
Definition: AthenaHiveEventLoopMgr.cxx:1336
AthenaHiveEventLoopMgr::tool_store
ToolHandleArray< tool_type > tool_store
Definition: AthenaHiveEventLoopMgr.h:123
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
EventID.h
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
AthenaHiveEventLoopMgr::number_type
EventID::number_type number_type
Definition: AthenaHiveEventLoopMgr.h:110
AthenaHiveEventLoopMgr::m_appMgrProperty
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: AthenaHiveEventLoopMgr.h:166
AthenaHiveEventLoopMgr::m_aess
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.
Definition: AthenaHiveEventLoopMgr.h:163
AthenaHiveEventLoopMgr::m_evtIdModSvc
IEvtIdModifierSvc_t m_evtIdModSvc
Definition: AthenaHiveEventLoopMgr.h:105
AthenaHiveEventLoopMgr::tool_iterator
tool_store::const_iterator tool_iterator
Definition: AthenaHiveEventLoopMgr.h:124
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition: AthMessaging.h:151
AthenaHiveEventLoopMgr::getEventRoot
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
Definition: AthenaHiveEventLoopMgr.cxx:958
EventID::number_type
EventIDBase::number_type number_type
Definition: EventID.h:37
AthenaHiveEventLoopMgr::EvtContext
IEvtSelector::Context EvtContext
Definition: AthenaHiveEventLoopMgr.h:77
Athena::TimeoutMaster
Class to modify timeout flag.
Definition: Timeout.h:77
AthenaHiveEventLoopMgr::modifyEventContext
virtual void modifyEventContext(EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
Definition: AthenaHiveEventLoopMgr.cxx:1166
AthenaHiveEventLoopMgr::m_doEvtHeartbeat
bool m_doEvtHeartbeat
Definition: AthenaHiveEventLoopMgr.h:256
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthenaHiveEventLoopMgr::stop
virtual StatusCode stop() override
implementation of IService::stop
Definition: AthenaHiveEventLoopMgr.cxx:677
IAthenaEvtLoopPreSelectTool.h
This file contains the class definition for the IAthenaEvtLoopPreSelectTool class.
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
ICollectionSize
Abstract interface for finding the size of an event collection.
Definition: ICollectionSize.h:31
AthenaHiveEventLoopMgr::m_terminateLoop
bool m_terminateLoop
Definition: AthenaHiveEventLoopMgr.h:250
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
AthenaHiveEventLoopMgr::writeHistograms
virtual StatusCode writeHistograms(bool force=false)
Dump out histograms as needed.
Definition: AthenaHiveEventLoopMgr.cxx:431
AthenaHiveEventLoopMgr::executeRun
virtual StatusCode executeRun(int maxevt) override
implementation of IEventProcessor::executeRun(int maxevt)
Definition: AthenaHiveEventLoopMgr.cxx:642
AthenaHiveEventLoopMgr::m_requireInputAttributeList
bool m_requireInputAttributeList
require input attribute list
Definition: AthenaHiveEventLoopMgr.h:137
AthenaHiveEventLoopMgr::drainScheduler
int drainScheduler(int &finishedEvents)
Drain the scheduler from all actions that may be queued.
Definition: AthenaHiveEventLoopMgr.cxx:1215
AthenaHiveEventLoopMgr::m_evtsel
StringProperty m_evtsel
Definition: AthenaHiveEventLoopMgr.h:93
AthenaHiveEventLoopMgr::executeEvent
virtual StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void* par)
Definition: AthenaHiveEventLoopMgr.cxx:504
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AthenaHiveEventLoopMgr::createEventContext
virtual EventContext createEventContext() override
Create event context.
Definition: AthenaHiveEventLoopMgr.cxx:1192
AthenaHiveEventLoopMgr::m_firstEventAlone
bool m_firstEventAlone
Definition: AthenaHiveEventLoopMgr.h:257
AthenaHiveEventLoopMgr::setupPreSelectTools
void setupPreSelectTools(Gaudi::Details::PropertyBase &)
property update handler:sets up the Pre-selection tools
Definition: AthenaHiveEventLoopMgr.cxx:330
AthenaHiveEventLoopMgr::~AthenaHiveEventLoopMgr
virtual ~AthenaHiveEventLoopMgr()
Standard Destructor.
Definition: AthenaHiveEventLoopMgr.cxx:126
AthenaHiveEventLoopMgr::initialize
virtual StatusCode initialize() override
implementation of IAppMgrUI::initalize
Definition: AthenaHiveEventLoopMgr.cxx:133
AthenaHiveEventLoopMgr::IIncidentSvc_t
ServiceHandle< IIncidentSvc > IIncidentSvc_t
Definition: AthenaHiveEventLoopMgr.h:80
AthenaHiveEventLoopMgr::AthenaHiveEventLoopMgr
AthenaHiveEventLoopMgr()=delete
Timeout.h
Timeout singleton.
AthenaHiveEventLoopMgr::m_flmbi
unsigned int m_flmbi
Definition: AthenaHiveEventLoopMgr.h:259
AthenaHiveEventLoopMgr::finalize
virtual StatusCode finalize() override
implementation of IAppMgrUI::finalize
Definition: AthenaHiveEventLoopMgr.cxx:363
AthenaHiveEventLoopMgr::m_toolInvoke
tool_stats m_toolInvoke
tool called counter
Definition: AthenaHiveEventLoopMgr.h:128
AthenaHiveEventLoopMgr::m_conditionsCleaner
ServiceHandle< Athena::IConditionsCleanerSvc > m_conditionsCleaner
Definition: AthenaHiveEventLoopMgr.h:271
AthenaHiveEventLoopMgr::m_scheduledStop
bool m_scheduledStop
Scheduled stop of event processing.
Definition: AthenaHiveEventLoopMgr.h:185
AthenaHiveEventLoopMgr::stopRun
virtual StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
Definition: AthenaHiveEventLoopMgr.cxx:662
AthMessaging.h
AthenaHiveEventLoopMgr::m_histoPersSvc
IConversionSvc_t m_histoPersSvc
Definition: AthenaHiveEventLoopMgr.h:101
AthenaHiveEventLoopMgr::tool_stats_iterator
tool_stats::const_iterator tool_stats_iterator
Definition: AthenaHiveEventLoopMgr.h:126
AthenaHiveEventLoopMgr::m_toolAccept
tool_stats m_toolAccept
tool returns StatusCode::SUCCESS counter
Definition: AthenaHiveEventLoopMgr.h:130
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
AthenaHiveEventLoopMgr::m_whiteboard
SmartIF< IHiveWhiteBoard > m_whiteboard
Reference to the Whiteboard interface.
Definition: AthenaHiveEventLoopMgr.h:157
AthenaHiveEventLoopMgr::curEvent
virtual int curEvent() const override
Return the current event count.
Definition: AthenaHiveEventLoopMgr.cxx:828
AthenaHiveEventLoopMgr::declareEventRootAddress
int declareEventRootAddress(EventContext &)
Declare the root address of the event.
Definition: AthenaHiveEventLoopMgr.cxx:980
IEventSeek
Abstract interface for seeking within an event stream.
Definition: IEventSeek.h:27
AthenaHiveEventLoopMgr::m_timeStamp
unsigned int m_timeStamp
Definition: AthenaHiveEventLoopMgr.h:245
AthenaHiveEventLoopMgr::m_lastEventContext
EventContext m_lastEventContext
Definition: AthenaHiveEventLoopMgr.h:275
AthenaHiveEventLoopMgr::eventStore
StoreGateSvc * eventStore() const
Definition: AthenaHiveEventLoopMgr.cxx:322
AthenaHiveEventLoopMgr::m_algResourcePool
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
Definition: AthenaHiveEventLoopMgr.h:160
AthenaHiveEventLoopMgr::m_currentRun
number_type m_currentRun
current run number
Definition: AthenaHiveEventLoopMgr.h:112
AthenaHiveEventLoopMgr::AthenaHiveEventLoopMgr
AthenaHiveEventLoopMgr(const AthenaHiveEventLoopMgr &)=delete
AthenaHiveEventLoopMgr::m_histoDataMgrSvc
IDataManagerSvc_t m_histoDataMgrSvc
Reference to the Histogram Data Service.
Definition: AthenaHiveEventLoopMgr.h:97
AthenaHiveEventLoopMgr::m_evtContext
EvtContext * m_evtContext
Gaudi event selector Context (may be used as a cursor by the evt selector)
Definition: AthenaHiveEventLoopMgr.h:91
AthenaHiveEventLoopMgr::m_nev
unsigned int m_nev
events processed
Definition: AthenaHiveEventLoopMgr.h:253
AthenaHiveEventLoopMgr::m_writeHists
bool m_writeHists
Definition: AthenaHiveEventLoopMgr.h:248
AthenaHiveEventLoopMgr::m_writeInterval
UnsignedIntegerProperty m_writeInterval
Definition: AthenaHiveEventLoopMgr.h:247
AthenaHiveEventLoopMgr::nextEvent
virtual StatusCode nextEvent(int maxevt) override
implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately
Definition: AthenaHiveEventLoopMgr.cxx:703
AthenaHiveEventLoopMgr::StoreGateSvc_t
ServiceHandle< StoreGateSvc > StoreGateSvc_t
Definition: AthenaHiveEventLoopMgr.h:84
AthenaHiveEventLoopMgr::seek
virtual StatusCode seek(int evt) override
Seek to a given event.
Definition: AthenaHiveEventLoopMgr.cxx:796
AthenaHiveEventLoopMgr::m_useTools
bool m_useTools
Definition: AthenaHiveEventLoopMgr.h:255
ServiceHandle< IIncidentSvc >
AthenaHiveEventLoopMgr::m_firstRun
bool m_firstRun
Definition: AthenaHiveEventLoopMgr.h:113