]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliCheb3DCalc.h
Moved old AliMagFCheb to AliMagF, small fixes/optimizations in field classes
[u/mrichter/AliRoot.git] / STEER / AliCheb3DCalc.h
index a9653ab6c70928b27bde46c319169c000f2207d1..c6f54b284bae56584283d232bdd6284fc43977a5 100644 (file)
@@ -3,7 +3,7 @@
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 #include <TNamed.h>
-#include <TSystem.h>
+class TSystem;
 //
 // Author: Ruben Shahoyan
 // ruben.shahoyan@cern.ch   09/09/2006
 
 // to decrease the compilable code size comment this define. This will exclude the routines 
 // used for the calculation and saving of the coefficients. 
-#define _INC_CREATION_ALICHEB3D_
+//#define _INC_CREATION_ALICHEB3D_
 
 // when _BRING_TO_BOUNDARY_ is defined, the point outside of the fitted folume is assumed
 // to be on the surface 
-#define _BRING_TO_BOUNDARY_
+// #define _BRING_TO_BOUNDARY_
 //
 
 
@@ -30,14 +30,14 @@ class AliCheb3DCalc: public TNamed
   ~AliCheb3DCalc()                                                           {Clear();}
   //
   AliCheb3DCalc& operator=(const AliCheb3DCalc& rhs);
-  void       Print(Option_t* opt="")                                   const;
+  void       Print(const Option_t* opt="")                              const;
   void       LoadData(FILE* stream);
-  Float_t    Eval(Float_t  *par)                                       const;
-  Float_t    EvalDeriv(int dim, Float_t  *par)                         const;
+  Float_t    EvalDeriv(int dim, const Float_t  *par)                    const;
+  Float_t    EvalDeriv2(int dim1,int dim2, const Float_t  *par)         const;
   //
 #ifdef _INC_CREATION_ALICHEB3D_
-  void       SaveData(const char* outfile,Bool_t append=kFALSE)        const;
-  void       SaveData(FILE* stream=stdout)                             const;
+  void       SaveData(const char* outfile,Bool_t append=kFALSE)         const;
+  void       SaveData(FILE* stream=stdout)                              const;
 #endif
   //
   void       InitRows(int nr);
@@ -47,14 +47,32 @@ class AliCheb3DCalc: public TNamed
   void       InitElemBound2D(int ne);
   Int_t*     GetCoefBound2D0()                                          const {return fCoefBound2D0;}
   Int_t*     GetCoefBound2D1()                                          const {return fCoefBound2D1;}
-  void       Clear(Option_t* option = "");
-  static Float_t    ChebEval1D(Float_t  x, const Float_t * array, int ncf);//     const;  
-  static Float_t    ChebEval1Deriv(Float_t  x, const Float_t * array, int ncf);// const;  
+  void       Clear(const Option_t* option = "");
+  static Float_t    ChebEval1D(Float_t  x, const Float_t * array, int ncf);
+  static Float_t    ChebEval1Deriv(Float_t  x, const Float_t * array, int ncf);
+  static Float_t    ChebEval1Deriv2(Float_t  x, const Float_t * array, int ncf);
   void       InitCoefs(int nc);
   Float_t *  GetCoefs()                                                 const {return fCoefs;}
   //
   static void ReadLine(TString& str,FILE* stream);
   //
+  template <class T>
+    T        Eval(const T  *par)                                        const {
+    // evaluate Chebyshev parameterization for 3D function.
+    // VERY IMPORTANT: par must contain the function arguments ALREADY MAPPED to [-1:1] interval
+    int ncfRC;
+    for (int id0=fNRows;id0--;) {
+      int nCLoc = fNColsAtRow[id0];                   // number of significant coefs on this row
+      int col0  = fColAtRowBg[id0];                   // beginning of local column in the 2D boundary matrix
+      for (int id1=nCLoc;id1--;) {
+       int id = id1+col0;
+       fTmpCf1[id1] = (ncfRC=fCoefBound2D0[id]) ? ChebEval1D(par[2],fCoefs + fCoefBound2D1[id], ncfRC) : 0.0;
+      }
+      fTmpCf0[id0] = nCLoc>0 ? ChebEval1D(par[1],fTmpCf1,nCLoc):0.0;
+    }
+    return ChebEval1D(par[0],fTmpCf0,fNRows);
+    }
+  //
  protected:
   Int_t      fNCoefs;            // total number of coeeficients
   Int_t      fNRows;             // number of significant rows in the 3D coeffs matrix
@@ -76,6 +94,7 @@ class AliCheb3DCalc: public TNamed
 inline Float_t AliCheb3DCalc::ChebEval1D(Float_t  x, const Float_t * array, int ncf ) 
 {
   // evaluate 1D Chebyshev parameterization. x is the argument mapped to [-1:1] interval
+  if (ncf<=0) return 0;
   Float_t b0, b1, b2, x2 = x+x;
   b0 = array[--ncf]; 
   b1 = b2 = 0;