]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STAT/TKDInterpolatorBase.h
o adapt Macro to new TPC structure (Benjamin Hess)
[u/mrichter/AliRoot.git] / STAT / TKDInterpolatorBase.h
index 4bd228e79b3a162dc67df827d5c63374c6a5743a..3654bea49edd4c1fcd3171a23ae298e93fd91ac6 100644 (file)
@@ -5,6 +5,10 @@
 #include "Rtypes.h"
 #endif
 
+#ifndef ROOT_TKDNodeInfo
+#include "TKDNodeInfo.h"
+#endif
+
 ///////////////////////////////////////////////////////////////
 //
 // Base non parametric interpolation algorithm.
 ///////////////////////////////////////////////////////////////
 
 template <typename Value> class TVectorT;
-typedef struct TVectorT<Double_t> TVectorD;
+typedef class TVectorT<Double_t> TVectorD;
 template <typename Value> class TMatrixT;
 typedef class TMatrixT<Double_t> TMatrixD;
 template <typename Index, typename Value> class TKDTree;
 typedef class TKDTree<Int_t, Float_t> TKDTreeIF;
 class TLinearFitter;
 class TClonesArray;
-class TKDNodeInfo;
 class TKDInterpolatorBase
 {
 public:        
@@ -30,42 +33,47 @@ public:
     kdN = 4       // increase in the number of PDF if fit failled
    ,kNhelper = 30 // bucket size in helper kdTree
   };
-
+  enum EKDInterpolatorBaseBits {
+    kCOG   = 0  // COG interpolation method
+   ,kSTORE = 1  // Store interpolation results
+   ,kWEIGHTS = 2 // use weights
+  };
   TKDInterpolatorBase(Int_t size = 0);
   virtual ~TKDInterpolatorBase();
 
-  Double_t   Eval(const Double_t *point, Double_t &result, Double_t &error, Bool_t force = kFALSE);
+  Bool_t        Bootstrap();
+  Double_t      Eval(const Double_t *point, Double_t &result, Double_t &error, Bool_t force = kFALSE);
   virtual Int_t GetNodeIndex(const Float_t *p) = 0;
-  Float_t    GetAlpha() const {return fAlpha;}
-  Bool_t     GetCOGPoint(Int_t node, Float_t *&coord, Float_t &val, Float_t &error) const;
-  Bool_t     GetInterpolationMethod() const {return fStatus&1;}
-  TKDNodeInfo* GetNodeInfo(Int_t inode) const;
-  Int_t      GetNTNodes() const {return fNTNodes;}
-  void       GetStatus();
-  Bool_t     GetStore() const {return fStatus&2;}
-  Bool_t     GetWeights() const {return fStatus&4;}
-
-  void       DrawBins(UInt_t ax1 = 0, UInt_t ax2 = 1, Float_t ax1min=-1., Float_t ax1max=1., Float_t ax2min=-1., Float_t ax2max=1.);
-  void       SetAlpha(Float_t a);
-  void       SetInterpolationMethod(Bool_t on = kTRUE);
-  void       SetStore(Bool_t on = kTRUE);
-  void       SetWeights(Bool_t on = kTRUE);
+  Float_t       GetAlpha() const {return fAlpha;}
+  Int_t         GetLambda() const {return fLambda;}
+  Int_t         GetSize() const {return fNSize;}
+  Bool_t        GetCOGPoint(Int_t node, Float_t *&coord, Float_t &val, Float_t &error) const;
+  TKDNodeInfo*  GetNodeInfo(Int_t inode) const;
+  Int_t         GetNTNodes() const;
+  Bool_t        GetRange(Int_t ax, Float_t &min, Float_t &max) const;
+  void          GetStatus(Option_t *opt="");
 
-protected:
-  virtual void      Build(Int_t nnodes);
+  Bool_t        HasStore() const {return TESTBIT(fStatus, kSTORE);}
+  Bool_t        UseCOG() const {return TESTBIT(fStatus, kCOG);}
+  Bool_t        UseWeights() const {return TESTBIT(fStatus, kWEIGHTS);}
 
-private:
-  TKDInterpolatorBase(const TKDInterpolatorBase &);
-  TKDInterpolatorBase& operator=(const TKDInterpolatorBase &);
+  void          DrawProjection(UInt_t ax1 = 0, UInt_t ax2 = 1);
+  void          SetAlpha(Float_t a);
+  void          SetCOG(Bool_t on = kTRUE) {on ? SETBIT(fStatus, kCOG) : CLRBIT(fStatus, kCOG);}
+  void          SetStore(Bool_t on = kTRUE) {on ? SETBIT(fStatus, kSTORE) : CLRBIT(fStatus, kSTORE);}
+  void          SetWeights(Bool_t on = kTRUE) {on ? SETBIT(fStatus, kWEIGHTS) : CLRBIT(fStatus, kWEIGHTS);}
 
 protected:
-  Int_t         fNSize;       // data dimension
-  Int_t         fNTNodes;     //Number of evaluation data points
-  TClonesArray  *fTNodes;     //interpolation nodes
+  virtual Bool_t    Build(Int_t nnodes);
+
+
+  Int_t         fNSize;       //!data dimension
+  TClonesArray  *fNodes;     //interpolation nodes
+  TKDNodeInfo::TKDNodeDraw  *fNodesDraw; //!graphical representation of interpolation nodes
 
 //private:
   UChar_t       fStatus;      // status of the interpolator
-  UChar_t       fLambda;      // number of parameters in polynom
+  UChar_t       fLambda;      //! number of parameters in polynom
   Short_t                  fDepth;       //! depth of the KD Tree structure used
   Float_t       fAlpha;       // parameter controlling the size of the region to interpolate n = (1+alpha)*lambda
   Float_t       **fRefPoints; //! temporary storage of COG data
@@ -73,7 +81,11 @@ protected:
   TKDTree<Int_t, Float_t> *fKDhelper;      //! kNN finder
   TLinearFitter *fFitter;     //! linear fitter        
 
-  ClassDef(TKDInterpolatorBase, 1)   // data interpolator based on KD tree
+private:
+  TKDInterpolatorBase(const TKDInterpolatorBase &);
+  TKDInterpolatorBase& operator=(const TKDInterpolatorBase &);
+
+  ClassDef(TKDInterpolatorBase, 3)   // data interpolator based on KD tree
 };