]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEERBase/AliTRDTKDInterpolator.h
- fast TRD PID implementation with muon constraints (Daniel Lohner)
[u/mrichter/AliRoot.git] / STEER / STEERBase / AliTRDTKDInterpolator.h
1 #ifndef ROOT_ALITRDTKDINTERPOLATOR_H
2 #define ROOT_ALITRDTKDINTERPOLATOR_H
3
4 #ifndef ROOT_TKDTree
5 #include "TKDTree.h"
6 #endif
7
8 #ifndef ROOT_TObject
9 #include "TObject.h"
10 #endif
11
12 #include "TVectorD.h"
13 #include "TMatrixD.h"
14 #include "TH2Poly.h"
15 class TClonesArray;
16
17 class AliTRDTKDInterpolator : public TKDTreeIF
18 {
19
20 public:
21     enum TRDTKDMode{
22         kInterpolation=0,
23         kMinError=1,
24         kNodeVal=2
25     };
26
27       // Bucket Object class
28     class AliTRDTKDNodeInfo : public TObject
29     {
30         friend class AliTRDTKDInterpolator;
31     public:
32
33         AliTRDTKDNodeInfo(Int_t ndim = 0);
34         AliTRDTKDNodeInfo(const AliTRDTKDInterpolator::AliTRDTKDNodeInfo &ref);
35         AliTRDTKDInterpolator::AliTRDTKDNodeInfo& operator=(const AliTRDTKDInterpolator::AliTRDTKDNodeInfo &ref);
36         virtual ~AliTRDTKDNodeInfo();
37         Bool_t        CookPDF(const Double_t *point, Double_t &result, Double_t &error,TRDTKDMode mod=kInterpolation) const;
38         Bool_t Has(const Float_t *p) const;
39         void          Print(const Option_t * = "") const;
40         void          Store(TVectorD const *par, TMatrixD const *cov,Bool_t storeCov);
41
42     private:
43         Int_t fNDim;              // Dimension of Points
44         Int_t fNBounds;           // 2* Dimension of Points
45         Int_t fNPar;            // Number of Parameters
46         Int_t fNCov;            // Size of Cov Matrix
47         Float_t   *fData;         //[fNDim] Data Point
48         Float_t *fBounds;         //[fNBounds] Boundaries
49         Float_t   fVal[2];        //measured value for node
50         Double_t  *fPar;          //[fNPar] interpolator parameters
51         Double_t  *fCov;          //[fNCov] interpolator covariance matrix
52
53         ClassDef(AliTRDTKDNodeInfo, 1)  // node info for interpolator
54     };
55
56 public:
57
58     AliTRDTKDInterpolator();
59     AliTRDTKDInterpolator(Int_t npoints, Int_t ndim, UInt_t bsize, Float_t **data);
60     ~AliTRDTKDInterpolator();
61
62     Bool_t        Eval(const Double_t *point, Double_t &result, Double_t &error);
63     void          Print(const Option_t *opt="") const;
64
65     TH2Poly *     Projection(Int_t xdim,Int_t ydim);
66
67     Int_t         GetNDIM() const {return fNDim;}
68     Bool_t        GetRange(Int_t idim,Float_t range[2]) const;
69   
70     void          SetNPointsInterpolation(Int_t np){fNPointsI=np;};
71     Int_t         GetNPointsInterpolation(){return fNPointsI;};
72
73     void          SetUseWeights(Bool_t k=kTRUE){fUseWeights=k;}
74     void          SetPDFMode(TRDTKDMode mod){fPDFMode=mod;}
75     void          SetStoreCov(Bool_t k){fStoreCov=k;}
76
77     Bool_t        Build();
78
79     void          SetUseHelperNodes(Bool_t k){fUseHelperNodes=k;}
80
81 private:
82
83     Int_t         GetNodeIndex(const Float_t *p);
84     AliTRDTKDInterpolator::AliTRDTKDNodeInfo*  GetNodeInfo(Int_t inode) const;
85     Int_t         GetNTNodes() const;
86     void          BuildInterpolation();
87     void          BuildBoundaryNodes();
88     AliTRDTKDInterpolator(const AliTRDTKDInterpolator &ref);
89     AliTRDTKDInterpolator &operator=(const AliTRDTKDInterpolator &ref);
90
91     Int_t fNDataNodes;         // Number of filled nodes (total-zero nodes)
92     TClonesArray  *fNodes;     //interpolation nodes
93     UChar_t       fLambda;      // number of parameters in polynom
94     Int_t         fNPointsI;    // number of points for interpolation
95     Bool_t        fUseHelperNodes; // Build Helper nodes to ensure boundary conditions
96     Bool_t fUseWeights; // Use tricubic weights
97     TRDTKDMode    fPDFMode; // Mode for PDF calculation
98     Bool_t        fStoreCov;
99
100     ClassDef(AliTRDTKDInterpolator, 2)   // data interpolator based on KD tree
101 };
102
103 #endif