226 fFunctions =
new TList;
241 for (
Int_t i = 0; i < fNpoints; ++i) {
259 for (
Int_t i = 0; i < fNpoints; ++i) {
277 for (
Int_t i = 0; i < fNpoints; ++i) {
306 Int_t xlast = xaxis->GetLast();
314 for (
Int_t i = xfirst; i <= xlast; i++) {
315 for (
Int_t j = yfirst; j <= ylast; j++) {
316 x = xaxis->GetBinCenter(i);
320 if (
z != 0. || ez != 0) {
321 SetPoint(k,
x,
y,
z);
387 std::ifstream infile(fname.
Data());
388 if (!infile.good()) {
390 Error(
"TGraph2D",
"Cannot open file: %s, TGraph2D is Zombie", filename);
398 if (strcmp(option,
"") == 0) {
400 while (std::getline(infile,
line,
'\n')) {
401 if (3 != sscanf(
line.c_str(), format, &
x, &
y, &
z)) {
419 Error(
"TGraph2D",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
424 Error(
"TGraph2D",
"Incorrect input format! Only %d tag(s) in format whereas 3 \"%%lg\" tags are expected!", ntokens);
427 Int_t ntokensToBeSaved = 0 ;
429 for (
Int_t idx = 0; idx < ntokens; idx++) {
431 if (isTokenToBeSaved[idx] == 1) {
435 if (ntokens >= 3 && ntokensToBeSaved != 3) {
436 Error(
"TGraph2D",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 3 and only 3 are expected!", ntokensToBeSaved);
437 delete [] isTokenToBeSaved ;
443 char * token = NULL ;
445 Int_t token_idx = 0 ;
447 Int_t value_idx = 0 ;
450 while (std::getline(infile,
line,
'\n')) {
452 if (
line[
line.size() - 1] == char(13)) {
455 token = strtok(const_cast<char*>(
line.c_str()), option) ;
456 while (token != NULL && value_idx < 3) {
457 if (isTokenToBeSaved[token_idx]) {
461 isLineToBeSkipped =
kTRUE ;
464 value[value_idx] = token_str.
Atof() ;
468 token = strtok(NULL, option) ;
471 if (!isLineToBeSkipped && value_idx == 3) {
479 isLineToBeSkipped =
kFALSE ;
486 delete [] isTokenToBeSaved ;
535 if (
this == &g)
return *
this;
538 if (
fX)
delete []
fX;
539 if (
fY)
delete []
fY;
540 if (
fZ)
delete []
fZ;
580 Error(
"TGraph2D",
"Invalid number of points (%d)", n);
626 if (
fX)
delete []
fX;
628 if (
fY)
delete []
fY;
630 if (
fZ)
delete []
fZ;
674 Int_t distance = 9999;
709 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
761 linear = (
char*)strstr(fname,
"++");
764 f2 =
new TF2(fname, fname);
766 f2 = (
TF2*)
gROOT->GetFunction(fname);
768 Printf(
"Unknown function: %s", fname);
772 return Fit(f2, option,
"");
924 gROOT->MakeDefCanvas();
927 Error(
"FitPanel",
"Unable to create a default canvas");
935 Error(
"FitPanel",
"Unable to crate the FitPanel");
937 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
983 Error(
"GetContourList",
"Empty TGraph2D");
1075 Double_t hxmax, hymax, hxmin, hymin;
1094 hxmin = hxmin-hxmin*0.01;
1095 hxmax = hxmax+hxmax*0.01;
1103 hymin = hymin-hymin*0.01;
1104 hymax = hymax+hymax*0.01;
1112 fNpx , hxmin, hxmax,
1113 fNpy, hymin, hymax);
1156 if (hzmin == hzmax) {
1159 hzmin = hz - 0.01 * hz;
1160 hzmax = hz + 0.01 * hz;
1173 x = hxmin + (ix - 0.5) * dx;
1175 y = hymin + (iy - 0.5) * dy;
1200 for (
Int_t i = 1; i < fNpoints; i++) if (fX[i] >
v) v =
fX[i];
1222 for (
Int_t i = 1; i < fNpoints; i++) if (fY[i] >
v) v =
fY[i];
1244 for (
Int_t i = 1; i < fNpoints; i++) if (fZ[i] >
v) v =
fZ[i];
1267 Error(
"Interpolate",
"Empty TGraph2D");
1304 Error(
"Paint",
"Empty TGraph2D");
1352 Error(
"Project",
"Empty TGraph2D");
1369 char *
name =
new char[nch];
1372 char *title =
new char[nch];
1383 h1 =
new TH1D(name, title,
fNpx, hxmin, hxmax);
1387 h1 =
new TH1D(name, title,
fNpy, hymin, hymax);
1391 h2 =
new TH2D(name, title,
fNpx, hxmin, hxmax,
fNpy, hymin, hymax);
1395 h2 =
new TH2D(name, title,
fNpy, hymin, hymax,
fNpx, hxmin, hxmax);
1403 if (h == 0)
return 0;
1438 if (ipoint < 0)
return -1;
1447 if (i == ipoint)
continue;
1474 out <<
" " << std::endl;
1478 out <<
" TGraph2D *";
1481 out <<
"graph2d = new TGraph2D(" <<
fNpoints <<
");" << std::endl;
1482 out <<
" graph2d->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
1483 out <<
" graph2d->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
1486 out <<
" " <<
GetName() <<
"->SetDirectory(0);" << std::endl;
1494 out <<
" graph2d->SetPoint(" << i <<
"," <<
fX[i] <<
"," <<
fY[i] <<
"," <<
fZ[i] <<
");" << std::endl;
1500 while ((obj = next())) {
1502 out <<
" graph2d->GetListOfFunctions()->Add(" << obj->
GetName() <<
");" << std::endl;
1504 out <<
" ptstats->SetParent(graph2d->GetListOfFunctions());" << std::endl;
1506 out <<
" " << obj->
GetName() <<
"->SetParent(graph);\n";
1511 out <<
" graph2d->Draw(" << quote << option << quote <<
");" << std::endl;
1571 if (m < 0 || m > 1) {
1572 Warning(
"SetMargin",
"The margin must be >= 0 && <= 1, fMargin set to 0.1");
1654 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 4");
1656 }
else if (npx > 500) {
1657 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 500");
1675 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 4");
1677 }
else if (npy > 500) {
1678 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 500");
1752 void TGraph2D::Streamer(
TBuffer &
b)
virtual const char * GetName() const
Returns name of object.
Int_t fMaxIter
Maximum number of iterations to find Delaunay triangles.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point px,py to a graph.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
void SetMarginBinsContent(Double_t z=0.)
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
TH2D * GetHistogram(Option_t *option="")
By default returns a pointer to the Delaunay histogram.
void SetMaxIter(Int_t n=100000)
Defines the number of triangles tested for a Delaunay triangle (number of iterations) before abandoni...
virtual void DirectoryAutoAdd(TDirectory *)
Perform the automatic addition of the graph to the given directory.
Int_t GetFirst() const
Return first bin on the axis i.e.
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetLimits(Double_t xmin, Double_t xmax)
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
TString & ReplaceAll(const TString &s1, const TString &s2)
Int_t fNpx
Number of bins along X in fHistogram.
void SetMargin(Double_t m=0.1)
Sets the extra space (in %) around interpolated area for the 2D histogram.
Double_t GetXmax() const
Returns the X maximum.
TGraph2D & operator=(const TGraph2D &)
Graph2D operator "=".
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
Buffer base class used for serializing objects.
virtual void Set(Int_t n)
Set number of points in the 2D graph.
virtual void SetMinimum(Double_t minimum=-1111)
virtual void Draw(Option_t *option="P0")
Specific drawing options can be used to paint a TGraph2D:
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Int_t LoadPlugin()
Load the plugin library for this handler.
TList * fFunctions
Pointer to list of functions (fits and user)
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the TGraphDelaunay convex hull ie: the bins in...
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Double_t GetZmin() const
Returns the Z minimum.
TVirtualHistPainter * fPainter
!Pointer to histogram painter
void ToLower()
Change string to lower-case.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Double_t GetYmax() const
Returns the Y maximum.
TObject * fDelaunay
! Pointer to Delaunay interpolator object
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 Width_t GetLineWidth() const
Return the line width.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
if object in a list can be deleted
virtual void SetHistogram(TH2 *h)
Sets the histogram to be filled.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual Style_t GetMarkerStyle() const
Return the marker style.
virtual Double_t GetXmaxE() const
virtual Style_t GetLineStyle() const
Return the line style.
Fill Area Attributes class.
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Executes action corresponding to one event.
Int_t fNpy
Number of bins along Y in fHistogram.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual void SetTitle(const char *title="")
Sets the 2D graph title.
TDirectory * fDirectory
!Pointer to directory holding this 2D graph
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.
The TNamed class is the base class for all named ROOT classes.
Double_t GetXmin() const
Returns the X minimum.
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the convex hull ie: the bins in the margin...
Int_t fSize
!Real size of fX, fY and fZ
virtual void Clear(Option_t *option="")
Free all memory allocated by this object.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
TString & Append(const char *cs)
virtual Size_t GetMarkerSize() const
Return the marker size.
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.
Double_t fMaximum
Maximum value for plotting along z.
void SetMaximum(Double_t maximum=-1111)
Set maximum.
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
void Paint(Option_t *option="")
Paints this 2D graph with its current attributes.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
virtual void SetName(const char *name)
Changes the name of this 2D graph.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Using a TBrowser one can browse all ROOT objects.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
virtual Double_t GetYminE() const
virtual TList * GetContourList(Double_t contour) const =0
void SetMinimum(Double_t minimum=-1111)
Set minimum.
Int_t GetLast() const
Return last bin on the axis i.e.
Service class for 2-Dim histogram classes.
Class to manage histogram axis.
R__EXTERN TSystem * gSystem
if object ctor succeeded but object should not be used
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
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...
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Saves primitive as a C++ statement(s) on output stream out.
Long_t ExecPlugin(int nargs, const T &... params)
TList * GetContourList(Double_t contour)
Returns the X and Y graphs building a contour.
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Double_t Interpolate(Double_t x, Double_t y)
Finds the z value at the position (x,y) thanks to the Delaunay interpolation.
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 void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Double_t fMinimum
Minimum value for plotting along z.
A 2-Dim function with parameters.
1-D histogram with a double per channel (see TH1 documentation)}
Int_t fNpoints
Number of points in the data set.
virtual ~TGraph2D()
TGraph2D destructor.
if object destructor must call RecursiveRemove()
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
TH2D * fHistogram
!2D histogram of z values linearly interpolated on the triangles
Int_t RemovePoint(Int_t ipoint)
Deletes point number ipoint.
Double_t GetZmax() const
Returns the Z maximum.
virtual Color_t GetLineColor() const
Return the line color.
virtual TObject * FindObject(const char *name) const
search object named name in the list of functions
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
Double_t fZout
fHistogram bin height for points lying outside the interpolated area
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
class describing the range in the coordinates it supports multiple range in a coordinate.
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
Describe directory structure in memory.
virtual Double_t GetYmaxE() const
virtual Color_t GetFillColor() const
Return the fill area color.
TGraphDelaunay2D generates a Delaunay triangulation of a TGraph2D.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Double_t GetEntries() const
Return the current number of entries.
THist< 2, double, THistStatContent, THistStatUncertainty > TH2D
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
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 ...
Mother of all ROOT objects.
you should not use this method at all Int_t Int_t z
TGraph2D()
Graph2D default constructor.
virtual void FitPanel()
Display a GUI panel with all graph fit options.
TAxis * GetXaxis() const
Get x axis of the graph.
void Build(Int_t n)
Creates the 2D graph basic data structure.
virtual void Add(TObject *obj)
Short_t Max(Short_t a, Short_t b)
Double_t GetYmin() const
Returns the Y minimum.
void SetNpy(Int_t npx=40)
Sets the number of bins along Y used to draw the function.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void Browse(TBrowser *)
Browse.
Int_t Atoi() const
Return integer value of string.
TAxis * GetZaxis() const
Get z axis of the graph.
virtual Double_t GetXminE() const
virtual void SetEntries(Double_t n)
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
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)
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual Color_t GetMarkerColor() const
Return the marker color.
void SetNpx(Int_t npx=40)
Sets the number of bins along X used to draw the function.
virtual Int_t GetNbinsX() const
virtual Style_t GetFillStyle() const
Return the fill area style.
Double_t fMargin
Extra space (in %) around interpolated area for fHistogram.
Graphics object made of three arrays X, Y and Z with the same number of points each.
virtual const char * GetName() const
Returns name of object.
virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this 2D graph.
Int_t Fill(Double_t)
Invalid Fill method.
TList * GetListOfFunctions() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
TGraphDelaunay generates a Delaunay triangulation of a TGraph2D.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual const char * GetTitle() const
Returns title of object.
virtual Int_t GetNbinsY() const
Double_t * fY
[fNpoints] Data set to be plotted
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
2-D histogram with a double per channel (see TH1 documentation)}
TAxis * GetYaxis() const
Get y axis of the graph.
const char * Data() const
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
static constexpr double g