225 fFunctions =
new TList;
240 for (
Int_t i = 0; i < fNpoints; ++i) {
258 for (
Int_t i = 0; i < fNpoints; ++i) {
276 for (
Int_t i = 0; i < fNpoints; ++i) {
305 Int_t xlast = xaxis->GetLast();
313 for (
Int_t i = xfirst; i <= xlast; i++) {
314 for (
Int_t j = yfirst; j <= ylast; j++) {
315 x = xaxis->GetBinCenter(i);
319 if (
z != 0. || ez != 0) {
320 SetPoint(k,
x,
y,
z);
386 std::ifstream infile(fname.
Data());
387 if (!infile.good()) {
389 Error(
"TGraph2D",
"Cannot open file: %s, TGraph2D is Zombie", filename);
397 if (strcmp(option,
"") == 0) {
399 while (std::getline(infile,
line,
'\n')) {
418 Error(
"TGraph2D",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
423 Error(
"TGraph2D",
"Incorrect input format! Only %d tag(s) in format whereas 3 \"%%lg\" tags are expected!", ntokens);
426 Int_t ntokensToBeSaved = 0 ;
428 for (
Int_t idx = 0; idx < ntokens; idx++) {
430 if (isTokenToBeSaved[idx] == 1) {
434 if (ntokens >= 3 && ntokensToBeSaved != 3) {
435 Error(
"TGraph2D",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 3 and only 3 are expected!", ntokensToBeSaved);
436 delete [] isTokenToBeSaved ;
442 char * token =
NULL ;
444 Int_t token_idx = 0 ;
446 Int_t value_idx = 0 ;
449 while (std::getline(infile,
line,
'\n')) {
451 if (
line[
line.size() - 1] == char(13)) {
454 token = strtok(const_cast<char*>(
line.c_str()), option) ;
455 while (token !=
NULL && value_idx < 3) {
456 if (isTokenToBeSaved[token_idx]) {
460 isLineToBeSkipped =
kTRUE ;
463 value[value_idx] = token_str.
Atof() ;
467 token = strtok(
NULL, option) ;
470 if (!isLineToBeSkipped && value_idx == 3) {
478 isLineToBeSkipped =
kFALSE ;
485 delete [] isTokenToBeSaved ;
534 if (
this == &g)
return *
this;
537 if (
fX)
delete []
fX;
538 if (
fY)
delete []
fY;
539 if (
fZ)
delete []
fZ;
579 Error(
"TGraph2D",
"Invalid number of points (%d)", n);
625 if (
fX)
delete []
fX;
627 if (
fY)
delete []
fY;
629 if (
fZ)
delete []
fZ;
673 Int_t distance = 9999;
708 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
760 linear = (
char*)strstr(fname,
"++");
763 f2 =
new TF2(fname, fname);
765 f2 = (
TF2*)
gROOT->GetFunction(fname);
767 Printf(
"Unknown function: %s", fname);
771 return Fit(f2, option,
"");
923 gROOT->MakeDefCanvas();
926 Error(
"FitPanel",
"Unable to create a default canvas");
934 Error(
"FitPanel",
"Unable to crate the FitPanel");
936 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
982 Error(
"GetContourList",
"Empty TGraph2D");
1074 Double_t hxmax, hymax, hxmin, hymin;
1093 hxmin = hxmin-hxmin*0.01;
1094 hxmax = hxmax+hxmax*0.01;
1102 hymin = hymin-hymin*0.01;
1103 hymax = hymax+hymax*0.01;
1111 fNpx , hxmin, hxmax,
1112 fNpy, hymin, hymax);
1155 if (hzmin == hzmax) {
1158 hzmin = hz - 0.01 * hz;
1159 hzmax = hz + 0.01 * hz;
1172 x = hxmin + (ix - 0.5) * dx;
1174 y = hymin + (iy - 0.5) * dy;
1199 for (
Int_t i = 1; i < fNpoints; i++) if (fX[i] >
v) v =
fX[i];
1221 for (
Int_t i = 1; i < fNpoints; i++) if (fY[i] >
v) v =
fY[i];
1243 for (
Int_t i = 1; i < fNpoints; i++) if (fZ[i] >
v) v =
fZ[i];
1266 Error(
"Interpolate",
"Empty TGraph2D");
1303 Error(
"Paint",
"Empty TGraph2D");
1351 Error(
"Project",
"Empty TGraph2D");
1368 char *
name =
new char[nch];
1371 char *title =
new char[nch];
1382 h1 =
new TH1D(name, title,
fNpx, hxmin, hxmax);
1386 h1 =
new TH1D(name, title,
fNpy, hymin, hymax);
1390 h2 =
new TH2D(name, title,
fNpx, hxmin, hxmax,
fNpy, hymin, hymax);
1394 h2 =
new TH2D(name, title,
fNpy, hymin, hymax,
fNpx, hxmin, hxmax);
1402 if (h == 0)
return 0;
1437 if (ipoint < 0)
return -1;
1446 if (i == ipoint)
continue;
1473 out <<
" " << std::endl;
1477 out <<
" TGraph2D *";
1480 out <<
"graph2d = new TGraph2D(" <<
fNpoints <<
");" << std::endl;
1481 out <<
" graph2d->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
1482 out <<
" graph2d->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
1485 out <<
" " <<
GetName() <<
"->SetDirectory(0);" << std::endl;
1493 out <<
" graph2d->SetPoint(" << i <<
"," <<
fX[i] <<
"," <<
fY[i] <<
"," <<
fZ[i] <<
");" << std::endl;
1499 while ((obj = next())) {
1501 out <<
" graph2d->GetListOfFunctions()->Add(" << obj->
GetName() <<
");" << std::endl;
1503 out <<
" ptstats->SetParent(graph2d->GetListOfFunctions());" << std::endl;
1507 out <<
" graph2d->Draw(" << quote << option << quote <<
");" << std::endl;
1567 if (m < 0 || m > 1) {
1568 Warning(
"SetMargin",
"The margin must be >= 0 && <= 1, fMargin set to 0.1");
1650 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 4");
1652 }
else if (npx > 500) {
1653 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 500");
1671 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 4");
1673 }
else if (npy > 500) {
1674 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 500");
1741 void TGraph2D::Streamer(
TBuffer &
b)
virtual const char * GetName() const
Returns name of object.
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 Draw(Option_t *option="")
Specific drawing options can be used to paint a TGraph2D:
virtual void SetLimits(Double_t xmin, Double_t xmax)
Double_t * fX
Real size of fX, fY and fZ.
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t TestBit(UInt_t f) const
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)
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.
Double_t GetZmin() const
Returns the Z minimum.
TVirtualHistPainter * fPainter
Pointer to directory holding this 2D graph.
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.
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 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
Find an object in this list using its name.
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.
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.
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...
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.
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.
A 2-Dim function with parameters.
tomato 1-D histogram with a double per channel (see TH1 documentation)}
virtual ~TGraph2D()
TGraph2D destructor.
if object destructor must call RecursiveRemove()
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
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
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)
Pointer to histogram painter.
virtual void Add(TObject *obj)
double f2(const double *x)
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)
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 ~.
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.
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.
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
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
tomato 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".