 |
Belle II Software
release-05-02-19
|
11 #include <boost/python.hpp>
15 #include <framework/core/RandomNumbers.h>
16 #include <framework/pcore/ProcHandler.h>
17 #include <framework/pcore/ProcHelper.h>
18 #include <framework/logging/Logger.h>
38 std::random_device random_device;
39 std::stringstream seed;
40 for (
int i = 0; i < 8; ++i) {
41 seed << std::hex << random_device();
58 B2DEBUG(100,
"Replacing gRandom from " << gRandom <<
" to " << gen);
75 B2ERROR(
"Random Generator gRandom is not Belle2::RandomGenerator, cannot increase barrier");
84 B2INFO(
"The random number seed is set to \"" << seed <<
'"');
141 std::string pythonObjectToString(
const boost::python::object& obj)
143 return boost::python::extract<std::string>(obj.attr(
"__str__")());
146 void setPythonSeed(
const boost::python::object& obj)
154 using namespace boost::python;
157 docstring_options options(
true,
true,
false);
159 def(
"set_random_seed", &setPythonSeed, args(
"seed"), R
"DOCSTRING(
160 Set the random seed. The argument can be any object and will be converted to a
161 string using the builtin str() function and will be used to initialize the
162 random generator.)DOCSTRING");
@ c_independent
Don't use event info to generate state.
@ c_runDependent
Use experiment and run number to generate state.
static std::string s_initialSeed
The random number generator seed set by the user.
static void useEventDependent()
Set Event dependent Random Generator as current one.
static void barrier()
Increase random barrier.
static RandomGenerator * s_runRng
event independent random generator to be used for begin/end run processing
@ c_eventDependent
Use experiment, run and event number to generate state.
Fast Random number Generator using on xorshift1024* [arXiv:1402.6246].
void setBarrier(int barrierIndex)
manually set the barrier index to a fixed value
static void initializeEndRun()
Initialize run independent random generator for end run.
static void initialize()
Initialize the random number generator with a unique random seed;.
static void exposePythonAPI()
Exposes methods of the RandomNumbers class to Python.
static void setSeed(const std::string &seed)
Sets the seed for the random number generator.
Abstract base class for different kinds of events.
static void initializeEvent(bool force=false)
Initialize event information.
static RandomGenerator * s_evtRng
event dependent random generator to be used for event processing
void setSeed(const unsigned char *seed, unsigned int n)
Set the seed information.
static bool isInitialized()
Truth that the random number generator has been initialized.
static std::string getSeed()
Get the random number generator seed.
static bool isInputProcess()
Return true if the process is an input process.
static int s_barrierOffset
barrier index offset to be used in begin/endRun.
static bool parallelProcessingUsed()
Returns true if multiple processes have been spawned, false in single-core mode.
static void initializeBeginRun()
Initialize run independent random generator for begin run.
void setMode(EGeneratorMode mode)
Set the generator mode.
void initialize()
set the State from event meta information like experiment, run, and event number.
int getBarrier() const
obtain the currently active barrier id