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 public:
15  GammaNumericalGenerator(double a = 0, double b = 0, double x1 = 0, double x2 = 0)
16  : BaseNumericalRandomGenerator(x1, x2, 1000), a_(a), b_(b), valid(false) {
17  if (a > 0 && b > 0) {
18  valid = true;
19  initialize();
20  }
21  }
22 
25 
27  double gamma(RandomEngineAndDistribution const* random) const { return generate(random); }
28 
29  double gamma_exp(RandomEngineAndDistribution const* random) const { return generateExp(random); }
30 
31  double gamma_lin(RandomEngineAndDistribution const* random) const { return generateLin(random); }
32 
34  double function(double x) override { return ersatzt(x); }
35 
36  inline bool isValid() const { return valid; }
37 
38 private:
40  double ersatzt(double x) {
41  double bt = b_ * x;
42  return b_ * pow(bt, a_ - 1) * exp(-bt);
43  }
44 
45  // gamma distribution parameters
46  double a_, b_;
47  bool valid;
48 };
49 
50 #endif
funct::false
false
Definition: Factorize.h:29
BaseNumericalRandomGenerator::generateExp
double generateExp(RandomEngineAndDistribution const *) const
Definition: BaseNumericalRandomGenerator.cc:83
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
BaseNumericalRandomGenerator::generateLin
double generateLin(RandomEngineAndDistribution const *) const
Definition: BaseNumericalRandomGenerator.cc:98
GammaNumericalGenerator::a_
double a_
Definition: GammaNumericalGenerator.h:46
GammaNumericalGenerator::gamma_exp
double gamma_exp(RandomEngineAndDistribution const *random) const
Definition: GammaNumericalGenerator.h:29
GammaNumericalGenerator::isValid
bool isValid() const
Definition: GammaNumericalGenerator.h:36
DDAxes::x
GammaNumericalGenerator::b_
double b_
Definition: GammaNumericalGenerator.h:46
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
BaseNumericalRandomGenerator::initialize
void initialize()
The initialization (numerical integarion, inversion)
Definition: BaseNumericalRandomGenerator.cc:13
GammaNumericalGenerator::GammaNumericalGenerator
GammaNumericalGenerator(double a=0, double b=0, double x1=0, double x2=0)
Constructor : initialization of the Random Generator.
Definition: GammaNumericalGenerator.h:15
BaseNumericalRandomGenerator::generate
double generate(RandomEngineAndDistribution const *) const
The random generation according to function()
Definition: BaseNumericalRandomGenerator.cc:75
GammaNumericalGenerator::gamma_lin
double gamma_lin(RandomEngineAndDistribution const *random) const
Definition: GammaNumericalGenerator.h:31
b
double b
Definition: hdecay.h:118
GammaNumericalGenerator::gamma
double gamma(RandomEngineAndDistribution const *random) const
Random generator.
Definition: GammaNumericalGenerator.h:27
GammaNumericalGenerator
Definition: GammaNumericalGenerator.h:12
a
double a
Definition: hdecay.h:119
BaseNumericalRandomGenerator.h
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
BaseNumericalRandomGenerator
Definition: BaseNumericalRandomGenerator.h:27
GammaNumericalGenerator::ersatzt
double ersatzt(double x)
Gamma Function.
Definition: GammaNumericalGenerator.h:40
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
GammaNumericalGenerator::valid
bool valid
Definition: GammaNumericalGenerator.h:47
GammaNumericalGenerator::~GammaNumericalGenerator
~GammaNumericalGenerator() override
Default destructor.
Definition: GammaNumericalGenerator.h:24
RandomEngineAndDistribution
Definition: RandomEngineAndDistribution.h:18