Line data Source code
1 : #ifndef ROOT_TKDPDF
2 : #define ROOT_TKDPDF
3 :
4 : #ifndef ROOT_TKDInterpolatorBase
5 : #include "TKDInterpolatorBase.h"
6 : #endif
7 :
8 : #ifndef ROOT_TKDTree
9 : #include "TKDTree.h"
10 : #endif
11 :
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.
15 :
16 : template <typename Index, typename Value> class TKDTree;
17 : typedef class TKDTree<Int_t, Float_t> TKDTreeIF;
18 : class TTree;
19 : class TLinearFitter;
20 : class TKDPDF : public TKDTreeIF, public TKDInterpolatorBase
21 : {
22 : public:
23 : TKDPDF();
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);
26 : ~TKDPDF();
27 :
28 : inline Bool_t GetDataPoint(Int_t n, Float_t *p) const;
29 0 : inline Int_t GetNodeIndex(const Float_t *p);
30 : void DrawNode(Int_t tnode, UInt_t ax1=0, UInt_t ax2=1);
31 :
32 : private:
33 : TKDPDF(const TKDPDF &);
34 : TKDPDF& operator=(const TKDPDF &);
35 : Bool_t Build(Int_t ndim = 0);
36 :
37 :
38 580 : ClassDef(TKDPDF, 1) // data interpolator based on KD tree
39 : };
40 :
41 :
42 : //__________________________________________________________________
43 : Bool_t TKDPDF::GetDataPoint(Int_t n, Float_t *p) const
44 : {
45 0 : if(n < 0 || n >= fNPoints) return kFALSE;
46 0 : if(!fData) return kFALSE;
47 :
48 0 : for(int i=0; i<fNDim; i++) p[i] = fData[i][n];
49 0 : return kTRUE;
50 0 : }
51 :
52 : //__________________________________________________________________
53 : Int_t TKDPDF::GetNodeIndex(const Float_t *p)
54 : {
55 0 : return FindNode(p) - fNNodes;
56 : }
57 :
58 : #endif
59 :
|