ATLAS Offline Software
Loading...
Searching...
No Matches
CP::BootstrapGenerator Class Reference

a class to generate random numbers with a unique seed More...

#include <BootstrapGeneratorAlg.h>

Collaboration diagram for CP::BootstrapGenerator:

Public Member Functions

 BootstrapGenerator ()
 the standard constructor
std::uint64_t fnv1a_64 (const void *buffer, size_t size, std::uint64_t offset_basis)
 implementation of the hash function from https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
void setSeed (std::uint64_t eventNumber, std::uint32_t runNumber, std::uint32_t mcChannelNumber)
 set the seed of the random number generator based on event properties
std::uint64_t generateSeed (std::uint64_t eventNumber, std::uint32_t runNumber, std::uint32_t mcChannelNumber)
 generate a unique seed based on event identifiers
std::uint8_t getBootstrap ()
 get the next bootstrap weight

Private Attributes

TRandomRanluxpp m_rng
 the random number generator (Ranlux++)

Static Private Attributes

static constexpr std::uint64_t m_offset = 14695981039346656037u
 constants for seed generation
static constexpr std::uint64_t m_prime = 1099511628211u

Detailed Description

a class to generate random numbers with a unique seed

Definition at line 21 of file BootstrapGeneratorAlg.h.

Constructor & Destructor Documentation

◆ BootstrapGenerator()

CP::BootstrapGenerator::BootstrapGenerator ( )
inline

the standard constructor

Definition at line 25 of file BootstrapGeneratorAlg.h.

25{};

Member Function Documentation

◆ fnv1a_64()

std::uint64_t CP::BootstrapGenerator::fnv1a_64 ( const void * buffer,
size_t size,
std::uint64_t offset_basis )

implementation of the hash function from https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function

Definition at line 15 of file BootstrapGeneratorAlg.cxx.

15 {
16 std::uint64_t h = offset_basis;
17 const unsigned char *p = static_cast<const unsigned char *>(buffer);
18 for (size_t i = 0; i < size; i++) {
19 h ^= p[i];
20 h *= m_prime;
21 }
22 return h;
23}
static constexpr std::uint64_t m_prime

◆ generateSeed()

std::uint64_t CP::BootstrapGenerator::generateSeed ( std::uint64_t eventNumber,
std::uint32_t runNumber,
std::uint32_t mcChannelNumber )

generate a unique seed based on event identifiers

Definition at line 25 of file BootstrapGeneratorAlg.cxx.

26{
27 std::uint64_t hash = fnv1a_64(&runNumber, sizeof(runNumber), m_offset);
28 hash = fnv1a_64(&eventNumber, sizeof(eventNumber), hash);
30 return hash;
31}
std::uint64_t fnv1a_64(const void *buffer, size_t size, std::uint64_t offset_basis)
implementation of the hash function from https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo...
static constexpr std::uint64_t m_offset
constants for seed generation

◆ getBootstrap()

std::uint8_t CP::BootstrapGenerator::getBootstrap ( )
inline

get the next bootstrap weight

Definition at line 41 of file BootstrapGeneratorAlg.h.

41{ return m_rng.Poisson(1); };
TRandomRanluxpp m_rng
the random number generator (Ranlux++)

◆ setSeed()

void CP::BootstrapGenerator::setSeed ( std::uint64_t eventNumber,
std::uint32_t runNumber,
std::uint32_t mcChannelNumber )

set the seed of the random number generator based on event properties

Definition at line 33 of file BootstrapGeneratorAlg.cxx.

34{
35 std::uint64_t seed = generateSeed(eventNumber, runNumber, mcChannelNumber);
36 m_rng.SetSeed(seed);
37}
std::uint64_t generateSeed(std::uint64_t eventNumber, std::uint32_t runNumber, std::uint32_t mcChannelNumber)
generate a unique seed based on event identifiers

Member Data Documentation

◆ m_offset

std::uint64_t CP::BootstrapGenerator::m_offset = 14695981039346656037u
staticconstexprprivate

constants for seed generation

Definition at line 45 of file BootstrapGeneratorAlg.h.

◆ m_prime

std::uint64_t CP::BootstrapGenerator::m_prime = 1099511628211u
staticconstexprprivate

Definition at line 46 of file BootstrapGeneratorAlg.h.

◆ m_rng

TRandomRanluxpp CP::BootstrapGenerator::m_rng
private

the random number generator (Ranlux++)

Definition at line 50 of file BootstrapGeneratorAlg.h.


The documentation for this class was generated from the following files: