Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
RandomEngine.hh
Go to the documentation of this file.
1#ifndef G_RANDOM_ENGINE_H
2#define G_RANDOM_ENGINE_H
3
4namespace Garfield {
5
7template <typename Engine, typename SeedType>
9 public:
10 using seed_t = SeedType;
11 using engine_t = Engine;
12 RandomEngine() = default;
13 RandomEngine(const SeedType& seed) { this->SetSeed(seed); }
15 inline void SetSeed(const seed_t& seed) {
16 m_seed = seed;
17 static_cast<Engine*>(this)->SetSeed(m_seed);
18 }
19
20 inline double operator()() { return Draw(); }
22 inline double Draw() { return static_cast<Engine*>(this)->Draw(); }
24 inline seed_t GetSeed() { return static_cast<Engine*>(this)->GetSeed(); }
26 inline void Print() { return static_cast<Engine*>(this)->Print(); }
27
28 protected:
30};
31
32} // namespace Garfield
33#endif
void Print()
Print some information about the random number generator.
double operator()()
Draw a random number.
RandomEngine(const SeedType &seed)
seed_t GetSeed()
Retrieve the seed that was used.
void SetSeed(const seed_t &seed)
Initialise the random number generator.
double Draw()
Draw a random number.