ATLAS Offline Software
Loading...
Searching...
No Matches
BkgStreamsCache Class Reference

In-memory cache for pileup events. More...

#include <BkgStreamsCache.h>

Inheritance diagram for BkgStreamsCache:
Collaboration diagram for BkgStreamsCache:

Public Member Functions

 BkgStreamsCache (const std::string &, const std::string &, const IInterface *)
virtual ~BkgStreamsCache ()
virtual StatusCode initialize () override final
virtual StatusCode finalize () override final
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
virtual void resetEvtsPerXingScaleFactor (float sf) override final
 reset scale factor at new run/lumiblk
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.
virtual StatusCode addSubEvts (unsigned int iXing, xAOD::EventInfo *overEvent, int t0BinCenter, bool loadEventProxies, unsigned int) override final
 Read input events in bkg stores and link them to overlay store.
virtual unsigned int nStores () const override final
 how many stores in this cache
long collXing ()
 meant to be used (mainly) via m_f_collDistr
long collXingPoisson ()
unsigned int numberOfBkgForBunchCrossingIgnoringBeamIntensity (unsigned int iXing) const
 meant to be used via m_f_numberOfBackgroundForBunchCrossing
unsigned int numberOfBkgForBunchCrossingDefaultImpl (unsigned int iXing) const
unsigned int numberOfCavernBkgForBunchCrossing (unsigned int iXing) const

Private Types

typedef std::vector< PileUpStreamStreamVector

Private Member Functions

const xAOD::EventInfonextEvent (bool isCentralBunchCrossing)
 get next bkg event from cache
StatusCode nextEvent_passive (bool isCentralBunchCrossing)
 as nextEvent except don't actually load anything
PileUpStreamcurrent ()
 get current (last asked) stream
unsigned int setNEvtsXing (unsigned int iXing)
unsigned int nEvtsXing (unsigned int iXing) const
bool alreadyInUse (StreamVector::size_type iStream)
void PileUpEventTypeHandler (Gaudi::Details::PropertyBase &)

Private Attributes

StreamVector::iterator m_cursor {}
StreamVector m_streams
std::vector< bool > m_usedStreams
unsigned int m_nXings {0}
unsigned int m_nStores {0}
std::vector< unsigned int > m_nEvtsXing
ServiceHandle< IEvtSelector > m_selecName {this, "EventSelector", "FakeEventSelector"}
ServiceHandle< IAtRndmGenSvcm_atRndmSvc
Gaudi::Property< float > m_collXing
Gaudi::Property< float > m_occupationFraction
Gaudi::Property< std::string > m_collDistrName
Gaudi::Property< float > m_readDownscale
Gaudi::Property< std::string > m_randomStreamName
Gaudi::CheckedProperty< unsigned short > m_pileUpEventTypeProp
Gaudi::Property< unsigned short > m_subtractBC0
Gaudi::Property< bool > m_ignoreBM
Gaudi::Property< bool > m_ignoreSF
Gaudi::Property< bool > m_forceReadForBC0
xAOD::EventInfo::PileUpType m_pileUpEventType
 the type of events in this cache
CLHEP::RandFlat * m_readEventRand {nullptr}
 read a new event every downscaleFactor accesses
CLHEP::RandFlat * m_chooseEventRand {nullptr}
 pickup an event store at random from the cache
CLHEP::RandPoisson * m_collXingPoisson {nullptr}
 set number of collisions per bunch crossing (if Poisson distribution chosen)
std::function< long() > m_f_collDistr
 function returning the number of collisions per bunch crossing before bunch structure modulation
std::function< unsigned int(unsigned int) > m_f_numberOfBackgroundForBunchCrossing
 function returning the number of bkg events per bunch crossing after bunch structure modulation
float m_collXingSF {1.0}
 float scaling number of collisions per bunch crossing
int m_zeroXing {-1}
 offset of BC=0 xing
IBeamIntensitym_beamInt {nullptr}
 pointer to the IBeamIntensity distribution tool

Detailed Description

In-memory cache for pileup events.

Definition at line 35 of file BkgStreamsCache.h.

Member Typedef Documentation

◆ StreamVector

typedef std::vector<PileUpStream> BkgStreamsCache::StreamVector
private

Definition at line 97 of file BkgStreamsCache.h.

Constructor & Destructor Documentation

