]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STAT/TKDPDF.h
Moving the QA for raw data inside the event loop (Yves). The list of the detectors...
[u/mrichter/AliRoot.git] / STAT / TKDPDF.h
1 #ifndef ROOT_TKDPDF
2 #define ROOT_TKDPDF
3
4 #ifndef ROOT_TKDTree
5 #include "TKDTree.h"
6 #endif
7
8 #ifndef ROOT_TKDInterpolatorBase
9 #include "TKDInterpolatorBase.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         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                 void       Build(Int_t ndim = 0);
36
37                                         
38         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         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;
50 }
51
52 //__________________________________________________________________
53 Int_t   TKDPDF::GetNodeIndex(const Float_t *p)
54 {
55         return FindNode(p) - fNnodes;
56 }
57
58 #endif
59