Implementation of local interpolation based on COG points
[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();
17
18 inline Bool_t GetEstimate(Int_t node, Float_t *coord, Float_t &val, Float_t &error) const ;
19 Double_t Eval(Float_t *point);
20 void DrawNodes(Int_t depth = -1, Int_t ax1 = 0, Int_t ax2 = 1);
21 void DrawNode(Int_t node, Int_t ax1 = 0, Int_t ax2 = 1);
a9c20b1f 22
f2040a8f 23private:
a9c20b1f 24 TKDInterpolator(const TKDInterpolator &);
25 TKDInterpolator& operator=(const TKDInterpolator &);
f2040a8f 26 void Build();
27
28protected:
29 Int_t fNTNodes; //Number of evaluation data points
30 Float_t **fRefPoints; //[fNDim][fNTNodes]
31 Float_t *fRefValues; //[fNTNodes]
32
33private:
34 Int_t fDepth; //! depth of the KD Tree structure used
35 Double_t *fTmpPoint; //! temporary storage for one data point
36 TKDTreeIF *fKDhelper; //! kNN finder
37 TLinearFitter *fFitter; //! linear fitter
38
39 ClassDef(TKDInterpolator, 1) // data interpolator based on KD tree
40};
41
42//__________________________________________________________________
43Bool_t TKDInterpolator::GetEstimate(Int_t node, Float_t *coord, Float_t &val, Float_t &error) const
44{
45 if(node < 0 || node > GetNTerminalNodes()) return kFALSE;
46
47 for(int idim=0; idim<fNDim; idim++) coord[idim] = fRefPoints[idim][node];
48 val = fRefValues[node];
a9c20b1f 49 error = fRefValues[node]; // to be implemented
f2040a8f 50 return kTRUE;
51}
52
53#endif
54