ATLAS Offline Software
BkgStreamsCache.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <cassert>
6 #include <cmath> /*ceil,sqrt*/
7 #include <stdexcept> /*runtime_error*/
8 #include <string>
9 
10 #include <functional>
12 
13 #include "StoreGate/StoreGateSvc.h" /*to print name() */
14 #include "GaudiKernel/IEvtSelector.h"
15 
16 #include "CLHEP/Random/RandFlat.h"
17 #include "CLHEP/Random/RandPoisson.h"
18 
20 
22 #include "PileUpTools/PileUpMisc.h"
25 
26 #include "BkgStreamsCache.h"
27 
29  const std::string& name,
30  const IInterface* parent)
31  : base_class( type, name, parent )
32  , m_nXings(0)
33  , m_nStores(0)
34  , m_collXing(23.0)
35  , m_occupationFraction(1.0)
36  , m_collDistrName("Poisson")
37  , m_selecName("FakeEventSelector", name)
38  , m_readDownscale(150)
39  , m_atRndmSvc("AtRndmGenSvc", name)
40  , m_randomStreamName("PileUpCollXingStream")
41  , m_pileUpEventTypeProp(0)
42  , m_pileUpEventType(xAOD::EventInfo::PileUpType::Signal)
43  , m_subtractBC0(0)
44  , m_ignoreBM(false)
45  , m_readEventRand(nullptr)
46  , m_chooseEventRand(nullptr)
47  , m_collXingPoisson(nullptr)
48  , m_f_collDistr(0)
49  , m_f_numberOfBackgroundForBunchCrossing(0)
50  , m_collXingSF(1.0)
51  , m_ignoreSF(false)
52  , m_zeroXing(-1)
53  , m_beamInt(nullptr)
54  , m_forceReadForBC0(true)
55 {
56  declareProperty("CollPerXing", m_collXing, "(average) number of collisions per beam crossing");
57  declareProperty("OccupationFraction", m_occupationFraction, "The maximum fraction of bunch-crossings which will be occupied.");
58  declareProperty("CollDistribution", m_collDistrName, "nEvts/Xings can be either Fixed at CollPerXing or Poisson with average CollPerXing");
59  declareProperty("EventSelector", m_selecName);
60  declareProperty("PileUpEventType", m_pileUpEventTypeProp, "Type of the pileup events in this cache: 0:Signal, 1:MinimumBias, 2:Cavern, 3:HaloGas, 4:ZeroBias. Default=0 (Signal, Invalid)");
61  declareProperty("ReadDownscaleFactor", m_readDownscale, "read one event every downscaleFactor accesses (asymptotically -> number of times an event in the cache will be reused)");
62  declareProperty("RndmGenSvc", m_atRndmSvc, "IAtRndmGenSvc controlling the distribution of bkg events/xing");
63  declareProperty("RndmStreamName", m_randomStreamName, "IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one ");
64  declareProperty("SubtractBC0", m_subtractBC0, "reduce the number of events at bunch xing t=0 by m_subtractBC0. Default=0, set to 1 when using the same type of events (e.g. minbias) for original and background streams");
67  declareProperty("IgnoreBeamInt", m_ignoreBM, "Default=False, set to True to ignore the PileUpEventLoopMgr beam intensity tool in setting the number of events per xing.");
68  declareProperty("IgnoreBeamLumi", m_ignoreSF, "Default=False, set to True to ignore the PileUpEventLoopMgr beam luminosity tool in setting the number of events per xing.");
69  declareProperty("ForceReadForBC0",m_forceReadForBC0,"Force events used in the central bunch crossing to be refreshed");
70 }
71 
73 {
74  delete m_collXingPoisson;
75  delete m_chooseEventRand;
76  delete m_readEventRand;
77 }
78 
79 void
80 BkgStreamsCache::PileUpEventTypeHandler(Gaudi::Details::PropertyBase&)
81 {
83 }
84 
86 BkgStreamsCache::setup(int firstXing,
87  unsigned int nXings,
88  unsigned int firstStore,
89  IBeamIntensity* iBM)
90 {
91  assert (0 < nXings);
92  m_nXings = nXings;
93  m_zeroXing = -firstXing;
94  if (m_zeroXing >= (int)nXings) m_zeroXing = -99;
95  m_beamInt = (m_ignoreBM.value() ? 0 : iBM);
96  float largestElement( ( m_ignoreBM.value() || m_collDistrName.value() == "Fixed" ) ? 1.0 : m_beamInt->largestElementInPattern() );
97  //ceil (cmath) rounds up to the nearest integer ceil(1.5)= 2
98  float occupiedCrossings = ceil(static_cast<float>(m_nXings) * m_occupationFraction);
99  m_nStores = static_cast<unsigned int>(ceil( m_collXing * occupiedCrossings * largestElement));
100  if (m_collDistrName.value() == "Poisson")
101  {
102  //allow for fluctuations in # of overlaid events
103  m_nStores += static_cast<unsigned int>(6.0 * sqrt(static_cast<float>(m_nStores)));
104  }
105 
106  //get bkg selectors, stores and iterators
107  ATH_MSG_DEBUG ( "Set up " << m_nStores << " stores" );
108 
109  m_nEvtsXing.reserve(m_nStores);
110  m_streams.reserve(m_nStores);
111  m_usedStreams.reserve(m_nStores);
112  m_usedStreams.assign(m_nStores, false);
113 
114  const std::string& selecName(m_selecName.name());
115  for (unsigned int i=0; i < m_nStores; ++i)
116  {
117  std::stringstream bufName;
118  bufName << "BkgEvent_" << i + firstStore;
119  const std::string& streamName(bufName.str());
120  try
121  {
122  m_streams.emplace_back(streamName,serviceLocator(),selecName);
123  }
124  catch (const std::runtime_error& e)
125  {
126  ATH_MSG_ERROR ( "Exception thrown while creating PileUpStream "
127  << streamName << " : " << e.what() );
128  return StatusCode::FAILURE;
129  }
130 
131  if(!(m_streams.back().setupStore()))
132  {
133  ATH_MSG_ERROR ( "Can not setup bkg evt store for stream "
134  << streamName );
135  return StatusCode::FAILURE;
136  }
137  }
138  m_cursor = m_streams.begin();
139 
140  CLHEP::HepRandomEngine* collEng(m_atRndmSvc->GetEngine(m_randomStreamName.value()));
141  if( !collEng )
142  {
143  ATH_MSG_ERROR ( "can not get random stream " << m_randomStreamName.value() );
144  return StatusCode::FAILURE;
145  }
146  //setup generator to pickup an event store at random from the cache
147  //notice how we pass collEng by reference. If ! CLHEP will take ownership...
148  m_chooseEventRand = new CLHEP::RandFlat(*(collEng),
149  0.0, double(m_nStores));
150 
151  return StatusCode::SUCCESS;
152 }
153 
155 {
156  if (!m_ignoreSF) m_collXingSF = sf;
157 }
158 
160 {
161  if (!m_collXingPoisson) { return collXing(); }
162  return m_collXingPoisson->fire(m_collXing * m_collXingSF);
163 }
164 
166 {
167  ATH_MSG_DEBUG ( "newEvent called resetting used event set" );
168  unsigned int totEvts(0);
169  do {
170  totEvts = 0;
171  for (unsigned int iXing=0; iXing<m_nXings; ++iXing) {
172  totEvts += setNEvtsXing(iXing);
173  if (totEvts > m_nStores) {
174  ATH_MSG_WARNING ( "newEvent: number of required evts (" << totEvts << ") exceeds number of available stores "
175  << m_nStores << ". Regenerating bkg sequence for this event \n"
176  << " the total number of bkg events may not exceed average by more than 6 sigmas"
177  );
178  break;
179  }
180  }
181  } while(totEvts > m_nStores);
182  m_usedStreams.assign(m_streams.size(), false);
183 }
184 
185 const xAOD::EventInfo* BkgStreamsCache::nextEvent(bool isCentralBunchCrossing)
186 {
187  const xAOD::EventInfo* pNextEvt(nullptr);
188  StreamVector::size_type iS(0);
189  do {
190  iS = (StreamVector::size_type)m_chooseEventRand->fire();
191  } while (alreadyInUse(iS));
192 
193  //set current store to iS
194  m_cursor = m_streams.begin();
195  std::advance(m_cursor, iS);
196 
197  ATH_MSG_DEBUG ( "using store " << iS );
198  PileUpStream* pCurrStream(current());
199  if (0 != pCurrStream) {
200  pCurrStream->store().makeCurrent();
201  //read a new event every downscaleFactor accesses
202  //force reading of new event if the event is being used for in-time pile-up
203  //FIXME a more careful strategy would have the PileUpStreams knowing if
204  //they have been used for the central bunch-crossing already.
205  bool readEvent(isCentralBunchCrossing || (m_readEventRand->fire()<1.0));
206  pNextEvt = pCurrStream->nextEventPre( readEvent );
207  }
208  return pNextEvt;
209 }
210 
211 //TODO update this method!!
212 StatusCode BkgStreamsCache::nextEvent_passive(bool isCentralBunchCrossing)
213 {
214  StreamVector::size_type iS(0);
215  do {
216  iS = (StreamVector::size_type)m_chooseEventRand->fire();
217  } while (alreadyInUse(iS));
218 
219  //set current store to iS
220  m_cursor = m_streams.begin();
221  std::advance(m_cursor, iS);
222 
223  ATH_MSG_DEBUG ( "using store " << iS );
224  PileUpStream* pCurrStream(current());
225  if (0 != pCurrStream) {
226  pCurrStream->store().makeCurrent();
227  //read a new event every downscaleFactor accesses
228  //force reading of new event if the event is being used for in-time pile-up
229  //FIXME a more careful strategy would have the PileUpStreams knowing if
230  //they have been used for the central bunch-crossing already.
231  bool readEvent(isCentralBunchCrossing || (m_readEventRand->fire()<1.0));
232  if(pCurrStream->nextEventPre_Passive(readEvent)) return StatusCode::SUCCESS;
233  }
234  return StatusCode::FAILURE;
235 }
236 
237 bool BkgStreamsCache::alreadyInUse(StreamVector::size_type iS)
238 {
239  assert(iS<m_usedStreams.size());
240  bool inUse(m_usedStreams[iS]);
241  if (!inUse) m_usedStreams[iS] = true;
242 #ifndef NDEBUG
243  ATH_MSG_VERBOSE ( "alreadyInUse: store " << iS << ' '
244  << (inUse ? "already" : "not yet") << " in use" );
245 #endif
246  return inUse;
247 }
248 
250 {
251  if (m_cursor != m_streams.end()) return &*m_cursor;
252  // m_cursor->isNotEmpty()) return &*m_cursor;
253  else return 0; //FIXME should reomve empty stream and keep going
254 }
255 
257 {
258  ATH_MSG_DEBUG ( "Initializing " << name()
259  << " - cache for events of type "
261 
263 
264  //create random number generators
265  ATH_CHECK(m_atRndmSvc.retrieve());
266  CLHEP::HepRandomEngine* collEng(m_atRndmSvc->GetEngine(m_randomStreamName.value()));
267  if( 0 == collEng )
268  {
269  ATH_MSG_ERROR ( "can not get random stream " << m_randomStreamName.value() );
270  return StatusCode::FAILURE;
271  }
272 
273  //setup distribution to read a new event every downscaleFactor accesses
274  //notice how we pass collEng by reference. If ! CLHEP will take ownership...
275  m_readEventRand = new CLHEP::RandFlat(*(collEng),
276  0.0, double(m_readDownscale));
277 
278  // select collision distribution functions
279  if (m_collDistrName.value() == "Fixed")
280  {
281  m_f_collDistr = std::bind(&BkgStreamsCache::collXing, this);
282  using namespace std::placeholders;
283  if(m_ignoreBM.value())
284  {
286  }
287  else
288  {
290  }
291  return StatusCode::SUCCESS;
292  }
293  if (m_collDistrName.value() == "Poisson")
294  {
295  //pass collEng by reference. If Not CLHEP will take ownership...
296  m_collXingPoisson = new CLHEP::RandPoisson(*(collEng), m_collXing);
297  // m_f_collDistr will call m_collXingPoisson->fire(m_collXing) USED TO BE boost::bind(&CLHEP::RandPoisson::fire, m_collXingPoisson);
299  using namespace std::placeholders;
300  if(m_ignoreBM.value())
301  {
303  }
304  else
305  {
307  }
308  return StatusCode::SUCCESS;
309  }
311  << " is not a know collision distribution function" );
312  return StatusCode::FAILURE;
313 }
314 
315 unsigned int BkgStreamsCache::nEvtsXing(unsigned int iXing) const
316 {
317  return (iXing + 1 > m_nEvtsXing.size()) ? 0 : m_nEvtsXing[iXing];
318 }
319 
321 {
322  return m_f_collDistr();
323 }
324 unsigned int BkgStreamsCache::numberOfBkgForBunchCrossingDefaultImpl(unsigned int iXing) const
325 {
326  return static_cast<unsigned int>(m_beamInt->normFactor(iXing-m_zeroXing)*static_cast<float>(m_f_collDistr()));
327 }
328 unsigned int BkgStreamsCache::numberOfCavernBkgForBunchCrossing(unsigned int iXing) const
329 {
330  return static_cast<unsigned int>(m_beamInt->normFactor(iXing-m_zeroXing)>0.0)*m_f_collDistr();
331 }
332 
333 unsigned int BkgStreamsCache::setNEvtsXing(unsigned int iXing)
334 {
335  if (iXing + 1 > m_nEvtsXing.size()) m_nEvtsXing.resize(2 * iXing + 1);
336  unsigned int nEvts(m_f_numberOfBackgroundForBunchCrossing(iXing));
337  //this is done mainly to handle the case in which original and backround
338  //events belong to the same stream. Of course we do not want m_nEvtsXing[m_zeroXing]<0
339  if ((int)iXing==m_zeroXing)
340  {
341  unsigned int subValue(m_subtractBC0.value());
342  while (nEvts<subValue) nEvts = m_f_numberOfBackgroundForBunchCrossing(iXing);
343  nEvts -= subValue;
344 #ifndef NDEBUG
345  ATH_MSG_VERBOSE ( "Subtracted " << m_subtractBC0.value()
346  << " events from BC=0 Xing " << iXing << " - Events at BC=0 "
347  << nEvts
348  );
349 #endif
350  }
351  ATH_MSG_VERBOSE ( "Will pile-up " << nEvts
352  << " events for BCID " << iXing );
353  m_nEvtsXing[iXing] = nEvts;
354  return nEvts;
355 }
356 
358  xAOD::EventInfo* overEvent,
359  int t0BinCenter)
360 {
361  return this->addSubEvts(iXing, overEvent, t0BinCenter, true, 0);
362 }
363 
364 
366  xAOD::EventInfo* overEvent,
367  int t0BinCenter, bool loadEventProxies, unsigned int BCID)
368 {
369  for (unsigned int iEvt=0; iEvt<nEvtsXing(iXing); ++iEvt)
370  {
371  // check if we're picking events for the central bunch-crossing,
372  // so we can choose to only use fresh events here.
373  bool isCentralBunchCrossing((0==t0BinCenter)&&m_forceReadForBC0);
374  // increment event iterators
375  if(!loadEventProxies) {
376  return this->nextEvent_passive(isCentralBunchCrossing);
377  }
378  const xAOD::EventInfo* pBkgEvent = nextEvent( isCentralBunchCrossing ); //FIXME update this for the case where loadProxies=False
379 
380  //check input selector is not empty
381  PileUpStream* currStream(this->current());
382  if (0 == pBkgEvent || 0 == currStream)
383  {
384  // This is the end of the loop. No more events in the selection
385  ATH_MSG_INFO ( "end of loop: background cache has no more events" );
386  return StatusCode::FAILURE;
387  }
388  StoreGateSvc* pBkgStore = &(currStream->store());
389  ATH_MSG_DEBUG ( "added event " << pBkgEvent->eventNumber()
390  << " run " << pBkgEvent->runNumber()
391  << " from store "
392  << pBkgStore->name()
393  << " @ Xing " << iXing );
394 
395  // register as sub event of the overlaid
396 
397  // get the SG container for subevents infos
398  xAOD::EventInfoContainer *subEvCnt (nullptr);
399  ATH_CHECK( overEvent->evtStore()->retrieve(subEvCnt, c_pileUpEventInfoContName) );
400  // temporary EI instance to modify BCID before adding the EI
401  xAOD::EventInfo tmp_ei( *pBkgEvent );
402  tmp_ei.setBCID( BCID );
403  tmp_ei.setEvtStore(pBkgStore);
404  // add subevent
405  addSubEvent( overEvent, &tmp_ei, t0BinCenter, m_pileUpEventType, subEvCnt, c_pileUpEventInfoContName );
406 
407 #ifdef DEBUG_PILEUP
408  const xAOD::EventInfo* pStoreInfo(nullptr);
409  if (pBkgStore->retrieve(pStoreInfo).isSuccess() && pStoreInfo &&
410  pBkgEvent->eventNumber() != pStoreInfo->eventNumber())
411  {
412  ATH_MSG_ERROR ( "added event " << pBkgEvent->eventNumber()
413  << " run " << pBkgEvent->runNumber()
414  << " differ from current store "
415  << pBkgStore->name()
416  << " event " << pStoreInfo->eventNumber()
417  << " run " << pStoreInfo->runNumber()
418  );
419  assert(1);
420  }
421 #endif
422  } //loop over evts in xing
423  return StatusCode::SUCCESS;
424 }
425 
427 {
428  StatusCode sc(StatusCode::SUCCESS);
429  ATH_MSG_DEBUG ( "Finalizing " << name()
430  << " - cache for events of type "
432  while (sc.isSuccess() && m_streams.size()>0)
433  {
434  sc=m_streams.back().finalize();
435  m_streams.pop_back();
436  }
437  return sc;
438 }
BkgStreamsCache::finalize
virtual StatusCode finalize() override final
Definition: BkgStreamsCache.cxx:426
c_pileUpEventInfoContName
const std::string c_pileUpEventInfoContName
default value for the EventInfoContainer storing subevents for PileUp
Definition: PileUpMisc.h:15
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
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
xAOD::EventInfo_v1::PileUp_NTYPES
@ PileUp_NTYPES
Definition: EventInfo_v1.h:272
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
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
AthMsgStreamMacros.h
IBeamIntensity::largestElementInPattern
virtual float largestElementInPattern() const =0
the largest element in the beam intensity pattern.
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::m_nStores
unsigned int m_nStores
Definition: BkgStreamsCache.h:104
BkgStreamsCache.h
In memory cache for pileup events.
StoreGateSvc::makeCurrent
void makeCurrent()
The current store is becoming the active store.
Definition: StoreGateSvc.cxx:496
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
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
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
trigbs_truncateEvents.readEvent
def readEvent(file)
Definition: trigbs_truncateEvents.py:10
BkgStreamsCache::setup
virtual StatusCode setup(int firstXing, unsigned int nXings, unsigned int firstStore, IBeamIntensity *) override final
Definition: BkgStreamsCache.cxx:86
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
BkgStreamsCache::nEvtsXing
unsigned int nEvtsXing(unsigned int iXing) const
Definition: BkgStreamsCache.cxx:315
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
EventInfoContainer.h
BkgStreamsCache::m_beamInt
IBeamIntensity * m_beamInt
pointer to the IBeamIntensity distribution tool
Definition: BkgStreamsCache.h:151
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
PixelByteStreamErrors::BCID
@ BCID
Definition: PixelByteStreamErrors.h:13
IBeamIntensity::normFactor
virtual float normFactor(int bunchXing) const =0
a scale factor (average value 1.0) for the beam intensity at a given xing.
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
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
PileUpStream::nextEventPre
const xAOD::EventInfo * nextEventPre(bool readRecord=true)
return next Event, load store with next Event
Definition: PileUpStream.cxx:216
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.PileUpEventType.Signal
int Signal
Definition: PileUpEventType.py:3
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
BkgStreamsCache::m_ignoreSF
Gaudi::Property< bool > m_ignoreSF
bool apply scaling number of collisions per bunch crossing ?
Definition: BkgStreamsCache.h:147
BkgStreamsCache::resetEvtsPerXingScaleFactor
virtual void resetEvtsPerXingScaleFactor(float sf) override final
reset scale factor at new run/lumiblk
Definition: BkgStreamsCache.cxx:154
test_pyathena.parent
parent
Definition: test_pyathena.py:15
PileUpStream
a triple selector/context/store defines a stream
Definition: PileUpStream.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BkgStreamsCache::m_nXings
unsigned int m_nXings
Definition: BkgStreamsCache.h:103
PileUpStream::nextEventPre_Passive
bool nextEventPre_Passive(bool readRecord)
like nextEventPre, but doesn't actually load anything
Definition: PileUpStream.cxx:241
xAOD::EventInfo_v1::setBCID
void setBCID(uint32_t value)
Set the bunch crossing ID of the event.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
PileUpStream::store
StoreGateSvc & store()
Definition: PileUpStream.h:60
BkgStreamsCache::initialize
virtual StatusCode initialize() override final
Definition: BkgStreamsCache.cxx:256
BkgStreamsCache::numberOfCavernBkgForBunchCrossing
unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const
Definition: BkgStreamsCache.cxx:328
IAtRndmGenSvc.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
BkgStreamsCache::m_zeroXing
int m_zeroXing
offset of BC=0 xing
Definition: BkgStreamsCache.h:149
errorcheck.h
Helpers for checking error return status codes and reporting errors.
BkgStreamsCache::collXing
long collXing()
meant to be used (mainly) via m_f_collDistr
Definition: BkgStreamsCache.h:81
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
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
PileUpType
For details on how the MC particles are defined and organized see https://twiki.cern....
Definition: PileUpType.h:33
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
xAOD::EventInfo_v1::PileUpInt2Type
static PileUpType PileUpInt2Type(unsigned short typ)
Convert int to PileUpType enum value.
Definition: EventInfo_v1.cxx:672
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
BkgStreamsCache::current
PileUpStream * current()
get current (last asked) stream
Definition: BkgStreamsCache.cxx:249
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
IBeamIntensity.h
provides the relative beam intensity as a function of the bunch xing.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PileUpMisc.h
xAOD::EventInfo_v1::PileUpType2Name
static const std::string & PileUpType2Name(PileUpType typ)
Convert PileUpType enum value to string.
Definition: EventInfo_v1.cxx:658
IBeamIntensity
Definition: IBeamIntensity.h:17
BkgStreamsCache::m_usedStreams
std::vector< bool > m_usedStreams
Definition: BkgStreamsCache.h:102
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
StoreGateSvc.h
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
addSubEvent
xAOD::EventInfo * addSubEvent(xAOD::EventInfo *targetEv, const xAOD::EventInfo::SubEvent &subev, xAOD::EventInfoContainer *eiContainer, const std::string &eiContKey, StoreGateSvc *subev_store=nullptr)
Definition: PileUpMisc.cxx:17
BkgStreamsCache::m_streams
StreamVector m_streams
Definition: BkgStreamsCache.h:101
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