8 #ifndef ROOT_TKDInterpolatorBase
9 #include "TKDInterpolatorBase.h"
12 // Non parametric interpolation class based on local polinomial regression.
13 // The class can be used to approximate PDF together with TKDTree or for
14 // general regression when the data points are given.
16 template <typename Index, typename Value> class TKDTree;
17 typedef class TKDTree<Int_t, Float_t> TKDTreeIF;
20 class TKDPDF : public TKDTreeIF, public TKDInterpolatorBase
24 TKDPDF(TTree *t, const Char_t *var, const Char_t *cut = 0, UInt_t bsize = 100, Long64_t nentries = 1000000000, Long64_t firstentry = 0);
25 TKDPDF(Int_t npoints, Int_t ndim, UInt_t bsize, Float_t **data);
28 inline Bool_t GetDataPoint(Int_t n, Float_t *p) const;
29 inline Int_t GetNodeIndex(const Float_t *p);
30 void DrawNode(Int_t tnode, UInt_t ax1=0, UInt_t ax2=1);
33 TKDPDF(const TKDPDF &);
34 TKDPDF& operator=(const TKDPDF &);
35 void Build(Int_t ndim = 0);
38 ClassDef(TKDPDF, 1) // data interpolator based on KD tree
42 //__________________________________________________________________
43 Bool_t TKDPDF::GetDataPoint(Int_t n, Float_t *p) const
45 if(n < 0 || n >= fNpoints) return kFALSE;
46 if(!fData) return kFALSE;
48 for(int i=0; i<fNDim; i++) p[i] = fData[i][n];
52 //__________________________________________________________________
53 Int_t TKDPDF::GetNodeIndex(const Float_t *p)
55 return FindNode(p) - fNnodes;