Logo ROOT   6.08/07
Reference Guide
Go to the documentation of this file.
1 // @(#)root/hist:$Id: TGraph2D.h,v 1.00
2 // Author: Olivier Couet
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  *************************************************************************/
12 #ifndef ROOT_TGraph2D
13 #define ROOT_TGraph2D
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGraph2D //
19 // //
20 // Graph 2D graphics class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
24 #ifndef ROOT_TNamed
25 #include "TNamed.h"
26 #endif
27 #ifndef ROOT_TVirtualHistPainter
28 #include "TVirtualHistPainter.h"
29 #endif
30 #ifndef ROOT_TAttLine
31 #include "TAttLine.h"
32 #endif
33 #ifndef ROOT_TAttFill
34 #include "TAttFill.h"
35 #endif
36 #ifndef ROOT_TAttMarker
37 #include "TAttMarker.h"
38 #endif
40 class TAxis;
41 class TList;
42 class TF2;
43 class TH2;
44 class TH2D;
45 class TView;
46 class TDirectory;
48 #include "TFitResultPtr.h"
50 class TGraph2D : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
52 protected:
54  Int_t fNpoints; // Number of points in the data set
55  Int_t fNpx; // Number of bins along X in fHistogram
56  Int_t fNpy; // Number of bins along Y in fHistogram
57  Int_t fMaxIter; // Maximum number of iterations to find Delaunay triangles
58  Int_t fSize; //!Real size of fX, fY and fZ
59  Double_t *fX; //[fNpoints]
60  Double_t *fY; //[fNpoints] Data set to be plotted
61  Double_t *fZ; //[fNpoints]
62  Double_t fMinimum; // Minimum value for plotting along z
63  Double_t fMaximum; // Maximum value for plotting along z
64  Double_t fMargin; // Extra space (in %) around interpolated area for fHistogram
65  Double_t fZout; // fHistogram bin height for points lying outside the interpolated area
66  TList *fFunctions; // Pointer to list of functions (fits and user)
67  TH2D *fHistogram; //!2D histogram of z values linearly interpolated on the triangles
68  TObject *fDelaunay; //! Pointer to Delaunay interpolator object
69  TDirectory *fDirectory; //!Pointer to directory holding this 2D graph
70  TVirtualHistPainter *fPainter; //!Pointer to histogram painter
72  void Build(Int_t n);
74 private:
76  Bool_t fUserHisto; // True when SetHistogram has been called
78  enum {
80  };
83 protected:
85 public:
87  TGraph2D();
88  TGraph2D(Int_t n);
89  TGraph2D(Int_t n, Int_t *x, Int_t *y, Int_t *z);
92  TGraph2D(TH2 *h2);
93  TGraph2D(const char *name, const char *title, Int_t n, Double_t *x, Double_t *y, Double_t *z);
94  TGraph2D(const char *filename, const char *format="%lg %lg %lg", Option_t *option="");
95  TGraph2D(const TGraph2D &);
97  virtual ~TGraph2D();
99  TGraph2D& operator=(const TGraph2D &);
101  virtual void Browse(TBrowser *);
102  virtual void Clear(Option_t *option="");
103  virtual void DirectoryAutoAdd(TDirectory *);
105  virtual void Draw(Option_t *option="");
106  void ExecuteEvent(Int_t event, Int_t px, Int_t py);
107  virtual TObject *FindObject(const char *name) const;
108  virtual TObject *FindObject(const TObject *obj) const;
109  virtual TFitResultPtr Fit(const char *formula ,Option_t *option="" ,Option_t *goption=""); // *MENU*
110  virtual TFitResultPtr Fit(TF2 *f2 ,Option_t *option="" ,Option_t *goption=""); // *MENU*
111  virtual void FitPanel(); // *MENU*
112  TList *GetContourList(Double_t contour);
113  TDirectory *GetDirectory() const {return fDirectory;}
114  Int_t GetNpx() const {return fNpx;}
115  Int_t GetNpy() const {return fNpy;}
116  TH2D *GetHistogram(Option_t *option="");
117  TList *GetListOfFunctions() const { return fFunctions; }
118  virtual Double_t GetErrorX(Int_t bin) const;
119  virtual Double_t GetErrorY(Int_t bin) const;
120  virtual Double_t GetErrorZ(Int_t bin) const;
121  Double_t GetMargin() const {return fMargin;}
122  Double_t GetMaximum() const {return fMaximum;};
123  Double_t GetMinimum() const {return fMinimum;};
124  TAxis *GetXaxis() const ;
125  TAxis *GetYaxis() const ;
126  TAxis *GetZaxis() const ;
127  Int_t GetN() const {return fNpoints;}
128  Double_t *GetX() const {return fX;}
129  Double_t *GetY() const {return fY;}
130  Double_t *GetZ() const {return fZ;}
131  virtual Double_t *GetEX() const {return 0;}
132  virtual Double_t *GetEY() const {return 0;}
133  virtual Double_t *GetEZ() const {return 0;}
134  Double_t GetXmax() const;
135  Double_t GetXmin() const;
136  Double_t GetYmax() const;
137  Double_t GetYmin() const;
138  Double_t GetZmax() const;
139  Double_t GetZmin() const;
140  virtual Double_t GetXmaxE() const {return GetXmax();};
141  virtual Double_t GetXminE() const {return GetXmin();};
142  virtual Double_t GetYmaxE() const {return GetYmax();};
143  virtual Double_t GetYminE() const {return GetYmin();};
144  virtual Double_t GetZmaxE() const {return GetZmax();};
145  virtual Double_t GetZminE() const {return GetZmin();};
147  void Paint(Option_t *option="");
148  TH1 *Project(Option_t *option="x") const; // *MENU*
149  Int_t RemovePoint(Int_t ipoint); // *MENU*
150  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
151  virtual void Set(Int_t n);
152  virtual void SetDirectory(TDirectory *dir);
153  virtual void SetHistogram(TH2 *h);
154  void SetMargin(Double_t m=0.1); // *MENU*
155  void SetMarginBinsContent(Double_t z=0.); // *MENU*
156  void SetMaximum(Double_t maximum=-1111); // *MENU*
157  void SetMinimum(Double_t minimum=-1111); // *MENU*
158  void SetMaxIter(Int_t n=100000) {fMaxIter = n;} // *MENU*
159  virtual void SetName(const char *name); // *MENU*
160  virtual void SetNameTitle(const char *name, const char *title);
161  void SetNpx(Int_t npx=40); // *MENU*
162  void SetNpy(Int_t npx=40); // *MENU*
163  virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z); // *MENU*
164  virtual void SetTitle(const char *title=""); // *MENU*
167  ClassDef(TGraph2D,1) //Set of n x[n],y[n],z[n] points with 3-d graphics including Delaunay triangulation
168 };
170 #endif
Int_t fMaxIter
Definition: TGraph2D.h:57
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point px,py to a graph.
Definition: TGraph2D.cxx:672
TH2D * GetHistogram(Option_t *option="")
By default returns a pointer to the Delaunay histogram.
Definition: TGraph2D.cxx:1037
virtual void DirectoryAutoAdd(TDirectory *)
Perform the automatic addition of the graph to the given directory.
Definition: TGraph2D.cxx:657
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:1019
TList * GetListOfFunctions() const
Definition: TGraph2D.h:117
virtual void Draw(Option_t *option="")
Specific drawing options can be used to paint a TGraph2D:
Definition: TGraph2D.cxx:704
Bool_t fUserHisto
Definition: TGraph2D.h:76
Double_t * fX
Real size of fX, fY and fZ.
Definition: TGraph2D.h:59
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Int_t fNpx
Definition: TGraph2D.h:55
#define BIT(n)
Definition: Rtypes.h:120
TH1 * h
Definition: legend2.C:5
void SetMargin(Double_t m=0.1)
Sets the extra space (in %) around interpolated area for the 2D histogram.
Definition: TGraph2D.cxx:1566
Double_t GetXmax() const
Returns the X maximum.
Definition: TGraph2D.cxx:1197
TGraph2D & operator=(const TGraph2D &)
Graph2D operator "=".
Definition: TGraph2D.cxx:533
TDirectory * GetDirectory() const
Definition: TGraph2D.h:113
See TView3D.
Definition: TView.h:29
virtual void Set(Int_t n)
Set number of points in the 2D graph.
Definition: TGraph2D.cxx:1517
TList * fFunctions
Definition: TGraph2D.h:66
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the TGraphDelaunay convex hull ie: the bins in...
Definition: TGraph2D.cxx:1585
Double_t GetZmin() const
Returns the Z minimum.
Definition: TGraph2D.cxx:1252
TVirtualHistPainter * fPainter
Pointer to directory holding this 2D graph.
Definition: TGraph2D.h:70
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t GetNpy() const
Definition: TGraph2D.h:115
Double_t GetYmax() const
Returns the Y maximum.
Definition: TGraph2D.cxx:1219
static std::string format(double x, double y, int digits, int width)
TObject * fDelaunay
2D histogram of z values linearly interpolated on the triangles
Definition: TGraph2D.h:68
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="")
Fits this graph with function with name fname Predefined functions such as gaus, expo and poln are au...
Definition: TGraph2D.cxx:757
Double_t GetMinimum() const
Definition: TGraph2D.h:123
virtual void SetHistogram(TH2 *h)
Sets the histogram to be filled.
Definition: TGraph2D.cxx:1554
virtual Double_t GetXmaxE() const
Definition: TGraph2D.h:140
Marker Attributes class.
Definition: TAttMarker.h:24
Fill Area Attributes class.
Definition: TAttFill.h:24
Double_t x[n]
Definition: legend1.C:17
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Executes action corresponding to one event.
Definition: TGraph2D.cxx:724
Int_t fNpy
Definition: TGraph2D.h:56
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual Double_t * GetEY() const
Definition: TGraph2D.h:132
virtual void SetTitle(const char *title="")
Sets graph title.
Definition: TGraph2D.cxx:1732
TDirectory * fDirectory
Pointer to Delaunay interpolator object.
Definition: TGraph2D.h:69
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
Double_t GetXmin() const
Returns the X minimum.
Definition: TGraph2D.cxx:1208
Int_t GetNpx() const
Definition: TGraph2D.h:114
Int_t fSize
Definition: TGraph2D.h:58
virtual void Clear(Option_t *option="")
Free all memory allocated by this object.
Definition: TGraph2D.cxx:624
Abstract interface to a histogram painter.
virtual Double_t GetZminE() const
Definition: TGraph2D.h:145
virtual Double_t * GetEZ() const
Definition: TGraph2D.h:133
Double_t fMaximum
Definition: TGraph2D.h:63
void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition: TGraph2D.cxx:1598
A doubly linked list.
Definition: TList.h:47
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:1009
void Paint(Option_t *option="")
Paints this 2D graph with its current attributes.
Definition: TGraph2D.cxx:1301
virtual void SetName(const char *name)
Changes the name of this 2D graph.
Definition: TGraph2D.cxx:1620
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
virtual Double_t GetYminE() const
Definition: TGraph2D.h:143
void SetMaxIter(Int_t n=100000)
Definition: TGraph2D.h:158
void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition: TGraph2D.cxx:1609
Service class for 2-Dim histogram classes.
Definition: TH2.h:36
Class to manage histogram axis.
Definition: TAxis.h:36
virtual void SetDirectory(TDirectory *dir)
By default when an 2D graph is created, it is added to the list of 2D graph objects in the current di...
Definition: TGraph2D.cxx:1533
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Saves primitive as a C++ statement(s) on output stream out.
Definition: TGraph2D.cxx:1471
TList * GetContourList(Double_t contour)
Returns the X and Y graphs building a contour.
Definition: TGraph2D.cxx:980
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:33
Double_t Interpolate(Double_t x, Double_t y)
Finds the z value at the position (x,y) thanks to the Delaunay interpolation.
Definition: TGraph2D.cxx:1264
TMarker * m
Definition: textangle.C:8
Double_t GetMaximum() const
Definition: TGraph2D.h:122
Double_t GetMargin() const
Definition: TGraph2D.h:121
Double_t fMinimum
Definition: TGraph2D.h:62
A 2-Dim function with parameters.
Definition: TF2.h:33
Int_t fNpoints
Definition: TGraph2D.h:54
virtual ~TGraph2D()
TGraph2D destructor.
Definition: TGraph2D.cxx:524
TH2D * fHistogram
Definition: TGraph2D.h:67
Int_t RemovePoint(Int_t ipoint)
Deletes point number ipoint.
Definition: TGraph2D.cxx:1436
virtual Double_t * GetEX() const
Definition: TGraph2D.h:131
Double_t * GetY() const
Definition: TGraph2D.h:129
Double_t GetZmax() const
Returns the Z maximum.
Definition: TGraph2D.cxx:1241
virtual TObject * FindObject(const char *name) const
search object named name in the list of functions
Definition: TGraph2D.cxx:733
Double_t fZout
Definition: TGraph2D.h:65
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
Definition: TGraph2D.cxx:1692
double Double_t
Definition: RtypesCore.h:55
Describe directory structure in memory.
Definition: TDirectory.h:44
virtual Double_t GetYmaxE() const
Definition: TGraph2D.h:142
Double_t y[n]
Definition: legend1.C:17
Double_t * GetZ() const
Definition: TGraph2D.h:130
The TH1 histogram class.
Definition: TH1.h:80
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:999
TH1 * Project(Option_t *option="x") const
Projects a 2-d graph into 1 or 2-d histograms depending on the option parameter option may contain a ...
Definition: TGraph2D.cxx:1349
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Graph2D default constructor.
Definition: TGraph2D.cxx:207
Double_t * fZ
Definition: TGraph2D.h:61
virtual void FitPanel()
Display a GUI panel with all graph fit options.
Definition: TGraph2D.cxx:921
TAxis * GetXaxis() const
Get x axis of the graph.
Definition: TGraph2D.cxx:945
void Build(Int_t n)
Pointer to histogram painter.
Definition: TGraph2D.cxx:577
double f2(const double *x)
virtual Double_t GetZmaxE() const
Definition: TGraph2D.h:144
Double_t GetYmin() const
Returns the Y minimum.
Definition: TGraph2D.cxx:1230
void SetNpy(Int_t npx=40)
Sets the number of bins along Y used to draw the function.
Definition: TGraph2D.cxx:1669
Int_t GetN() const
Definition: TGraph2D.h:127
virtual void Browse(TBrowser *)
Definition: TGraph2D.cxx:614
TAxis * GetZaxis() const
Get z axis of the graph.
Definition: TGraph2D.cxx:967
virtual Double_t GetXminE() const
Definition: TGraph2D.h:141
void SetNpx(Int_t npx=40)
Sets the number of bins along X used to draw the function.
Definition: TGraph2D.cxx:1648
Double_t fMargin
Definition: TGraph2D.h:64
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition: TGraph2D.h:50
virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this 2D graph.
Definition: TGraph2D.cxx:1634
const Int_t n
Definition: legend1.C:16
Line Attributes class.
Definition: TAttLine.h:24
char name[80]
Definition: TGX11.cxx:109
Double_t * GetX() const
Definition: TGraph2D.h:128
Double_t * fY
Definition: TGraph2D.h:60
tomato 2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:296
TAxis * GetYaxis() const
Get y axis of the graph.
Definition: TGraph2D.cxx:956