CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
ExponentialDistribution.hpp
1 /*
2  * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
12 #include <random>
13 
14 namespace corsika {
15 
16  template <typename Quantity>
18 
19  typedef typename Quantity::value_type real_type;
20  typedef std::exponential_distribution<real_type> distribution_type;
21 
22  public:
23  typedef Quantity value_type;
24 
25  ExponentialDistribution() = delete;
26 
27  ExponentialDistribution(value_type const& beta)
28  : beta_(beta) {}
29 
31  : beta_(other.getBeta()) {}
32 
35  if (this == &other) return *this;
36  beta_ = other.getBeta();
37  return *this;
38  }
39 
47  value_type getBeta() const { return beta_; }
48 
57  void setBeta(value_type const& beta) { beta_ = beta; }
58 
69  template <class Generator>
70  value_type operator()(Generator& g) {
71  return beta_ * dist_(g);
72  }
73 
74  private:
75  distribution_type dist_{1.};
76  value_type beta_;
77  };
78 
79 } // namespace corsika
Import and extend the phys::units package.
The cascade namespace assembles all objects needed to simulate full particles cascades.
void setBeta(value_type const &beta)
Set parameter of exponential distribution .
value_type operator()(Generator &g)
Generate a random number distributed like .
value_type getBeta() const
Get parameter of exponential distribution .