BOSS 6.6.4.p01
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 31 of file EvtPolInt.hh.

Constructor & Destructor Documentation

◆ EvtPolInt()

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

Definition at line 33 of file EvtPolInt.hh.

33 {
34 xx = x;
35 size = xi.size();
36 vx.clear();
37 vy.clear();
38 for(int i=0;i<size;i++){
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 172 of file EvtPolInt.cc.

172 {
173 polynomial();
174 //ratint();
175return error;
176}
void polynomial()
Definition: EvtPolInt.cc:23

◆ getvalue()

double EvtPolInt::getvalue ( )

Definition at line 165 of file EvtPolInt.cc.

165 {
166 polynomial();
167 // ratint();
168 // splint();
169return value;
170}

◆ 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 if ((dift = fabs(xx-vx[i]))<dif){
33 ns=i;
34 dif = dift;
35 }
36 c[i] = vy[i];
37 d[i] = vy[i];
38 }
39 y = vy[ns--];
40 for (m=1;m<n;m++){
41 for (i=0;i<n-m;i++){
42 ho = vx[i] -xx;
43 hp = vx[i+m] -xx;
44 w = c[i+1] - d[i];
45 if(( den = ho-hp) == 0.0) std::cout<<"Error in routine polint"<<std::endl;
46 den = w/den;
47 d[i] = hp*den;
48 c[i] = ho*den;
49 }
50 y += (dy=(2*(ns+1)< (n-m) ? c[ns+1]: d[ns--]));
51 }
52 value = y;
53 error = dy;
54 // std::cout<<"value= "<<value<<std::endl;
55 if(value <0) value = 0;
56 return;
57}
const Int_t n
#define ns(x)
Definition: xmltok.c:1504

Referenced by geterror(), and getvalue().

◆ ratint()

void EvtPolInt::ratint ( )

Definition at line 59 of file EvtPolInt.cc.

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

◆ spline()

vector< double > EvtPolInt::spline ( )

Definition at line 102 of file EvtPolInt.cc.

103{
104 vector <double> y2;
105 y2.clear();
106 for(int i=0;i<size;i++){y2.push_back(0.0);}
107 double yp1=0;
108 double ypn=0;
109 int i,k;
110 double p,qn,sig,un;
111
112 int n=size;
113 vector<double> u; //(n-1);
114 if (yp1 > 0.99e30){
115 u[0]=0.0;
116 y2.push_back(0.0);}
117 else {
118 y2.push_back(-0.5);
119 u[0]=(3.0/(vx[1]-vx[0]))*((vy[1]-vy[0])/(vx[1]-vx[0])-yp1);
120 }
121 for (i=1;i<n-1;i++) {
122 sig=(vx[i]-vx[i-1])/(vx[i+1]-vx[i-1]);
123 p=sig*y2[i-1]+2.0;
124 double yy2=(sig-1.0)/p;
125 y2.push_back(yy2);
126 u[i]=(vy[i+1]-vy[i])/(vx[i+1]-vx[i]) - (vy[i]-vy[i-1])/(vx[i]-vx[i-1]);
127 u[i]=(6.0*u[i]/(vx[i+1]-vx[i-1])-sig*u[i-1])/p;
128 }
129 if (ypn > 0.99e30)
130 qn=un=0.0;
131 else {
132 qn=0.5;
133 un=(3.0/(vx[n-1]-vx[n-2]))*(ypn-(vy[n-1]-vy[n-2])/(vx[n-1]-vx[n-2]));
134 }
135 y2[n-1]=(un-qn*u[n-2])/(qn*y2[n-2]+1.0);
136 for (k=n-2;k>=0;k--)
137 y2[k]=y2[k]*y2[k+1]+u[k];
138 return y2;
139 }

Referenced by splint().

◆ splint()

void EvtPolInt::splint ( )

Definition at line 141 of file EvtPolInt.cc.

141 {
142 vector <double> y2a = spline();
143 double y;
144 int k;
145 double h,b,a;
146
147 int n=vx.size();
148 int klo=0;
149 int khi=n-1;
150 while (khi-klo > 1) {
151 k=(khi+klo) >> 1;
152 if (vx[k] > xx) khi=k;
153 else klo=k;
154 }
155 h=vx[khi]-vx[klo];
156 if (h == 0.0) std::cout<<"Bad xa input to routine splint"<<std::endl;
157 a=(vx[khi]-xx)/h;
158 b=(xx-vx[klo])/h;
159 y=a*vy[klo]+b*vy[khi]+((a*a*a-a)*y2a[klo]
160 +(b*b*b-b)*y2a[khi])*(h*h)/6.0;
161 value = y;
162 return;
163}
vector< double > spline()
Definition: EvtPolInt.cc:102

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