#include "TMVA/TSpline2.h"
#include "Riostream.h"
#include "TMath.h"
ClassImp(TMVA::TSpline2)
TMVA::TSpline2::TSpline2( TString title, TGraph* theGraph )
   : fGraph( theGraph )
{
   
   
   SetNameTitle( title, title );  
}
TMVA::TSpline2::~TSpline2( void )
{
   
   if (NULL != fGraph) delete fGraph;
}
Double_t TMVA::TSpline2::Eval( const Double_t x ) const
{  
   
   Double_t retval=0;
  
   Int_t ibin = TMath::BinarySearch( fGraph->GetN(),
                                     fGraph->GetX(),
                                     x );
   
   if (ibin < 0               ) ibin = 0;
   if (ibin >= fGraph->GetN()) ibin =  fGraph->GetN() - 1;
  
   Float_t dx = 0; 
  
   if (ibin == 0 ) {
    
      retval = Quadrax(  x,
                         fGraph->GetX()[ibin]   + dx,
                         fGraph->GetX()[ibin+1] + dx,
                         fGraph->GetX()[ibin+2] + dx,
                         fGraph->GetY()[ibin],
                         fGraph->GetY()[ibin+1],
                         fGraph->GetY()[ibin+2]);
    
   }
   else if (ibin >= (fGraph->GetN()-1)) {
    
      retval = Quadrax( x, 
                        fGraph->GetX()[ibin-2] + dx,
                        fGraph->GetX()[ibin-1] + dx,
                        fGraph->GetX()[ibin]   + dx,
                        fGraph->GetY()[ibin-2],
                        fGraph->GetY()[ibin-1],
                        fGraph->GetY()[ibin]);
   }
   else {  
    
      retval = ( Quadrax( x, 
                          fGraph->GetX()[ibin-1] + dx,
                          fGraph->GetX()[ibin]   + dx,
                          fGraph->GetX()[ibin+1] + dx,
                          fGraph->GetY()[ibin-1],
                          fGraph->GetY()[ibin],
                          fGraph->GetY()[ibin+1])
                 + 
                 Quadrax( x, fGraph->GetX()[ibin] + dx,
                          fGraph->GetX()[ibin+1]  + dx,
                          fGraph->GetX()[ibin+2]  + dx,
                          fGraph->GetY()[ibin],
                          fGraph->GetY()[ibin+1],
                          fGraph->GetY()[ibin+2]) )*0.5;
   }
   return retval;
}
void TMVA::TSpline2::BuildCoeff( void )
{
   
}
void TMVA::TSpline2::GetKnot( Int_t  , Double_t& , Double_t&  ) const
{
   
}
Double_t TMVA::TSpline2::Quadrax(const Float_t dm,const Float_t dm1,const Float_t dm2,const Float_t dm3,
                                 const Float_t cos1, const Float_t cos2, const Float_t cos3 ) const
{  
   
   
   
   
   
   Float_t a = cos1*(dm2-dm3) + cos2*(dm3-dm1) + cos3*(dm1-dm2);
   Float_t b = cos1*(dm2*dm2-dm3*dm3) + cos2*(dm3*dm3-dm1*dm1) + cos3*(dm1*dm1-dm2*dm2);
   Float_t c = cos1*(dm2-dm3)*dm2*dm3 + cos2*(dm3-dm1)*dm3*dm1 + cos3*(dm1-dm2)*dm1*dm2;
   Float_t denom = (dm2-dm3)*(dm3-dm1)*(dm1-dm2);
  
   return (denom != 0.0) ? (-a*dm*dm+b*dm-c)/denom : 0.0;
}
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.