Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
29class TAxis;
30class TList;
31class TF2;
32class TH1;
33class TH2;
34class TH2D;
35class TView;
36class TDirectory;
38
39#include "TFitResultPtr.h"
40
41class TGraph2D : public TNamed, public TAttLine, public TAttFill, public TAttMarker {
42
43protected:
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
65private:
66
67 Bool_t fUserHisto; // True when SetHistogram has been called
68
71 };
72
73 void CreateInterpolator(Bool_t oldInterp);
74
75protected:
76
77public:
78
79 TGraph2D();
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 ~TGraph2D() override;
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 Add(TF2 *f, Double_t c1=1);
95 virtual void Apply(TF2 *f);
96 void Browse(TBrowser *) override;
97 void Clear(Option_t *option="") override;
98 virtual void DirectoryAutoAdd(TDirectory *);
99 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
100 void Draw(Option_t *option="P0") override;
101 void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
102 TObject *FindObject(const char *name) const override;
103 TObject *FindObject(const TObject *obj) const override;
104 virtual TFitResultPtr Fit(const char *formula ,Option_t *option="" ,Option_t *goption=""); // *MENU*
105 virtual TFitResultPtr Fit(TF2 *f2 ,Option_t *option="" ,Option_t *goption=""); // *MENU*
106 virtual void FitPanel(); // *MENU*
107 TList *GetContourList(Double_t contour);
109 Int_t GetNpx() const {return fNpx;}
110 Int_t GetNpy() const {return fNpy;}
113 virtual Double_t GetErrorX(Int_t bin) const;
114 virtual Double_t GetErrorY(Int_t bin) const;
115 virtual Double_t GetErrorZ(Int_t bin) const;
116 Double_t GetMargin() const {return fMargin;}
117 Double_t GetMaximum() const {return fMaximum;};
118 Double_t GetMinimum() const {return fMinimum;};
119 TAxis *GetXaxis() const ;
120 TAxis *GetYaxis() const ;
121 TAxis *GetZaxis() const ;
122 Int_t GetN() const {return fNpoints;}
123 Double_t *GetX() const {return fX;}
124 Double_t *GetY() const {return fY;}
125 Double_t *GetZ() const {return fZ;}
126 virtual Double_t *GetEX() const {return nullptr;}
127 virtual Double_t *GetEY() const {return nullptr;}
128 virtual Double_t *GetEZ() const {return nullptr;}
129 virtual Double_t *GetEXlow() const {return nullptr;}
130 virtual Double_t *GetEXhigh() const {return nullptr;}
131 virtual Double_t *GetEYlow() const {return nullptr;}
132 virtual Double_t *GetEYhigh() const {return nullptr;}
133 virtual Double_t *GetEZlow() const {return nullptr;}
134 virtual Double_t *GetEZhigh() const {return nullptr;}
135 Double_t GetXmax() const;
136 Double_t GetXmin() const;
137 Double_t GetYmax() const;
138 Double_t GetYmin() const;
139 Double_t GetZmax() const;
140 Double_t GetZmin() const;
141 virtual Double_t GetXmaxE() const {return GetXmax();}
142 virtual Double_t GetXminE() const {return GetXmin();}
143 virtual Double_t GetYmaxE() const {return GetYmax();}
144 virtual Double_t GetYminE() const {return GetYmin();}
145 virtual Double_t GetZmaxE() const {return GetZmax();}
146 virtual Double_t GetZminE() const {return GetZmin();}
147 virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y, Double_t &z) const;
149 void Paint(Option_t *option="") override;
150 void Print(Option_t *chopt="") const override;
151 TH1 *Project(Option_t *option="x") const; // *MENU*
152 Int_t RemovePoint(Int_t ipoint); // *MENU*
153 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
154 virtual void Scale(Double_t c1=1., Option_t *option="z"); // *MENU*
155 virtual void Set(Int_t n);
156 virtual void SetDirectory(TDirectory *dir);
157 virtual void SetHistogram(TH2 *h, Option_t *option="");
158 void SetMargin(Double_t m=0.1); // *MENU*
159 void SetMarginBinsContent(Double_t z=0.); // *MENU*
160 void SetMaximum(Double_t maximum=-1111); // *MENU*
161 void SetMinimum(Double_t minimum=-1111); // *MENU*
162 void SetMaxIter(Int_t n=100000) {fMaxIter = n;} // *MENU*
163 void SetName(const char *name) override; // *MENU*
164 void SetNameTitle(const char *name, const char *title) override;
165 void SetNpx(Int_t npx=40); // *MENU*
166 void SetNpy(Int_t npx=40); // *MENU*
167 virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z); // *MENU*
168 void SetTitle(const char *title="") override; // *MENU*
169
170
171 ClassDefOverride(TGraph2D,1) //Set of n x[n],y[n],z[n] points with 3-d graphics including Delaunay triangulation
172};
173
174#endif
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
char name[80]
Definition TGX11.cxx:110
Fill Area Attributes class.
Definition TAttFill.h:19
Line Attributes class.
Definition TAttLine.h:18
Marker Attributes class.
Definition TAttMarker.h:19
Class to manage histogram axis.
Definition TAxis.h:31
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Describe directory structure in memory.
Definition TDirectory.h:45
A 2-Dim function with parameters.
Definition TF2.h:29
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Graphics object made of three arrays X, Y and Z with the same number of points each.
Definition TGraph2D.h:41
Int_t fMaxIter
Maximum number of iterations to find Delaunay triangles.
Definition TGraph2D.h:48
TObject * FindObject(const char *name) const override
search object named name in the list of functions
Definition TGraph2D.cxx:791
virtual Double_t * GetEZhigh() const
Definition TGraph2D.h:134
Double_t GetMaximum() const
Definition TGraph2D.h:117
void SetNameTitle(const char *name, const char *title) override
Change the name and title of this 2D graph.
virtual Double_t GetYminE() const
Definition TGraph2D.h:144
TGraph2D()
Graph2D default constructor.
Definition TGraph2D.cxx:238
void Build(Int_t n)
Creates the 2D graph basic data structure.
Definition TGraph2D.cxx:602
Int_t fNpoints
Number of points in the data set.
Definition TGraph2D.h:45
virtual Double_t GetZminE() const
Definition TGraph2D.h:146
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition TGraph2D.cxx:959
Double_t GetMinimum() const
Definition TGraph2D.h:118
Double_t * GetY() const
Definition TGraph2D.h:124
virtual void FitPanel()
Display a GUI panel with all graph fit options.
Definition TGraph2D.cxx:861
virtual void Apply(TF2 *f)
Apply function f to all the data points f may be a 2-D function TF2 or 3-d function TF3 The Z values ...
Definition TGraph2D.cxx:658
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the TGraphDelaunay convex hull ie: the bins in...
Int_t fNpx
Number of bins along X in fHistogram.
Definition TGraph2D.h:46
void SavePrimitive(std::ostream &out, Option_t *option="") override
Saves primitive as a C++ statement(s) on output stream out.
virtual Double_t GetYmaxE() const
Definition TGraph2D.h:143
Double_t GetYmin() const
Returns the Y minimum.
Bool_t fUserHisto
Definition TGraph2D.h:67
Double_t GetZmin() const
Returns the Z minimum.
void Browse(TBrowser *) override
Browse.
Definition TGraph2D.cxx:671
Double_t * GetX() const
Definition TGraph2D.h:123
virtual Double_t GetZmaxE() const
Definition TGraph2D.h:145
Double_t * fZ
[fNpoints]
Definition TGraph2D.h:52
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition TGraph2D.cxx:939
Double_t fMargin
Extra space (in %) around interpolated area for fHistogram.
Definition TGraph2D.h:55
Double_t fMinimum
Minimum value for plotting along z.
Definition TGraph2D.h:53
Double_t GetXmin() const
Returns the X minimum.
void Print(Option_t *chopt="") const override
Print 2D graph values.
virtual Double_t * GetEZ() const
Definition TGraph2D.h:128
TH2D * GetHistogram(Option_t *option="")
By default returns a pointer to the Delaunay histogram.
TVirtualHistPainter * fPainter
!Pointer to histogram painter
Definition TGraph2D.h:61
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:815
Double_t GetMargin() const
Definition TGraph2D.h:116
Double_t GetZmax() const
Returns the Z maximum.
Int_t RemovePoint(Int_t ipoint)
Deletes point number ipoint.
Double_t fMaximum
Maximum value for plotting along z.
Definition TGraph2D.h:54
~TGraph2D() override
TGraph2D destructor.
Definition TGraph2D.cxx:548
TAxis * GetZaxis() const
Get z axis of the graph.
Definition TGraph2D.cxx:907
void SetMargin(Double_t m=0.1)
Sets the extra space (in %) around interpolated area for the 2D histogram.
void SetName(const char *name) override
Changes the name of this 2D graph.
void SetNpy(Int_t npx=40)
Sets the number of bins along Y used to draw the function.
Double_t fZout
fHistogram bin height for points lying outside the interpolated area
Definition TGraph2D.h:56
void SetTitle(const char *title="") override
Sets the 2D graph title.
TH2D * fHistogram
!2D histogram of z values linearly interpolated on the triangles
Definition TGraph2D.h:58
virtual Double_t GetXminE() const
Definition TGraph2D.h:142
TList * GetContourList(Double_t contour)
Returns the X and Y graphs building a contour.
Definition TGraph2D.cxx:920
Double_t GetXmax() const
Returns the X maximum.
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.
TAxis * GetYaxis() const
Get y axis of the graph.
Definition TGraph2D.cxx:896
virtual Double_t * GetEYhigh() const
Definition TGraph2D.h:132
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
Definition TGraph2D.cxx:949
virtual Double_t * GetEY() const
Definition TGraph2D.h:127
TList * GetListOfFunctions() const
Definition TGraph2D.h:112
TObject * fDelaunay
! Pointer to Delaunay interpolator object
Definition TGraph2D.h:59
TH1 * Project(Option_t *option="x") const
Projects a 2-d graph into 1 or 2-d histograms depending on the option parameter.
Int_t GetN() const
Definition TGraph2D.h:122
virtual Double_t GetXmaxE() const
Definition TGraph2D.h:141
virtual void Set(Int_t n)
Set number of points in the 2D graph.
void SetMinimum(Double_t minimum=-1111)
Set minimum.
TGraph2D & operator=(const TGraph2D &)
Graph2D operator "=".
Definition TGraph2D.cxx:557
virtual Double_t * GetEXhigh() const
Definition TGraph2D.h:130
Double_t * fX
[fNpoints]
Definition TGraph2D.h:50
Double_t * fY
[fNpoints] Data set to be plotted
Definition TGraph2D.h:51
virtual void SetHistogram(TH2 *h, Option_t *option="")
Sets the histogram to be filled.
void SetMaximum(Double_t maximum=-1111)
Set maximum.
virtual Double_t * GetEXlow() const
Definition TGraph2D.h:129
virtual void Add(TF2 *f, Double_t c1=1)
Performs the operation: z = z + c1*f(x,y,z) Errors are not recalculated.
Definition TGraph2D.cxx:642
Double_t GetYmax() const
Returns the Y maximum.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point px,py to a graph.
Definition TGraph2D.cxx:730
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...
TDirectory * fDirectory
!Pointer to directory holding this 2D graph
Definition TGraph2D.h:60
void Clear(Option_t *option="") override
Free all memory allocated by this object.
Definition TGraph2D.cxx:681
virtual void Scale(Double_t c1=1., Option_t *option="z")
Multiply the values of a TGraph2D by a constant c1.
virtual Double_t * GetEX() const
Definition TGraph2D.h:126
virtual void DirectoryAutoAdd(TDirectory *)
Perform the automatic addition of the graph to the given directory.
Definition TGraph2D.cxx:715
void CreateInterpolator(Bool_t oldInterp)
Add a TGraphDelaunay in the list of the fHistogram's functions.
Definition TGraph2D.cxx:968
Int_t GetNpy() const
Definition TGraph2D.h:110
TDirectory * GetDirectory() const
Definition TGraph2D.h:108
Int_t fNpy
Number of bins along Y in fHistogram.
Definition TGraph2D.h:47
virtual void AddPoint(Double_t x, Double_t y, Double_t z)
Append a new point to the graph.
Definition TGraph2D.h:93
TList * fFunctions
Pointer to list of functions (fits and user)
Definition TGraph2D.h:57
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
void Paint(Option_t *option="") override
Paints this 2D graph with its current attributes.
virtual Double_t * GetEZlow() const
Definition TGraph2D.h:133
Int_t GetNpx() const
Definition TGraph2D.h:109
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Executes action corresponding to one event.
Definition TGraph2D.cxx:782
Int_t fSize
!Real size of fX, fY and fZ
Definition TGraph2D.h:49
void SetMaxIter(Int_t n=100000)
Definition TGraph2D.h:162
@ kOldInterpolation
Definition TGraph2D.h:70
TAxis * GetXaxis() const
Get x axis of the graph.
Definition TGraph2D.cxx:885
virtual Double_t * GetEYlow() const
Definition TGraph2D.h:131
Double_t * GetZ() const
Definition TGraph2D.h:125
void SetNpx(Int_t npx=40)
Sets the number of bins along X used to draw the function.
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
2-D histogram with a double per channel (see TH1 documentation)
Definition TH2.h:357
Service class for 2-D histogram classes.
Definition TH2.h:30
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
See TView3D.
Definition TView.h:25
Abstract interface to a histogram painter.
#define Interpolate(a, x, b, y)
Definition geom.c:179
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
th1 Draw()
TMarker m
Definition textangle.C:8