Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Functions
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. More...
 
size_t calculateSeedMC20 (const std::string &algName, uint64_t ev, uint64_t run)
 Set the random seed using a string (e.g. More...
 
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. More...
 
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=crc_combine(theHash, offset);
18  uint32_t runNumber = static_cast<uint32_t>(run);
19  theHash=crc_combine(theHash, runNumber);
20  theHash=crc_combine(theHash, algName);
21  return theHash;
22 }

◆ 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 }

◆ 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];
66  return seeds[0];
67 }
CxxUtils::MurmurHash64A
uint64_t MurmurHash64A(const void *key, int len, uint64_t seed)
Definition: MurmurHash2.cxx:103
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
xAOD::JetAlgorithmType::algName
const std::string & algName(ID id)
Converts a JetAlgorithmType::ID into a string.
Definition: JetContainerInfo.cxx:67
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
crc_combine
uint32_t crc_combine(uint32_t seed, uint32_t v)
using crc32 for architecture independence in combining the seeds
Definition: AthenaKernel/src/crc_combine.h:11
ev
int ev
Definition: globals.cxx:25
CxxUtils::crc64addint
uint64_t crc64addint(uint64_t crc, uint64_t x)
Extend a previously-calculated CRC to include an int.
Definition: crc64.cxx:732
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
run
Definition: run.py:1
CxxUtils::crc64
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.
Definition: crc64.cxx:696
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
ATHRNG::calculateSeedsMC21
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.
Definition: RNGWrapper.cxx:37