346 for (
Int_t i = xfirst; i <= xlast; i++) {
347 for (
Int_t j = yfirst; j <= ylast; j++) {
352 if (z != 0. || ez != 0) {
419 std::ifstream infile(fname.
Data());
420 if (!infile.good()) {
422 Error(
"TGraph2D",
"Cannot open file: %s, TGraph2D is Zombie", filename);
430 if (strcmp(option,
"") == 0) {
432 while (std::getline(infile,
line,
'\n')) {
433 if (3 != sscanf(
line.c_str(), format, &
x, &
y, &z)) {
451 Error(
"TGraph2D",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
456 Error(
"TGraph2D",
"Incorrect input format! Only %d tag(s) in format whereas 3 \"%%lg\" tags are expected!", ntokens);
459 Int_t ntokensToBeSaved = 0 ;
461 for (
Int_t idx = 0; idx < ntokens; idx++) {
463 if (isTokenToBeSaved[idx] == 1) {
467 if (ntokens >= 3 && ntokensToBeSaved != 3) {
468 Error(
"TGraph2D",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 3 and only 3 are expected!", ntokensToBeSaved);
469 delete [] isTokenToBeSaved ;
475 char * token = NULL ;
477 Int_t token_idx = 0 ;
479 Int_t value_idx = 0 ;
483 while (std::getline(infile,
line,
'\n')) {
485 if (
line[
line.size() - 1] ==
char(13)) {
488 token = R__STRTOK_R(
const_cast<char*
>(
line.c_str()), option, &rest);
489 while (token != NULL && value_idx < 3) {
490 if (isTokenToBeSaved[token_idx]) {
494 isLineToBeSkipped =
kTRUE ;
497 value[value_idx] = token_str.
Atof() ;
501 token = R__STRTOK_R(NULL, option, &rest);
504 if (!isLineToBeSkipped && value_idx == 3) {
512 isLineToBeSkipped =
kFALSE ;
519 delete [] isTokenToBeSaved ;
534 fHistogram(0), fDirectory(0), fPainter(0)
568 if (
this == &
g)
return *
this;
571 if (
fX)
delete []
fX;
572 if (
fY)
delete []
fY;
573 if (
fZ)
delete []
fZ;
614 Error(
"TGraph2D",
"Invalid number of points (%d)",
n);
660 if (
fX)
delete []
fX;
662 if (
fY)
delete []
fY;
664 if (
fZ)
delete []
fZ;
709 Int_t distance = 9999;
744 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
796 linear = (
char*)strstr(fname,
"++");
799 TF2 f2(fname, fname);
800 return Fit(&f2, option,
"");
804 Printf(
"Unknown function: %s", fname);
807 return Fit(f2, option,
"");
969 gROOT->MakeDefCanvas();
972 Error(
"FitPanel",
"Unable to create a default canvas");
980 Error(
"FitPanel",
"Unable to crate the FitPanel");
982 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
1028 Error(
"GetContourList",
"Empty TGraph2D");
1147 Double_t hxmax, hymax, hxmin, hymin;
1183 fNpx , hxmin, hxmax,
1184 fNpy, hymin, hymax);
1208 if (hzmin == hzmax) {
1211 hzmin = hz - 0.01 * hz;
1212 hzmax = hz + 0.01 * hz;
1225 x = hxmin + (ix - 0.5) * dx;
1227 y = hymin + (iy - 0.5) * dy;
1317 if (i < 0 || i >=
fNpoints)
return -1;
1318 if (!
fX || !
fY || !
fZ)
return -1;
1332 Error(
"Interpolate",
"Empty TGraph2D");
1352 if (
fDelaunay->IsA() == TGraphDelaunay2D::Class() )
1354 else if (
fDelaunay->IsA() == TGraphDelaunay::Class() )
1369 Error(
"Paint",
"Empty TGraph2D");
1411 printf(
"x[%d]=%g, y[%d]=%g, z[%d]=%g\n", i,
fX[i], i,
fY[i], i,
fZ[i]);
1428 Error(
"Project",
"Empty TGraph2D");
1445 char *
name =
new char[nch];
1448 char *title =
new char[nch];
1479 if (
h == 0)
return 0;
1504 h->SetEntries(entries);
1514 if (ipoint < 0)
return -1;
1523 if (i == ipoint)
continue;
1551 out <<
" " << std::endl;
1552 if (
gROOT->ClassSaved(TGraph2D::Class())) {
1555 out <<
" TGraph2D *";
1558 out <<
"graph2d = new TGraph2D(" <<
fNpoints <<
");" << std::endl;
1559 out <<
" graph2d->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
1560 out <<
" graph2d->SetTitle(" << quote <<
GetTitle() <<
";"
1566 out <<
" graph2d->SetDirectory(0);" << std::endl;
1574 out <<
" graph2d->SetPoint(" << i <<
"," <<
fX[i] <<
"," <<
fY[i] <<
"," <<
fZ[i] <<
");" << std::endl;
1580 while ((obj = next())) {
1582 out <<
" graph2d->GetListOfFunctions()->Add(" << obj->
GetName() <<
");" << std::endl;
1584 out <<
" ptstats->SetParent(graph2d->GetListOfFunctions());" << std::endl;
1586 out <<
" " << obj->
GetName() <<
"->SetParent(graph);\n";
1591 out <<
" graph2d->Draw(" << quote << option << quote <<
");" << std::endl;
1665 fNpx =
h->GetNbinsX();
1666 fNpy =
h->GetNbinsY();
1676 if (m < 0 || m > 1) {
1677 Warning(
"SetMargin",
"The margin must be >= 0 && <= 1, fMargin set to 0.1");
1712 if (
h)
h->SetMaximum(maximum);
1723 if (
h)
h->SetMinimum(minimum);
1761 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 4");
1763 }
else if (npx > 500) {
1764 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 500");
1783 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 4");
1785 }
else if (npy > 500) {
1786 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 500");
1863 if (
b.IsReading()) {
1865 Version_t R__v =
b.ReadVersion(&R__s, &R__c);
1866 b.ReadClassBuffer(TGraph2D::Class(),
this, R__v, R__s, R__c);
1870 b.WriteClassBuffer(TGraph2D::Class(),
this);
void Printf(const char *fmt,...)
R__EXTERN TSystem * gSystem
class describing the range in the coordinates it supports multiple range in a coordinate.
Fill Area Attributes class.
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
virtual Color_t GetLineColor() const
Return the line color.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual Style_t GetLineStyle() const
Return the line style.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual Style_t GetMarkerStyle() const
Return the marker style.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual Color_t GetMarkerColor() const
Return the marker color.
virtual Size_t GetMarkerSize() const
Return the marker size.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Class to manage histogram axis.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual void SetLimits(Double_t xmin, Double_t xmax)
const char * GetTitle() const
Returns title of object.
Int_t GetFirst() const
Return first bin on the axis i.e.
Using a TBrowser one can browse all ROOT objects.
Buffer base class used for serializing objects.
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
A 2-Dim function with parameters.
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.
Int_t fMaxIter
Maximum number of iterations to find Delaunay triangles.
virtual Double_t GetYminE() const
TGraph2D()
Graph2D default constructor.
void Build(Int_t n)
Creates the 2D graph basic data structure.
Double_t Interpolate(Double_t x, Double_t y)
Finds the z value at the position (x,y) thanks to the Delaunay interpolation.
Int_t fNpoints
Number of points in the data set.
virtual Double_t GetZminE() const
virtual void Print(Option_t *chopt="") const
Print 2D graph values.
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
virtual void FitPanel()
Display a GUI panel with all graph fit options.
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.
virtual Double_t GetYmaxE() const
Double_t GetYmin() const
Returns the Y minimum.
Double_t GetZmin() const
Returns the Z minimum.
virtual Double_t GetZmaxE() const
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
Double_t fMargin
Extra space (in %) around interpolated area for fHistogram.
Double_t fMinimum
Minimum value for plotting along z.
Double_t GetXmin() const
Returns the X minimum.
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point px,py to a graph.
virtual void Browse(TBrowser *)
Browse.
TH2D * GetHistogram(Option_t *option="")
By default returns a pointer to the Delaunay histogram.
TVirtualHistPainter * fPainter
!Pointer to histogram painter
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...
virtual TObject * FindObject(const char *name) const
search object named name in the list of functions
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Saves primitive as a C++ statement(s) on output stream out.
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.
TAxis * GetZaxis() const
Get z axis of the graph.
void SetMargin(Double_t m=0.1)
Sets the extra space (in %) around interpolated area for the 2D histogram.
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
TH2D * fHistogram
!2D histogram of z values linearly interpolated on the triangles
virtual Double_t GetXminE() const
TList * GetContourList(Double_t contour)
Returns the X and Y graphs building a contour.
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.
virtual void SetTitle(const char *title="")
Sets the 2D graph title.
TAxis * GetYaxis() const
Get y axis of the graph.
virtual ~TGraph2D()
TGraph2D destructor.
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
TObject * fDelaunay
! Pointer to Delaunay interpolator object
TH1 * Project(Option_t *option="x") const
Projects a 2-d graph into 1 or 2-d histograms depending on the option parameter.
virtual void SetHistogram(TH2 *h)
Sets the histogram to be filled.
virtual Double_t GetXmaxE() const
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 "=".
Double_t * fY
[fNpoints] Data set to be plotted
void SetMaximum(Double_t maximum=-1111)
Set maximum.
virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this 2D graph.
Double_t GetYmax() const
Returns the Y maximum.
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
virtual void Scale(Double_t c1=1., Option_t *option="z")
Multiply the values of a TGraph2D by a constant c1.
virtual void DirectoryAutoAdd(TDirectory *)
Perform the automatic addition of the graph to the given directory.
void CreateInterpolator(Bool_t oldInterp)
Add a TGraphDelaunay in the list of the fHistogram's functions.
Int_t fNpy
Number of bins along Y in fHistogram.
virtual void SetName(const char *name)
Changes the name of this 2D graph.
TList * fFunctions
Pointer to list of functions (fits and user)
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
void Paint(Option_t *option="")
Paints this 2D graph with its current attributes.
virtual void Draw(Option_t *option="P0")
Specific drawing options can be used to paint a TGraph2D:
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Executes action corresponding to one event.
Int_t fSize
!Real size of fX, fY and fZ
virtual void Clear(Option_t *option="")
Free all memory allocated by this object.
TAxis * GetXaxis() const
Get x axis of the graph.
void SetNpx(Int_t npx=40)
Sets the number of bins along X used to draw the function.
TGraphDelaunay2D generates a Delaunay triangulation of a TGraph2D.
void SetMarginBinsContent(Double_t z=0.)
TGraphDelaunay generates a Delaunay triangulation of a TGraph2D.
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the convex hull ie: the bins in the margin.
void SetMaxIter(Int_t n=100000)
Defines the number of triangles tested for a Delaunay triangle (number of iterations) before abandoni...
1-D histogram with a double per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
@ kNoStats
Don't draw stats box.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
virtual Int_t GetNbinsX() const
virtual void SetMaximum(Double_t maximum=-1111)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetMinimum(Double_t minimum=-1111)
virtual Double_t GetEntries() const
Return the current number of entries.
TList * GetListOfFunctions() const
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
2-D histogram with a double per channel (see TH1 documentation)}
Service class for 2-D histogram classes.
Int_t Fill(Double_t)
Invalid Fill method.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void Add(TObject *obj)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
@ kCanDelete
if object in a list can be deleted
@ kInvalidObject
if object ctor succeeded but object should not be used
@ kMustCleanup
if object destructor must call RecursiveRemove()
Longptr_t ExecPlugin(int nargs, const T &... params)
Int_t LoadPlugin()
Load the plugin library for this handler.
void ToLower()
Change string to lower-case.
Int_t Atoi() const
Return integer value of string.
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
const char * Data() const
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual TList * GetContourList(Double_t contour) const =0
TFitResultPtr FitObject(TH1 *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
fitting function for a TH1 (called from TH1::Fit)
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Short_t Max(Short_t a, Short_t b)
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754