Logo ROOT  
Reference Guide
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 "TAttLine.h"
26 #include "TAttFill.h"
27 #include "TAttMarker.h"
28 
29 class TAxis;
30 class TList;
31 class TF2;
32 class TH1;
33 class TH2;
34 class TH2D;
35 class TView;
36 class TDirectory;
38 
39 #include "TFitResultPtr.h"
40 
41 class TGraph2D : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
42 
43 protected:
44 
45  Int_t fNpoints; ///< Number of points in the data set
46  Int_t fNpx; ///< Number of bins along X in fHistogram
47  Int_t fNpy; ///< Number of bins along Y in fHistogram
48  Int_t fMaxIter; ///< Maximum number of iterations to find Delaunay triangles
49  Int_t fSize; ///<!Real size of fX, fY and fZ
50  Double_t *fX; ///<[fNpoints]
51  Double_t *fY; ///<[fNpoints] Data set to be plotted
52  Double_t *fZ; ///<[fNpoints]
53  Double_t fMinimum; ///< Minimum value for plotting along z
54  Double_t fMaximum; ///< Maximum value for plotting along z
55  Double_t fMargin; ///< Extra space (in %) around interpolated area for fHistogram
56  Double_t fZout; ///< fHistogram bin height for points lying outside the interpolated area
57  TList *fFunctions; ///< Pointer to list of functions (fits and user)
58  TH2D *fHistogram; ///<!2D histogram of z values linearly interpolated on the triangles
59  TObject *fDelaunay; ///<! Pointer to Delaunay interpolator object
60  TDirectory *fDirectory; ///<!Pointer to directory holding this 2D graph
61  TVirtualHistPainter *fPainter; ///<!Pointer to histogram painter
62 
63  void Build(Int_t n);
64 
65 private:
66 
67  Bool_t fUserHisto; // True when SetHistogram has been called
68 
69  enum EStatusBits {
71  };
72 
73  void CreateInterpolator(Bool_t oldInterp);
74 
75 protected:
76 
77 public:
78 
79  TGraph2D();
80  TGraph2D(Int_t n);
81  TGraph2D(Int_t n, Int_t *x, Int_t *y, Int_t *z);
84  TGraph2D(TH2 *h2);
85  TGraph2D(const char *name, const char *title, Int_t n, Double_t *x, Double_t *y, Double_t *z);
86  TGraph2D(const char *filename, const char *format="%lg %lg %lg", Option_t *option="");
87  TGraph2D(const TGraph2D &);
88 
89  virtual ~TGraph2D();
90 
91  TGraph2D& operator=(const TGraph2D &);
92 
93  virtual void AddPoint(Double_t x, Double_t y, Double_t z) { SetPoint(fNpoints, x, y, z); } ///< Append a new point to the graph.
94  virtual void Browse(TBrowser *);
95  virtual void Clear(Option_t *option="");
96  virtual void DirectoryAutoAdd(TDirectory *);
98  virtual void Draw(Option_t *option="P0");
99  void ExecuteEvent(Int_t event, Int_t px, Int_t py);
100  virtual TObject *FindObject(const char *name) const;
101  virtual TObject *FindObject(const TObject *obj) const;
102  virtual TFitResultPtr Fit(const char *formula ,Option_t *option="" ,Option_t *goption=""); // *MENU*
103  virtual TFitResultPtr Fit(TF2 *f2 ,Option_t *option="" ,Option_t *goption=""); // *MENU*
104  virtual void FitPanel(); // *MENU*
105  TList *GetContourList(Double_t contour);
106  TDirectory *GetDirectory() const {return fDirectory;}
107  Int_t GetNpx() const {return fNpx;}
108  Int_t GetNpy() const {return fNpy;}
109  TH2D *GetHistogram(Option_t *option="");
110  TList *GetListOfFunctions() const { return fFunctions; }
111  virtual Double_t GetErrorX(Int_t bin) const;
112  virtual Double_t GetErrorY(Int_t bin) const;
113  virtual Double_t GetErrorZ(Int_t bin) const;
114  Double_t GetMargin() const {return fMargin;}
115  Double_t GetMaximum() const {return fMaximum;};
116  Double_t GetMinimum() const {return fMinimum;};
117  TAxis *GetXaxis() const ;
118  TAxis *GetYaxis() const ;
119  TAxis *GetZaxis() const ;
120  Int_t GetN() const {return fNpoints;}
121  Double_t *GetX() const {return fX;}
122  Double_t *GetY() const {return fY;}
123  Double_t *GetZ() const {return fZ;}
124  virtual Double_t *GetEX() const {return 0;}
125  virtual Double_t *GetEY() const {return 0;}
126  virtual Double_t *GetEZ() const {return 0;}
127  Double_t GetXmax() const;
128  Double_t GetXmin() const;
129  Double_t GetYmax() const;
130  Double_t GetYmin() const;
131  Double_t GetZmax() const;
132  Double_t GetZmin() const;
133  virtual Double_t GetXmaxE() const {return GetXmax();};
134  virtual Double_t GetXminE() const {return GetXmin();};
135  virtual Double_t GetYmaxE() const {return GetYmax();};
136  virtual Double_t GetYminE() const {return GetYmin();};
137  virtual Double_t GetZmaxE() const {return GetZmax();};
138  virtual Double_t GetZminE() const {return GetZmin();};
139  virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y, Double_t &z) const;
141  void Paint(Option_t *option="");
142  virtual void Print(Option_t *chopt="") const;
143  TH1 *Project(Option_t *option="x") const; // *MENU*
144  Int_t RemovePoint(Int_t ipoint); // *MENU*
145  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
146  virtual void Set(Int_t n);
147  virtual void SetDirectory(TDirectory *dir);
148  virtual void SetHistogram(TH2 *h);
149  void SetMargin(Double_t m=0.1); // *MENU*
150  void SetMarginBinsContent(Double_t z=0.); // *MENU*
151  void SetMaximum(Double_t maximum=-1111); // *MENU*
152  void SetMinimum(Double_t minimum=-1111); // *MENU*
153  void SetMaxIter(Int_t n=100000) {fMaxIter = n;} // *MENU*
154  virtual void SetName(const char *name); // *MENU*
155  virtual void SetNameTitle(const char *name, const char *title);
156  void SetNpx(Int_t npx=40); // *MENU*
157  void SetNpy(Int_t npx=40); // *MENU*
158  virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z); // *MENU*
159  virtual void SetTitle(const char *title=""); // *MENU*
160 
161 
162  ClassDef(TGraph2D,1) //Set of n x[n],y[n],z[n] points with 3-d graphics including Delaunay triangulation
163 };
164 
165 #endif
TGraph2D::GetXmin
Double_t GetXmin() const
Returns the X minimum.
Definition: TGraph2D.cxx:1233
m
auto * m
Definition: textangle.C:8
n
const Int_t n
Definition: legend1.C:16
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
TGraph2D::fSize
Int_t fSize
!Real size of fX, fY and fZ
Definition: TGraph2D.h:49
TGraph2D::GetX
Double_t * GetX() const
Definition: TGraph2D.h:121
TGraph2D::fY
Double_t * fY
[fNpoints] Data set to be plotted
Definition: TGraph2D.h:51
TGraph2D::GetErrorZ
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:1037
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
TGraph2D::fZ
Double_t * fZ
[fNpoints]
Definition: TGraph2D.h:52
TGraph2D::GetXaxis
TAxis * GetXaxis() const
Get x axis of the graph.
Definition: TGraph2D.cxx:963
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGraph2D::Draw
virtual void Draw(Option_t *option="P0")
Specific drawing options can be used to paint a TGraph2D:
Definition: TGraph2D.cxx:712
TGraph2D::SetNameTitle
virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this 2D graph.
Definition: TGraph2D.cxx:1693
TGraph2D::Fit
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:765
TGraph2D::operator=
TGraph2D & operator=(const TGraph2D &)
Graph2D operator "=".
Definition: TGraph2D.cxx:539
TNamed.h
TGraph2D::ExecuteEvent
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Executes action corresponding to one event.
Definition: TGraph2D.cxx:732
TGraph2D::GetEZ
virtual Double_t * GetEZ() const
Definition: TGraph2D.h:126
TGraph2D::GetContourList
TList * GetContourList(Double_t contour)
Returns the X and Y graphs building a contour.
Definition: TGraph2D.cxx:998
TGraph2D::GetN
Int_t GetN() const
Definition: TGraph2D.h:120
TAttMarker.h
Float_t
float Float_t
Definition: RtypesCore.h:57
TGraph2D::GetDirectory
TDirectory * GetDirectory() const
Definition: TGraph2D.h:106
TGraph2D::GetZmin
Double_t GetZmin() const
Returns the Z minimum.
Definition: TGraph2D.cxx:1277
TGraph2D::fMaxIter
Int_t fMaxIter
Maximum number of iterations to find Delaunay triangles.
Definition: TGraph2D.h:48
TGraph2D::GetXmaxE
virtual Double_t GetXmaxE() const
Definition: TGraph2D.h:133
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
TGraph2D::Set
virtual void Set(Int_t n)
Set number of points in the 2D graph.
Definition: TGraph2D.cxx:1573
TGraph2D::fNpy
Int_t fNpy
Number of bins along Y in fHistogram.
Definition: TGraph2D.h:47
TGraph2D::SetMaxIter
void SetMaxIter(Int_t n=100000)
Definition: TGraph2D.h:153
TGraph2D::Paint
void Paint(Option_t *option="")
Paints this 2D graph with its current attributes.
Definition: TGraph2D.cxx:1339
TGraph2D::SetMinimum
void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition: TGraph2D.cxx:1668
TGraph2D::DirectoryAutoAdd
virtual void DirectoryAutoAdd(TDirectory *)
Perform the automatic addition of the graph to the given directory.
Definition: TGraph2D.cxx:665
TGraph2D::GetMinimum
Double_t GetMinimum() const
Definition: TGraph2D.h:116
TGraph2D::GetZmax
Double_t GetZmax() const
Returns the Z maximum.
Definition: TGraph2D.cxx:1266
TGraph2D::GetXmax
Double_t GetXmax() const
Returns the X maximum.
Definition: TGraph2D.cxx:1222
TGraph2D::GetZminE
virtual Double_t GetZminE() const
Definition: TGraph2D.h:138
TGraph2D::fZout
Double_t fZout
fHistogram bin height for points lying outside the interpolated area
Definition: TGraph2D.h:56
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGraph2D::GetEY
virtual Double_t * GetEY() const
Definition: TGraph2D.h:125
TGraph2D::fX
Double_t * fX
[fNpoints]
Definition: TGraph2D.h:50
TGraph2D::CreateInterpolator
void CreateInterpolator(Bool_t oldInterp)
Add a TGraphDelaunay in the list of the fHistogram's functions.
Definition: TGraph2D.cxx:1046
bool
TGraph2D::Interpolate
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:1302
TGraph2D::kOldInterpolation
@ kOldInterpolation
Definition: TGraph2D.h:70
TGraph2D::GetNpy
Int_t GetNpy() const
Definition: TGraph2D.h:108
TAttLine.h
TGraph2D::fPainter
TVirtualHistPainter * fPainter
!Pointer to histogram painter
Definition: TGraph2D.h:61
TGraph2D::SetDirectory
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:1589
TVirtualHistPainter
Abstract interface to a histogram painter.
Definition: TVirtualHistPainter.h:30
TGraph2D::fMinimum
Double_t fMinimum
Minimum value for plotting along z.
Definition: TGraph2D.h:53
TGraph2D::SetName
virtual void SetName(const char *name)
Changes the name of this 2D graph.
Definition: TGraph2D.cxx:1679
TGraph2D
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition: TGraph2D.h:41
TGraph2D::fDirectory
TDirectory * fDirectory
!Pointer to directory holding this 2D graph
Definition: TGraph2D.h:60
TAttFill.h
TAttLine
Line Attributes class.
Definition: TAttLine.h:18
TView
See TView3D.
Definition: TView.h:25
TGraph2D::fNpx
Int_t fNpx
Number of bins along X in fHistogram.
Definition: TGraph2D.h:46
TFitResultPtr
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:32
TGraph2D::GetZmaxE
virtual Double_t GetZmaxE() const
Definition: TGraph2D.h:137
TGraph2D::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Saves primitive as a C++ statement(s) on output stream out.
Definition: TGraph2D.cxx:1521
TGraph2D::fDelaunay
TObject * fDelaunay
! Pointer to Delaunay interpolator object
Definition: TGraph2D.h:59
TGraph2D::fMaximum
Double_t fMaximum
Maximum value for plotting along z.
Definition: TGraph2D.h:54
h
#define h(i)
Definition: RSha256.hxx:106
TGraph2D::GetMaximum
Double_t GetMaximum() const
Definition: TGraph2D.h:115
TGraph2D::GetErrorY
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:1027
TGraph2D::GetNpx
Int_t GetNpx() const
Definition: TGraph2D.h:107
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TGraph2D::SetMaximum
void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition: TGraph2D.cxx:1657
TGraph2D::Clear
virtual void Clear(Option_t *option="")
Free all memory allocated by this object.
Definition: TGraph2D.cxx:631
TH2D
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:292
TGraph2D::AddPoint
virtual void AddPoint(Double_t x, Double_t y, Double_t z)
Append a new point to the graph.
Definition: TGraph2D.h:93
TGraph2D::Project
TH1 * Project(Option_t *option="x") const
Projects a 2-d graph into 1 or 2-d histograms depending on the option parameter.
Definition: TGraph2D.cxx:1398
TAttMarker
Marker Attributes class.
Definition: TAttMarker.h:19
TH2
Service class for 2-Dim histogram classes.
Definition: TH2.h:30
BIT
#define BIT(n)
Definition: Rtypes.h:85
TGraph2D::TGraph2D
TGraph2D()
Graph2D default constructor.
Definition: TGraph2D.cxx:212
TGraph2D::SetTitle
virtual void SetTitle(const char *title="")
Sets the 2D graph title.
Definition: TGraph2D.cxx:1800
TGraph2D::FitPanel
virtual void FitPanel()
Display a GUI panel with all graph fit options.
Definition: TGraph2D.cxx:939
y
Double_t y[n]
Definition: legend1.C:17
TGraph2D::fNpoints
Int_t fNpoints
Number of points in the data set.
Definition: TGraph2D.h:45
TGraph2D::GetYminE
virtual Double_t GetYminE() const
Definition: TGraph2D.h:136
TGraph2D::GetErrorX
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition: TGraph2D.cxx:1017
TGraph2D::GetEX
virtual Double_t * GetEX() const
Definition: TGraph2D.h:124
TGraph2D::Browse
virtual void Browse(TBrowser *)
Browse.
Definition: TGraph2D.cxx:621
TF2
A 2-Dim function with parameters.
Definition: TF2.h:29
TGraph2D::SetPoint
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
Definition: TGraph2D.cxx:1753
TGraph2D::GetY
Double_t * GetY() const
Definition: TGraph2D.h:122
TGraph2D::GetXminE
virtual Double_t GetXminE() const
Definition: TGraph2D.h:134
Double_t
double Double_t
Definition: RtypesCore.h:59
TFitResultPtr.h
TGraph2D::GetZ
Double_t * GetZ() const
Definition: TGraph2D.h:123
TGraph2D::GetYmaxE
virtual Double_t GetYmaxE() const
Definition: TGraph2D.h:135
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TGraph2D::FindObject
virtual TObject * FindObject(const char *name) const
search object named name in the list of functions
Definition: TGraph2D.cxx:741
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGraph2D::SetNpy
void SetNpy(Int_t npx=40)
Sets the number of bins along Y used to draw the function.
Definition: TGraph2D.cxx:1729
TGraph2D::~TGraph2D
virtual ~TGraph2D()
TGraph2D destructor.
Definition: TGraph2D.cxx:530
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
TGraph2D::Build
void Build(Int_t n)
Creates the 2D graph basic data structure.
Definition: TGraph2D.cxx:584
name
char name[80]
Definition: TGX11.cxx:110
TGraph2D::GetMargin
Double_t GetMargin() const
Definition: TGraph2D.h:114
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:40
TGraph2D::GetPoint
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y, Double_t &z) const
Get x, y and z values for point number i.
Definition: TGraph2D.cxx:1288
TGraph2D::SetMarginBinsContent
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:1643
TGraph2D::GetListOfFunctions
TList * GetListOfFunctions() const
Definition: TGraph2D.h:110
TAttFill
Fill Area Attributes class.
Definition: TAttFill.h:19
TGraph2D::GetYmin
Double_t GetYmin() const
Returns the Y minimum.
Definition: TGraph2D.cxx:1255
TGraph2D::RemovePoint
Int_t RemovePoint(Int_t ipoint)
Deletes point number ipoint.
Definition: TGraph2D.cxx:1485
TGraph2D::SetMargin
void SetMargin(Double_t m=0.1)
Sets the extra space (in %) around interpolated area for the 2D histogram.
Definition: TGraph2D.cxx:1623
TGraph2D::fHistogram
TH2D * fHistogram
!2D histogram of z values linearly interpolated on the triangles
Definition: TGraph2D.h:58
TGraph2D::SetNpx
void SetNpx(Int_t npx=40)
Sets the number of bins along X used to draw the function.
Definition: TGraph2D.cxx:1707
TGraph2D::fUserHisto
Bool_t fUserHisto
Definition: TGraph2D.h:67
TGraph2D::GetHistogram
TH2D * GetHistogram(Option_t *option="")
By default returns a pointer to the Delaunay histogram.
Definition: TGraph2D.cxx:1081
TGraph2D::GetZaxis
TAxis * GetZaxis() const
Get z axis of the graph.
Definition: TGraph2D.cxx:985
TGraph2D::fFunctions
TList * fFunctions
Pointer to list of functions (fits and user)
Definition: TGraph2D.h:57
TGraph2D::SetHistogram
virtual void SetHistogram(TH2 *h)
Sets the histogram to be filled.
Definition: TGraph2D.cxx:1610
TObject::EStatusBits
EStatusBits
Definition: TObject.h:57
TGraph2D::DistancetoPrimitive
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point px,py to a graph.
Definition: TGraph2D.cxx:680
TList
A doubly linked list.
Definition: TList.h:44
TGraph2D::GetYaxis
TAxis * GetYaxis() const
Get y axis of the graph.
Definition: TGraph2D.cxx:974
TGraph2D::fMargin
Double_t fMargin
Extra space (in %) around interpolated area for fHistogram.
Definition: TGraph2D.h:55
int
TGraph2D::Print
virtual void Print(Option_t *chopt="") const
Print 2D graph values.
Definition: TGraph2D.cxx:1381
TGraph2D::GetYmax
Double_t GetYmax() const
Returns the Y maximum.
Definition: TGraph2D.cxx:1244