CMS 3D CMS Logo

GammaNumericalGenerator.h
Go to the documentation of this file.
1 #ifndef GammaNumericalGenerator_H
2 #define GammaNumericalGenerator_H
4 
5 #include <cmath>
11 
13 {
14  public:
15 
17  GammaNumericalGenerator(double a=0,double b=0,double x1=0,double x2=0) :
19  a_(a),b_(b),valid(false) {
20 
21  if(a>0&&b>0)
22  {
23  valid=true;
24  initialize();
25  }
26  }
27 
30 
32  double gamma(RandomEngineAndDistribution const* random) const { return generate(random); }
33 
34  double gamma_exp(RandomEngineAndDistribution const* random) const {return generateExp(random);}
35 
36  double gamma_lin(RandomEngineAndDistribution const* random) const {return generateLin(random);}
37 
39  double function(double x) override { return ersatzt(x); }
40 
41  inline bool isValid() const {return valid;}
42 
43  private:
44 
46  double ersatzt(double x) {
47  double bt=b_*x;
48  return b_*pow(bt,a_-1)*exp(-bt);
49  }
50 
51  // gamma distribution parameters
52  double a_,b_;
53  bool valid;
54 };
55 
56 #endif
double generate(RandomEngineAndDistribution const *) const
The random generation according to function()
double generateLin(RandomEngineAndDistribution const *) const
double gamma(RandomEngineAndDistribution const *random) const
Random generator.
TRandom random
Definition: MVATrainer.cc:138
void initialize()
The initialization (numerical integarion, inversion)
double gamma_exp(RandomEngineAndDistribution const *random) const
GammaNumericalGenerator(double a=0, double b=0, double x1=0, double x2=0)
Constructor : initialization of the Random Generator.
double generateExp(RandomEngineAndDistribution const *) const
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
~GammaNumericalGenerator() override
Default destructor.
double gamma_lin(RandomEngineAndDistribution const *random) const
double ersatzt(double x)
Gamma Function.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40