5#ifndef ATHENAKERNEL_RNGWRAPPER_H
6#define ATHENAKERNEL_RNGWRAPPER_H
13#include "GaudiKernel/EventContext.h"
14#include "GaudiKernel/ThreadLocalContext.h"
17 class HepRandomEngine;
58 typedef std::function<CLHEP::HepRandomEngine*(void)>
factoryFunc;
69 inline void setSeed(
const std::string& algName,
const EventContext& ctx);
73 inline void setSeed(
const std::string& algName,
size_t slot, uint64_t
ev, uint64_t
run,
74 EventContext::ContextEvt_t evt = EventContext::INVALID_CONTEXT_EVT);
90 EventContext::ContextEvt_t evt = EventContext::INVALID_CONTEXT_EVT);
93 void setSeed(
size_t slot,
size_t seed,
94 EventContext::ContextEvt_t evt = EventContext::INVALID_CONTEXT_EVT);
97 void setSeeds(
size_t slot,
const long * seeds,
98 EventContext::ContextEvt_t evt = EventContext::INVALID_CONTEXT_EVT);
103 operator CLHEP::HepRandomEngine*()
const {
104 return m_engines[Gaudi::Hive::currentContext().slot()];
108 CLHEP::HepRandomEngine*
getEngine(
const EventContext &ctx)
const {
113 EventContext::ContextEvt_t
evtSeeded(
const EventContext &ctx)
const
124 void setSeedMC16(
const std::string& algName,
size_t slot, uint64_t
ev, uint64_t
run, uint32_t offset=0,
125 EventContext::ContextEvt_t evt = EventContext::INVALID_CONTEXT_EVT);
129 void setSeedMC20(
const std::string& algName,
size_t slot, uint64_t
ev, uint64_t
run,
130 EventContext::ContextEvt_t evt = EventContext::INVALID_CONTEXT_EVT);
134 void setSeedMC21(
const std::string& algName,
size_t slot, uint64_t
ev, uint64_t
run, uint64_t offset=0,
135 EventContext::ContextEvt_t evt = EventContext::INVALID_CONTEXT_EVT);
149 EventContext::ContextEvt_t evt )
157 ctx.eventID().event_number(),
158 ctx.eventID().run_number(),
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
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.
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.
std::function< CLHEP::HepRandomEngine *(void)> factoryFunc
RNGWrapper(const factoryFunc &genFact, size_t nSlots)
Constructor takes a factory function which can instantiate a CLHEP::HepRandomEngine and the number of...
std::vector< EventContext::ContextEvt_t > m_evtSeeded
Event counter when the engine was last seeded.
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.
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.
std::vector< CLHEP::HepRandomEngine * > m_engines
Vector of random engines, ordered by slot number.
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.
SeedingOptionType
Options for seeding.
static constexpr std::initializer_list< SeedingOptionType > all_SeedingOptions
EventContext::ContextEvt_t evtSeeded(const EventContext &ctx) const
Return the event count at which the current slot of CTX was last seeded.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
size_t calculateSeedMC20(const std::string &algName, uint64_t ev, uint64_t run)
Set the random seed using a string (e.g.
void calculateSeedsMC21(long *seeds, const std::string &algName, uint64_t ev, uint64_t run, uint64_t offset=0)
Set the random seed using a string (e.g.
long calculateSeedsPython(const std::string &algName, uint64_t ev, uint64_t run, uint64_t offset=0)
size_t calculateSeedMC16(const std::string &algName, uint64_t ev, uint64_t run, uint32_t offset=0)
Helper methods.
int run(int argc, char *argv[])