]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STAT/TKDNodeInfo.h
- extend user interface
[u/mrichter/AliRoot.git] / STAT / TKDNodeInfo.h
1 #ifndef ROOT_TKDNodeInfo
2 #define ROOT_TKDNodeInfo
3
4 ////////////////////////////////////////////////////////
5 //
6 // Bucket representation for TKDInterpolator(Base)
7 //
8 // Author Alexandru Bercuci <A.Bercuci@gsi.de>
9 //
10 ////////////////////////////////////////////////////////
11
12 #ifndef ROOT_TObject
13 #include "TObject.h"
14 #endif
15
16 #ifndef ROOT_TBox
17 #include "TBox.h"
18 #endif
19
20 #ifndef ROOT_TMarker
21 #include "TMarker.h"
22 #endif
23
24 template <typename Value> class TVectorT;
25 typedef struct TVectorT<Double_t> TVectorD;
26 template <typename Value> class TMatrixT;
27 typedef class TMatrixT<Double_t> TMatrixD;
28 class TKDNodeInfo : public TObject
29 {
30 public:
31   friend class TKDPDF;
32   friend class TKDInterpolatorBase;
33   class TKDNodeDraw : public TBox {
34   public:
35     TKDNodeDraw();
36     ~TKDNodeDraw() {;}
37     void  Draw(Option_t* option = "");
38     void  Print(const Option_t* option = "") const; // *MENU*
39     void  SetNode(TKDNodeInfo*, UChar_t s, UChar_t ax1=0, UChar_t ax2=1);
40   private:
41     TKDNodeDraw(const TKDNodeDraw & ref);
42     TKDNodeDraw& operator=(const TKDNodeDraw & ref);
43
44     TMarker     fCOG;    // COG of the node
45     TKDNodeInfo *fNode;  //! node data
46     ClassDef(TKDNodeDraw, 1)   // graphical representation of TKDNodeInfo
47   };
48
49   TKDNodeInfo(Int_t ndim = 0);
50   TKDNodeInfo(const TKDNodeInfo & ref);
51   TKDNodeInfo& operator=(const TKDNodeInfo & ref);
52   virtual ~TKDNodeInfo();
53   Double_t      CookPDF(const Double_t *point, Double_t &result, Double_t &error);
54   inline void   GetBoundary(Int_t ax, Float_t &min, Float_t &max) const;
55   inline void   GetCOG(Float_t* &p) const;
56   Int_t         GetDimension() const { return fNDim/3; }
57   void          GetPDF(Float_t &pdf, Float_t &error) const {pdf=fVal[0]; error=fVal[1];}
58   Int_t         GetSize() const { return fNDim; }
59   inline Bool_t Has(const Float_t *p) const;
60   void          Print(const Option_t * = "") const;
61   void          Store(const TVectorD &par, const TMatrixD &cov);
62
63   TMatrixD*     Cov() const  { return fCov; }
64   TVectorD*     Par() const  { return fPar; }
65
66   void          SetNode(Int_t ndim, Float_t *data, Float_t *pdf);
67 protected:
68   Float_t*      Data() { return fData;}
69   Float_t*      Val()  { return &fVal[0]; }
70   void          Build(Int_t ndim);
71
72 private:
73   Int_t     fNDim;          // 3 times data dimension
74   Float_t   *fData;         //[fNDim] node's data
75   Float_t   fVal[2];        // measured value for node
76   TMatrixD  *fCov;          // interpolator covariance matrix
77   TVectorD  *fPar;          // interpolator parameters
78
79   ClassDef(TKDNodeInfo, 1)  // node info for interpolator
80 };
81
82 //_____________________________________________________________________
83 inline Bool_t TKDNodeInfo::Has(const Float_t *p) const
84 {
85   Int_t ndim = fNDim/3;
86   
87   Float_t *it = &fData[ndim]; Int_t n(0);
88   for(int id=0; id<ndim; id++, it+=2)
89     if(p[id]>=it[0] && p[id]<it[1]) n++;
90   if(n==ndim) return kTRUE;
91   return kFALSE;
92 }
93
94 //_____________________________________________________________________
95 inline void TKDNodeInfo::GetBoundary(Int_t ax, Float_t &min, Float_t &max) const
96 {
97   Int_t ndim = fNDim/3;
98   if(ax<0 || ax>=ndim){
99     min=0.; max=0.;
100     return;
101   }
102   Float_t *it = &fData[ndim+(ax<<1)];
103   min = it[0]; max = it[1];
104 }
105
106 //_____________________________________________________________________
107 inline void TKDNodeInfo::GetCOG(Float_t* &p) const
108 {
109   Int_t ndim = fNDim/3;
110   memcpy(p, fData, ndim*sizeof(Float_t));
111 }
112
113 #endif
114