]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCheb3DCalc.h
New mapping in agreement with the new instructions from Paolo and Giacinto
[u/mrichter/AliRoot.git] / STEER / AliCheb3DCalc.h
1 #ifndef ALICHEB3DCALC_H
2 #define ALICHEB3DCALC_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 //
9 // Author: Ruben Shahoyan
10 // ruben.shahoyan@cern.ch   09/09/2006
11 // See Comments in AliCheb3D.h
12 //
13 #include <TNamed.h>
14
15 class AliCheb3DCalc: public TNamed
16 {
17  public:
18   AliCheb3DCalc();
19   AliCheb3DCalc(FILE* stream); // read coefs from text file
20   AliCheb3DCalc(const AliCheb3DCalc &src);
21   AliCheb3DCalc& operator= (const AliCheb3DCalc &rhs);
22   ~AliCheb3DCalc() {Clear();}
23   //
24   void       Print(Option_t* opt="")                                   const;
25   void       LoadData(FILE* stream);
26   Float_t    Eval(Float_t  *par)                                       const;
27   //
28 #ifdef _INC_CREATION_ALICHEB3D_
29   void       SaveData(const char* outfile,Bool_t append=kFALSE)        const;
30   void       SaveData(FILE* stream=stdout)                             const;
31 #endif
32   //
33   static void ReadLine(TString& str,FILE* stream);
34   //
35  protected:
36   //
37   void       Clear(Option_t* option = "");
38   void       Init0();
39   Float_t    ChebEval1D(Float_t  x, const Float_t * array, int ncf)     const;  
40   void       InitRows(int nr);
41   void       InitCols(int nc);
42   void       InitElemBound2D(int ne);
43   void       InitCoefs(int nc);
44   Int_t*     GetNColsAtRow()                                            const {return fNColsAtRow;}
45   Int_t*     GetColAtRowBg()                                            const {return fColAtRowBg;}
46   Int_t*     GetCoefBound2D0()                                          const {return fCoefBound2D0;}
47   Int_t*     GetCoefBound2D1()                                          const {return fCoefBound2D1;}
48   Float_t *  GetCoefs()                                                 const {return fCoefs;}
49   //
50  protected:
51   Int_t      fNCoefs;            // total number of coeeficients
52   Int_t      fNRows;             // number of significant rows in the 3D coeffs matrix
53   Int_t      fNCols;             // max number of significant cols in the 3D coeffs matrix
54   Int_t      fNElemBound2D;      // number of elements (fNRows*fNCols) to store for the 2D boundary of significant coeffs
55   Int_t*     fNColsAtRow;        //[fNRows] number of sighificant columns (2nd dim) at each row of 3D coefs matrix
56   Int_t*     fColAtRowBg;        //[fNRows] beginnig of significant columns (2nd dim) for row in the 2D boundary matrix
57   Int_t*     fCoefBound2D0;      //[fNElemBound2D] 2D matrix defining the boundary of significance for 3D coeffs.matrix (Ncoefs for col/row)
58   Int_t*     fCoefBound2D1;      //[fNElemBound2D] 2D matrix defining the start beginnig of significant coeffs for col/row
59   Float_t *  fCoefs;             //[fNCoefs] array of Chebyshev coefficients
60   //
61   Float_t *  fTmpCf1;            //[fNCols] temp. coeffs for 2d summation
62   Float_t *  fTmpCf0;            //[fNRows] temp. coeffs for 1d summation
63   //
64   ClassDef(AliCheb3DCalc,1)  // Class for interpolation of 3D->1 function by Chebyshev parametrization 
65 };
66
67 inline Float_t AliCheb3DCalc::ChebEval1D(Float_t  x, const Float_t * array, int ncf ) const
68 {
69   // evaluate 1D Chebyshev parameterization. x is the argument mapped to [-1:1] interval
70   Float_t b0, b1, b2;
71   Float_t x2 = x+x;
72   b0 = array[--ncf]; 
73   b1 = b2 = 0;
74   for (int i=ncf;i--;) {
75     b2 = b1;
76     b1 = b0;
77     b0 = array[i] + x2*b1 -b2;
78   }
79   return b0 - x*b1;
80 }
81
82 #endif