From Philippe & Laurent: new variant of MUON visualization.
[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;
25typedef struct TVectorT<Double_t> TVectorD;
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();
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; }
1a439134 65
b273c7cb 66 void SetNode(Int_t ndim, Float_t *data, Float_t *pdf);
a3408ed3 67protected:
b273c7cb 68 Float_t* Data() { return fData;}
69 Float_t* Val() { return &fVal[0]; }
70 void Build(Int_t ndim);
a3408ed3 71
1a439134 72private:
b6f6b31a 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
a3408ed3 78
b6f6b31a 79 ClassDef(TKDNodeInfo, 1) // node info for interpolator
a3408ed3 80};
81
82//_____________________________________________________________________
b273c7cb 83inline Bool_t TKDNodeInfo::Has(const Float_t *p) const
a3408ed3 84{
b6f6b31a 85 Int_t ndim = fNDim/3;
b273c7cb 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++;
b6f6b31a 90 if(n==ndim) return kTRUE;
91 return kFALSE;
a3408ed3 92}
93
b273c7cb 94//_____________________________________________________________________
95inline 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//_____________________________________________________________________
107inline void TKDNodeInfo::GetCOG(Float_t* &p) const
108{
109 Int_t ndim = fNDim/3;
110 memcpy(p, fData, ndim*sizeof(Float_t));
111}
a3408ed3 112
113#endif
114