ATLAS Offline Software
PileUpEventLoopMgr.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef PILEUPEVENTLOOPMGR_H
6 #define PILEUPEVENTLOOPMGR_H
7 
12 // Base class headers
14 #include "GaudiKernel/MinimalEventLoopMgr.h"
15 
16 // Athena headers
20 #include "PileUpTools/PileUpMisc.h"
21 
22 // Gaudi headers
23 #include "Gaudi/Property.h"
24 #include "GaudiKernel/ServiceHandle.h"
25 #include "GaudiKernel/ToolHandle.h"
26 #include "GaudiKernel/IAlgExecStateSvc.h"
27 #include <string>
28 
29 // Forward declarations
30 class IBeamIntensity;
31 class IBeamLuminosity;
32 class IBkgStreamsCache;
33 class IEvtSelector;
34 class IIncidentSvc;
35 class PileUpMergeSvc;
36 class StoreGateSvc;
37 class EventContext;
38 class EventID;
39 
40 
45 class PileUpEventLoopMgr : public extends<MinimalEventLoopMgr, IEventSeek>,
46  public AthMessaging
47 {
48 public:
49 
51  PileUpEventLoopMgr(const std::string& nam, ISvcLocator* svcLoc);
53  virtual ~PileUpEventLoopMgr();
54 
55 public:
56  virtual StatusCode initialize() override;
57  virtual StatusCode finalize() override;
58  virtual StatusCode nextEvent(int maxevt) override;
59  virtual StatusCode executeEvent( EventContext &&ctx ) override;
60 
61  virtual StatusCode seek(int evt) override;
62  virtual int curEvent() const override;
63 
64  using AthMessaging::msg;
66 
67 private:
69  SmartIF<IAlgExecStateSvc> m_aess;
70 
71  void modifyEventContext(EventContext& ctx, const EventID& eID, bool consume_modifier_stream);
72 
75 
77  virtual StatusCode executeAlgorithms(const EventContext& ctx);
78 
80  inline unsigned int getBCID(int bunchXing, unsigned int centralBCID) const {
81  //FIXME to be completely safe this should should probably depend on the bunch spacing too. Perhaps that concept should be deprecated though?
82  return static_cast<unsigned int>((((bunchXing + static_cast<int>(centralBCID)) % static_cast<int>(m_maxBunchCrossingPerOrbit)) + static_cast<int>(m_maxBunchCrossingPerOrbit) ) % static_cast<int>(m_maxBunchCrossingPerOrbit));
83  }
84 
87 
90 
92  ServiceHandle<StoreGateSvc> m_evtStore; // overlaid (output) event store
93 
94  ServiceHandle<IEvtSelector> m_origSel{this, "OrigSelector", "EventSelector",
95  "EventSelector for original (physics) events stream"};
96  ServiceHandle<IEvtSelector> m_signalSel{this, "SignalSelector", "",
97  "EventSelector for signal (hard-scatter) events stream"};
98  ServiceHandle<IBeamIntensity> m_beamInt{this, "BeamInt", "FlatBM",
99  "The service providing the beam intensity distribution"};
100  ServiceHandle<IBeamLuminosity> m_beamLumi{this, "BeamLuminosity", "LumiProfileSvc",
101  "The service providing the beam luminosity distribution vs. run"};
102  ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc",
103  "PileUp Merge Service"};
104  ServiceHandle<IEvtIdModifierSvc> m_evtIdModSvc{this, "EvtIdModifierSvc", "",
105  "ServiceHandle for EvtIdModifierSvc"};
106 
107  Gaudi::Property<unsigned int> m_maxBunchCrossingPerOrbit{this, "MaxBunchCrossingPerOrbit", 3564,
108  "The number of slots in each LHC beam. Default: 3564."};
109  Gaudi::Property<float> m_xingFreq{this, "XingFrequency", 25.0,
110  "ns"};
111  Gaudi::Property<int> m_firstXing{this, "firstXing", -2,
112  "time of first xing / XingFrequency (0th xing is 1st after trigger)"};
113  Gaudi::Property<int> m_lastXing{this, "lastXing", 1,
114  "time of last xing / XingFrequency (0th xing is 1st after trigger)"};
115  Gaudi::Property<float> m_maxCollPerXing{this, "MaxMinBiasCollPerXing", 23.0,
116  "Set to digitization numberOfCollisions prop. for variable-mu and RunDMC jobs."};
117  ToolHandleArray<IBkgStreamsCache> m_caches{this, "bkgCaches", {},
118  "list of tools managing bkg events"};
119  Gaudi::Property<bool> m_allowSubEvtsEOF{this, "AllowSubEvtsEOF", true,
120  "if true(default) an EOF condition in the BkgStreamsCaches is not considered "
121  "to be an error IF maxevt=-1 (loop over all available events)"};
122  Gaudi::Property<bool> m_xingByXing{this, "XingByXing", false,
123  "if set to true we will not cache bkg events from one xing to then next. "
124  "This greatly increases the amount of I/O and greatly reduces the memory required to run a job"};
125  Gaudi::Property<int> m_failureMode{this, "FailureMode", 1,
126  "Controls behaviour of event loop depending on return code of"
127  " Algorithms. 0: all non-SUCCESSes terminate job. "
128  "1: RECOVERABLE skips to next event, FAILURE terminates job "
129  "(DEFAULT). 2: RECOVERABLE and FAILURE skip to next events"};
130  Gaudi::Property<bool> m_allowSerialAndMPToDiffer{this, "AllowSerialAndMPToDiffer", true,
131  "When set to False, this will allow the code to reproduce serial output in an "
132  "AthenaMP job, albeit with a significant performance penalty."};
133  Gaudi::Property<std::string> m_evinfName{this, "EventInfoName", c_pileUpEventInfoObjName,
134  "SG key for the EventInfo object"};
135  Gaudi::Property<std::string> m_evinfContName{this, "EventInfoContName", c_pileUpEventInfoContName,
136  "SG key for the EventInfoContainer object"};
137  Gaudi::Property<uint32_t> m_mcChannelNumber{ this, "MCChannelNumber", 0,
138  "sample MC channel number" };
139 
142  bool m_firstRun{true};
143 
144  int m_nevt{0};
145  int m_ncurevt{0};
146  bool m_skipExecAlgs{false};
147  bool m_loadProxies{true};
148 
149 };
150 #endif // PILEUPTOOLS_PILEUPEVENTLOOPMGR_H
c_pileUpEventInfoContName
const std::string c_pileUpEventInfoContName
default value for the EventInfoContainer storing subevents for PileUp
Definition: PileUpMisc.h:15
IBkgStreamsCache
Interface to in-memory cache for pileup events.
Definition: IBkgStreamsCache.h:24
PileUpEventLoopMgr::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Incident Service.
Definition: PileUpEventLoopMgr.h:86
PileUpEventLoopMgr::executeEvent
virtual StatusCode executeEvent(EventContext &&ctx) override
Definition: PileUpEventLoopMgr.cxx:580
IEventSeek.h
Abstract interface for seeking within an event stream.
PileUpEventLoopMgr::~PileUpEventLoopMgr
virtual ~PileUpEventLoopMgr()
Standard Destructor.
Definition: PileUpEventLoopMgr.cxx:59
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
PileUpEventLoopMgr::curEvent
virtual int curEvent() const override
Definition: PileUpEventLoopMgr.cxx:514
PileUpEventLoopMgr::m_allowSerialAndMPToDiffer
Gaudi::Property< bool > m_allowSerialAndMPToDiffer
Definition: PileUpEventLoopMgr.h:130
PileUpEventLoopMgr::m_signalSel
ServiceHandle< IEvtSelector > m_signalSel
Definition: PileUpEventLoopMgr.h:96
PileUpEventLoopMgr::m_origSel
ServiceHandle< IEvtSelector > m_origSel
Definition: PileUpEventLoopMgr.h:94
PileUpEventLoopMgr
The ATLAS event loop for pile-up applications.
Definition: PileUpEventLoopMgr.h:47
PileUpEventLoopMgr::m_xingFreq
Gaudi::Property< float > m_xingFreq
Definition: PileUpEventLoopMgr.h:109
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
PileUpEventLoopMgr::m_skipExecAlgs
bool m_skipExecAlgs
Definition: PileUpEventLoopMgr.h:146
PileUpEventLoopMgr::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
output store
Definition: PileUpEventLoopMgr.h:92
PileUpEventLoopMgr::m_evinfName
Gaudi::Property< std::string > m_evinfName
Definition: PileUpEventLoopMgr.h:133
PileUpEventLoopMgr::executeAlgorithms
virtual StatusCode executeAlgorithms(const EventContext &ctx)
Run the algorithms for the current event.
Definition: PileUpEventLoopMgr.cxx:555
PileUpEventLoopMgr::m_origStream
PileUpStream m_origStream
Input Stream.
Definition: PileUpEventLoopMgr.h:89
PileUpMergeSvc
the preferred mechanism to access information from the different event stores in a pileup job.
Definition: PileUpMergeSvc.h:56
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:120
IEvtIdModifierSvc.h
PileUpEventLoopMgr::m_ncurevt
int m_ncurevt
Definition: PileUpEventLoopMgr.h:145
PileUpEventLoopMgr::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: PileUpEventLoopMgr.h:102
AthMessaging::msgLvl
bool msgLvl(const MSG::Level lvl) const
Test the output level.
Definition: AthMessaging.h:151
PileUpEventLoopMgr::m_allowSubEvtsEOF
Gaudi::Property< bool > m_allowSubEvtsEOF
Definition: PileUpEventLoopMgr.h:119
PileUpEventLoopMgr::PileUpEventLoopMgr
PileUpEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
Definition: PileUpEventLoopMgr.cxx:46
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PileUpEventLoopMgr::seek
virtual StatusCode seek(int evt) override
Definition: PileUpEventLoopMgr.cxx:493
PileUpEventLoopMgr::m_evtIdModSvc
ServiceHandle< IEvtIdModifierSvc > m_evtIdModSvc
Definition: PileUpEventLoopMgr.h:104
PileUpEventLoopMgr::m_beamInt
ServiceHandle< IBeamIntensity > m_beamInt
Definition: PileUpEventLoopMgr.h:98
PileUpEventLoopMgr::m_nevt
int m_nevt
Definition: PileUpEventLoopMgr.h:144
PileUpEventLoopMgr::nextEvent
virtual StatusCode nextEvent(int maxevt) override
Definition: PileUpEventLoopMgr.cxx:195
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
PileUpStream
a triple selector/context/store defines a stream
Definition: PileUpStream.h:32
PileUpEventLoopMgr::m_evinfContName
Gaudi::Property< std::string > m_evinfContName
Definition: PileUpEventLoopMgr.h:135
PileUpEventLoopMgr::setupStreams
StatusCode setupStreams()
setup input and overlay selectors and iters
Definition: PileUpEventLoopMgr.cxx:523
PileUpEventLoopMgr::m_mcChannelNumber
Gaudi::Property< uint32_t > m_mcChannelNumber
Definition: PileUpEventLoopMgr.h:137
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
PileUpEventLoopMgr::m_firstXing
Gaudi::Property< int > m_firstXing
Definition: PileUpEventLoopMgr.h:111
PileUpEventLoopMgr::getBCID
unsigned int getBCID(int bunchXing, unsigned int centralBCID) const
return the 'fake BCID' corresponding to bunchXing
Definition: PileUpEventLoopMgr.h:80
PileUpEventLoopMgr::m_maxCollPerXing
Gaudi::Property< float > m_maxCollPerXing
Definition: PileUpEventLoopMgr.h:115
PileUpEventLoopMgr::m_firstRun
bool m_firstRun
Definition: PileUpEventLoopMgr.h:142
PileUpEventLoopMgr::m_maxBunchCrossingPerOrbit
Gaudi::Property< unsigned int > m_maxBunchCrossingPerOrbit
Definition: PileUpEventLoopMgr.h:107
PileUpEventLoopMgr::finalize
virtual StatusCode finalize() override
Definition: PileUpEventLoopMgr.cxx:138
PileUpEventLoopMgr::m_caches
ToolHandleArray< IBkgStreamsCache > m_caches
Definition: PileUpEventLoopMgr.h:117
PileUpEventLoopMgr::initialize
virtual StatusCode initialize() override
Definition: PileUpEventLoopMgr.cxx:64
IBeamLuminosity
Definition: IBeamLuminosity.h:17
PileUpEventLoopMgr::m_xingByXing
Gaudi::Property< bool > m_xingByXing
Definition: PileUpEventLoopMgr.h:122
c_pileUpEventInfoObjName
const std::string c_pileUpEventInfoObjName
default value for the EventInfoContainer storing subevents for PileUp
Definition: PileUpMisc.h:12
PileUpEventLoopMgr::m_currentRun
uint32_t m_currentRun
current run number
Definition: PileUpEventLoopMgr.h:141
AthMessaging.h
PileUpEventLoopMgr::m_aess
SmartIF< IAlgExecStateSvc > m_aess
Reference to the Algorithm Execution State Svc.
Definition: PileUpEventLoopMgr.h:69
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
PileUpMisc.h
PileUpEventLoopMgr::m_lastXing
Gaudi::Property< int > m_lastXing
Definition: PileUpEventLoopMgr.h:113
PileUpStream.h
a triple selector/context/store defines a stream
IBeamIntensity
Definition: IBeamIntensity.h:17
PileUpEventLoopMgr::m_failureMode
Gaudi::Property< int > m_failureMode
Definition: PileUpEventLoopMgr.h:125
PileUpEventLoopMgr::modifyEventContext
void modifyEventContext(EventContext &ctx, const EventID &eID, bool consume_modifier_stream)
Definition: PileUpEventLoopMgr.cxx:168
PileUpEventLoopMgr::m_beamLumi
ServiceHandle< IBeamLuminosity > m_beamLumi
Definition: PileUpEventLoopMgr.h:100
PileUpEventLoopMgr::m_loadProxies
bool m_loadProxies
Definition: PileUpEventLoopMgr.h:147
ServiceHandle< IIncidentSvc >