CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Landau.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: Landau.cc,v 1.4 2003/10/10 17:40:39 garren Exp $
3// ---------------------------------------------------------------------------
4
5#include "CLHEP/GenericFunctions/Landau.hh"
6#include "CLHEP/GenericFunctions/Variable.hh"
7#include <cmath>
8#include <assert.h>
9#include <iostream>
10
11using namespace std;
12
13namespace Genfun {
15
17 _peak("Peak", 5.0 ,0, 10),
18 _width("Width",1.0,0, 10)
19{}
20
22}
23
24Landau::Landau(const Landau & right):
25AbsFunction(right),
26_peak(right._peak),
27_width(right._width)
28{
29}
30
31double Landau::operator() (double x) const {
32 double s = _width.getValue();
33 double x0 = _peak.getValue();
34 double xs = x0 + 0.222782*s;
35 return _denlan((x-xs)/s)/s;
36}
37
39 return _peak;
40}
41
43 return _width;
44}
45
46const Parameter & Landau::peak() const {
47 return _peak;
48}
49
50const Parameter & Landau::width() const {
51 return _width;
52}
53
54double Landau::_denlan(double x) const {
55 /* Initialized data */
56
57 static float p1[5] = { (float).4259894875,(float)-.124976255,(float)
58 .039842437,(float)-.006298287635,(float).001511162253 };
59 static float q5[5] = { (float)1.,(float)156.9424537,(float)3745.310488,(
60 float)9834.698876,(float)66924.28357 };
61 static float p6[5] = { (float)1.000827619,(float)664.9143136,(float)
62 62972.92665,(float)475554.6998,(float)-5743609.109 };
63 static float q6[5] = { (float)1.,(float)651.4101098,(float)56974.73333,(
64 float)165917.4725,(float)-2815759.939 };
65 static float a1[3] = { (float).04166666667,(float)-.01996527778,(float)
66 .02709538966 };
67 static float a2[2] = { (float)-1.84556867,(float)-4.284640743 };
68 static float q1[5] = { (float)1.,(float)-.3388260629,(float).09594393323,(
69 float)-.01608042283,(float).003778942063 };
70 static float p2[5] = { (float).1788541609,(float).1173957403,(float)
71 .01488850518,(float)-.001394989411,(float)1.283617211e-4 };
72 static float q2[5] = { (float)1.,(float).7428795082,(float).3153932961,(
73 float).06694219548,(float).008790609714 };
74 static float p3[5] = { (float).1788544503,(float).09359161662,(float)
75 .006325387654,(float)6.611667319e-5,(float)-2.031049101e-6 };
76 static float q3[5] = { (float)1.,(float).6097809921,(float).2560616665,(
77 float).04746722384,(float).006957301675 };
78 static float p4[5] = { (float).9874054407,(float)118.6723273,(float)
79 849.279436,(float)-743.7792444,(float)427.0262186 };
80 static float q4[5] = { (float)1.,(float)106.8615961,(float)337.6496214,(
81 float)2016.712389,(float)1597.063511 };
82 static float p5[5] = { (float)1.003675074,(float)167.5702434,(float)
83 4789.711289,(float)21217.86767,(float)-22324.9491 };
84
85 /* System generated locals */
86 float ret_val, r__1;
87
88 /* Local variables */
89 static float u, v;
90 v = x;
91 if (v < (float)-5.5) {
92 u = exp(v + (float)1.);
93 ret_val = exp(-1 / u) / sqrt(u) * (float).3989422803 * ((a1[0] + (a1[
94 1] + a1[2] * u) * u) * u + 1);
95 } else if (v < (float)-1.) {
96 u = exp(-v - 1);
97 ret_val = exp(-u) * sqrt(u) * (p1[0] + (p1[1] + (p1[2] + (p1[3] + p1[
98 4] * v) * v) * v) * v) / (q1[0] + (q1[1] + (q1[2] + (q1[3] +
99 q1[4] * v) * v) * v) * v);
100 } else if (v < (float)1.) {
101 ret_val = (p2[0] + (p2[1] + (p2[2] + (p2[3] + p2[4] * v) * v) * v) *
102 v) / (q2[0] + (q2[1] + (q2[2] + (q2[3] + q2[4] * v) * v) * v)
103 * v);
104 } else if (v < (float)5.) {
105 ret_val = (p3[0] + (p3[1] + (p3[2] + (p3[3] + p3[4] * v) * v) * v) *
106 v) / (q3[0] + (q3[1] + (q3[2] + (q3[3] + q3[4] * v) * v) * v)
107 * v);
108 } else if (v < (float)12.) {
109 u = 1 / v;
110/* Computing 2nd power */
111 r__1 = u;
112 ret_val = r__1 * r__1 * (p4[0] + (p4[1] + (p4[2] + (p4[3] + p4[4] * u)
113 * u) * u) * u) / (q4[0] + (q4[1] + (q4[2] + (q4[3] + q4[4] *
114 u) * u) * u) * u);
115 } else if (v < (float)50.) {
116 u = 1 / v;
117/* Computing 2nd power */
118 r__1 = u;
119 ret_val = r__1 * r__1 * (p5[0] + (p5[1] + (p5[2] + (p5[3] + p5[4] * u)
120 * u) * u) * u) / (q5[0] + (q5[1] + (q5[2] + (q5[3] + q5[4] *
121 u) * u) * u) * u);
122 } else if (v < (float)300.) {
123 u = 1 / v;
124/* Computing 2nd power */
125 r__1 = u;
126 ret_val = r__1 * r__1 * (p6[0] + (p6[1] + (p6[2] + (p6[3] + p6[4] * u)
127 * u) * u) * u) / (q6[0] + (q6[1] + (q6[2] + (q6[3] + q6[4] *
128 u) * u) * u) * u);
129 } else {
130 u = 1 / (v - v * log(v) / (v + 1));
131/* Computing 2nd power */
132 r__1 = u;
133 ret_val = r__1 * r__1 * ((a2[0] + a2[1] * u) * u + 1);
134 }
135 return ret_val;
136
137}
138
139} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual ~Landau()
Definition: Landau.cc:21
Parameter & peak()
Definition: Landau.cc:38
virtual double operator()(double argument) const override
Definition: Landau.cc:31
Parameter & width()
Definition: Landau.cc:42
virtual double getValue() const
Definition: Parameter.cc:29
Definition: Abs.hh:14