CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
PtRelFcn.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id:
3#include "CLHEP/GenericFunctions/defs.h"
4#include "CLHEP/GenericFunctions/PtRelFcn.hh"
5#include "CLHEP/GenericFunctions/Variable.hh"
6#include <assert.h>
7#include <cmath> // for pow() and exp() and isfinite()
8#include <float.h>
9#include <iostream>
10
11#if (defined __STRICT_ANSI__) || (defined _WIN32)
12#ifndef M_PI
13#define M_PI 3.14159265358979323846
14#endif // M_PI
15#endif // __STRICT_ANSI__
16
17namespace Genfun {
18FUNCTION_OBJECT_IMP(PtRelFcn)
19
21 _p0("P0", 0, 0, 1),
22 _p1("P1", 0, 0, 2),
23 _p2("P2", 1, 0, 10),
24 _p3("P3", 0, 0, 10),
25 _p4("P4", 1.0, 0.1, 5.0),
26 _p5("P5", 0.0, 0, 50)
27{}
28
30}
31
33AbsFunction(right),
34_p0(right._p0),
35_p1(right._p1),
36_p2(right._p2),
37_p3(right._p3),
38_p4(right._p4),
39_p5(right._p5)
40{
41}
42
43double PtRelFcn::operator() (double x) const {
44
45 double p0 = _p0.getValue();
46 double p1 = _p1.getValue();
47 double p2 = _p2.getValue();
48 double p3 = _p3.getValue();
49 double p4 = _p4.getValue();
50 double p5 = _p5.getValue();
51
52 //assert ((p0>=0.0) && (p0<=1.0));
53 if (p0<0.0) p0=FLT_MIN;
54 if (p0>1.0) p0=1.0-FLT_MIN;
55
56 if (x<=0.0) return 1.0E-10;
57
58 double n = (1+p1)/p3;
59 double a = (1/p3)*std::pow(p2,-n);
60
61 double norm = 1.0/(a*exp(_logGamma(n)));
62 static const double s2 = sqrt(2.0);
63 double retVal=
64 norm*p0*std::pow(x,p1)*exp(-p2*std::pow(x,p3)) +
65 (2.0/(1+_erf(p5/p4/s2))*(1.0-p0)/(sqrt(2*M_PI)*p4))*exp(-(x-p5)*(x-p5)/(2.0*p4*p4));
66
67 //if (!std::isfinite(retVal)) return 1.0E-10;
68
69 return std::max(retVal,1.0E-10);
70}
71
73 return _p0;
74}
75
76const Parameter & PtRelFcn::P0() const {
77 return _p0;
78}
79
81 return _p1;
82}
83
84const Parameter & PtRelFcn::P1() const {
85 return _p1;
86}
87
89 return _p2;
90}
91
92const Parameter & PtRelFcn::P2() const {
93 return _p2;
94}
95
97 return _p3;
98}
99
100const Parameter & PtRelFcn::P3() const {
101 return _p3;
102}
103
105 return _p4;
106}
107
108const Parameter & PtRelFcn::P4() const {
109 return _p4;
110}
111
113 return _p5;
114}
115
116const Parameter & PtRelFcn::P5() const {
117 return _p5;
118}
119
120
121
122
123
124} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual double getValue() const
Definition: Parameter.cc:29
Parameter & P2()
Definition: PtRelFcn.cc:88
Parameter & P4()
Definition: PtRelFcn.cc:104
Parameter & P5()
Definition: PtRelFcn.cc:112
virtual ~PtRelFcn()
Definition: PtRelFcn.cc:29
Parameter & P0()
Definition: PtRelFcn.cc:72
virtual double operator()(double argument) const override
Definition: PtRelFcn.cc:43
Parameter & P1()
Definition: PtRelFcn.cc:80
Parameter & P3()
Definition: PtRelFcn.cc:96
Definition: Abs.hh:14