]>
Commit | Line | Data |
---|---|---|
1 | #ifndef ROOT_TKDInterpolator | |
2 | #define ROOT_TKDInterpolator | |
3 | ||
4 | #ifndef ROOT_TKDTree | |
5 | #include "TKDTree.h" | |
6 | #endif | |
7 | ||
8 | class TTree; | |
9 | class TLinearFitter; | |
10 | class TKDInterpolator : public TKDTreeIF | |
11 | { | |
12 | public: | |
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); | |
22 | ||
23 | private: | |
24 | TKDInterpolator(const TKDInterpolator &); | |
25 | TKDInterpolator& operator=(const TKDInterpolator &); | |
26 | void Build(); | |
27 | ||
28 | protected: | |
29 | Int_t fNTNodes; //Number of evaluation data points | |
30 | Float_t **fRefPoints; //[fNDim][fNTNodes] | |
31 | Float_t *fRefValues; //[fNTNodes] | |
32 | ||
33 | private: | |
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 | //__________________________________________________________________ | |
43 | Bool_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]; | |
49 | error = fRefValues[node]; // to be implemented | |
50 | return kTRUE; | |
51 | } | |
52 | ||
53 | #endif | |
54 |