238 fFunctions =
new TList;
253 for (
Int_t i = 0; i < fNpoints; ++i) {
271 for (
Int_t i = 0; i < fNpoints; ++i) {
289 for (
Int_t i = 0; i < fNpoints; ++i) {
318 Int_t xlast = xaxis->GetLast();
326 for (
Int_t i = xfirst; i <= xlast; i++) {
327 for (
Int_t j = yfirst; j <= ylast; j++) {
328 x = xaxis->GetBinCenter(i);
332 if (z != 0. || ez != 0) {
333 SetPoint(k, x, y, z);
374 for (
Int_t i = 0; i < fNpoints; i++) {
402 Error(
"TGraph2D",
"Cannot open file: %s, TGraph2D is Zombie", filename);
410 if (strcmp(option,
"") == 0) {
412 while (std::getline(
infile, line,
'\n')) {
413 if (3 != sscanf(line.c_str(),
format, &
x, &
y, &
z)) {
416 SetPoint(np, x, y, z);
431 Error(
"TGraph2D",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
436 Error(
"TGraph2D",
"Incorrect input format! Only %d tag(s) in format whereas 3 \"%%lg\" tags are expected!", ntokens);
439 Int_t ntokensToBeSaved = 0 ;
441 for (
Int_t idx = 0; idx < ntokens; idx++) {
443 if (isTokenToBeSaved[idx] == 1) {
447 if (ntokens >= 3 && ntokensToBeSaved != 3) {
448 Error(
"TGraph2D",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 3 and only 3 are expected!", ntokensToBeSaved);
449 delete [] isTokenToBeSaved ;
455 char * token =
NULL ;
457 Int_t token_idx = 0 ;
459 Int_t value_idx = 0 ;
462 while (std::getline(
infile, line,
'\n')) {
464 if (line[line.size() - 1] == char(13)) {
465 line.erase(line.end() - 1, line.end()) ;
467 token = strtok(const_cast<char*>(line.c_str()), option) ;
468 while (token !=
NULL && value_idx < 3) {
469 if (isTokenToBeSaved[token_idx]) {
473 isLineToBeSkipped =
kTRUE ;
476 value[value_idx] = token_str.
Atof() ;
480 token = strtok(
NULL, option) ;
483 if (!isLineToBeSkipped && value_idx == 3) {
487 SetPoint(np, x, y, z) ;
491 isLineToBeSkipped =
kFALSE ;
498 delete [] isTokenToBeSaved ;
513 fHistogram(0), fDirectory(0), fPainter(0)
515 fFunctions =
new TList();
527 fDirectory->Append(
this);
549 if (
this == &g)
return *
this;
552 if (
fX)
delete []
fX;
553 if (
fY)
delete []
fY;
554 if (
fZ)
delete []
fZ;
594 Error(
"TGraph2D",
"Invalid number of points (%d)", n);
640 if (
fX)
delete []
fX;
642 if (
fY)
delete []
fY;
644 if (
fZ)
delete []
fZ;
723 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
775 linear = (
char*)strstr(fname,
"++");
778 f2 =
new TF2(fname, fname);
780 f2 = (
TF2*)
gROOT->GetFunction(fname);
782 Printf(
"Unknown function: %s", fname);
786 return Fit(f2, option,
"");
938 gROOT->MakeDefCanvas();
941 Error(
"FitPanel",
"Unable to create a default canvas");
949 Error(
"FitPanel",
"Unable to crate the FitPanel");
951 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
997 Error(
"GetContourList",
"Empty TGraph2D");
1089 Double_t hxmax, hymax, hxmin, hymin;
1108 hxmin = hxmin-hxmin*0.01;
1109 hxmax = hxmax+hxmax*0.01;
1117 hymin = hymin-hymin*0.01;
1118 hymax = hymax+hymax*0.01;
1126 fNpx , hxmin, hxmax,
1127 fNpy, hymin, hymax);
1170 if (hzmin == hzmax) {
1173 hzmin = hz - 0.01 * hz;
1174 hzmax = hz + 0.01 * hz;
1187 x = hxmin + (ix - 0.5) * dx;
1189 y = hymin + (iy - 0.5) * dy;
1214 for (
Int_t i = 1; i < fNpoints; i++) if (fX[i] >
v) v =
fX[i];
1236 for (
Int_t i = 1; i < fNpoints; i++) if (fY[i] >
v) v =
fY[i];
1258 for (
Int_t i = 1; i < fNpoints; i++) if (fZ[i] >
v) v =
fZ[i];
1281 Error(
"Interpolate",
"Empty TGraph2D");
1318 Error(
"Paint",
"Empty TGraph2D");
1366 Error(
"Project",
"Empty TGraph2D");
1383 char *
name =
new char[nch];
1384 snprintf(name, nch,
"%s_%s",
GetName(), option);
1386 char *
title =
new char[nch];
1387 snprintf(title, nch,
"%s_%s",
GetTitle(), option);
1397 h1 =
new TH1D(name, title,
fNpx, hxmin, hxmax);
1401 h1 =
new TH1D(name, title,
fNpy, hymin, hymax);
1405 h2 =
new TH2D(name, title,
fNpx, hxmin, hxmax,
fNpy, hymin, hymax);
1409 h2 =
new TH2D(name, title,
fNpy, hymin, hymax,
fNpx, hxmin, hxmax);
1417 if (h == 0)
return 0;
1452 if (ipoint < 0)
return -1;
1461 if (i == ipoint)
continue;
1488 out <<
" " << std::endl;
1492 out <<
" TGraph2D *";
1495 out <<
"graph2d = new TGraph2D(" <<
fNpoints <<
");" << std::endl;
1496 out <<
" graph2d->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
1497 out <<
" graph2d->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
1500 out <<
" " <<
GetName() <<
"->SetDirectory(0);" << std::endl;
1508 out <<
" graph2d->SetPoint(" << i <<
"," <<
fX[i] <<
"," <<
fY[i] <<
"," <<
fZ[i] <<
");" << std::endl;
1514 while ((obj =
next())) {
1516 out <<
" graph2d->GetListOfFunctions()->Add(" << obj->
GetName() <<
");" << std::endl;
1518 out <<
" ptstats->SetParent(graph2d->GetListOfFunctions());" << std::endl;
1522 out <<
" graph2d->Draw(" << quote << option << quote <<
");" << std::endl;
1582 if (m < 0 || m > 1) {
1583 Warning(
"SetMargin",
"The margin must be >= 0 && <= 1, fMargin set to 0.1");
1665 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 4");
1667 }
else if (npx > 500) {
1668 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 500");
1686 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 4");
1688 }
else if (npy > 500) {
1689 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 500");
1756 void TGraph2D::Streamer(
TBuffer &b)
Int_t GetFirst() const
Return first bin on the axis i.e.
virtual const char * GetTitle() const
Returns title of object.
virtual Style_t GetLineStyle() const
virtual Style_t GetFillStyle() const
virtual void SetLineWidth(Width_t lwidth)
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.
TList * GetListOfFunctions() const
TAxis * GetXaxis() const
Get x axis of the graph.
virtual TObject * FindObject(const char *name) const
search object named name in the list of functions
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.
virtual void SetMaximum(Double_t maximum=-1111)
virtual void Draw(Option_t *option="")
Specific drawing options can be used to paint a TGraph2D:
virtual void SetLimits(Double_t xmin, Double_t xmax)
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Double_t * fX
Real size of fX, fY and fZ.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
TVirtualHistPainter * GetPainter(Option_t *option="")
return pointer to painter if painter does not exist, it is created
TString & ReplaceAll(const TString &s1, const TString &s2)
Double_t GetXmax() const
Returns the X maximum.
Double_t distance(const TPoint2 &p1, const TPoint2 &p2)
Double_t GetZmin() const
Returns the Z minimum.
void SetMargin(Double_t m=0.1)
Sets the extra space (in %) around interpolated area for the 2D histogram.
Double_t Atof() const
Return floating-point value contained in string.
TGraph2D & operator=(const TGraph2D &)
Graph2D operator "=".
Double_t GetYmax() const
Returns the Y maximum.
Buffer base class used for serializing objects.
static const char * filename()
virtual void Set(Int_t n)
Set number of points in the 2D graph.
virtual void SetMinimum(Double_t minimum=-1111)
Int_t LoadPlugin()
Load the plugin library for this handler.
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
TVirtualHistPainter * fPainter
Pointer to directory holding this 2D graph.
void ToLower()
Change string to lower-case.
virtual void SetFillStyle(Style_t fstyle)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
TAxis * GetZaxis() const
Get z axis of the graph.
virtual Int_t GetNbinsX() const
static std::string format(double x, double y, int digits, int width)
TObject * fDelaunay
2D histogram of z values linearly interpolated on the triangles
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 Double_t GetEntries() const
return the current number of entries
Long_t ExecPlugin(int nargs, const T &...params)
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
virtual Double_t GetYminE() const
virtual void SetHistogram(TH2 *h)
Sets the histogram to be filled.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Double_t GetXmin() const
Returns the X minimum.
virtual Double_t GetErrorY(Int_t bin) const
This function is called by Graph2DFitChisquare.
const char * Data() const
Fill Area Attributes class.
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Executes action corresponding to one event.
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 graph title.
TDirectory * fDirectory
Pointer to Delaunay interpolator object.
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.
void SetMarginBinsContent(Double_t z=0.)
Sets the histogram bin height for points lying outside the convex hull ie: the bins in the margin...
virtual void Clear(Option_t *option="")
Free all memory allocated by this object.
Double_t GetZmax() const
Returns the Z maximum.
virtual void SetMarkerColor(Color_t mcolor=1)
TString & Append(const char *cs)
Int_t Atoi() const
Return integer value of string.
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 void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void Error(const char *location, const char *msgfmt,...)
TAxis * GetYaxis() const
Get y axis of the graph.
void SetMaximum(Double_t maximum=-1111)
Set maximum.
virtual Double_t GetXminE() const
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
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)
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 TList * GetContourList(Double_t contour) const =0
virtual Size_t GetMarkerSize() const
virtual Double_t GetErrorX(Int_t bin) const
This function is called by Graph2DFitChisquare.
void SetMinimum(Double_t minimum=-1111)
Set minimum.
virtual Double_t GetYmaxE() const
Service class for 2-Dim histogram classes.
Class to manage histogram axis.
R__EXTERN TSystem * gSystem
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetFillColor(Color_t fcolor)
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 ...
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.
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 Color_t GetFillColor() const
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.
Bool_t TestBit(UInt_t f) const
Double_t GetYmin() const
Returns the Y minimum.
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
virtual const char * GetName() const
Returns name of object.
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual Double_t GetXmaxE() const
A 2-Dim function with parameters.
virtual Color_t GetLineColor() const
1-D histogram with a double per channel (see TH1 documentation)}
virtual ~TGraph2D()
TGraph2D destructor.
virtual void SetMarkerSize(Size_t msize=1)
Int_t RemovePoint(Int_t ipoint)
Deletes point number ipoint.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
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.
virtual const char * GetName() const
Returns name of object.
Describe directory structure in memory.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
TGraphDelaunay2D generates a Delaunay triangulation of a TGraph2D.
virtual void SetLineStyle(Style_t lstyle)
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Int_t GetLast() const
Return last bin on the axis i.e.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Mother of all ROOT objects.
virtual Double_t GetErrorZ(Int_t bin) const
This function is called by Graph2DFitChisquare.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
virtual Int_t GetNbinsY() const
virtual Color_t GetMarkerColor() const
virtual void FitPanel()
Display a GUI panel with all graph fit options.
void Build(Int_t n)
Pointer to histogram painter.
virtual void Add(TObject *obj)
Short_t Max(Short_t a, Short_t b)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void SetNpy(Int_t npx=40)
Sets the number of bins along Y used to draw the function.
virtual void Browse(TBrowser *)
Browse.
virtual void SetEntries(Double_t n)
virtual void SetTitle(const char *title)
Change (i.e.
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 ~.
void SetNpx(Int_t npx=40)
Sets the number of bins along X used to draw the function.
Graphics object made of three arrays X, Y and Z with the same number of points each.
virtual void SetNameTitle(const char *name, const char *title)
Change the name and title of this 2D graph.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Style_t GetMarkerStyle() const
Int_t Fill(Double_t)
Invalid Fill method.
virtual Width_t GetLineWidth() const
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
2-D histogram with a double per channel (see TH1 documentation)}
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.