 |
ATLAS Offline Software
|
Go to the documentation of this file.
8 #include "GaudiKernel/IEvtSelector.h"
10 #include "CLHEP/Random/RandFlat.h"
11 #include "CLHEP/Random/RandPoisson.h"
27 const std::string&
name,
50 unsigned int firstStore,
61 m_nStores =
static_cast<unsigned int>(ceil(
m_collXing * occupiedCrossings * largestElement));
79 std::stringstream bufName;
80 bufName <<
"BkgEvent_" <<
i + firstStore;
86 catch (
const std::runtime_error&
e)
88 ATH_MSG_ERROR (
"Exception thrown while creating PileUpStream "
90 return StatusCode::FAILURE;
97 return StatusCode::FAILURE;
106 return StatusCode::FAILURE;
113 return StatusCode::SUCCESS;
129 ATH_MSG_DEBUG (
"newEvent called resetting used event set" );
130 unsigned int totEvts(0);
133 for (
unsigned int iXing=0; iXing<
m_nXings; ++iXing) {
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"
150 StreamVector::size_type iS(0);
161 if (0 != pCurrStream) {
176 StreamVector::size_type iS(0);
187 if (0 != pCurrStream) {
196 return StatusCode::FAILURE;
206 << (inUse ?
"already" :
"not yet") <<
" in use" );
221 <<
" - cache for events of type "
232 return StatusCode::FAILURE;
244 using namespace std::placeholders;
253 return StatusCode::SUCCESS;
261 using namespace std::placeholders;
270 return StatusCode::SUCCESS;
273 <<
" is not a know collision distribution function" );
274 return StatusCode::FAILURE;
308 <<
" events from BC=0 Xing " << iXing <<
" - Events at BC=0 "
314 <<
" events for BCID " << iXing );
323 return this->
addSubEvts(iXing, overEvent, t0BinCenter,
true, 0);
329 int t0BinCenter,
bool loadEventProxies,
unsigned int BCID)
331 for (
unsigned int iEvt=0; iEvt<
nEvtsXing(iXing); ++iEvt)
337 if(!loadEventProxies) {
344 if (0 == pBkgEvent || 0 == currStream)
347 ATH_MSG_INFO (
"end of loop: background cache has no more events" );
348 return StatusCode::FAILURE;
355 <<
" @ Xing " << iXing );
365 subEvCnt->
back()->setEvtStore( pBkgStore );
369 if (pBkgStore->
retrieve(pStoreInfo).isSuccess() && pStoreInfo &&
374 <<
" differ from current store "
383 return StatusCode::SUCCESS;
390 <<
" - cache for events of type "
virtual StatusCode finalize() override final
const std::string c_pileUpEventInfoContName
default value for the EventInfoContainer storing subevents for PileUp
void PileUpEventTypeHandler(Gaudi::Details::PropertyBase &)
StreamVector::iterator m_cursor
StatusCode nextEvent_passive(bool isCentralBunchCrossing)
as nextEvent except don't actually load anything
Gaudi::CheckedProperty< unsigned short > m_pileUpEventTypeProp
Gaudi::Property< bool > m_ignoreBM
CLHEP::RandFlat * m_chooseEventRand
pickup an event store at random from the cache
uint64_t eventNumber() const
The current event's event number.
virtual float largestElementInPattern() const =0
the largest element in the beam intensity pattern.
std::vector< unsigned int > m_nEvtsXing
ServiceHandle< IAtRndmGenSvc > m_atRndmSvc
xAOD::EventInfo::PileUpType m_pileUpEventType
the type of events in this cache
unsigned int numberOfBkgForBunchCrossingDefaultImpl(unsigned int iXing) const
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
float scaling number of collisions per bunch crossing
Gaudi::Property< unsigned short > m_subtractBC0
In memory cache for pileup events.
void makeCurrent()
The current store is becoming the active store.
Gaudi::Property< bool > m_forceReadForBC0
Gaudi::Property< float > m_occupationFraction
std::function< long() > m_f_collDistr
function returning the number of collisions per bunch crossing before bunch structure modulation
Gaudi::Property< float > m_collXing
virtual StatusCode setup(int firstXing, unsigned int nXings, unsigned int firstStore, IBeamIntensity *) override final
#define ATH_MSG_VERBOSE(x)
uint32_t runNumber() const
The current event's run number.
unsigned int nEvtsXing(unsigned int iXing) const
IBeamIntensity * m_beamInt
pointer to the IBeamIntensity distribution tool
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
virtual float normFactor(int bunchXing) const =0
a scale factor (average value 1.0) for the beam intensity at a given xing.
Gaudi::Property< std::string > m_collDistrName
bool alreadyInUse(StreamVector::size_type iStream)
The Athena Transient Store API.
const xAOD::EventInfo * nextEventPre(bool readRecord=true)
return next Event, load store with next Event
Gaudi::Property< float > m_readDownscale
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Property< bool > m_ignoreSF
virtual void resetEvtsPerXingScaleFactor(float sf) override final
reset scale factor at new run/lumiblk
a triple selector/context/store defines a stream
bool nextEventPre_Passive(bool readRecord)
like nextEventPre, but doesn't actually load anything
const T * back() const
Access the last element in the collection as an rvalue.
virtual StatusCode initialize() override final
unsigned int numberOfCavernBkgForBunchCrossing(unsigned int iXing) const
int m_zeroXing
offset of BC=0 xing
Helpers for checking error return status codes and reporting errors.
long collXing()
meant to be used (mainly) via m_f_collDistr
CLHEP::RandPoisson * m_collXingPoisson
set number of collisions per bunch crossing (if Poisson distribution chosen)
ServiceHandle< IEvtSelector > m_selecName
unsigned int setNEvtsXing(unsigned int iXing)
Class describing the basic event information.
static PileUpType PileUpInt2Type(unsigned short typ)
Convert int to PileUpType enum value.
PileUpStream * current()
get current (last asked) stream
#define ATH_MSG_WARNING(x)
provides the relative beam intensity as a function of the bunch xing.
static const std::string & PileUpType2Name(PileUpType typ)
Convert PileUpType enum value to string.
std::vector< bool > m_usedStreams
virtual ~BkgStreamsCache()
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.
BkgStreamsCache(const std::string &, const std::string &, const IInterface *)
virtual void newEvent() override final
inform cache that we start overlaying a new event
unsigned int numberOfBkgForBunchCrossingIgnoringBeamIntensity(unsigned int iXing) const
meant to be used via m_f_numberOfBackgroundForBunchCrossing
Gaudi::Property< std::string > m_randomStreamName
xAOD::EventInfo * addSubEvent(xAOD::EventInfo *targetEv, const xAOD::EventInfo::SubEvent &subev, xAOD::EventInfoContainer *eiContainer, const std::string &eiContKey, StoreGateSvc *subev_store=nullptr)
const xAOD::EventInfo * nextEvent(bool isCentralBunchCrossing)
get next bkg event from cache
CLHEP::RandFlat * m_readEventRand
read a new event every downscaleFactor accesses