Fixed problem with z length mismatch (Marian, Marek)
[u/mrichter/AliRoot.git] / STAT / TKDInterpolator.h
CommitLineData
f2040a8f 1#ifndef ROOT_TKDInterpolator
2#define ROOT_TKDInterpolator
3
4#ifndef ROOT_TKDTree
5#include "TKDTree.h"
6#endif
7
8class TTree;
9class TLinearFitter;
10class TKDInterpolator : public TKDTreeIF
11{
12public:
13 TKDInterpolator();
14 TKDInterpolator(TTree *t, const Char_t *var, const Char_t *cut = 0, UInt_t bsize = 100);
15 TKDInterpolator(Int_t npoints, Int_t ndim, UInt_t bsize, Float_t **data);
16 ~TKDInterpolator();
e0b38166 17
18 TKDTreeIF* GetHelper() {return fKDhelper;}
19 inline Bool_t GetCOGPoint(Int_t node, Float_t *coord, Float_t &val, Float_t &error) const ;
20 inline Bool_t GetDataPoint(Int_t n, Float_t *p) const;
21 Double_t Eval(const Double_t *point, Int_t npoints = 12);
22 void DrawNodes(UInt_t ax1 = 0, UInt_t ax2 = 1, Int_t depth = -1);
23 void DrawNode(Int_t tnode, UInt_t ax1 = 0, UInt_t ax2 = 1);
a9c20b1f 24
f2040a8f 25private:
a9c20b1f 26 TKDInterpolator(const TKDInterpolator &);
27 TKDInterpolator& operator=(const TKDInterpolator &);
e0b38166 28 void Build();
f2040a8f 29
30protected:
31 Int_t fNTNodes; //Number of evaluation data points
32 Float_t **fRefPoints; //[fNDim][fNTNodes]
33 Float_t *fRefValues; //[fNTNodes]
34
35private:
36 Int_t fDepth; //! depth of the KD Tree structure used
37 Double_t *fTmpPoint; //! temporary storage for one data point
38 TKDTreeIF *fKDhelper; //! kNN finder
39 TLinearFitter *fFitter; //! linear fitter
40
41 ClassDef(TKDInterpolator, 1) // data interpolator based on KD tree
42};
43
44//__________________________________________________________________
e0b38166 45Bool_t TKDInterpolator::GetCOGPoint(Int_t node, Float_t *coord, Float_t &val, Float_t &error) const
f2040a8f 46{
e0b38166 47 if(node < 0 || node > fNTNodes) return kFALSE;
f2040a8f 48
49 for(int idim=0; idim<fNDim; idim++) coord[idim] = fRefPoints[idim][node];
50 val = fRefValues[node];
a9c20b1f 51 error = fRefValues[node]; // to be implemented
f2040a8f 52 return kTRUE;
53}
54
e0b38166 55//__________________________________________________________________
56Bool_t TKDInterpolator::GetDataPoint(Int_t n, Float_t *p) const
57{
58 if(n < 0 || n >= fNpoints) return kFALSE;
59
60 for(int i=0; i<fNDim; i++) p[i] = fData[i][n];
61 return kTRUE;
62}
63
64
f2040a8f 65#endif
66