GhostInterpolation Class Reference

#include <GhostInterpolation.h>

List of all members.

Public Member Functions

 GhostInterpolation ()
 ~GhostInterpolation ()
void Input (Double_t m2, Double_t m1, Double_t nom, Double_t p1, Double_t p2)
Double_t Interpolate (Double_t x)
void Interpolate (Double_t x, Double_t &y)
void Interpolate (Double_t x, Double_t &m2, Double_t &m1, Double_t &nom, Double_t &p1, Double_t &p2)
void Debug (Bool_t debug=1)

Private Member Functions

Double_t InterpolateOld (Double_t x)
Double_t InterpolateNew (Double_t x)

Private Attributes

Double_t fX [5]
Double_t fY [5]
Bool_t fDebug

Detailed Description

Definition at line 6 of file GhostInterpolation.h.


Constructor & Destructor Documentation

GhostInterpolation::GhostInterpolation (  ) 

Definition at line 8 of file GhostInterpolation.cxx.

00009 {
00010   fX[0]=-2.0;   fY[0]=0.0;   
00011   fX[1]=-1.0;   fY[1]=0.0;   
00012   fX[2]=0.0;    fY[2]=0.0;   
00013   fX[3]=+1.0;   fY[3]=0.0;   
00014   fX[4]=+2.0;   fY[4]=0.0;  
00015 
00016   fDebug = 0; 
00017 }

GhostInterpolation::~GhostInterpolation (  ) 

Definition at line 19 of file GhostInterpolation.cxx.

00020 {
00021 
00022 }


Member Function Documentation

void GhostInterpolation::Debug ( Bool_t  debug = 1  )  [inline]

Definition at line 26 of file GhostInterpolation.h.

References fDebug.

00026 { if( debug ) fDebug = debug; }

void GhostInterpolation::Input ( Double_t  m2,
Double_t  m1,
Double_t  nom,
Double_t  p1,
Double_t  p2 
)

Definition at line 24 of file GhostInterpolation.cxx.

References fY.

00025 {
00026   fY[0]=m2; fY[1]=m1; fY[2]=nom; fY[3]=p1; fY[4]=p2;
00027 }

void GhostInterpolation::Interpolate ( Double_t  x,
Double_t &  m2,
Double_t &  m1,
Double_t &  nom,
Double_t &  p1,
Double_t &  p2 
)

Definition at line 98 of file GhostInterpolation.cxx.

References fDebug, fX, and n.

00099 {
00100   Double_t weight = 1.0;
00101   Double_t dx = 1.0; 
00102 
00103   Double_t fW[5];
00104 
00105   for( Int_t n=0; n<5; n++ ){
00106     fW[n] = 0.0;
00107   }
00108 
00109   for( Int_t n=-1; n<5; n++ ){
00110     if( ( n==-1 && x<fX[0] )
00111      || ( n==+4 && x>=fX[4] )
00112      || ( n<4 && x>=fX[n] && x<fX[n+1] ) ){
00113 
00114       if( n>=0 && n<=3 
00115        && x>=fX[n] && x<fX[n+1] ){
00116         dx = fabs(fX[n+1]-fX[n]);
00117         weight = dx*dx*dx;
00118         fW[n]   += -weight*(x-fX[n+1])/(fX[n+1]-fX[n]);
00119         fW[n+1] += +weight*(x-fX[n])/(fX[n+1]-fX[n]);
00120       }
00121         
00122       if( n>=1 && n<=4 ){
00123         if( n<=3 ) dx = fabs(x-fX[n+1]);
00124         else dx = fabs(fX[n]-fX[n-1]);
00125         weight = dx*dx*dx; 
00126         fW[n-1] += -weight*(x-fX[n])/(fX[n]-fX[n-1]);
00127         fW[n]   += +weight*(x-fX[n-1])/(fX[n]-fX[n-1]);
00128       }
00129 
00130       if( n>=-1 && n<=2 ) {   
00131         if( n>=0 ) dx = fabs(x-fX[n]);
00132         else dx = fabs(fX[n+2]-fX[n+1]);
00133         weight = dx*dx*dx;
00134         fW[n+1] += -weight*(x-fX[n+2])/(fX[n+2]-fX[n+1]);
00135         fW[n+2] += +weight*(x-fX[n+1])/(fX[n+2]-fX[n+1]);
00136       }
00137     }
00138   }
00139       
00140   weight = 0.0;
00141      
00142   for( Int_t n=0; n<5; n++ ){
00143     weight += fW[n];
00144   }
00145 
00146   if( weight>0.0 ){
00147     for( Int_t n=0; n<5; n++ ){
00148       fW[n] /= weight;
00149     }
00150   }
00151   else{
00152     fW[2] = 1.0;
00153   }
00154 
00155   m2 = fW[0];
00156   m1 = fW[1];
00157   nom = fW[2];
00158   p1 = fW[3];
00159   p2 = fW[4];
00160 
00161   if( fDebug ){
00162     std::cout << " x=" << x << " w=[" << m2 << "|" << m1 << "|" << nom << "|" << p1 << "|" << p2 << "]" << std::endl;
00163   }
00164 }

