ATLAS Offline Software
|
A wrapper class for event-slot-local random engines. More...
#include <RNGWrapper.h>
Public Types | |
enum | SeedingOptionType { MC20Seeding =0, MC16Seeding =1, MC21Seeding =2, SeedingDefault =MC21Seeding } |
Options for seeding option=0 is setSeed as in MC20 option=1 is setSeedLegacy as in MC16 option=2 is setSeedImproved. More... | |
Public Member Functions | |
RNGWrapper (const factoryFunc &genFact, size_t nSlots) | |
Constructor takes a factory function which can instantiate a CLHEP::HepRandomEngine and the number of event slots. More... | |
~RNGWrapper () | |
void | setSeed (const std::string &algName, const EventContext &ctx) |
Set the random seed using a string (e.g. More... | |
void | setSeed (const std::string &algName, size_t slot, uint64_t ev, uint64_t run, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the random seed using a string (e.g. More... | |
void | setSeedMC16 (const std::string &algName, size_t slot, uint64_t ev, uint64_t run, uint32_t offset=0, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the random seed using a string (e.g. More... | |
void | setSeedMC20 (const std::string &algName, size_t slot, uint64_t ev, uint64_t run, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the random seed using a string (e.g. More... | |
void | setSeedMC21 (const std::string &algName, size_t slot, uint64_t ev, uint64_t run, uint64_t offset=0, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the random seed using a string (e.g. More... | |
void | setSeedLegacy (const std::string &algName, size_t slot, uint64_t ev, uint64_t run, uint64_t offset, SeedingOptionType seeding, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the random seed using a string (e.g. More... | |
void | setSeedLegacy (const std::string &algName, const EventContext &ctx, uint32_t offset, SeedingOptionType seeding, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the random seed using a string (e.g. More... | |
void | setSeed (size_t slot, size_t seed, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the seed value directly for a specified slot. More... | |
void | setSeeds (size_t slot, const long *seeds, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT) |
Set the seed value(s) directly for a specified slot. More... | |
operator CLHEP::HepRandomEngine * () const | |
Cast-to-engine pointer operator. More... | |
CLHEP::HepRandomEngine * | getEngine (const EventContext &ctx) const |
Retrieve the random engine corresponding to the provided EventContext. More... | |
EventContext::ContextEvt_t | evtSeeded () const |
Return the event count at which the current slot was last seeded. More... | |
EventContext::ContextEvt_t | evtSeeded (const EventContext &ctx) const |
Return the event count at which the current slot of CTX was last seeded. More... | |
Static Public Attributes | |
static constexpr std::initializer_list< SeedingOptionType > | all_SeedingOptions = {MC20Seeding, MC16Seeding, MC21Seeding} |
Private Types | |
typedef std::function< CLHEP::HepRandomEngine *(void)> | factoryFunc |
Private Attributes | |
std::vector< CLHEP::HepRandomEngine * > | m_engines |
Vector of random engines, ordered by slot number. More... | |
std::vector< EventContext::ContextEvt_t > | m_evtSeeded |
Event counter when the engine was last seeded. More... | |
A wrapper class for event-slot-local random engines.
Implemented primarily for use in services implementing IAthRNGSvc for thread-safe random number generation in AthenaMT.
The slot-local HepRandomEngine is retrieved via the dereference operator or the getEngine method.
This class also provides a seed setting and generating mechanism. The seed is calculated from an algorithm name and the slot, event, and run numbers.
Definition at line 55 of file RNGWrapper.h.
|
private |
Definition at line 58 of file RNGWrapper.h.
Options for seeding option=0 is setSeed as in MC20 option=1 is setSeedLegacy as in MC16 option=2 is setSeedImproved.
Enumerator | |
---|---|
MC20Seeding | |
MC16Seeding | |
MC21Seeding | |
SeedingDefault |
Definition at line 97 of file RNGWrapper.h.
ATHRNG::RNGWrapper::RNGWrapper | ( | const factoryFunc & | genFact, |
size_t | nSlots | ||
) |
Constructor takes a factory function which can instantiate a CLHEP::HepRandomEngine and the number of event slots.
Definition at line 69 of file RNGWrapper.cxx.
ATHRNG::RNGWrapper::~RNGWrapper | ( | ) |
Definition at line 79 of file RNGWrapper.cxx.
|
inline |
Return the event count at which the current slot was last seeded.
Definition at line 139 of file RNGWrapper.h.
|
inline |
Return the event count at which the current slot of CTX was last seeded.
Definition at line 145 of file RNGWrapper.h.
|
inline |
Retrieve the random engine corresponding to the provided EventContext.
Definition at line 134 of file RNGWrapper.h.
|
inline |
Cast-to-engine pointer operator.
Retrieves the current event context and returns the engine corresponding to the current event slot.
Definition at line 129 of file RNGWrapper.h.
Set the random seed using a string (e.g.
algorithm name) and the current EventContext. Does nothing if the context is invalid.
Definition at line 169 of file RNGWrapper.h.
|
inline |
Set the random seed using a string (e.g.
algorithm name) and the current slot, event, and run numbers.
Definition at line 163 of file RNGWrapper.h.
void ATHRNG::RNGWrapper::setSeed | ( | size_t | slot, |
size_t | seed, | ||
EventContext::ContextEvt_t | evt = EventContext::INVALID_CONTEXT_EVT |
||
) |
|
inline |
Set the random seed using a string (e.g.
algorithm name) and the current EventContext and an optional offset. Does nothing if the context is invalid. - Version allowing to switch the seeding options
Definition at line 177 of file RNGWrapper.h.
void ATHRNG::RNGWrapper::setSeedLegacy | ( | const std::string & | algName, |
size_t | slot, | ||
uint64_t | ev, | ||
uint64_t | run, | ||
uint64_t | offset, | ||
SeedingOptionType | seeding, | ||
EventContext::ContextEvt_t | evt = EventContext::INVALID_CONTEXT_EVT |
||
) |
Set the random seed using a string (e.g.
algorithm name) and the current slot, event, and run numbers and an optional offset. - Version allowing to switch the seeding options
Definition at line 104 of file RNGWrapper.cxx.
void ATHRNG::RNGWrapper::setSeedMC16 | ( | const std::string & | algName, |
size_t | slot, | ||
uint64_t | ev, | ||
uint64_t | run, | ||
uint32_t | offset = 0 , |
||
EventContext::ContextEvt_t | evt = EventContext::INVALID_CONTEXT_EVT |
||
) |
Set the random seed using a string (e.g.
algorithm name) and the current slot, event, and run numbers and an optional offset. - MC16 Legacy Version attempting to reproduce seeds from thread-unsafe random number services
Definition at line 122 of file RNGWrapper.cxx.
void ATHRNG::RNGWrapper::setSeedMC20 | ( | const std::string & | algName, |
size_t | slot, | ||
uint64_t | ev, | ||
uint64_t | run, | ||
EventContext::ContextEvt_t | evt = EventContext::INVALID_CONTEXT_EVT |
||
) |
Set the random seed using a string (e.g.
algorithm name) and the current slot, event, and run numbers. MC20 seeding algorithm
Definition at line 87 of file RNGWrapper.cxx.
void ATHRNG::RNGWrapper::setSeedMC21 | ( | const std::string & | algName, |
size_t | slot, | ||
uint64_t | ev, | ||
uint64_t | run, | ||
uint64_t | offset = 0 , |
||
EventContext::ContextEvt_t | evt = EventContext::INVALID_CONTEXT_EVT |
||
) |
Set the random seed using a string (e.g.
algorithm name) and the current slot, event, and run numbers. MC21 seeding algorithm
Definition at line 95 of file RNGWrapper.cxx.
void ATHRNG::RNGWrapper::setSeeds | ( | size_t | slot, |
const long * | seeds, | ||
EventContext::ContextEvt_t | evt = EventContext::INVALID_CONTEXT_EVT |
||
) |
|
staticconstexpr |
Definition at line 103 of file RNGWrapper.h.
|
private |
Vector of random engines, ordered by slot number.
Definition at line 153 of file RNGWrapper.h.
|
private |
Event counter when the engine was last seeded.
Definition at line 156 of file RNGWrapper.h.