Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGraph2D.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id: TGraph2D.h,v 1.00
2 // Author: Olivier Couet
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGraph2D
13 #define ROOT_TGraph2D
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGraph2D //
19 // //
20 // Graph 2D graphics class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TNamed.h"
25 #include "TVirtualHistPainter.h"
26 #include "TAttLine.h"
27 #include "TAttFill.h"
28 #include "TAttMarker.h"
29 
30 class TAxis;
31 class TList;
32 class TF2;
33 class TH2;
34 class TH2D;
35 class TView;
36 class TDirectory;
37 
38 #include "TFitResultPtr.h"
39 
40 class TGraph2D : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
41 
42 protected:
43 
44  Int_t fNpoints; ///< Number of points in the data set
45  Int_t fNpx; ///< Number of bins along X in fHistogram
46  Int_t fNpy; ///< Number of bins along Y in fHistogram
47  Int_t fMaxIter; ///< Maximum number of iterations to find Delaunay triangles
48  Int_t fSize; ///<!Real size of fX, fY and fZ
49  Double_t *fX; ///<[fNpoints]
50  Double_t *fY; ///<[fNpoints] Data set to be plotted
51  Double_t *fZ; ///<[fNpoints]
52  Double_t fMinimum; ///< Minimum value for plotting along z
53  Double_t fMaximum; ///< Maximum value for plotting along z
54  Double_t fMargin; ///< Extra space (in %) around interpolated area for fHistogram
55  Double_t fZout; ///< fHistogram bin height for points lying outside the interpolated area
56  TList *fFunctions; ///< Pointer to list of functions (fits and user)
57  TH2D *fHistogram; ///<!2D histogram of z values linearly interpolated on the triangles
58  TObject *fDelaunay; ///<! Pointer to Delaunay interpolator object
59  TDirectory *fDirectory; ///<!Pointer to directory holding this 2D graph
60  TVirtualHistPainter *fPainter; ///<!Pointer to histogram painter
61 
62  void Build(Int_t n);
63 
64 private:
65 
66  Bool_t fUserHisto; // True when SetHistogram has been called
67 
68  enum EStatusBits {
69  kOldInterpolation = BIT(15)
70  };
71 
72  void CreateInterpolator(Bool_t oldInterp);
73 
74 protected:
75 
76 public:
77 
78  TGraph2D();
79  TGraph2D(Int_t n);
80  TGraph2D(Int_t n, Int_t *x, Int_t *y, Int_t *z);
81  TGraph2D(Int_t n, Float_t *x, Float_t *y, Float_t *z);
82  TGraph2D(Int_t n, Double_t *x, Double_t *y, Double_t *z);
83  TGraph2D(TH2 *h2);
84  TGraph2D(const char *name, const char *title, Int_t n, Double_t *x, Double_t *y, Double_t *z);
85  TGraph2D(const char *filename, const char *format="%lg %lg %lg", Option_t *option="");
86  TGraph2D(const TGraph2D &);
87 
88  virtual ~TGraph2D();
89 
90  TGraph2D& operator=(const TGraph2D &);
91 
92  virtual void Browse(TBrowser *);
93  virtual void Clear(Option_t *option="");
94  virtual void DirectoryAutoAdd(TDirectory *);
95  Int_t DistancetoPrimitive(Int_t px, Int_t py);
96  virtual void Draw(Option_t *option="P0");
97  void ExecuteEvent(Int_t event, Int_t px, Int_t py);
98  virtual TObject *FindObject(const char *name) const;
99  virtual TObject *FindObject(const TObject *obj) const;
100  virtual TFitResultPtr Fit(const char *formula ,Option_t *option="" ,Option_t *goption=""); // *MENU*
101  virtual TFitResultPtr Fit(TF2 *f2 ,Option_t *option="" ,Option_t *goption=""); // *MENU*
102  virtual void FitPanel(); // *MENU*
103  TList *GetContourList(Double_t contour);
104  TDirectory *GetDirectory() const {return fDirectory;}
105  Int_t GetNpx() const {return fNpx;}
106  Int_t GetNpy() const {return fNpy;}
107  TH2D *GetHistogram(Option_t *option="");
108  TList *GetListOfFunctions() const { return fFunctions; }
109  virtual Double_t GetErrorX(Int_t bin) const;
110  virtual Double_t GetErrorY(Int_t bin) const;
111  virtual Double_t GetErrorZ(Int_t bin) const;
112  Double_t GetMargin() const {return fMargin;}
113  Double_t GetMaximum() const {return fMaximum;};
114  Double_t GetMinimum() const {return fMinimum;};
115  TAxis *GetXaxis() const ;
116  TAxis *GetYaxis() const ;
117  TAxis *GetZaxis() const ;
118  Int_t GetN() const {return fNpoints;}
119  Double_t *GetX() const {return fX;}
120  Double_t *GetY() const {return fY;}
121  Double_t *GetZ() const {return fZ;}
122  virtual Double_t *GetEX() const {return 0;}
123  virtual Double_t *GetEY() const {return 0;}
124  virtual Double_t *GetEZ() const {return 0;}
125  Double_t GetXmax() const;
126  Double_t GetXmin() const;
127  Double_t GetYmax() const;
128  Double_t GetYmin() const;
129  Double_t GetZmax() const;
130  Double_t GetZmin() const;
131  virtual Double_t GetXmaxE() const {return GetXmax();};
132  virtual Double_t GetXminE() const {return GetXmin();};
133  virtual Double_t GetYmaxE() const {return GetYmax();};
134  virtual Double_t GetYminE() const {return GetYmin();};
135  virtual Double_t GetZmaxE() const {return GetZmax();};
136  virtual Double_t GetZminE() const {return GetZmin();};
137  virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y, Double_t &z) const;
138  Double_t Interpolate(Double_t x, Double_t y);
139  void Paint(Option_t *option="");
140  virtual void Print(Option_t *chopt="") const;
141  TH1 *Project(Option_t *option="x") const; // *MENU*
142  Int_t RemovePoint(Int_t ipoint); // *MENU*
143  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
144  virtual void Set(Int_t n);
145  virtual void SetDirectory(TDirectory *dir);
146  virtual void SetHistogram(TH2 *h);
147  void SetMargin(Double_t m=0.1); // *MENU*
148  void SetMarginBinsContent(Double_t z=0.); // *MENU*
149  void SetMaximum(Double_t maximum=-1111); // *MENU*
150  void SetMinimum(Double_t minimum=-1111); // *MENU*
151  void SetMaxIter(Int_t n=100000) {fMaxIter = n;} // *MENU*
152  virtual void SetName(const char *name); // *MENU*
153  virtual void SetNameTitle(const char *name, const char *title);
154  void SetNpx(Int_t npx=40); // *MENU*
155  void SetNpy(Int_t npx=40); // *MENU*
156  virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z); // *MENU*
157  virtual void SetTitle(const char *title=""); // *MENU*
158 
159 
160  ClassDef(TGraph2D,1) //Set of n x[n],y[n],z[n] points with 3-d graphics including Delaunay triangulation
161 };
162 
163 #endif