◆ BkgStreamsCache()

BkgStreamsCache::BkgStreamsCache ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 26 of file BkgStreamsCache.cxx.

29 : base_class( type, name, parent )
30{
32}
Gaudi::CheckedProperty< unsigned short > m_pileUpEventTypeProp

◆ ~BkgStreamsCache()

BkgStreamsCache::~BkgStreamsCache ( )
virtual

Definition at line 34 of file BkgStreamsCache.cxx.

35{
36 delete m_collXingPoisson;
37 delete m_chooseEventRand;
38 delete m_readEventRand;
39}
CLHEP::RandPoisson * m_collXingPoisson
set number of collisions per bunch crossing (if Poisson distribution chosen)
CLHEP::RandFlat * m_readEventRand
read a new event every downscaleFactor accesses
CLHEP::RandFlat * m_chooseEventRand
pickup an event store at random from the cache

Member Function Documentation

◆ addSubEvts() [1/2]

StatusCode BkgStreamsCache::addSubEvts ( unsigned int iXing,
xAOD::EventInfo * overEvent,
int t0BinCenter,
bool loadEventProxies,
unsigned int BCID )
finaloverridevirtual

Read input events in bkg stores and link them to overlay store.

Parameters
iXingoffset to first xing number (=0 first Xing, =nXings for last xing)
overlaidEventreference to resulting overlaid event
t0BinCentertime wrto t0 of current bin center in ns
loadEventProxiesshould we load the event proxies or not.
BCIDbunch-crossing ID of signal bunch crossing

Definition at line 327 of file BkgStreamsCache.cxx.

330{
331 for (unsigned int iEvt=0; iEvt<nEvtsXing(iXing); ++iEvt)
332 {
333 // check if we're picking events for the central bunch-crossing,
334 // so we can choose to only use fresh events here.
335 bool isCentralBunchCrossing((0==t0BinCenter)&&m_forceReadForBC0);
336 // increment event iterators
337 if(!loadEventProxies) {
338 return this->nextEvent_passive(isCentralBunchCrossing);
339 }
340 const xAOD::EventInfo* pBkgEvent = nextEvent( isCentralBunchCrossing ); //FIXME update this for the case where loadProxies=False
341
342 //check input selector is not empty
343 PileUpStream* currStream(this->current());
344 if (0 == pBkgEvent || 0 == currStream)
345 {
346 // This is the end of the loop. No more events in the selection
347 ATH_MSG_INFO ( "end of loop: background cache has no more events" );
348 return StatusCode::FAILURE;
349 }
350 StoreGateSvc* pBkgStore = &(currStream->store());
351 ATH_MSG_DEBUG ( "added event " << pBkgEvent->eventNumber()
352 << " run " << pBkgEvent->runNumber()
353 << " from store "
354 << pBkgStore->name()
355 << " @ Xing " << iXing );
356
357 // register as sub event of the overlaid
358
359 // get the SG container for subevents infos
360 xAOD::EventInfoContainer *subEvCnt (nullptr);
361 ATH_CHECK( overEvent->evtStore()->retrieve(subEvCnt, c_pileUpEventInfoContName) );
362 // add subevent
363 addSubEvent( overEvent, pBkgEvent, t0BinCenter, m_pileUpEventType, subEvCnt, c_pileUpEventInfoContName );
364 subEvCnt->back()->setBCID( BCID );
365 subEvCnt->back()->setEvtStore( pBkgStore );
366
367#ifdef DEBUG_PILEUP
368 const xAOD::EventInfo* pStoreInfo(nullptr);
369 if (pBkgStore->retrieve(pStoreInfo).isSuccess() && pStoreInfo &&
370 pBkgEvent->eventNumber() != pStoreInfo->eventNumber())
371 {
372 ATH_MSG_ERROR ( "added event " << pBkgEvent->eventNumber()
373 << " run " << pBkgEvent->runNumber()
374 << " differ from current store "
375 << pBkgStore->name()
376 << " event " << pStoreInfo->eventNumber()
377 << " run " << pStoreInfo->runNumber()
378 );
379 assert(1);
380 }
381#endif
382 } //loop over evts in xing
383 return StatusCode::SUCCESS;
384}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
xAOD::EventInfo * addSubEvent(xAOD::EventInfo *targetEv, const xAOD::EventInfo::SubEvent &subev, xAOD::EventInfoContainer *eiContainer, const std::string &eiContKey, StoreGateSvc *subev_store=nullptr)
const std::string c_pileUpEventInfoContName
default value for the EventInfoContainer storing subevents for PileUp
Definition PileUpMisc.h:15
const xAOD::EventInfo * nextEvent(bool isCentralBunchCrossing)
get next bkg event from cache
xAOD::EventInfo::PileUpType m_pileUpEventType
the type of events in this cache
PileUpStream * current()
get current (last asked) stream
unsigned int nEvtsXing(unsigned int iXing) const
Gaudi::Property< bool > m_forceReadForBC0
StatusCode nextEvent_passive(bool isCentralBunchCrossing)
as nextEvent except don't actually load anything
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ addSubEvts() [2/2]

