ATLAS Offline Software
AthenaHiveEventLoopMgr.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2024 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 
68 class AthenaHiveEventLoopMgr : public extends<MinimalEventLoopMgr,
69  IEventSeek, ICollectionSize, IIncidentListener>,
70  public Athena::TimeoutMaster,
71  public AthMessaging
72 {
73 public:
74  typedef IEvtSelector::Context EvtContext;
75 
76 protected:
80 
84 
86  IEvtSelector* m_evtSelector;
90  StringProperty m_evtsel;
91 
95 
99 
103 
105  StringProperty m_histPersName;
106 
111 
113  IntegerProperty m_failureMode;
114 
116  UnsignedIntegerProperty m_eventPrintoutInterval;
117 
120  typedef ToolHandleArray< tool_type > tool_store;
121  typedef tool_store::const_iterator tool_iterator;
122  typedef std::vector<unsigned int> tool_stats;
123  typedef tool_stats::const_iterator tool_stats_iterator;
124 
129 
131  void setupPreSelectTools(Gaudi::Details::PropertyBase&);
132 
135 
138 
140  virtual StatusCode writeHistograms(bool force=false);
141 
143  virtual StatusCode executeAlgorithms();
144 
147 
148 
149  //***********************************************************//
150  // for Hive
151 protected:
152 
154  SmartIF<IHiveWhiteBoard> m_whiteboard;
155 
157  SmartIF<IAlgResourcePool> m_algResourcePool;
158 
160  SmartIF<IAlgExecStateSvc> m_aess;
161 
163  SmartIF<IProperty> m_appMgrProperty;
164 
166  SmartIF<IScheduler> m_schedulerSvc;
168  StatusCode clearWBSlot(int evtSlot);
170  int declareEventRootAddress(EventContext&);
172  virtual EventContext createEventContext() override;
174  int drainScheduler(int& finishedEvents);
176  SmartIF< IIncidentListener > m_abortEventListener;
178  std::string m_schedulerName;
180  std::string m_whiteboardName;
183 
184 
185 
186 public:
188  StatusCode getEventRoot(IOpaqueAddress*& refpAddr);
189 
190 
191 
192 //***********************************************************//
193 
194 public:
196  AthenaHiveEventLoopMgr(const std::string& nam, ISvcLocator* svcLoc);
198  virtual ~AthenaHiveEventLoopMgr();
200  virtual StatusCode initialize() override;
202  virtual StatusCode finalize() override;
204  virtual StatusCode nextEvent(int maxevt) override;
206  virtual StatusCode executeEvent( EventContext&& ctx ) override;
208  virtual StatusCode executeRun(int maxevt) override;
210  virtual StatusCode stopRun() override;
212  virtual StatusCode stop() override;
213 
214 
216  virtual StatusCode seek(int evt) override;
218  virtual int curEvent() const override;
220  virtual int size() override;
222  virtual void handle(const Incident& inc) override;
223 
224  using AthMessaging::msg;
225  using AthMessaging::msgLvl;
226 
227  //FIXME hack to workaround pylcgdict problem...
228  virtual const std::string& name() const override { return Service::name(); } //FIXME
229 
230  virtual void modifyEventContext(EventContext& ctx, const EventID& eID, bool consume_modifier_stream);
231 
232 private:
236 
237  unsigned int m_nevt;
238  unsigned int m_timeStamp { 0 };
240  UnsignedIntegerProperty m_writeInterval;
242 
243  bool m_terminateLoop { false };
244 
246  unsigned int m_nev;
247  unsigned int m_proc;
251 
252  unsigned int m_flmbi, m_timeStampInt;
253 
254  // from MinimalEventLoopMgr
255 public:
256  typedef std::list<SmartIF<IAlgorithm> > ListAlg;
257  // typedef std::list<IAlgorithm*> ListAlgPtrs;
258  // typedef std::list<std::string> ListName;
259  // typedef std::vector<std::string> VectorName;
260 
261 private:
262  StoreGateSvc* eventStore() const;
263 
265 
266  // Save a copy of the last event context to use
267  // at the end of event processing.
268  EventContext m_lastEventContext;
269 };
270 
271 #endif // ATHENASERVICES_ATHENAHIVEEVENTLOOPMGR_H
AthenaHiveEventLoopMgr::m_toolReject
tool_stats m_toolReject
tool returns StatusCode::FAILURE counter
Definition: AthenaHiveEventLoopMgr.h:126
AthenaHiveEventLoopMgr::m_nevt
unsigned int m_nevt
Definition: AthenaHiveEventLoopMgr.h:237
AthenaHiveEventLoopMgr::handle
virtual void handle(const Incident &inc) override
IIncidentListenet interfaces.
Definition: AthenaHiveEventLoopMgr.cxx:855
AthenaHiveEventLoopMgr::size
virtual int size() override
Return the size of the collection.
Definition: AthenaHiveEventLoopMgr.cxx:833
AthenaHiveEventLoopMgr::m_evtSelector
IEvtSelector * m_evtSelector
Reference to the Event Selector.
Definition: AthenaHiveEventLoopMgr.h:86
AthenaHiveEventLoopMgr::m_schedulerName
std::string m_schedulerName
Name of the scheduler to be used.
Definition: AthenaHiveEventLoopMgr.h:178
AthenaHiveEventLoopMgr::m_useSecondaryEventNumber
bool m_useSecondaryEventNumber
read event number from secondary input
Definition: AthenaHiveEventLoopMgr.h:137
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:492
AthenaHiveEventLoopMgr::tool_stats
std::vector< unsigned int > tool_stats
Definition: AthenaHiveEventLoopMgr.h:122
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:128
AthenaHiveEventLoopMgr::m_incidentSvc
IIncidentSvc_t m_incidentSvc
Reference to the incident service.
Definition: AthenaHiveEventLoopMgr.h:79
AthenaHiveEventLoopMgr::initializeAlgorithms
StatusCode initializeAlgorithms()
Initialize all algorithms and output streams.
Definition: AthenaHiveEventLoopMgr.cxx:484
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:72
AthenaHiveEventLoopMgr::IConversionSvc_t
ServiceHandle< IConversionSvc > IConversionSvc_t
Definition: AthenaHiveEventLoopMgr.h:96
AthenaHiveEventLoopMgr::m_histPersName
StringProperty m_histPersName
Definition: AthenaHiveEventLoopMgr.h:105
ICollectionSize.h
Abstract interface for finding the size of an event collection.
AthenaHiveEventLoopMgr::name
virtual const std::string & name() const override
Definition: AthenaHiveEventLoopMgr.h:228
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:176
AthenaHiveEventLoopMgr::IEvtIdModifierSvc_t
ServiceHandle< IEvtIdModifierSvc > IEvtIdModifierSvc_t
Definition: AthenaHiveEventLoopMgr.h:100
AthenaHiveEventLoopMgr::IDataManagerSvc_t
ServiceHandle< IDataManagerSvc > IDataManagerSvc_t
Definition: AthenaHiveEventLoopMgr.h:92
IEvtIdModifierSvc
Definition: IEvtIdModifierSvc.h:37
AthenaHiveEventLoopMgr::operator=
AthenaHiveEventLoopMgr & operator=(const AthenaHiveEventLoopMgr &)=delete
AthenaHiveEventLoopMgr::m_eventStore
StoreGateSvc_t m_eventStore
Reference to StoreGateSvc;.
Definition: AthenaHiveEventLoopMgr.h:83
AthenaHiveEventLoopMgr::m_failureMode
IntegerProperty m_failureMode
Definition: AthenaHiveEventLoopMgr.h:113
AthenaHiveEventLoopMgr::m_timeStampInt
unsigned int m_timeStampInt
Definition: AthenaHiveEventLoopMgr.h:252
AthenaHiveEventLoopMgr::m_eventPrintoutInterval
UnsignedIntegerProperty m_eventPrintoutInterval
Definition: AthenaHiveEventLoopMgr.h:116
AthenaHiveEventLoopMgr::m_whiteboardName
std::string m_whiteboardName
Name of the Whiteboard to be used.
Definition: AthenaHiveEventLoopMgr.h:180
AthenaHiveEventLoopMgr::m_schedulerSvc
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
Definition: AthenaHiveEventLoopMgr.h:166
AthenaHiveEventLoopMgr::ListAlg
std::list< SmartIF< IAlgorithm > > ListAlg
Definition: AthenaHiveEventLoopMgr.h:256
AthenaHiveEventLoopMgr::m_proc
unsigned int m_proc
Definition: AthenaHiveEventLoopMgr.h:247
AthenaHiveEventLoopMgr::tool_type
IAthenaEvtLoopPreSelectTool tool_type
Definition: AthenaHiveEventLoopMgr.h:119
AthenaHiveEventLoopMgr::clearWBSlot
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
Definition: AthenaHiveEventLoopMgr.cxx:1304
AthenaHiveEventLoopMgr::tool_store
ToolHandleArray< tool_type > tool_store
Definition: AthenaHiveEventLoopMgr.h:120
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
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:107
AthenaHiveEventLoopMgr::m_appMgrProperty
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: AthenaHiveEventLoopMgr.h:163
AthenaHiveEventLoopMgr::m_aess
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.
Definition: AthenaHiveEventLoopMgr.h:160
AthenaHiveEventLoopMgr::m_evtIdModSvc
IEvtIdModifierSvc_t m_evtIdModSvc
Definition: AthenaHiveEventLoopMgr.h:102
AthenaHiveEventLoopMgr::tool_iterator
tool_store::const_iterator tool_iterator
Definition: AthenaHiveEventLoopMgr.h:121
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:930
EventID::number_type
EventIDBase::number_type number_type
Definition: EventID.h:37
AthenaHiveEventLoopMgr::EvtContext
IEvtSelector::Context EvtContext
Definition: AthenaHiveEventLoopMgr.h:74
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:1141
AthenaHiveEventLoopMgr::m_doEvtHeartbeat
bool m_doEvtHeartbeat
Definition: AthenaHiveEventLoopMgr.h:249
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:674
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
AthenaHiveEventLoopMgr::m_terminateLoop
bool m_terminateLoop
Definition: AthenaHiveEventLoopMgr.h:243
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:428
AthenaHiveEventLoopMgr::executeRun
virtual StatusCode executeRun(int maxevt) override
implementation of IEventProcessor::executeRun(int maxevt)
Definition: AthenaHiveEventLoopMgr.cxx:639
AthenaHiveEventLoopMgr::m_requireInputAttributeList
bool m_requireInputAttributeList
require input attribute list
Definition: AthenaHiveEventLoopMgr.h:134
AthenaHiveEventLoopMgr::drainScheduler
int drainScheduler(int &finishedEvents)
Drain the scheduler from all actions that may be queued.
Definition: AthenaHiveEventLoopMgr.cxx:1190
AthenaHiveEventLoopMgr::m_evtsel
StringProperty m_evtsel
Definition: AthenaHiveEventLoopMgr.h:90
AthenaHiveEventLoopMgr::executeEvent
virtual StatusCode executeEvent(EventContext &&ctx) override
implementation of IEventProcessor::executeEvent(void* par)
Definition: AthenaHiveEventLoopMgr.cxx:501
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthenaHiveEventLoopMgr::createEventContext
virtual EventContext createEventContext() override
Create event context.
Definition: AthenaHiveEventLoopMgr.cxx:1167
AthenaHiveEventLoopMgr::m_firstEventAlone
bool m_firstEventAlone
Definition: AthenaHiveEventLoopMgr.h:250
AthenaHiveEventLoopMgr::setupPreSelectTools
void setupPreSelectTools(Gaudi::Details::PropertyBase &)
property update handler:sets up the Pre-selection tools
Definition: AthenaHiveEventLoopMgr.cxx:327
AthenaHiveEventLoopMgr::~AthenaHiveEventLoopMgr
virtual ~AthenaHiveEventLoopMgr()
Standard Destructor.
Definition: AthenaHiveEventLoopMgr.cxx:129
AthenaHiveEventLoopMgr::initialize
virtual StatusCode initialize() override
implementation of IAppMgrUI::initalize
Definition: AthenaHiveEventLoopMgr.cxx:136
AthenaHiveEventLoopMgr::IIncidentSvc_t
ServiceHandle< IIncidentSvc > IIncidentSvc_t
Definition: AthenaHiveEventLoopMgr.h:77
AthenaHiveEventLoopMgr::AthenaHiveEventLoopMgr
AthenaHiveEventLoopMgr()=delete
Timeout.h
Timeout singleton.
AthenaHiveEventLoopMgr::m_flmbi
unsigned int m_flmbi
Definition: AthenaHiveEventLoopMgr.h:252
AthenaHiveEventLoopMgr::finalize
virtual StatusCode finalize() override
implementation of IAppMgrUI::finalize
Definition: AthenaHiveEventLoopMgr.cxx:360
AthenaHiveEventLoopMgr::m_toolInvoke
tool_stats m_toolInvoke
tool called counter
Definition: AthenaHiveEventLoopMgr.h:125
AthenaHiveEventLoopMgr::m_conditionsCleaner
ServiceHandle< Athena::IConditionsCleanerSvc > m_conditionsCleaner
Definition: AthenaHiveEventLoopMgr.h:264
AthenaHiveEventLoopMgr::m_scheduledStop
bool m_scheduledStop
Scheduled stop of event processing.
Definition: AthenaHiveEventLoopMgr.h:182
AthenaHiveEventLoopMgr::stopRun
virtual StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
Definition: AthenaHiveEventLoopMgr.cxx:659
AthMessaging.h
AthenaHiveEventLoopMgr::m_histoPersSvc
IConversionSvc_t m_histoPersSvc
Definition: AthenaHiveEventLoopMgr.h:98
AthenaHiveEventLoopMgr::tool_stats_iterator
tool_stats::const_iterator tool_stats_iterator
Definition: AthenaHiveEventLoopMgr.h:123
AthenaHiveEventLoopMgr::m_toolAccept
tool_stats m_toolAccept
tool returns StatusCode::SUCCESS counter
Definition: AthenaHiveEventLoopMgr.h:127
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:154
AthenaHiveEventLoopMgr::curEvent
virtual int curEvent() const override
Return the current event count.
Definition: AthenaHiveEventLoopMgr.cxx:825
AthenaHiveEventLoopMgr::declareEventRootAddress
int declareEventRootAddress(EventContext &)
Declare the root address of the event.
Definition: AthenaHiveEventLoopMgr.cxx:952
AthenaHiveEventLoopMgr::m_timeStamp
unsigned int m_timeStamp
Definition: AthenaHiveEventLoopMgr.h:238
AthenaHiveEventLoopMgr::m_lastEventContext
EventContext m_lastEventContext
Definition: AthenaHiveEventLoopMgr.h:268
AthenaHiveEventLoopMgr::eventStore
StoreGateSvc * eventStore() const
Definition: AthenaHiveEventLoopMgr.cxx:319
AthenaHiveEventLoopMgr::m_algResourcePool
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
Definition: AthenaHiveEventLoopMgr.h:157
AthenaHiveEventLoopMgr::m_currentRun
number_type m_currentRun
current run number
Definition: AthenaHiveEventLoopMgr.h:109
AthenaHiveEventLoopMgr::AthenaHiveEventLoopMgr
AthenaHiveEventLoopMgr(const AthenaHiveEventLoopMgr &)=delete
AthenaHiveEventLoopMgr::m_histoDataMgrSvc
IDataManagerSvc_t m_histoDataMgrSvc
Reference to the Histogram Data Service.
Definition: AthenaHiveEventLoopMgr.h:94
AthenaHiveEventLoopMgr::m_evtContext
EvtContext * m_evtContext
Gaudi event selector Context (may be used as a cursor by the evt selector)
Definition: AthenaHiveEventLoopMgr.h:88
AthenaHiveEventLoopMgr::m_nev
unsigned int m_nev
events processed
Definition: AthenaHiveEventLoopMgr.h:246
AthenaHiveEventLoopMgr::m_writeHists
bool m_writeHists
Definition: AthenaHiveEventLoopMgr.h:241
AthenaHiveEventLoopMgr::m_writeInterval
UnsignedIntegerProperty m_writeInterval
Definition: AthenaHiveEventLoopMgr.h:240
AthenaHiveEventLoopMgr::nextEvent
virtual StatusCode nextEvent(int maxevt) override
implementation of IAppMgrUI::nextEvent. maxevt==0 returns immediately
Definition: AthenaHiveEventLoopMgr.cxx:700
AthenaHiveEventLoopMgr::StoreGateSvc_t
ServiceHandle< StoreGateSvc > StoreGateSvc_t
Definition: AthenaHiveEventLoopMgr.h:81
AthenaHiveEventLoopMgr::seek
virtual StatusCode seek(int evt) override
Seek to a given event.
Definition: AthenaHiveEventLoopMgr.cxx:793
AthenaHiveEventLoopMgr::m_useTools
bool m_useTools
Definition: AthenaHiveEventLoopMgr.h:248
ServiceHandle< IIncidentSvc >
AthenaHiveEventLoopMgr::m_firstRun
bool m_firstRun
Definition: AthenaHiveEventLoopMgr.h:110