ATLAS Offline Software
BkgStreamsCache.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef PILEUPTOOLS_BKGSTREAMSCACHE_H
6 # define PILEUPTOOLS_BKGSTREAMSCACHE_H
7 
14 #include <string>
15 #include <vector>
16 #include <functional>
17 
19 #include "GaudiKernel/ServiceHandle.h"
20 #include "Gaudi/Property.h"
23 
24 class IEvtSelector;
25 class IAtRndmGenSvc;
26 class IBeamIntensity;
27 namespace CLHEP {
28  class RandFlat;
29  class RandPoisson;
30 }
31 
32 
37  public extends<AthAlgTool, IBkgStreamsCache>
38 {
39 public:
40  BkgStreamsCache( const std::string&, const std::string&, const IInterface*);
41  virtual ~BkgStreamsCache();
42 
43  virtual StatusCode initialize() override final;
44  virtual StatusCode finalize() override final;
49  virtual StatusCode setup(int firstXing,
50  unsigned int nXings,
51  unsigned int firstStore,
52  IBeamIntensity*) override final;
54  virtual void newEvent() override final;
56  virtual void resetEvtsPerXingScaleFactor(float sf) override final;
63  virtual StatusCode addSubEvts(unsigned int iXing,
64  xAOD::EventInfo* overlaidEvent,
65  int t0BinCenter) override final;
74  virtual StatusCode addSubEvts(unsigned int iXing,
75  xAOD::EventInfo* overEvent,
76  int t0BinCenter, bool loadEventProxies, unsigned int /*BCID*/) override final;
78  virtual unsigned int nStores() const override final { return m_nStores; }
79 
81  long collXing() { return m_collXing; }
82  long collXingPoisson();
84  unsigned int numberOfBkgForBunchCrossingIgnoringBeamIntensity(unsigned int iXing) const;
85  unsigned int numberOfBkgForBunchCrossingDefaultImpl(unsigned int iXing) const;
86  unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const;
87 private:
89  const xAOD::EventInfo* nextEvent(bool isCentralBunchCrossing);
91  StatusCode nextEvent_passive(bool isCentralBunchCrossing);
94 
95  unsigned int setNEvtsXing(unsigned int iXing);
96  unsigned int nEvtsXing(unsigned int iXing) const;
97 
98  typedef std::vector<PileUpStream> StreamVector;
99  bool alreadyInUse(StreamVector::size_type iStream);
102  std::vector<bool> m_usedStreams;
103  unsigned int m_nXings;
104  unsigned int m_nStores;
105  std::vector<unsigned int> m_nEvtsXing;
106 
108 
109  Gaudi::Property<float> m_collXing;
112  Gaudi::Property<float> m_occupationFraction;
114  Gaudi::Property<std::string> m_collDistrName;
117  Gaudi::Property<float> m_readDownscale;
121  Gaudi::Property<std::string> m_randomStreamName;
123  Gaudi::CheckedProperty<unsigned short> m_pileUpEventTypeProp;
124  void PileUpEventTypeHandler(Gaudi::Details::PropertyBase&);
128  Gaudi::Property<unsigned short> m_subtractBC0;
130  Gaudi::Property<bool> m_ignoreBM;
132  CLHEP::RandFlat* m_readEventRand;
135  CLHEP::RandFlat* m_chooseEventRand;
137  CLHEP::RandPoisson* m_collXingPoisson;
140  std::function< long() > m_f_collDistr;
143  std::function< unsigned int(unsigned int) > m_f_numberOfBackgroundForBunchCrossing;
147  Gaudi::Property<bool> m_ignoreSF;
153  Gaudi::Property<bool> m_forceReadForBC0;
154 
155 };
156 
157 #endif // PILEUPTOOLS_BKGSTREAMSCACHE_H
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
BkgStreamsCache::finalize
virtual StatusCode finalize() override final
Definition: BkgStreamsCache.cxx:426
BkgStreamsCache::PileUpEventTypeHandler
void PileUpEventTypeHandler(Gaudi::Details::PropertyBase &)
Definition: BkgStreamsCache.cxx:80
BkgStreamsCache::m_cursor
StreamVector::iterator m_cursor
Definition: BkgStreamsCache.h:100
BkgStreamsCache::nextEvent_passive
StatusCode nextEvent_passive(bool isCentralBunchCrossing)
as nextEvent except don't actually load anything
Definition: BkgStreamsCache.cxx:212
BkgStreamsCache::m_pileUpEventTypeProp
Gaudi::CheckedProperty< unsigned short > m_pileUpEventTypeProp
the type of events in this cache
Definition: BkgStreamsCache.h:123
BkgStreamsCache::m_ignoreBM
Gaudi::Property< bool > m_ignoreBM
ignore the PileUpEventLoopMgr beam intensity tool
Definition: BkgStreamsCache.h:130
BkgStreamsCache::m_chooseEventRand
CLHEP::RandFlat * m_chooseEventRand
pickup an event store at random from the cache
Definition: BkgStreamsCache.h:135
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
BkgStreamsCache::m_nEvtsXing
std::vector< unsigned int > m_nEvtsXing
Definition: BkgStreamsCache.h:105
BkgStreamsCache::m_atRndmSvc
ServiceHandle< IAtRndmGenSvc > m_atRndmSvc
IAtRndmGenSvc controlling the distribution of bkg events per bunch crossing.
Definition: BkgStreamsCache.h:119
BkgStreamsCache::m_pileUpEventType
xAOD::EventInfo::PileUpType m_pileUpEventType
the type of events in this cache
Definition: BkgStreamsCache.h:126
BkgStreamsCache::numberOfBkgForBunchCrossingDefaultImpl
unsigned int numberOfBkgForBunchCrossingDefaultImpl(unsigned int iXing) const
Definition: BkgStreamsCache.cxx:324
BkgStreamsCache::m_f_numberOfBackgroundForBunchCrossing
std::function< unsigned int(unsigned int) > m_f_numberOfBackgroundForBunchCrossing
function returning the number of bkg events per bunch crossing after bunch structure modulation
Definition: BkgStreamsCache.h:143
BkgStreamsCache::m_collXingSF
float m_collXingSF
float scaling number of collisions per bunch crossing
Definition: BkgStreamsCache.h:145
BkgStreamsCache::m_subtractBC0
Gaudi::Property< unsigned short > m_subtractBC0
subtract from number of events at bunch xing = 0
Definition: BkgStreamsCache.h:128
BkgStreamsCache::StreamVector
std::vector< PileUpStream > StreamVector
Definition: BkgStreamsCache.h:98
BkgStreamsCache::m_nStores
unsigned int m_nStores
Definition: BkgStreamsCache.h:104
BkgStreamsCache::m_forceReadForBC0
Gaudi::Property< bool > m_forceReadForBC0
Force events used in the central bunch crossing to be refreshed.
Definition: BkgStreamsCache.h:153
BkgStreamsCache::m_occupationFraction
Gaudi::Property< float > m_occupationFraction
The maximum fraction of bunch-crossings which will be occupied.
Definition: BkgStreamsCache.h:112
xAOD::EventInfo_v1::PileUpType
PileUpType
Enumerator describing the types of pileup events.
Definition: EventInfo_v1.h:264
BkgStreamsCache::nStores
virtual unsigned int nStores() const override final
how many stores in this cache
Definition: BkgStreamsCache.h:78
BkgStreamsCache::m_f_collDistr
std::function< long() > m_f_collDistr
function returning the number of collisions per bunch crossing before bunch structure modulation
Definition: BkgStreamsCache.h:140
BkgStreamsCache::m_collXing
Gaudi::Property< float > m_collXing
Definition: BkgStreamsCache.h:110
BkgStreamsCache::setup
virtual StatusCode setup(int firstXing, unsigned int nXings, unsigned int firstStore, IBeamIntensity *) override final
Definition: BkgStreamsCache.cxx:86
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
BkgStreamsCache::nEvtsXing
unsigned int nEvtsXing(unsigned int iXing) const
Definition: BkgStreamsCache.cxx:315
BkgStreamsCache::m_beamInt
IBeamIntensity * m_beamInt
pointer to the IBeamIntensity distribution tool
Definition: BkgStreamsCache.h:151
BkgStreamsCache::m_collDistrName
Gaudi::Property< std::string > m_collDistrName
select collision distribution
Definition: BkgStreamsCache.h:114
BkgStreamsCache::alreadyInUse
bool alreadyInUse(StreamVector::size_type iStream)
Definition: BkgStreamsCache.cxx:237
BkgStreamsCache::m_readDownscale
Gaudi::Property< float > m_readDownscale
read downscale factor (average number of times a min bias is reused)
Definition: BkgStreamsCache.h:117
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
BkgStreamsCache::m_ignoreSF
Gaudi::Property< bool > m_ignoreSF
bool apply scaling number of collisions per bunch crossing ?
Definition: BkgStreamsCache.h:147
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
BkgStreamsCache
In-memory cache for pileup events.
Definition: BkgStreamsCache.h:38
AthAlgTool.h
BkgStreamsCache::resetEvtsPerXingScaleFactor
virtual void resetEvtsPerXingScaleFactor(float sf) override final
reset scale factor at new run/lumiblk
Definition: BkgStreamsCache.cxx:154
PileUpStream
a triple selector/context/store defines a stream
Definition: PileUpStream.h:32
BkgStreamsCache::m_nXings
unsigned int m_nXings
Definition: BkgStreamsCache.h:103
IAtRndmGenSvc
manage multiple CLHEP random engines as named streams
Definition: IAtRndmGenSvc.h:23
BkgStreamsCache::initialize
virtual StatusCode initialize() override final
Definition: BkgStreamsCache.cxx:256
BkgStreamsCache::numberOfCavernBkgForBunchCrossing
unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const
Definition: BkgStreamsCache.cxx:328
BkgStreamsCache::m_zeroXing
int m_zeroXing
offset of BC=0 xing
Definition: BkgStreamsCache.h:149
BkgStreamsCache::collXing
long collXing()
meant to be used (mainly) via m_f_collDistr
Definition: BkgStreamsCache.h:81
BkgStreamsCache::m_collXingPoisson
CLHEP::RandPoisson * m_collXingPoisson
set number of collisions per bunch crossing (if Poisson distribution chosen)
Definition: BkgStreamsCache.h:137
BkgStreamsCache::m_selecName
ServiceHandle< IEvtSelector > m_selecName
Definition: BkgStreamsCache.h:115
BkgStreamsCache::setNEvtsXing
unsigned int setNEvtsXing(unsigned int iXing)
Definition: BkgStreamsCache.cxx:333
BkgStreamsCache::collXingPoisson
long collXingPoisson()
Definition: BkgStreamsCache.cxx:159
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
BkgStreamsCache::current
PileUpStream * current()
get current (last asked) stream
Definition: BkgStreamsCache.cxx:249
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
PileUpStream.h
a triple selector/context/store defines a stream
IBeamIntensity
Definition: IBeamIntensity.h:17
BkgStreamsCache::m_usedStreams
std::vector< bool > m_usedStreams
Definition: BkgStreamsCache.h:102
IBkgStreamsCache.h
Interface to in-memory cache for pileup events.
BkgStreamsCache::~BkgStreamsCache
virtual ~BkgStreamsCache()
Definition: BkgStreamsCache.cxx:72
BkgStreamsCache::addSubEvts
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.
Definition: BkgStreamsCache.cxx:357
BkgStreamsCache::BkgStreamsCache
BkgStreamsCache(const std::string &, const std::string &, const IInterface *)
Definition: BkgStreamsCache.cxx:28
BkgStreamsCache::newEvent
virtual void newEvent() override final
inform cache that we start overlaying a new event
Definition: BkgStreamsCache.cxx:165
BkgStreamsCache::numberOfBkgForBunchCrossingIgnoringBeamIntensity
unsigned int numberOfBkgForBunchCrossingIgnoringBeamIntensity(unsigned int iXing) const
meant to be used via m_f_numberOfBackgroundForBunchCrossing
Definition: BkgStreamsCache.cxx:320
BkgStreamsCache::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
the IAtRndmGenSvc stream to generate number of bkg events per bunch crossing
Definition: BkgStreamsCache.h:121
BkgStreamsCache::m_streams
StreamVector m_streams
Definition: BkgStreamsCache.h:101
ServiceHandle< IEvtSelector >
BkgStreamsCache::nextEvent
const xAOD::EventInfo * nextEvent(bool isCentralBunchCrossing)
get next bkg event from cache
Definition: BkgStreamsCache.cxx:185
BkgStreamsCache::m_readEventRand
CLHEP::RandFlat * m_readEventRand
read a new event every downscaleFactor accesses
Definition: BkgStreamsCache.h:133