StatusCode BkgStreamsCache::addSubEvts ( unsigned int iXing,
xAOD::EventInfo * overlaidEvent,
int t0BinCenter )
finaloverridevirtual

Read input events in bkg stores and link them to overlay store.

Parameters
iXingoffset to first xing number (=0 first Xing, =nXings for last xing)
overlaidEventreference to resulting overlaid event
t0BinCentertime wrto t0 of current bin center in ns

Definition at line 319 of file BkgStreamsCache.cxx.

322{
323 return this->addSubEvts(iXing, overEvent, t0BinCenter, true, 0);
324}
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.

◆ alreadyInUse()

bool BkgStreamsCache::alreadyInUse ( StreamVector::size_type iStream)
private

Definition at line 199 of file BkgStreamsCache.cxx.

200{
201 assert(iS<m_usedStreams.size());
202 bool inUse(m_usedStreams[iS]);
203 if (!inUse) m_usedStreams[iS] = true;
204#ifndef NDEBUG
205 ATH_MSG_VERBOSE ( "alreadyInUse: store " << iS << ' '
206 << (inUse ? "already" : "not yet") << " in use" );
207#endif
208 return inUse;
209}
#define ATH_MSG_VERBOSE(x)
std::vector< bool > m_usedStreams

◆ collXing()

long BkgStreamsCache::collXing ( )
inline

meant to be used (mainly) via m_f_collDistr

Definition at line 80 of file BkgStreamsCache.h.

80{ return m_collXing; }
Gaudi::Property< float > m_collXing

◆ collXingPoisson()

long BkgStreamsCache::collXingPoisson ( )

Definition at line 121 of file BkgStreamsCache.cxx.

122{
123 if (!m_collXingPoisson) { return collXing(); }
125}
float m_collXingSF
float scaling number of collisions per bunch crossing
long collXing()
meant to be used (mainly) via m_f_collDistr

◆ current()

PileUpStream * BkgStreamsCache::current ( )
private

get current (last asked) stream

Definition at line 211 of file BkgStreamsCache.cxx.

212{
213 if (m_cursor != m_streams.end()) return &*m_cursor;
214 // m_cursor->isNotEmpty()) return &*m_cursor;
215 else return 0; //FIXME should reomve empty stream and keep going
216}
StreamVector::iterator m_cursor
StreamVector m_streams

◆ finalize()

StatusCode BkgStreamsCache::finalize ( )
finaloverridevirtual

Definition at line 386 of file BkgStreamsCache.cxx.

