]>
Commit | Line | Data |
---|---|---|
a3408ed3 | 1 | #ifndef ROOT_TKDPDF |
2 | #define ROOT_TKDPDF | |
3 | ||
a3408ed3 | 4 | #ifndef ROOT_TKDInterpolatorBase |
5 | #include "TKDInterpolatorBase.h" | |
6 | #endif | |
7 | ||
50c4eb3a | 8 | #ifndef ROOT_TKDTree |
9 | #include "TKDTree.h" | |
10 | #endif | |
11 | ||
a3408ed3 | 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: | |
53ee3cad | 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(); | |
a3408ed3 | 27 | |
53ee3cad | 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); | |
a3408ed3 | 31 | |
32 | private: | |
53ee3cad | 33 | TKDPDF(const TKDPDF &); |
34 | TKDPDF& operator=(const TKDPDF &); | |
afb669c1 | 35 | Bool_t Build(Int_t ndim = 0); |
a3408ed3 | 36 | |
53ee3cad | 37 | |
38 | ClassDef(TKDPDF, 1) // data interpolator based on KD tree | |
a3408ed3 | 39 | }; |
40 | ||
41 | ||
42 | //__________________________________________________________________ | |
43 | Bool_t TKDPDF::GetDataPoint(Int_t n, Float_t *p) const | |
44 | { | |
53ee3cad | 45 | if(n < 0 || n >= fNPoints) return kFALSE; |
46 | if(!fData) return kFALSE; | |
47 | ||
48 | for(int i=0; i<fNDim; i++) p[i] = fData[i][n]; | |
49 | return kTRUE; | |
a3408ed3 | 50 | } |
51 | ||
52 | //__________________________________________________________________ | |
53 | Int_t TKDPDF::GetNodeIndex(const Float_t *p) | |
54 | { | |
53ee3cad | 55 | return FindNode(p) - fNNodes; |
a3408ed3 | 56 | } |
57 | ||
58 | #endif | |
59 |