CMake: Removing all lhapdf link dependencies
[u/mrichter/AliRoot.git] / STAT / TKDNodeInfo.h
CommitLineData
a3408ed3 1#ifndef ROOT_TKDNodeInfo
2#define ROOT_TKDNodeInfo
3
b273c7cb 4////////////////////////////////////////////////////////
5//
6// Bucket representation for TKDInterpolator(Base)
7//
8// Author Alexandru Bercuci <A.Bercuci@gsi.de>
9//
10////////////////////////////////////////////////////////
11
a3408ed3 12#ifndef ROOT_TObject
13#include "TObject.h"
14#endif
15
b6f6b31a 16#ifndef ROOT_TBox
17#include "TBox.h"
18#endif
19
20#ifndef ROOT_TMarker
21#include "TMarker.h"
22#endif
23
a3408ed3 24template <typename Value> class TVectorT;
ec7e7b6b 25typedef class TVectorT<Double_t> TVectorD;
a3408ed3 26template <typename Value> class TMatrixT;
27typedef class TMatrixT<Double_t> TMatrixD;
a3408ed3 28class TKDNodeInfo : public TObject
29{
a3408ed3 30public:
b273c7cb 31 friend class TKDPDF;
32 friend class TKDInterpolatorBase;
b6f6b31a 33 class TKDNodeDraw : public TBox {
34 public:
35 TKDNodeDraw();
36 ~TKDNodeDraw() {;}
37 void Draw(Option_t* option = "");
b273c7cb 38 void Print(const Option_t* option = "") const; // *MENU*
b6f6b31a 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
b273c7cb 44 TMarker fCOG; // COG of the node
45 TKDNodeInfo *fNode; //! node data
b6f6b31a 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);
b273c7cb 52 virtual ~TKDNodeInfo();
afb669c1 53 Bool_t CookPDF(const Double_t *point, Double_t &result, Double_t &error) const;
b273c7cb 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; }
afb669c1 59 Int_t GetNcov() const { return fNcov; }
60 Int_t GetNpar() const { return fNpar; }
b273c7cb 61 inline Bool_t Has(const Float_t *p) const;
62 void Print(const Option_t * = "") const;
afb669c1 63 void Store(TVectorD const *par, TMatrixD const *cov=NULL);
b273c7cb 64
afb669c1 65 Double_t* Cov() const { return fCov; }
66 Double_t* Par() const { return fPar; }
1a439134 67
b273c7cb 68 void SetNode(Int_t ndim, Float_t *data, Float_t *pdf);
a3408ed3 69protected:
afb669c1 70 void Bootstrap();
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));}
b273c7cb 74 Float_t* Data() { return fData;}
75 Float_t* Val() { return &fVal[0]; }
afb669c1 76
a3408ed3 77
1a439134 78private:
afb669c1 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
a3408ed3 87
afb669c1 88 ClassDef(TKDNodeInfo, 2) // node info for interpolator
a3408ed3 89};
90
91//_____________________________________________________________________
b273c7cb 92inline Bool_t TKDNodeInfo::Has(const Float_t *p) const
a3408ed3 93{
b6f6b31a 94 Int_t ndim = fNDim/3;
b273c7cb 95
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++;
b6f6b31a 99 if(n==ndim) return kTRUE;
100 return kFALSE;
a3408ed3 101}
102
b273c7cb 103//_____________________________________________________________________
104inline void TKDNodeInfo::GetBoundary(Int_t ax, Float_t &min, Float_t &max) const
105{
106 Int_t ndim = fNDim/3;
107 if(ax<0 || ax>=ndim){
108 min=0.; max=0.;
109 return;
110 }
111 Float_t *it = &fData[ndim+(ax<<1)];
112 min = it[0]; max = it[1];
113}
114
115//_____________________________________________________________________
116inline void TKDNodeInfo::GetCOG(Float_t* &p) const
117{
118 Int_t ndim = fNDim/3;
119 memcpy(p, fData, ndim*sizeof(Float_t));
120}
a3408ed3 121
122#endif
123