387{
388 StatusCode sc(StatusCode::SUCCESS);
389 ATH_MSG_DEBUG ( "Finalizing " << name()
390 << " - cache for events of type "
392 while (sc.isSuccess() && m_streams.size()>0)
393 {
394 sc=m_streams.back().finalize();
395 m_streams.pop_back();
396 }
397 return sc;
398}
static Double_t sc
static const std::string & PileUpType2Name(PileUpType typ)
Convert PileUpType enum value to string.
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ initialize()

StatusCode BkgStreamsCache::initialize ( )
finaloverridevirtual

Definition at line 218 of file BkgStreamsCache.cxx.

219{
220 ATH_MSG_DEBUG ( "Initializing " << name()
221 << " - cache for events of type "
223
225
226 //create random number generators
227 ATH_CHECK(m_atRndmSvc.retrieve());
228 CLHEP::HepRandomEngine* collEng(m_atRndmSvc->GetEngine(m_randomStreamName.value()));
229 if( 0 == collEng )
230 {
231 ATH_MSG_ERROR ( "can not get random stream " << m_randomStreamName.value() );
232 return StatusCode::FAILURE;
233 }
234
235 //setup distribution to read a new event every downscaleFactor accesses
236 //notice how we pass collEng by reference. If ! CLHEP will take ownership...
237 m_readEventRand = new CLHEP::RandFlat(*(collEng),
238 0.0, double(m_readDownscale));
239
240 // select collision distribution functions
241 if (m_collDistrName.value() == "Fixed")
242 {
243 m_f_collDistr = std::bind(&BkgStreamsCache::collXing, this);
244 using namespace std::placeholders;
245 if(m_ignoreBM.value())
246 {
248 }
249 else
250 {
252 }
253 return StatusCode::SUCCESS;
254 }
255 if (m_collDistrName.value() == "Poisson")
256 {
257 //pass collEng by reference. If Not CLHEP will take ownership...
258 m_collXingPoisson = new CLHEP::RandPoisson(*(collEng), m_collXing);
259 // m_f_collDistr will call m_collXingPoisson->fire(m_collXing) USED TO BE boost::bind(&CLHEP::RandPoisson::fire, m_collXingPoisson);
261 using namespace std::placeholders;
262 if(m_ignoreBM.value())
263 {
265 }
266 else
267 {
269 }
270 return StatusCode::SUCCESS;
271 }
273 << " is not a know collision distribution function" );
274 return StatusCode::FAILURE;
275}
unsigned int numberOfBkgForBunchCrossingIgnoringBeamIntensity(unsigned int iXing) const
meant to be used via m_f_numberOfBackgroundForBunchCrossing
ServiceHandle< IAtRndmGenSvc > m_atRndmSvc
Gaudi::Property< std::string > m_collDistrName
Gaudi::Property< float > m_readDownscale
Gaudi::Property< std::string > m_randomStreamName
Gaudi::Property< bool > m_ignoreBM
std::function< long() > m_f_collDistr
function returning the number of collisions per bunch crossing before bunch structure modulation
unsigned int numberOfBkgForBunchCrossingDefaultImpl(unsigned int iXing) const
unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const
void PileUpEventTypeHandler(Gaudi::Details::PropertyBase &)
std::function< unsigned int(unsigned int) > m_f_numberOfBackgroundForBunchCrossing
function returning the number of bkg events per bunch crossing after bunch structure modulation

◆ nEvtsXing()

unsigned int BkgStreamsCache::nEvtsXing ( unsigned int iXing) const
private

Definition at line 277 of file BkgStreamsCache.cxx.

278{
279 return (iXing + 1 > m_nEvtsXing.size()) ? 0 : m_nEvtsXing[iXing];
280}
std::vector< unsigned int > m_nEvtsXing

◆ newEvent()

void BkgStreamsCache::newEvent ( )
finaloverridevirtual

inform cache that we start overlaying a new event

Definition at line 127 of file BkgStreamsCache.cxx.

128{
129 ATH_MSG_DEBUG ( "newEvent called resetting used event set" );
130 unsigned int totEvts(0);
131 do {
132 totEvts = 0;
133 for (unsigned int iXing=0; iXing<m_nXings; ++iXing) {
134 totEvts += setNEvtsXing(iXing);
135 if (totEvts > m_nStores) {
136 ATH_MSG_WARNING ( "newEvent: number of required evts (" << totEvts << ") exceeds number of available stores "
137 << m_nStores << ". Regenerating bkg sequence for this event \n"
138 << " the total number of bkg events may not exceed average by more than 6 sigmas"
139 );
140 break;
141 }
142 }
143 } while(totEvts > m_nStores);
144 m_usedStreams.assign(m_streams.size(), false);
145}
#define ATH_MSG_WARNING(x)
unsigned int m_nXings
unsigned int m_nStores
unsigned int setNEvtsXing(unsigned int iXing)

◆ nextEvent()

const xAOD::EventInfo * BkgStreamsCache::nextEvent ( bool isCentralBunchCrossing)
private

get next bkg event from cache

Definition at line 147 of file BkgStreamsCache.cxx.

148{
149 const xAOD::EventInfo* pNextEvt(nullptr);
150 StreamVector::size_type iS(0);
151 do {
152 iS = (StreamVector::size_type)m_chooseEventRand->fire();
153 } while (alreadyInUse(iS));
154
155 //set current store to iS
156 m_cursor = m_streams.begin();
157 std::advance(m_cursor, iS);
158
159 ATH_MSG_DEBUG ( "using store " << iS );
160 PileUpStream* pCurrStream(current());
161 if (0 != pCurrStream) {
162 pCurrStream->store().makeCurrent();
163 //read a new event every downscaleFactor accesses
164 //force reading of new event if the event is being used for in-time pile-up
165 //FIXME a more careful strategy would have the PileUpStreams knowing if
166 //they have been used for the central bunch-crossing already.
167 bool readEvent(isCentralBunchCrossing || (m_readEventRand->fire()<1.0));
168 pNextEvt = pCurrStream->nextEventPre( readEvent );
169 }
170 return pNextEvt;
171}
bool alreadyInUse(StreamVector::size_type iStream)

◆ nextEvent_passive()

StatusCode BkgStreamsCache::nextEvent_passive ( bool isCentralBunchCrossing)
private

as nextEvent except don't actually load anything

Definition at line 174 of file BkgStreamsCache.cxx.

175{
176 StreamVector::size_type iS(0);
177 do {
178 iS = (StreamVector::size_type)m_chooseEventRand->fire();
179 } while (alreadyInUse(iS));
180
181 //set current store to iS
182 m_cursor = m_streams.begin();
183 std::advance(m_cursor, iS);
184
185 ATH_MSG_DEBUG ( "using store " << iS );
186 PileUpStream* pCurrStream(current());
187 if (0 != pCurrStream) {
188 pCurrStream->store().makeCurrent();
189 //read a new event every downscaleFactor accesses
190 //force reading of new event if the event is being used for in-time pile-up
191 //FIXME a more careful strategy would have the PileUpStreams knowing if
192 //they have been used for the central bunch-crossing already.
193 bool readEvent(isCentralBunchCrossing || (m_readEventRand->fire()<1.0));
194 if(pCurrStream->nextEventPre_Passive(readEvent)) return StatusCode::SUCCESS;
195 }
196 return StatusCode::FAILURE;
197}

◆ nStores()

virtual unsigned int BkgStreamsCache::nStores ( ) const
inlinefinaloverridevirtual

how many stores in this cache

Definition at line 77 of file BkgStreamsCache.h.

77{ return m_nStores; }

◆ numberOfBkgForBunchCrossingDefaultImpl()

unsigned int BkgStreamsCache::numberOfBkgForBunchCrossingDefaultImpl ( unsigned int iXing) const

Definition at line 286 of file BkgStreamsCache.cxx.

287{
288 return static_cast<unsigned int>(m_beamInt->normFactor(iXing-m_zeroXing)*static_cast<float>(m_f_collDistr()));
289}
int m_zeroXing
offset of BC=0 xing
IBeamIntensity * m_beamInt
pointer to the IBeamIntensity distribution tool

◆ numberOfBkgForBunchCrossingIgnoringBeamIntensity()

unsigned int BkgStreamsCache::numberOfBkgForBunchCrossingIgnoringBeamIntensity ( unsigned int iXing) const

meant to be used via m_f_numberOfBackgroundForBunchCrossing

Definition at line 282 of file BkgStreamsCache.cxx.

283{
284 return m_f_collDistr();
285}

◆ numberOfCavernBkgForBunchCrossing()

unsigned int BkgStreamsCache::numberOfCavernBkgForBunchCrossing ( unsigned int iXing) const

Definition at line 290 of file BkgStreamsCache.cxx.

291{
292 return static_cast<unsigned int>(m_beamInt->normFactor(iXing-m_zeroXing)>0.0)*m_f_collDistr();
293}

◆ PileUpEventTypeHandler()

void BkgStreamsCache::PileUpEventTypeHandler ( Gaudi::Details::PropertyBase & )
private

Definition at line 42 of file BkgStreamsCache.cxx.

43{
45}
static PileUpType PileUpInt2Type(unsigned short typ)
Convert int to PileUpType enum value.

◆ resetEvtsPerXingScaleFactor()

void BkgStreamsCache::resetEvtsPerXingScaleFactor ( float sf)
finaloverridevirtual

reset scale factor at new run/lumiblk

Definition at line 116 of file BkgStreamsCache.cxx.

117{
118 if (!m_ignoreSF) m_collXingSF = sf;
119}
Gaudi::Property< bool > m_ignoreSF

◆ setNEvtsXing()

unsigned int BkgStreamsCache::setNEvtsXing ( unsigned int iXing)
private

Definition at line 295 of file BkgStreamsCache.cxx.

296{
297 if (iXing + 1 > m_nEvtsXing.size()) m_nEvtsXing.resize(2 * iXing + 1);
298 unsigned int nEvts(m_f_numberOfBackgroundForBunchCrossing(iXing));
299 //this is done mainly to handle the case in which original and backround
300 //events belong to the same stream. Of course we do not want m_nEvtsXing[m_zeroXing]<0
301 if ((int)iXing==m_zeroXing)
302 {
303 unsigned int subValue(m_subtractBC0.value());
304 while (nEvts<subValue) nEvts = m_f_numberOfBackgroundForBunchCrossing(iXing);
305 nEvts -= subValue;
306#ifndef NDEBUG
307 ATH_MSG_VERBOSE ( "Subtracted " << m_subtractBC0.value()
308 << " events from BC=0 Xing " << iXing << " - Events at BC=0 "
309 << nEvts
310 );
311#endif
312 }
313 ATH_MSG_VERBOSE ( "Will pile-up " << nEvts
314 << " events for BCID " << iXing );
315 m_nEvtsXing[iXing] = nEvts;
316 return nEvts;
317}
Gaudi::Property< unsigned short > m_subtractBC0

◆ setup()

StatusCode BkgStreamsCache::setup ( int firstXing,
unsigned int nXings,
unsigned int firstStore,
IBeamIntensity * iBM )
finaloverridevirtual
Parameters
nXingsbunch Xings to be processed
firstStoreid of first store in cache

Definition at line 48 of file BkgStreamsCache.cxx.

52{
53 assert (0 < nXings);
54 m_nXings = nXings;
55 m_zeroXing = -firstXing;
56 if (m_zeroXing >= (int)nXings) m_zeroXing = -99;
57 m_beamInt = (m_ignoreBM.value() ? 0 : iBM);
58 float largestElement( ( m_ignoreBM.value() || m_collDistrName.value() == "Fixed" ) ? 1.0 : m_beamInt->largestElementInPattern() );
59 //ceil (cmath) rounds up to the nearest integer ceil(1.5)= 2
60 float occupiedCrossings = ceil(static_cast<float>(m_nXings) * m_occupationFraction);
61 m_nStores = static_cast<unsigned int>(ceil( m_collXing * occupiedCrossings * largestElement));
62 if (m_collDistrName.value() == "Poisson")
63 {
64 //allow for fluctuations in # of overlaid events
65 m_nStores += static_cast<unsigned int>(6.0 * sqrt(static_cast<float>(m_nStores)));
66 }
67
68 //get bkg selectors, stores and iterators
69 ATH_MSG_DEBUG ( "Set up " << m_nStores << " stores" );
70
71 m_nEvtsXing.reserve(m_nStores);
72 m_streams.reserve(m_nStores);
73 m_usedStreams.reserve(m_nStores);
74 m_usedStreams.assign(m_nStores, false);
75
76 const std::string& selecName(m_selecName.name());
77 for (unsigned int i=0; i < m_nStores; ++i)
78 {
79 std::stringstream bufName;
80 bufName << "BkgEvent_" << i + firstStore;
81 const std::string& streamName(bufName.str());
82 try
83 {
84 m_streams.emplace_back(streamName,serviceLocator(),selecName);
85 }
86 catch (const std::runtime_error& e)
87 {
88 ATH_MSG_ERROR ( "Exception thrown while creating PileUpStream "
89 << streamName << " : " << e.what() );
90 return StatusCode::FAILURE;
91 }
92
93 if(!(m_streams.back().setupStore()))
94 {
95 ATH_MSG_ERROR ( "Can not setup bkg evt store for stream "
96 << streamName );
97 return StatusCode::FAILURE;
98 }
99 }
100 m_cursor = m_streams.begin();
101
102 CLHEP::HepRandomEngine* collEng(m_atRndmSvc->GetEngine(m_randomStreamName.value()));
103 if( !collEng )
104 {
105 ATH_MSG_ERROR ( "can not get random stream " << m_randomStreamName.value() );
106 return StatusCode::FAILURE;
107 }
108 //setup generator to pickup an event store at random from the cache
109 //notice how we pass collEng by reference. If ! CLHEP will take ownership...
110 m_chooseEventRand = new CLHEP::RandFlat(*(collEng),
111 0.0, double(m_nStores));
112
113 return StatusCode::SUCCESS;
114}
Gaudi::Property< float > m_occupationFraction
ServiceHandle< IEvtSelector > m_selecName

Member Data Documentation

◆ m_atRndmSvc

ServiceHandle<IAtRndmGenSvc> BkgStreamsCache::m_atRndmSvc
private
Initial value:
{this, "RndmGenSvc", "AtRndmGenSvc",
"IAtRndmGenSvc controlling the distribution of bkg events/xing"}

Definition at line 108 of file BkgStreamsCache.h.

108 {this, "RndmGenSvc", "AtRndmGenSvc",
109 "IAtRndmGenSvc controlling the distribution of bkg events/xing"};

◆ m_beamInt

IBeamIntensity* BkgStreamsCache::m_beamInt {nullptr}
private

pointer to the IBeamIntensity distribution tool

Definition at line 167 of file BkgStreamsCache.h.

167{nullptr};

◆ m_chooseEventRand

CLHEP::RandFlat* BkgStreamsCache::m_chooseEventRand {nullptr}
private

pickup an event store at random from the cache

Definition at line 153 of file BkgStreamsCache.h.

153{nullptr};

◆ m_collDistrName

Gaudi::Property<std::string> BkgStreamsCache::m_collDistrName
private
Initial value:
{this, "CollDistribution", "Poisson",
"nEvts/Xings can be either Fixed at CollPerXing or Poisson with average CollPerXing"}

Definition at line 117 of file BkgStreamsCache.h.

117 {this, "CollDistribution", "Poisson",
118 "nEvts/Xings can be either Fixed at CollPerXing or Poisson with average CollPerXing"};

◆ m_collXing

Gaudi::Property<float> BkgStreamsCache::m_collXing
private
Initial value:
{this, "CollPerXing", 23.0,
"(average) number of collisions per beam crossing"}

Definition at line 111 of file BkgStreamsCache.h.

111 {this, "CollPerXing", 23.0,
112 "(average) number of collisions per beam crossing"};

◆ m_collXingPoisson

CLHEP::RandPoisson* BkgStreamsCache::m_collXingPoisson {nullptr}
private

set number of collisions per bunch crossing (if Poisson distribution chosen)

Definition at line 155 of file BkgStreamsCache.h.

155{nullptr};

◆ m_collXingSF

float BkgStreamsCache::m_collXingSF {1.0}
private

float scaling number of collisions per bunch crossing

Definition at line 163 of file BkgStreamsCache.h.

163{1.0};

◆ m_cursor

StreamVector::iterator BkgStreamsCache::m_cursor {}
private

Definition at line 99 of file BkgStreamsCache.h.

99{};

◆ m_f_collDistr

std::function< long() > BkgStreamsCache::m_f_collDistr
private

function returning the number of collisions per bunch crossing before bunch structure modulation

Definition at line 158 of file BkgStreamsCache.h.

◆ m_f_numberOfBackgroundForBunchCrossing

std::function< unsigned int(unsigned int) > BkgStreamsCache::m_f_numberOfBackgroundForBunchCrossing
private

function returning the number of bkg events per bunch crossing after bunch structure modulation

Definition at line 161 of file BkgStreamsCache.h.

◆ m_forceReadForBC0

Gaudi::Property<bool> BkgStreamsCache::m_forceReadForBC0
private
Initial value:
{this, "ForceReadForBC0", true,
"Force events used in the central bunch crossing to be refreshed"}

Definition at line 145 of file BkgStreamsCache.h.

145 {this, "ForceReadForBC0", true,
146 "Force events used in the central bunch crossing to be refreshed"};

◆ m_ignoreBM

Gaudi::Property<bool> BkgStreamsCache::m_ignoreBM
private
Initial value:
{this, "IgnoreBeamInt", false,
"Default=False, set to True to ignore the PileUpEventLoopMgr beam intensity "
"tool in setting the number of events per xing."}

Definition at line 137 of file BkgStreamsCache.h.

137 {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."};

◆ m_ignoreSF

Gaudi::Property<bool> BkgStreamsCache::m_ignoreSF
private
Initial value:
{this, "IgnoreBeamLumi", false,
"Default=False, set to True to ignore the PileUpEventLoopMgr beam luminosity "
"tool in setting the number of events per xing."}

Definition at line 141 of file BkgStreamsCache.h.

141 {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."};

◆ m_nEvtsXing

std::vector<unsigned int> BkgStreamsCache::m_nEvtsXing
private

Definition at line 104 of file BkgStreamsCache.h.

◆ m_nStores

unsigned int BkgStreamsCache::m_nStores {0}
private

Definition at line 103 of file BkgStreamsCache.h.

103{0};

◆ m_nXings

unsigned int BkgStreamsCache::m_nXings {0}
private

Definition at line 102 of file BkgStreamsCache.h.

102{0};

◆ m_occupationFraction

Gaudi::Property<float> BkgStreamsCache::m_occupationFraction
private
Initial value:
{this, "OccupationFraction", 1.0,
"The maximum fraction of bunch-crossings which will be occupied."}

Definition at line 114 of file BkgStreamsCache.h.

114 {this, "OccupationFraction", 1.0,
115 "The maximum fraction of bunch-crossings which will be occupied."};

◆ m_pileUpEventType

xAOD::EventInfo::PileUpType BkgStreamsCache::m_pileUpEventType
private

the type of events in this cache

Definition at line 149 of file BkgStreamsCache.h.

◆ m_pileUpEventTypeProp

Gaudi::CheckedProperty<unsigned short> BkgStreamsCache::m_pileUpEventTypeProp
private
Initial value:
{this, "PileUpEventType", 0,
"Type of the pileup events in this cache: 0:Signal, 1:MinimumBias, 2:Cavern, 3:HaloGas, "
"4:ZeroBias. Default=0 (Signal, Invalid)"}

Definition at line 127 of file BkgStreamsCache.h.

127 {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)"};

◆ m_randomStreamName

Gaudi::Property<std::string> BkgStreamsCache::m_randomStreamName
private
Initial value:
{this, "RndmStreamName", "PileUpCollXingStream",
"IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one "}

Definition at line 124 of file BkgStreamsCache.h.

124 {this, "RndmStreamName", "PileUpCollXingStream",
125 "IAtRndmGenSvc stream used as engine for our various random distributions, including the CollPerXing one "};

◆ m_readDownscale

Gaudi::Property<float> BkgStreamsCache::m_readDownscale
private
Initial value:
{this, "ReadDownscaleFactor", 150,
"read one event every downscaleFactor accesses (asymptotically -> number of times "
"an event in the cache will be reused)"}

Definition at line 120 of file BkgStreamsCache.h.

120 {this, "ReadDownscaleFactor", 150,
121 "read one event every downscaleFactor accesses (asymptotically -> number of times "
122 "an event in the cache will be reused)"};

◆ m_readEventRand

CLHEP::RandFlat* BkgStreamsCache::m_readEventRand {nullptr}
private

read a new event every downscaleFactor accesses

Definition at line 151 of file BkgStreamsCache.h.

151{nullptr};

◆ m_selecName

ServiceHandle<IEvtSelector> BkgStreamsCache::m_selecName {this, "EventSelector", "FakeEventSelector"}
private

Definition at line 106 of file BkgStreamsCache.h.

106{this, "EventSelector", "FakeEventSelector"};

◆ m_streams

StreamVector BkgStreamsCache::m_streams
private

Definition at line 100 of file BkgStreamsCache.h.

◆ m_subtractBC0

Gaudi::Property<unsigned short> BkgStreamsCache::m_subtractBC0
private
Initial value:
{this, "SubtractBC0", 0,
"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"}

Definition at line 133 of file BkgStreamsCache.h.

133 {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"};

◆ m_usedStreams

std::vector<bool> BkgStreamsCache::m_usedStreams
private

Definition at line 101 of file BkgStreamsCache.h.

◆ m_zeroXing

int BkgStreamsCache::m_zeroXing {-1}
private

offset of BC=0 xing

Definition at line 165 of file BkgStreamsCache.h.

165{-1};

The documentation for this class was generated from the following files: