ATLAS Offline Software
Loading...
Searching...
No Matches
BkgStreamsCache.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 PILEUPTOOLS_BKGSTREAMSCACHE_H
6# define PILEUPTOOLS_BKGSTREAMSCACHE_H
12
13#include <string>
14#include <vector>
15#include <functional>
16
19#include "GaudiKernel/ServiceHandle.h"
20#include "Gaudi/Property.h"
23
24class IEvtSelector;
25class IBeamIntensity;
26namespace CLHEP {
27 class RandFlat;
28 class RandPoisson;
29}
30
31
36 public extends<AthAlgTool, IBkgStreamsCache>
37{
38public:
39 BkgStreamsCache( const std::string&, const std::string&, const IInterface*);
40 virtual ~BkgStreamsCache();
41
42 virtual StatusCode initialize() override final;
43 virtual StatusCode finalize() override final;
48 virtual StatusCode setup(int firstXing,
49 unsigned int nXings,
50 unsigned int firstStore,
51 IBeamIntensity*) override final;
53 virtual void newEvent() override final;
55 virtual void resetEvtsPerXingScaleFactor(float sf) override final;
62 virtual StatusCode addSubEvts(unsigned int iXing,
63 xAOD::EventInfo* overlaidEvent,
64 int t0BinCenter) override final;
73 virtual StatusCode addSubEvts(unsigned int iXing,
74 xAOD::EventInfo* overEvent,
75 int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/) override final;
77 virtual unsigned int nStores() const override final { return m_nStores; }
78
80 long collXing() { return m_collXing; }
81 long collXingPoisson();
83 unsigned int numberOfBkgForBunchCrossingIgnoringBeamIntensity(unsigned int iXing) const;
84 unsigned int numberOfBkgForBunchCrossingDefaultImpl(unsigned int iXing) const;
85 unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const;
86private:
88 const xAOD::EventInfo* nextEvent(bool isCentralBunchCrossing);
90 StatusCode nextEvent_passive(bool isCentralBunchCrossing);
93
94 unsigned int setNEvtsXing(unsigned int iXing);
95 unsigned int nEvtsXing(unsigned int iXing) const;
96
97 typedef std::vector<PileUpStream> StreamVector;
98 bool alreadyInUse(StreamVector::size_type iStream);
99 StreamVector::iterator m_cursor{};
101 std::vector<bool> m_usedStreams;
102 unsigned int m_nXings{0};
103 unsigned int m_nStores{0};
104 std::vector<unsigned int> m_nEvtsXing;
105
106 ServiceHandle<IEvtSelector> m_selecName{this, "EventSelector", "FakeEventSelector"};
107
108 ServiceHandle<IAtRndmGenSvc> m_atRndmSvc{this, "RndmGenSvc", "AtRndmGenSvc",
109 "IAtRndmGenSvc controlling the distribution of bkg events/xing"};
110
111 Gaudi::Property<float> m_collXing{this, "CollPerXing", 23.0,
112 "(average) number of collisions per beam crossing"};
113
114 Gaudi::Property<float> m_occupationFraction{this, "OccupationFraction", 1.0,
115 "The maximum fraction of bunch-crossings which will be occupied."};
116
117 Gaudi::Property<std::string> m_collDistrName{this, "CollDistribution", "Poisson",
118 "nEvts/Xings can be either Fixed at CollPerXing or Poisson with average CollPerXing"};
119
120 Gaudi::Property<float> m_readDownscale{this, "ReadDownscaleFactor", 150,
121 "read one event every downscaleFactor accesses (asymptotically -> number of times "
122 "an event in the cache will be reused)"};
123
124 Gaudi::Property<std::string> m_randomStreamName{this, "RndmStreamName", "PileUpCollXingStream",
125 "IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one "};
126
127 Gaudi::CheckedProperty<unsigned short> m_pileUpEventTypeProp{this, "PileUpEventType", 0,
129 "Type of the pileup events in this cache: 0:Signal, 1:MinimumBias, 2:Cavern, 3:HaloGas, "
130 "4:ZeroBias. Default=0 (Signal, Invalid)"};
131 void PileUpEventTypeHandler(Gaudi::Details::PropertyBase&);
132
133 Gaudi::Property<unsigned short> m_subtractBC0{this, "SubtractBC0", 0,
134 "reduce the number of events at bunch xing t=0 by m_subtractBC0. Default=0, set to 1 when "
135 "using the same type of events (e.g. minbias) for original and background streams"};
136
137 Gaudi::Property<bool> m_ignoreBM{this, "IgnoreBeamInt", false,
138 "Default=False, set to True to ignore the PileUpEventLoopMgr beam intensity "
139 "tool in setting the number of events per xing."};
140
141 Gaudi::Property<bool> m_ignoreSF{this, "IgnoreBeamLumi", false,
142 "Default=False, set to True to ignore the PileUpEventLoopMgr beam luminosity "
143 "tool in setting the number of events per xing."};
144
145 Gaudi::Property<bool> m_forceReadForBC0{this, "ForceReadForBC0", true,
146 "Force events used in the central bunch crossing to be refreshed"};
147
151 CLHEP::RandFlat* m_readEventRand{nullptr};
153 CLHEP::RandFlat* m_chooseEventRand{nullptr};
155 CLHEP::RandPoisson* m_collXingPoisson{nullptr};
158 std::function< long() > m_f_collDistr;
161 std::function< unsigned int(unsigned int) > m_f_numberOfBackgroundForBunchCrossing;
163 float m_collXingSF{1.0};
165 int m_zeroXing{-1};
168
169};
170
171#endif // PILEUPTOOLS_BKGSTREAMSCACHE_H
Interface to in-memory cache for pileup events.
a triple selector/context/store defines a stream
Gaudi::Property< unsigned short > m_subtractBC0
unsigned int numberOfBkgForBunchCrossingIgnoringBeamIntensity(unsigned int iXing) const
meant to be used via m_f_numberOfBackgroundForBunchCrossing
ServiceHandle< IAtRndmGenSvc > m_atRndmSvc
unsigned int m_nXings
Gaudi::Property< float > m_occupationFraction
Gaudi::Property< std::string > m_collDistrName
Gaudi::Property< float > m_readDownscale
ServiceHandle< IEvtSelector > m_selecName
virtual StatusCode setup(int firstXing, unsigned int nXings, unsigned int firstStore, IBeamIntensity *) override final
virtual void newEvent() override final
inform cache that we start overlaying a new event
unsigned int m_nStores
Gaudi::Property< std::string > m_randomStreamName
int m_zeroXing
offset of BC=0 xing
CLHEP::RandPoisson * m_collXingPoisson
set number of collisions per bunch crossing (if Poisson distribution chosen)
float m_collXingSF
float scaling number of collisions per bunch crossing
const xAOD::EventInfo * nextEvent(bool isCentralBunchCrossing)
get next bkg event from cache
virtual StatusCode addSubEvts(unsigned int iXing, xAOD::EventInfo *overlaidEvent, int t0BinCenter) override final
Read input events in bkg stores and link them to overlay store.
Gaudi::Property< bool > m_ignoreBM
StreamVector::iterator m_cursor
xAOD::EventInfo::PileUpType m_pileUpEventType
the type of events in this cache
CLHEP::RandFlat * m_readEventRand
read a new event every downscaleFactor accesses
PileUpStream * current()
get current (last asked) stream
unsigned int nEvtsXing(unsigned int iXing) const
std::function< long() > m_f_collDistr
function returning the number of collisions per bunch crossing before bunch structure modulation
virtual ~BkgStreamsCache()
std::vector< PileUpStream > StreamVector
unsigned int setNEvtsXing(unsigned int iXing)
long collXing()
meant to be used (mainly) via m_f_collDistr
unsigned int numberOfBkgForBunchCrossingDefaultImpl(unsigned int iXing) const
Gaudi::Property< float > m_collXing
virtual StatusCode finalize() override final
BkgStreamsCache(const std::string &, const std::string &, const IInterface *)
Gaudi::Property< bool > m_ignoreSF
CLHEP::RandFlat * m_chooseEventRand
pickup an event store at random from the cache
StreamVector m_streams
virtual void resetEvtsPerXingScaleFactor(float sf) override final
reset scale factor at new run/lumiblk
bool alreadyInUse(StreamVector::size_type iStream)
unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const
virtual unsigned int nStores() const override final
how many stores in this cache
void PileUpEventTypeHandler(Gaudi::Details::PropertyBase &)
std::vector< bool > m_usedStreams
std::function< unsigned int(unsigned int) > m_f_numberOfBackgroundForBunchCrossing
function returning the number of bkg events per bunch crossing after bunch structure modulation
IBeamIntensity * m_beamInt
pointer to the IBeamIntensity distribution tool
Gaudi::CheckedProperty< unsigned short > m_pileUpEventTypeProp
virtual StatusCode initialize() override final
std::vector< unsigned int > m_nEvtsXing
Gaudi::Property< bool > m_forceReadForBC0
StatusCode nextEvent_passive(bool isCentralBunchCrossing)
as nextEvent except don't actually load anything
a triple selector/context/store defines a stream
PileUpType
Enumerator describing the types of pileup events.
EventInfo_v1 EventInfo
Definition of the latest event info version.