ATLAS Offline Software
Loading...
Searching...
No Matches
ATHRNG Namespace Reference

Classes

class  RNGWrapper
 A wrapper class for event-slot-local random engines. More...

Functions

size_t calculateSeedMC16 (const std::string &algName, uint64_t ev, uint64_t run, uint32_t offset=0)
 Helper methods.
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)

Function Documentation

◆ calculateSeedMC16()

size_t ATHRNG::calculateSeedMC16 ( const std::string & algName,
uint64_t ev,
uint64_t run,
uint32_t offset = 0 )

Helper methods.

Set the random seed using a string (e.g.

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

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 15 of file RNGWrapper.cxx.

15 {
16 uint32_t theHash = static_cast<uint32_t>(ev);
17 if (0 != offset) theHash = CxxUtils::crc_combine(theHash, offset);
18 uint32_t runNumber = static_cast<uint32_t>(run);
19 theHash = CxxUtils::crc_combine(theHash, runNumber);
20 theHash = CxxUtils::crc_combine(theHash, algName);
21 return theHash;
22}
int ev
Definition globals.cxx:25
uint32_t crc_combine(uint32_t seed, uint32_t v)
Combines a 32-bit seed with another 32-bit value using CRC32.
Definition crc_combine.h:13
int run(int argc, char *argv[])

◆ calculateSeedMC20()

size_t ATHRNG::calculateSeedMC20 ( const std::string & algName,
uint64_t ev,
uint64_t run )

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 26 of file RNGWrapper.cxx.

26 {
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));
32 return hsh;
33}

◆ calculateSeedsMC21()

void ATHRNG::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.

algorithm name) and the current slot, event, and run numbers. MC21 seeding algorithm

Definition at line 37 of file RNGWrapper.cxx.

37 {
38 //RanecuEngine only takes the first seed, so the first seed should be good on it's own
39 //using 64bit crc which is already performing quite well on it's own
40 uint64_t theHash = CxxUtils::crc64(algName);
41 theHash = CxxUtils::crc64addint(theHash,ev);
42 theHash = CxxUtils::crc64addint(theHash,offset);
43 theHash = CxxUtils::crc64addint(theHash,run);
44
45 size_t iseed=0;
46 seeds[iseed]=(long)theHash; //CLHEP takes a zero terminated array for seeding. Avoid 0
47 if(seeds[iseed]!=0) ++iseed; //if zero, make the seed vector shorter, which should in itself already cause a different seeding
48 seeds[iseed]=(long)ev; //CLHEP takes a zero terminated array for seeding. Avoid ev==0
49 if(seeds[iseed]!=0) ++iseed; //Avoid 0
50 seeds[iseed]=(long)(ev >> 32); //explicitly split out the upper 32bit as dSFMTEngine only takes 32bits.
51 if(seeds[iseed]!=0) ++iseed; //Avoid 0
52 seeds[iseed]=(long)run;
53 if(seeds[iseed]!=0) ++iseed; //Avoid 0
54 uint64_t algHash = CxxUtils::MurmurHash64A ( algName.data(), algName.size(), 0 );
55 seeds[iseed]=(long)algHash;
56 if(seeds[iseed]!=0) ++iseed; //Avoid 0
57 seeds[iseed]=(long)offset;
58 if(seeds[iseed]!=0) ++iseed; //Avoid 0
59 seeds[iseed]=0; //CLHEP takes a zero terminated array for seeding, so end with 0
60 return;
61}
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
Definition crc64.cxx:695
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.
Definition crc64.cxx:731

◆ calculateSeedsPython()

long ATHRNG::calculateSeedsPython ( const std::string & algName,
uint64_t ev,
uint64_t run,
uint64_t offset = 0 )

Definition at line 63 of file RNGWrapper.cxx.

63 {
64 long seeds[7];
65 calculateSeedsMC21(seeds, algName, ev, run, offset);
66 return seeds[0];
67}
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.