51 explicit RandomGenerator(
const std::string& name =
"Belle2 Random Generator");
65 void setSeed(
const unsigned char* seed,
unsigned int n);
119 void RndmArray(Int_t n, Float_t* array)
override;
124 void RndmArray(Int_t n, Double_t* array)
override;
130 void RndmArray(Int_t n, ULong64_t* array);
157 void RndmArray(Int_t n,
unsigned char* array);
216 for (
int i = 0; i < n; ++i) array[i] =
random01();
222 for (
int i = 0; i < n; ++i) array[i] =
random01();
228 for (
int i = 0; i < n; ++i) array[i] =
random64();
237 if (n % 2) array[n - 1] =
random32();
260 union { uint64_t i;
double d; } x;
265 x.i |= 0x3FF0000000000000ULL;
271 const uint64_t x =
random64() >> 12;
276 return x * 2.220446049250313080847263336181640625e-16;
void RndmArray(Int_t n, Long64_t *array)
Fill an array of 64bit integers with random values in [INT64_MIN, INT64_MAX], both limits included.
void setState(int barrier)
Set the state of the random number generator.
void setBarrier(int barrierIndex)
manually set the barrier index to a fixed value
const std::vector< unsigned char > & getSeed() const
return the seed object
EGeneratorMode
Generator mode: determines which information is used to generate the internal state.
@ c_runDependent
Use experiment and run number to generate state.
@ c_eventDependent
Use experiment, run and event number to generate state.
@ c_independent
Don't use event info to generate state.
uint64_t m_state[16]
Internal state of the random number generator.
void initialize()
set the State from event meta information like experiment, run, and event number.
int getBarrier() const
obtain the currently active barrier id
Double_t Rndm(Int_t) override
Generate a random value in (0,1), both limits excluded (backward compatibility with root < 6....
void RndmArray(Int_t n, Int_t *array)
Fill an array of 32bit integers with random values in [INT32_MIN, INT32_MAX], both limits included.
void SetSeed(ULong_t) override
argument type was changed in root 6.08.
unsigned int m_index
currently active index in the internal state
int m_barrier
current barrier index.
EGeneratorMode m_mode
Current generator mode.
Double_t Rndm() override
Generate a random value in (0,1), both limits excluded.
EGeneratorMode getMode() const
Get the generator mode.
void setSeed(const unsigned char *seed, unsigned int n)
Set the seed information.
ClassDefOverride(RandomGenerator, 2)
and the root dictionary macro needs to be documented as well :) Version 2: merge m_eventDependent and...
std::vector< unsigned char > m_seed
seed information
void setMode(EGeneratorMode mode)
Set the generator mode.
void SetSeed(UInt_t)
override base class SetSeed to do nothing, we don't need it but it gets called by parent constructor
uint32_t random32()
Generate one 32bit unsigned integer between 0 and UINT32_MAX (both inclusive)
RandomGenerator(const std::string &name="Belle2 Random Generator")
Default constructor, does not initialize the generator.
virtual ~RandomGenerator()
Destructor to free the seed information.
void barrier()
increase the barrier index.
double random01()
Generate a random double value between 0 and 1, both limits excluded.
uint64_t random64()
Generate one 64bit unsigned integer between 0 and UINT64_MAX (both inclusive).
void RndmArray(Int_t n, Float_t *array) override
Fill an array of floats with random values in (0,1), both limits excluded.
Abstract base class for different kinds of events.