Belle II Software  release-08-01-10
RandomEngine.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 #ifndef SIMULATION_KERNEL_RANDOMENGINE_H
11 #define SIMULATION_KERNEL_RANDOMENGINE_H
12 
13 #include <CLHEP/Random/Random.h>
14 #include <framework/core/RandomGenerator.h>
15 
16 namespace Belle2 {
22  class RandomEngine final: public CLHEP::HepRandomEngine {
23  public:
25  RandomEngine(): CLHEP::HepRandomEngine() {}
27  double flat() override final { return dynamic_cast<RandomGenerator&>(*gRandom).random01(); }
32  void flatArray(const int size, double* vect) override final { dynamic_cast<RandomGenerator&>(*gRandom).RndmArray(size, vect); }
34  void setSeed(long, int) override final {}
36  void setSeeds(const long*, int) override final {}
38  void saveStatus(const char[]) const override final {}
40  void restoreStatus(const char[]) override final {}
42  void showStatus() const override final {}
44  std::string name() const override final { return "Belle2::RandomGenerator"; }
46  std::vector<unsigned long> put() const override final { return std::vector<unsigned long>(); }
48  std::ostream& put(std::ostream& o) const override final { return o; }
50  bool get(const std::vector<unsigned long>&) override final { return false; }
52  std::istream& get(std::istream& i) override final { return i; }
53  };
54 
56 } //Belle2 namespace
57 #endif // SIMULATION_KERNEL_RANDOMENGINE_H
Interface class to make Geant4 use the Belle2 RandomGenerator.
Definition: RandomEngine.h:22
std::vector< unsigned long > put() const override final
put call, whatever that does.
Definition: RandomEngine.h:46
void restoreStatus(const char[]) override final
restore status from file, ignored
Definition: RandomEngine.h:40
void flatArray(const int size, double *vect) override final
fill an array of doubles with values in (0,1), both exluded
Definition: RandomEngine.h:32
void setSeed(long, int) override final
set the seed, ignored
Definition: RandomEngine.h:34
void saveStatus(const char[]) const override final
save status to file, ignored
Definition: RandomEngine.h:38
std::ostream & put(std::ostream &o) const override final
put call, whatever that does.
Definition: RandomEngine.h:48
void showStatus() const override final
show status, ignored
Definition: RandomEngine.h:42
void setSeeds(const long *, int) override final
set array of seed values, ignored
Definition: RandomEngine.h:36
std::string name() const override final
return name of the generator
Definition: RandomEngine.h:44
RandomEngine()
Constructor expecting a reference to the Belle2::RandomGenerator.
Definition: RandomEngine.h:25
std::istream & get(std::istream &i) override final
get call, I assume same as above
Definition: RandomEngine.h:52
bool get(const std::vector< unsigned long > &) override final
get call, I assume same as above
Definition: RandomEngine.h:50
double flat() override final
return a flat distributed double in (0,1), both excluded
Definition: RandomEngine.h:27
Fast Random number Generator using on xorshift1024* [arXiv:1402.6246].
double random01()
Generate a random double value between 0 and 1, both limits excluded.
void RndmArray(Int_t n, Float_t *array)
Fill an array of floats with random values in (0,1), both limits excluded.
Abstract base class for different kinds of events.