1 #ifndef ROOT_TKDNodeInfo
2 #define ROOT_TKDNodeInfo
4 ////////////////////////////////////////////////////////
6 // Bucket representation for TKDInterpolator(Base)
8 // Author Alexandru Bercuci <A.Bercuci@gsi.de>
10 ////////////////////////////////////////////////////////
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
32 friend class TKDInterpolatorBase;
33 class TKDNodeDraw : public TBox {
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);
41 TKDNodeDraw(const TKDNodeDraw & ref);
42 TKDNodeDraw& operator=(const TKDNodeDraw & ref);
44 TMarker fCOG; // COG of the node
45 TKDNodeInfo *fNode; //! node data
46 ClassDef(TKDNodeDraw, 1) // graphical representation of TKDNodeInfo
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 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 Int_t GetNcov() const { return fNcov; }
60 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);
65 Double_t* Cov() const { return fCov; }
66 Double_t* Par() const { return fPar; }
68 void SetNode(Int_t ndim, Float_t *data, Float_t *pdf);
71 void Build(Int_t ndim);
72 void SetNcov() { fNcov=Int_t(.5*fNpar*(fNpar+1.));}
73 void SetNpar() { Int_t dim=Int_t(fNDim/3); fNpar=Int_t(1 + dim + .5*dim*(dim+1));}
74 Float_t* Data() { return fData;}
75 Float_t* Val() { return &fVal[0]; }
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
88 ClassDef(TKDNodeInfo, 2) // node info for interpolator
91 //_____________________________________________________________________
92 inline Bool_t TKDNodeInfo::Has(const Float_t *p) const
96 Float_t *it = &fData[ndim]; Int_t n(0);
97 for(int id=0; id<ndim; id++, it+=2)
98 if(p[id]>=it[0] && p[id]<it[1]) n++;
99 if(n==ndim) return kTRUE;
103 //_____________________________________________________________________
104 inline void TKDNodeInfo::GetBoundary(Int_t ax, Float_t &min, Float_t &max) const
106 Int_t ndim = fNDim/3;
107 if(ax<0 || ax>=ndim){
111 Float_t *it = &fData[ndim+(ax<<1)];
112 min = it[0]; max = it[1];
115 //_____________________________________________________________________
116 inline void TKDNodeInfo::GetCOG(Float_t* &p) const
118 Int_t ndim = fNDim/3;
119 memcpy(p, fData, ndim*sizeof(Float_t));