6#include "CLHEP/Random/RandomEngine.h"
16 uint32_t theHash =
static_cast<uint32_t
>(
ev);
17 if (0 != offset) theHash=
crc_combine(theHash, offset);
18 uint32_t runNumber =
static_cast<uint32_t
>(
run);
27 auto algHash = std::hash<std::string>{}(algName);
28 auto evHash = std::hash<uint64_t>{}(
ev);
29 auto runHash = std::hash<uint64_t>{}(
run);
30 auto hsh = evHash ^ (runHash + (evHash << 6) + (evHash >> 2));
31 hsh = hsh ^ (algHash + (hsh << 6) + (hsh >> 2));
46 seeds[iseed]=(long)theHash;
47 if(seeds[iseed]!=0) ++iseed;
48 seeds[iseed]=(long)
ev;
49 if(seeds[iseed]!=0) ++iseed;
50 seeds[iseed]=(long)(
ev >> 32);
51 if(seeds[iseed]!=0) ++iseed;
52 seeds[iseed]=(long)
run;
53 if(seeds[iseed]!=0) ++iseed;
55 seeds[iseed]=(long)algHash;
56 if(seeds[iseed]!=0) ++iseed;
57 seeds[iseed]=(long)offset;
58 if(seeds[iseed]!=0) ++iseed;
73 for(
size_t t = 0; t < nSlots; t++){
76 m_evtSeeded.resize (nSlots, EventContext::INVALID_CONTEXT_EVT);
88 uint64_t
ev, uint64_t
run,
89 EventContext::ContextEvt_t evt )
96 uint64_t
ev, uint64_t
run, uint64_t offset,
97 EventContext::ContextEvt_t evt )
106 EventContext::ContextEvt_t evt )
123 EventContext::ContextEvt_t evt )
130 EventContext::ContextEvt_t evt )
133 if (evt == EventContext::INVALID_CONTEXT_EVT) {
134 evt = Gaudi::Hive::currentContext().evt();
140 EventContext::ContextEvt_t evt )
143 if (evt == EventContext::INVALID_CONTEXT_EVT) {
144 evt = Gaudi::Hive::currentContext().evt();
uint32_t crc_combine(uint32_t seed, uint32_t v)
using crc32 for architecture independence in combining the seeds
Implementation of MurmurHash2.
void setSeed(const std::string &algName, const EventContext &ctx)
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 option=0 is setSeed as in MC20 option=1 is setSeedLegacy as in MC16 option=2 is s...
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.
A crc-64 implementation, using pclmul where possible.
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.
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
uint64_t MurmurHash64A(const void *key, int len, uint64_t seed)
uint64_t crc64addint(uint64_t crc, uint64_t x)
Extend a previously-calculated CRC to include an int.