BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtPolInt Class Reference

#include <EvtPolInt.hh>

Public Member Functions

 EvtPolInt (vector< double > xi, vector< double > yi, double x)
virtual ~EvtPolInt ()
void polynomial ()
void ratint ()
vector< double > spline ()
void splint ()
double getvalue ()
double geterror ()

Detailed Description

Definition at line 30 of file EvtPolInt.hh.

Constructor & Destructor Documentation

◆ EvtPolInt()

EvtPolInt::EvtPolInt ( vector< double > xi,
vector< double > yi,
double x )
inline

Definition at line 32 of file EvtPolInt.hh.

32 {
33 xx = x;
34 size = xi.size();
35 vx.clear();
36 vy.clear();
37 for ( int i = 0; i < size; i++ )
38 {
39 vx.push_back( xi[i] );
40 vy.push_back( yi[i] );
41 }
42 }
Double_t x[10]

◆ ~EvtPolInt()

virtual EvtPolInt::~EvtPolInt ( )
inlinevirtual

Definition at line 43 of file EvtPolInt.hh.

43{}

Member Function Documentation

◆ geterror()

double EvtPolInt::geterror ( )

Definition at line 186 of file EvtPolInt.cc.

186 {
187 polynomial();
188 // ratint();
189 return error;
190}
void polynomial()
Definition EvtPolInt.cc:23

◆ getvalue()

double EvtPolInt::getvalue ( )

Definition at line 179 of file EvtPolInt.cc.

179 {
180 polynomial();
181 // ratint();
182 // splint();
183 return value;
184}

◆ polynomial()

void EvtPolInt::polynomial ( )

Definition at line 23 of file EvtPolInt.cc.

23 {
24 double y, dy;
25 int i, m, ns = 0;
26 double den, dif, dift, ho, hp, w;
27
28 int n = vx.size();
29 vector<double> c( n ), d( n );
30 dif = fabs( xx - vx[0] );
31 for ( i = 0; i < n; i++ )
32 {
33 if ( ( dift = fabs( xx - vx[i] ) ) < dif )
34 {
35 ns = i;
36 dif = dift;
37 }
38 c[i] = vy[i];
39 d[i] = vy[i];
40 }
41 y = vy[ns--];
42 for ( m = 1; m < n; m++ )
43 {
44 for ( i = 0; i < n - m; i++ )
45 {
46 ho = vx[i] - xx;
47 hp = vx[i + m] - xx;
48 w = c[i + 1] - d[i];
49 if ( ( den = ho - hp ) == 0.0 ) std::cout << "Error in routine polint" << std::endl;
50 den = w / den;
51 d[i] = hp * den;
52 c[i] = ho * den;
53 }
54 y += ( dy = ( 2 * ( ns + 1 ) < ( n - m ) ? c[ns + 1] : d[ns--] ) );
55 }
56 value = y;
57 error = dy;
58 // std::cout<<"value= "<<value<<std::endl;
59 if ( value < 0 ) value = 0;
60 return;
61}
const Int_t n
double w
#define ns(x)
Definition xmltok.c:1355

Referenced by geterror(), and getvalue().

◆ ratint()

void EvtPolInt::ratint ( )

Definition at line 63 of file EvtPolInt.cc.

63 {
64 double y, dy;
65 const double TINY = 1.0e-25;
66 int m, i, ns = 0;
67 double w, t, hh, h, dd;
68
69 int n = vx.size();
70 vector<double> c( n ), d( n );
71 hh = fabs( xx - vx[0] );
72 for ( i = 0; i < n; i++ )
73 {
74 h = fabs( xx - vx[i] );
75 if ( h == 0.0 )
76 {
77 y = vy[i];
78 dy = 0.0;
79 return;
80 }
81 else if ( h < hh )
82 {
83 ns = i;
84 hh = h;
85 }
86 c[i] = vy[i];
87 d[i] = vy[i] + TINY;
88 }
89 y = vy[ns--];
90 for ( m = 1; m < n; m++ )
91 {
92 for ( i = 0; i < n - m; i++ )
93 {
94 w = c[i + 1] - d[i];
95 h = vx[i + m] - xx;
96 t = ( vx[i] - xx ) * d[i] / h;
97 dd = t - c[i + 1];
98 if ( dd == 0.0 ) std::cout << "Error in routine ratint" << std::endl;
99 dd = w / dd;
100 d[i] = c[i + 1] * dd;
101 c[i] = t * dd;
102 }
103 y += ( dy = ( 2 * ( ns + 1 ) < ( n - m ) ? c[ns + 1] : d[ns--] ) );
104 }
105 value = y;
106 error = dy;
107 if ( value < 0 ) value = 0;
108 return;
109}
#define TINY
Definition TRunge.cxx:1112
int t()
Definition t.c:1