void GhostInterpolation::Interpolate ( Double_t  x,
Double_t &  y 
)

Definition at line 89 of file GhostInterpolation.cxx.

References fY, Interpolate(), and Munits::m2.

00090 {
00091   Double_t m2,m1,nom,p1,p2;
00092 
00093   this->Interpolate(x,m2,m1,nom,p1,p2);
00094 
00095   y = fY[0]*m2 + fY[1]*m1 + fY[2]*nom + fY[3]*p1 + fY[4]*p2;
00096 }

Double_t GhostInterpolation::Interpolate ( Double_t  x  ) 

Definition at line 84 of file GhostInterpolation.cxx.

References InterpolateNew().

Referenced by GhostSample::InterpMin(), Interpolate(), and InterpolateNew().

00085 {
00086   return this->InterpolateNew(x);
00087 }

Double_t GhostInterpolation::InterpolateNew ( Double_t  x  )  [private]

Definition at line 75 of file GhostInterpolation.cxx.

References Interpolate().

Referenced by Interpolate().

00076 {
00077   Double_t y;
00078 
00079   this->Interpolate(x,y);
00080 
00081   return y;
00082 }

Double_t GhostInterpolation::InterpolateOld ( Double_t  x  )  [private]

Definition at line 29 of file GhostInterpolation.cxx.

References fX, fY, and n.

00030 {
00031   Double_t dx = 1.0; 
00032   Double_t y = fY[2];
00033 
00034   for( Int_t n=-1; n<5; n++ ){
00035     if( ( n==-1 && x<fX[0] )
00036      || ( n==+4 && x>=fX[4] )
00037      || ( n<4 && x>=fX[n] && x<fX[n+1] ) ){
00038 
00039       Double_t y_0 = fY[n];
00040       Double_t w_0 = 0.0;
00041       if( n>=0 && n<=3 
00042        && x>=fX[n] && x<fX[n+1] ){
00043         y_0 = (fY[n+1]*(x-fX[n])-fY[n]*(x-fX[n+1]))/(fX[n+1]-fX[n]);
00044         dx = fabs(fX[n+1]-fX[n]);
00045         w_0 = dx*dx*dx;
00046       }
00047         
00048       Double_t y_p = y_0;
00049       Double_t w_p = 0.0;
00050       if( n>=1 && n<=4 ){
00051         y_p = (fY[n]*(x-fX[n-1])-fY[n-1]*(x-fX[n]))/(fX[n]-fX[n-1]);
00052         if( n<=3 ) dx = fabs(x-fX[n+1]);
00053         else dx = fabs(fX[n]-fX[n-1]);
00054         w_p = dx*dx*dx; 
00055       }
00056 
00057       Double_t y_m = y_0;
00058       Double_t w_m = 0.0;
00059       if( n>=-1 && n<=2 ) { 
00060         y_m = (fY[n+2]*(x-fX[n+1])-fY[n+1]*(x-fX[n+2]))/(fX[n+2]-fX[n+1]);
00061         if( n>=0 ) dx = fabs(x-fX[n]);
00062         else dx = fabs(fX[n+2]-fX[n+1]);
00063         w_m = dx*dx*dx;
00064       }
00065 
00066       if( w_m + w_0 + w_p>0.0 ){
00067         y = ( y_m*w_m+y_0*w_0+y_p*w_p ) / ( w_m+w_0+w_p );
00068       }
00069     }
00070   }
00071  
00072   return y;
00073 }


Member Data Documentation

Bool_t GhostInterpolation::fDebug [private]

Definition at line 36 of file GhostInterpolation.h.

Referenced by Debug(), and Interpolate().

Double_t GhostInterpolation::fX[5] [private]

Definition at line 33 of file GhostInterpolation.h.

Referenced by Interpolate(), and InterpolateOld().

Double_t GhostInterpolation::fY[5] [private]

Definition at line 34 of file GhostInterpolation.h.

Referenced by Input(), Interpolate(), and InterpolateOld().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1