Line data Source code
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 class 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 0 : ~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 128 : 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 : Bool_t CookPDF(const Double_t *point, Double_t &result, Double_t &error) const;
54 : inline void GetBoundary(Int_t ax, Float_t &min, Float_t &max) const;
55 : inline void GetCOG(Float_t* &p) const;
56 0 : Int_t GetDimension() const { return fNDim/3; }
57 0 : void GetPDF(Float_t &pdf, Float_t &error) const {pdf=fVal[0]; error=fVal[1];}
58 0 : Int_t GetSize() const { return fNDim; }
59 0 : Int_t GetNcov() const { return fNcov; }
60 0 : Int_t GetNpar() const { return fNpar; }
61 : inline Bool_t Has(const Float_t *p) const;
62 : void Print(const Option_t * = "") const;
63 : void Store(TVectorD const *par, TMatrixD const *cov=NULL);
64 :
65 0 : Double_t* Cov() const { return fCov; }
66 0 : Double_t* Par() const { return fPar; }
67 :
68 : void SetNode(Int_t ndim, Float_t *data, Float_t *pdf);
69 : protected:
70 : void Bootstrap();
71 : void Build(Int_t ndim);
72 0 : void SetNcov() { fNcov=Int_t(.5*fNpar*(fNpar+1.));}
73 0 : void SetNpar() { Int_t dim=Int_t(fNDim/3); fNpar=Int_t(1 + dim + .5*dim*(dim+1));}
74 0 : Float_t* Data() { return fData;}
75 0 : Float_t* Val() { return &fVal[0]; }
76 :
77 :
78 : private:
79 : Int_t fNDim; //! 3 times data dimension
80 : Float_t *fData; //![fNDim] node's data
81 : Float_t fVal[2]; //!measured value for node
82 : Int_t fNpar; //number of parameters
83 : Int_t fNcov; //number of covarince elements
84 : Double_t *fPar; //[fNpar] interpolator parameters
85 : Double_t *fCov; //[fNcov] interpolator covariance matrix
86 :
87 :
88 44132 : ClassDef(TKDNodeInfo, 2) // node info for interpolator
89 : };
90 :
91 : //_____________________________________________________________________
92 : inline Bool_t TKDNodeInfo::Has(const Float_t *p) const
93 : {
94 0 : Int_t ndim = fNDim/3;
95 :
96 0 : Float_t *it = &fData[ndim]; Int_t n(0);
97 0 : for(int id=0; id<ndim; id++, it+=2)
98 0 : if(p[id]>=it[0] && p[id]<it[1]) n++;
99 0 : if(n==ndim) return kTRUE;
100 0 : return kFALSE;
101 0 : }
102 :
103 : //_____________________________________________________________________
104 : inline void TKDNodeInfo::GetBoundary(Int_t ax, Float_t &min, Float_t &max) const
105 : {
106 0 : Int_t ndim = fNDim/3;
107 0 : if(ax<0 || ax>=ndim){
108 0 : min=0.; max=0.;
109 0 : return;
110 : }
111 0 : Float_t *it = &fData[ndim+(ax<<1)];
112 0 : min = it[0]; max = it[1];
113 0 : }
114 :
115 : //_____________________________________________________________________
116 : inline void TKDNodeInfo::GetCOG(Float_t* &p) const
117 : {
118 0 : Int_t ndim = fNDim/3;
119 0 : memcpy(p, fData, ndim*sizeof(Float_t));
120 0 : }
121 :
122 : #endif
123 :
|