◆ spline()

vector< double > EvtPolInt::spline ( )

Definition at line 111 of file EvtPolInt.cc.

111 {
112 vector<double> y2;
113 y2.clear();
114 for ( int i = 0; i < size; i++ ) { y2.push_back( 0.0 ); }
115 double yp1 = 0;
116 double ypn = 0;
117 int i, k;
118 double p, qn, sig, un;
119
120 int n = size;
121 vector<double> u; //(n-1);
122 if ( yp1 > 0.99e30 )
123 {
124 u[0] = 0.0;
125 y2.push_back( 0.0 );
126 }
127 else
128 {
129 y2.push_back( -0.5 );
130 u[0] = ( 3.0 / ( vx[1] - vx[0] ) ) * ( ( vy[1] - vy[0] ) / ( vx[1] - vx[0] ) - yp1 );
131 }
132 for ( i = 1; i < n - 1; i++ )
133 {
134 sig = ( vx[i] - vx[i - 1] ) / ( vx[i + 1] - vx[i - 1] );
135 p = sig * y2[i - 1] + 2.0;
136 double yy2 = ( sig - 1.0 ) / p;
137 y2.push_back( yy2 );
138 u[i] = ( vy[i + 1] - vy[i] ) / ( vx[i + 1] - vx[i] ) -
139 ( vy[i] - vy[i - 1] ) / ( vx[i] - vx[i - 1] );
140 u[i] = ( 6.0 * u[i] / ( vx[i + 1] - vx[i - 1] ) - sig * u[i - 1] ) / p;
141 }
142 if ( ypn > 0.99e30 ) qn = un = 0.0;
143 else
144 {
145 qn = 0.5;
146 un = ( 3.0 / ( vx[n - 1] - vx[n - 2] ) ) *
147 ( ypn - ( vy[n - 1] - vy[n - 2] ) / ( vx[n - 1] - vx[n - 2] ) );
148 }
149 y2[n - 1] = ( un - qn * u[n - 2] ) / ( qn * y2[n - 2] + 1.0 );
150 for ( k = n - 2; k >= 0; k-- ) y2[k] = y2[k] * y2[k + 1] + u[k];
151 return y2;
152}

Referenced by splint().

◆ splint()

void EvtPolInt::splint ( )

Definition at line 154 of file EvtPolInt.cc.

154 {
155 vector<double> y2a = spline();
156 double y;
157 int k;
158 double h, b, a;
159
160 int n = vx.size();
161 int klo = 0;
162 int khi = n - 1;
163 while ( khi - klo > 1 )
164 {
165 k = ( khi + klo ) >> 1;
166 if ( vx[k] > xx ) khi = k;
167 else klo = k;
168 }
169 h = vx[khi] - vx[klo];
170 if ( h == 0.0 ) std::cout << "Bad xa input to routine splint" << std::endl;
171 a = ( vx[khi] - xx ) / h;
172 b = ( xx - vx[klo] ) / h;
173 y = a * vy[klo] + b * vy[khi] +
174 ( ( a * a * a - a ) * y2a[klo] + ( b * b * b - b ) * y2a[khi] ) * ( h * h ) / 6.0;
175 value = y;
176 return;
177}
vector< double > spline()
Definition EvtPolInt.cc:111

The documentation for this class was generated from the following files: