|
ATLAS Offline Software
|
Go to the documentation of this file.
14 #include "GaudiKernel/IEvtSelector.h"
16 #include "CLHEP/Random/RandFlat.h"
17 #include "CLHEP/Random/RandPoisson.h"
29 const std::string&
name,
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)
45 , m_readEventRand(nullptr)
46 , m_chooseEventRand(nullptr)
47 , m_collXingPoisson(nullptr)
49 , m_f_numberOfBackgroundForBunchCrossing(0)
54 , m_forceReadForBC0(true)
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");
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");
88 unsigned int firstStore,
99 m_nStores =
static_cast<unsigned int>(ceil(
m_collXing * occupiedCrossings * largestElement));
117 std::stringstream bufName;
118 bufName <<
"BkgEvent_" <<
i + firstStore;
124 catch (
const std::runtime_error&
e)
126 ATH_MSG_ERROR (
"Exception thrown while creating PileUpStream "
128 return StatusCode::FAILURE;
135 return StatusCode::FAILURE;
144 return StatusCode::FAILURE;
151 return StatusCode::SUCCESS;
167 ATH_MSG_DEBUG (
"newEvent called resetting used event set" );
168 unsigned int totEvts(0);
171 for (
unsigned int iXing=0; iXing<
m_nXings; ++iXing) {
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"
188 StreamVector::size_type iS(0);
199 if (0 != pCurrStream) {
214 StreamVector::size_type iS(0);
225 if (0 != pCurrStream) {
234 return StatusCode::FAILURE;
244 << (inUse ?
"already" :
"not yet") <<
" in use" );
259 <<
" - cache for events of type "
270 return StatusCode::FAILURE;
282 using namespace std::placeholders;
291 return StatusCode::SUCCESS;
299 using namespace std::placeholders;
308 return StatusCode::SUCCESS;
311 <<
" is not a know collision distribution function" );
312 return StatusCode::FAILURE;
346 <<
" events from BC=0 Xing " << iXing <<
" - Events at BC=0 "
352 <<
" events for BCID " << iXing );
361 return this->
addSubEvts(iXing, overEvent, t0BinCenter,
true, 0);
367 int t0BinCenter,
bool loadEventProxies,
unsigned int BCID)
369 for (
unsigned int iEvt=0; iEvt<
nEvtsXing(iXing); ++iEvt)
375 if(!loadEventProxies) {
382 if (0 == pBkgEvent || 0 == currStream)
385 ATH_MSG_INFO (
"end of loop: background cache has no more events" );
386 return StatusCode::FAILURE;
393 <<
" @ Xing " << iXing );
403 tmp_ei.setEvtStore(pBkgStore);
409 if (pBkgStore->
retrieve(pStoreInfo).isSuccess() && pStoreInfo &&
414 <<
" differ from current store "
423 return StatusCode::SUCCESS;
430 <<
" - 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
the type of events in this cache
Gaudi::Property< bool > m_ignoreBM
ignore the PileUpEventLoopMgr beam intensity tool
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
IAtRndmGenSvc controlling the distribution of bkg events per bunch crossing.
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
subtract from number of events at bunch xing = 0
In memory cache for pileup events.
void makeCurrent()
The current store is becoming the active store.
Gaudi::Property< bool > m_forceReadForBC0
Force events used in the central bunch crossing to be refreshed.
Gaudi::Property< float > m_occupationFraction
The maximum fraction of bunch-crossings which will be occupied.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
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
select collision distribution
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
read downscale factor (average number of times a min bias is reused)
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Property< bool > m_ignoreSF
bool apply scaling number of collisions per bunch crossing ?
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
void setBCID(uint32_t value)
Set the bunch crossing ID of the event.
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
This class provides general information about an event. Event information is provided by the accessor...
CLHEP::RandPoisson * m_collXingPoisson
set number of collisions per bunch crossing (if Poisson distribution chosen)
ServiceHandle< IEvtSelector > m_selecName
For details on how the MC particles are defined and organized see https://twiki.cern....
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
the IAtRndmGenSvc stream to generate number of bkg events per bunch crossing
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