1 #ifndef ROOT_TKDInterpolator
2 #define ROOT_TKDInterpolator
17 class TKDInterpolator : public TKDTreeIF
22 TKDNodeInfo(const Int_t ndim = 0);
24 void Build(const Int_t ndim);
26 Int_t fNDim; // data dimension
27 Float_t *fRefPoint; //[fNDim] node's COG
28 Float_t fRefValue; // measured value for node
29 TMatrixD fCov; // interpolator covariance matrix
30 TVectorD fPar; // interpolator parameters
31 Bool_t fPDFstatus; // status bit for node's PDF
33 ClassDef(TKDNodeInfo, 1) // node info for interpolator
37 TKDInterpolator(TTree *t, const Char_t *var, const Char_t *cut = 0, UInt_t bsize = 100, Long64_t nentries = 1000000000, Long64_t firstentry = 0);
38 TKDInterpolator(Int_t npoints, Int_t ndim, UInt_t bsize, Float_t **data);
41 Double_t Eval(const Double_t *point, Double_t &result, Double_t &error);
42 inline Bool_t GetCOGPoint(Int_t node, Float_t *coord, Float_t &val, Float_t &error) const ;
43 inline Bool_t GetDataPoint(Int_t n, Float_t *p) const;
44 TKDTreeIF* GetHelper() {return fKDhelper;}
45 inline Bool_t GetIntInterpolation() const {return fStatus&1;}
46 inline Bool_t GetSetStore() const {return fStatus&2;}
47 inline Bool_t GetUseWeights() const {return fStatus&4;}
49 void DrawNodes(UInt_t ax1 = 0, UInt_t ax2 = 1, Int_t depth = -1);
50 void DrawNode(Int_t tnode, UInt_t ax1 = 0, UInt_t ax2 = 1);
52 void SetIntInterpolation(const Bool_t on = kTRUE);
53 void SetSetStore(const Bool_t on = kTRUE);
54 void SetUseWeights(const Bool_t on = kTRUE);
57 TKDInterpolator(const TKDInterpolator &);
58 TKDInterpolator& operator=(const TKDInterpolator &);
60 Double_t CookPDF(const Double_t *point, const Int_t node, Double_t &result, Double_t &error);
63 Int_t fNTNodes; //Number of evaluation data points
64 TKDNodeInfo *fTNodes; //[fNTNodes] interpolation node
65 // Float_t *fRefValues; //[fNTNodes]
66 // TMatrixD *fCov; //[fNTNodes] cov matrix array for nodes
67 // TVectorD *fPar; //[fNTNodes] parameters array for nodes
68 // Bool_t *fPDFstatus; //[fNTNodes] status bit for node's PDF
71 UChar_t fStatus; // status of the interpolator
72 Int_t fLambda; // number of parameters in polynom
73 Int_t fDepth; //! depth of the KD Tree structure used
74 Float_t **fRefPoints; //! temporary storage of COG data
75 Double_t *fBuffer; //! working space [2*fLambda]
76 TKDTreeIF *fKDhelper; //! kNN finder
77 TLinearFitter *fFitter; //! linear fitter
79 ClassDef(TKDInterpolator, 1) // data interpolator based on KD tree
82 //__________________________________________________________________
83 Bool_t TKDInterpolator::GetCOGPoint(Int_t node, Float_t *coord, Float_t &val, Float_t &err) const
85 if(node < 0 || node > fNTNodes) return kFALSE;
87 for(int idim=0; idim<fNDim; idim++) coord[idim] = fTNodes[node].fRefPoint[idim];
88 val = fTNodes[node].fRefValue;
89 err = fTNodes[node].fRefValue/TMath::Sqrt(fBucketSize);
93 //__________________________________________________________________
94 Bool_t TKDInterpolator::GetDataPoint(Int_t n, Float_t *p) const
96 if(n < 0 || n >= fNpoints) return kFALSE;
98 for(int i=0; i<fNDim; i++) p[i] = fData[i][n];