Belle II Software  release-08-01-10
RandomNumbers Class Reference

The class for handling the random number generation. More...

#include <RandomNumbers.h>

Collaboration diagram for RandomNumbers:

Static Public Member Functions

static void initialize ()
 Initialize the random number generator with a unique random seed;.
 
static void initialize (const std::string &seed)
 Initialize the random number generator. More...
 
static bool isInitialized ()
 Truth that the random number generator has been initialized.
 
static void initializeBeginRun ()
 Initialize run independent random generator for begin run. More...
 
static void initializeEndRun ()
 Initialize run independent random generator for end run. More...
 
static void initializeEvent (bool force=false)
 Initialize event information. More...
 
static void useEventDependent ()
 Set Event dependent Random Generator as current one. More...
 
static RandomGeneratorgetEventRandomGenerator ()
 return reference to the event dependent random generator
 
static void barrier ()
 Increase random barrier. More...
 
static void setSeed (const std::string &seed)
 Sets the seed for the random number generator. More...
 
static std::string getSeed ()
 Get the random number generator seed. More...
 
static void exposePythonAPI ()
 Exposes methods of the RandomNumbers class to Python.
 

Static Private Attributes

static RandomGenerators_evtRng {nullptr}
 event dependent random generator to be used for event processing
 
static RandomGenerators_runRng {nullptr}
 event independent random generator to be used for begin/end run processing
 
static std::string s_initialSeed
 The random number generator seed set by the user. More...
 
static int s_barrierOffset
 barrier index offset to be used in begin/endRun. More...
 

Detailed Description

The class for handling the random number generation.

Definition at line 23 of file RandomNumbers.h.

Member Function Documentation

◆ barrier()

void barrier ( )
static

Increase random barrier.

current random generator will be reseeded with a different "barrier index" which makes it's state independent from previous calls

Definition at line 69 of file RandomNumbers.cc.

70 {
71  auto* gen = dynamic_cast<RandomGenerator*>(gRandom);
72  if (!gen) {
73  B2ERROR("Random Generator gRandom is not Belle2::RandomGenerator, cannot increase barrier");
74  } else {
75  gen->barrier();
76  }
77 }
Fast Random number Generator using on xorshift1024* [arXiv:1402.6246].

◆ getSeed()

static std::string getSeed ( )
inlinestatic

Get the random number generator seed.

Returns
The initial random number generator seed.

Definition at line 92 of file RandomNumbers.h.

92 {return s_initialSeed;};
static std::string s_initialSeed
The random number generator seed set by the user.

◆ initialize()

void initialize ( const std::string &  seed)
static

Initialize the random number generator.

Parameters
seedThe random number generator seed.

Definition at line 44 of file RandomNumbers.cc.

◆ initializeBeginRun()

void initializeBeginRun ( )
static

Initialize run independent random generator for begin run.

Called by EventProcessor, should not be called by other users

Definition at line 85 of file RandomNumbers.cc.

◆ initializeEndRun()

void initializeEndRun ( )
static

Initialize run independent random generator for end run.

Called by EventProcessor, should not be called by other users

Definition at line 97 of file RandomNumbers.cc.

◆ initializeEvent()

void initializeEvent ( bool  force = false)
static

Initialize event information.

Called by EventProcessor, should not be called by other users

Parameters
forceif true force initialization even in parallel processing mode for all processes and ignore the generator state that might have been passed in the event stream. This is only used on HLT event processor

Definition at line 108 of file RandomNumbers.cc.

◆ setSeed()

void setSeed ( const std::string &  seed)
static

Sets the seed for the random number generator.

Parameters
seedThe random number generator seed.

Definition at line 79 of file RandomNumbers.cc.

◆ useEventDependent()

void useEventDependent ( )
static

Set Event dependent Random Generator as current one.

Called by EventProcessor, should not be called by other users

Definition at line 128 of file RandomNumbers.cc.

Member Data Documentation

◆ s_barrierOffset

int s_barrierOffset
staticprivate

barrier index offset to be used in begin/endRun.

Obtained from event dependent generator

Definition at line 113 of file RandomNumbers.h.

◆ s_initialSeed

std::string s_initialSeed
staticprivate

The random number generator seed set by the user.

initialized to a non-deterministic 64byte hex string if not set by user

Definition at line 111 of file RandomNumbers.h.


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