249 fDirectory =
nullptr;
250 fHistogram =
nullptr;
260 fFunctions =
new TList;
274 for (
Int_t i = 0; i < fNpoints; ++i) {
291 for (
Int_t i = 0; i < fNpoints; ++i) {
308 for (
Int_t i = 0; i < fNpoints; ++i) {
341 for (
Int_t i = xfirst; i <= xlast; i++) {
342 for (
Int_t j = yfirst; j <= ylast; j++) {
347 if (z != 0. || ez != 0) {
348 SetPoint(k,
x,
y, z);
371 for (
Int_t i = 0; i < fNpoints; ++i) {
387 for (
Int_t i = 0; i < fNpoints; i++) {
409 gSystem->ExpandPathName(fname);
412 if (!infile.good()) {
414 Error(
"TGraph2D",
"Cannot open file: %s, TGraph2D is Zombie", filename);
422 if (strcmp(option,
"") == 0) {
424 while (std::getline(infile,
line,
'\n')) {
425 if (3 != sscanf(
line.c_str(), format, &
x, &
y, &z)) {
428 SetPoint(np,
x,
y, z);
443 Error(
"TGraph2D",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
448 Error(
"TGraph2D",
"Incorrect input format! Only %d tag(s) in format whereas 3 \"%%lg\" tags are expected!", ntokens);
451 Int_t ntokensToBeSaved = 0 ;
453 for (
Int_t idx = 0; idx < ntokens; idx++) {
455 if (isTokenToBeSaved[idx] == 1) {
459 if (ntokens >= 3 && ntokensToBeSaved != 3) {
460 Error(
"TGraph2D",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 3 and only 3 are expected!", ntokensToBeSaved);
461 delete [] isTokenToBeSaved ;
467 char * token = nullptr ;
469 Int_t token_idx = 0 ;
471 Int_t value_idx = 0 ;
475 while (std::getline(infile,
line,
'\n')) {
477 if (
line[
line.size() - 1] ==
char(13)) {
480 token = R__STRTOK_R(
const_cast<char*
>(
line.c_str()), option, &rest);
481 while (token !=
nullptr && value_idx < 3) {
482 if (isTokenToBeSaved[token_idx]) {
486 isLineToBeSkipped =
kTRUE ;
489 value[value_idx] = token_str.
Atof() ;
493 token = R__STRTOK_R(
nullptr, option, &rest);
496 if (!isLineToBeSkipped && value_idx == 3) {
500 SetPoint(np,
x,
y, z) ;
504 isLineToBeSkipped =
kFALSE ;
511 delete [] isTokenToBeSaved ;
525 fX(nullptr), fY(nullptr), fZ(nullptr),
526 fHistogram(nullptr), fDirectory(nullptr), fPainter(nullptr)
528 fFunctions =
new TList();
538 fDirectory->Append(
this);
558 if (
this == &
g)
return *
this;
561 if (
fX)
delete []
fX;
562 if (
fY)
delete []
fY;
563 if (
fZ)
delete []
fZ;
602 Error(
"TGraph2D",
"Invalid number of points (%d)",
n);
686 if (
fX)
delete []
fX;
688 if (
fY)
delete []
fY;
690 if (
fZ)
delete []
fZ;
732 Int_t distance = 9999;
764 TString opt = option;
767 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
825 linear = (
char*)strstr(fname,
"++");
828 TF2 f2(fname, fname);
829 return Fit(&f2, option,
"");
831 TF2 * f2 = (TF2*)
gROOT->GetFunction(fname);
833 Printf(
"Unknown function: %s", fname);
836 return Fit(f2, option,
"");
856 ROOT::Fit::DataRange range(2);
857 ROOT::Math::MinimizerOptions minOption;
870 gROOT->MakeDefCanvas();
873 Error(
"FitPanel",
"Unable to create a default canvas");
878 TPluginHandler *handler =
gROOT->GetPluginManager()->FindHandler(
"TFitEditor");
881 Error(
"FitPanel",
"Unable to crate the FitPanel");
883 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
893 TH1 *
h = ((
TGraph2D*)
this)->GetHistogram(
"empty");
894 if (!
h)
return nullptr;
895 return h->GetXaxis();
904 TH1 *
h = ((
TGraph2D*)
this)->GetHistogram(
"empty");
905 if (!
h)
return nullptr;
906 return h->GetYaxis();
915 TH1 *
h = ((
TGraph2D*)
this)->GetHistogram(
"empty");
916 if (!
h)
return nullptr;
917 return h->GetZaxis();
929 Error(
"GetContourList",
"Empty TGraph2D");
937 return fPainter->GetContourList(contour);
980 TGraphDelaunay *dt =
new TGraphDelaunay(
this);
987 TGraphDelaunay2D *dt =
new TGraphDelaunay2D(
this);
1033 TString opt = option;
1039 if (!empty &&
fHistogram->GetEntries() == 0) {
1059 Double_t hxmax, hymax, hxmin, hymin;
1077 hxmin = hxmin-
TMath::Abs(hxmin)*(epsilon/2.);
1078 hxmax = hxmax+
TMath::Abs(hxmax)*(epsilon/2.);
1086 hymin = hymin-
TMath::Abs(hymin)*(epsilon/2.);
1087 hymax = hymax+
TMath::Abs(hymax)*(epsilon/2.);
1091 fHistogram->GetXaxis()->SetLimits(hxmin, hxmax);
1092 fHistogram->GetYaxis()->SetLimits(hymin, hymax);
1096 fNpx , hxmin, hxmax,
1097 fNpy, hymin, hymax);
1122 if (hzmin == hzmax) {
1143 x = hxmin + (ix - 0.5) * dx;
1145 y = hymin + (iy - 0.5) * dy;
1239 if (i < 0 || i >=
fNpoints)
return -1;
1240 if (!
fX || !
fY || !
fZ)
return -1;
1254 Error(
"Interpolate",
"Empty TGraph2D");
1260 TList *hl =
fHistogram->GetListOfFunctions();
1275 return ((TGraphDelaunay2D*)
fDelaunay)->ComputeZ(
x,
y);
1277 return ((TGraphDelaunay*)
fDelaunay)->ComputeZ(
x,
y);
1291 Error(
"Paint",
"Empty TGraph2D");
1295 TString opt = option;
1333 printf(
"x[%d]=%g, y[%d]=%g, z[%d]=%g\n", i,
fX[i], i,
fY[i], i,
fZ[i]);
1350 Error(
"Project",
"Empty TGraph2D");
1354 TString opt = option;
1367 char *
name =
new char[nch];
1370 char *title =
new char[nch];
1381 h1 =
new TH1D(
name, title,
fNpx, hxmin, hxmax);
1385 h1 =
new TH1D(
name, title,
fNpy, hymin, hymax);
1389 h2 =
new TH2D(
name, title,
fNpx, hxmin, hxmax,
fNpy, hymin, hymax);
1393 h2 =
new TH2D(
name, title,
fNpy, hymin, hymax,
fNpx, hxmin, hxmax);
1401 if (
h ==
nullptr)
return nullptr;
1426 h->SetEntries(entries);
1447 for (
int i = 0; i <
fNpoints; i++) {
1450 for (
int j = i + 1; j <
fNpoints; j++) {
1451 if (
x ==
fX[j] &&
y ==
fY[j]) {
1481 if (ipoint < 0)
return -1;
1510 if (strcmp(
GetName(),
"Graph2D"))
1511 out <<
" graph2d->SetName(\"" << TString(
GetName()).ReplaceSpecialCppChars() <<
"\");\n";
1518 out <<
" graph2d->SetTitle(\"" << title.ReplaceSpecialCppChars() <<
"\");\n";
1521 out <<
" graph2d->SetDirectory(nullptr);\n";
1542 TString opt = option; opt.
ToLower();
1604 TString opt = option;
1610 fNpx =
h->GetNbinsX();
1611 fNpy =
h->GetNbinsY();
1622 Warning(
"SetMargin",
"The margin must be >= 0 && <= 1, fMargin set to 0.1");
1657 if (
h)
h->SetMaximum(maximum);
1668 if (
h)
h->SetMinimum(minimum);
1706 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 4");
1708 }
else if (npx > 500) {
1709 Warning(
"SetNpx",
"Number of points must be >4 && < 500, fNpx set to 500");
1728 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 4");
1730 }
else if (npy > 500) {
1731 Warning(
"SetNpy",
"Number of points must be >4 && < 500, fNpy set to 500");
1808 if (
b.IsReading()) {
1810 Version_t R__v =
b.ReadVersion(&R__s, &R__c);
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual Color_t GetLineColor() const
Return the line color.
virtual Width_t GetLineWidth() const
Return the line width.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
virtual Style_t GetLineStyle() const
Return the line style.
virtual Style_t GetMarkerStyle() const
Return the marker style.
virtual Color_t GetMarkerColor() const
Return the marker color.
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)
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.
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.
Describe directory structure in memory.
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Int_t fMaxIter
Maximum number of iterations to find Delaunay triangles.
TF2 * GetFunction(const char *name) const
TObject * FindObject(const char *name) const override
Must be redefined in derived classes.
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
virtual Double_t GetErrorZ(Int_t bin) const
void SetNameTitle(const char *name, const char *title) override
Set all the TNamed parameters (name and title).
virtual Double_t GetYminE() const
Double_t Interpolate(Double_t x, Double_t y)
Int_t fNpoints
Number of points in the data set.
virtual Double_t GetZminE() const
Double_t GetMinimum() const
virtual Double_t GetErrorX(Int_t bin) const
virtual void Add(TF2 *f, Double_t c1=1)
void SetMarginBinsContent(Double_t z=0.)
Int_t fNpx
Number of bins along X in fHistogram.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
virtual Double_t GetYmaxE() const
void Browse(TBrowser *) override
Browse object. May be overridden for another default action.
virtual void Scale(Double_t c1=1., Option_t *option="z")
virtual Double_t GetZmaxE() const
void RecursiveRemove(TObject *obj) override
Recursively remove this object from a list.
virtual Double_t GetErrorY(Int_t bin) const
void Streamer(TBuffer &) override
Stream an object of class TObject.
Double_t fMargin
Extra space (in %) around interpolated area for fHistogram.
Double_t fMinimum
Minimum value for plotting along z.
void Print(Option_t *chopt="") const override
This method must be overridden when a class wants to print itself.
TH2D * GetHistogram(Option_t *option="")
TVirtualHistPainter * fPainter
!Pointer to histogram painter
Int_t RemovePoint(Int_t ipoint)
Double_t fMaximum
Maximum value for plotting along z.
void SetMargin(Double_t m=0.1)
void SetName(const char *name) override
Set the name of the TNamed.
void SetNpy(Int_t npx=40)
Double_t fZout
fHistogram bin height for points lying outside the interpolated area
void SetTitle(const char *title="") override
Set the title of the TNamed.
TH2D * fHistogram
!2D histogram of z values linearly interpolated on the triangles
virtual Double_t GetXminE() const
TList * GetContourList(Double_t contour)
virtual void DirectoryAutoAdd(TDirectory *)
TObject * fDelaunay
! Pointer to Delaunay interpolator object
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y, Double_t &z) const
TH1 * Project(Option_t *option="x") const
virtual void Apply(TF2 *f)
virtual Double_t GetXmaxE() const
void SetMinimum(Double_t minimum=-1111)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="")
TGraph2D & operator=(const TGraph2D &)
Double_t * fY
[fNpoints] Data set to be plotted
void SetMaximum(Double_t maximum=-1111)
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
virtual void Set(Int_t n)
TDirectory * fDirectory
!Pointer to directory holding this 2D graph
void Clear(Option_t *option="") override
virtual void SetDirectory(TDirectory *dir)
void CreateInterpolator(Bool_t oldInterp)
Int_t fNpy
Number of bins along Y in fHistogram.
virtual void SetHistogram(TH2 *h, Option_t *option="")
TList * fFunctions
Pointer to list of functions (fits and user).
void Paint(Option_t *option="") override
This method must be overridden if a class wants to paint itself.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
void Draw(Option_t *option="P0") override
Default Draw method for all objects.
Int_t fSize
!Real size of fX, fY and fZ
void SetNpx(Int_t npx=40)
void SetMarginBinsContent(Double_t z=0.)
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...
TH1 is the base class of all histogram classes in ROOT.
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.
virtual Int_t GetNbinsX() const
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
static Bool_t AddDirectoryStatus()
Check whether TH1-derived classes should register themselves to the current gDirectory.
static void SavePrimitiveFunctions(std::ostream &out, const char *varname, TList *lst)
Save list of functions Also can be used by TGraph classes.
2-D histogram with a double per channel (see TH1 documentation)
Service class for 2-D histogram classes.
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Int_t Fill(Double_t) override
Invalid Fill method.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
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.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
@ 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)
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
bool ObjectAutoRegistrationEnabled()
Test whether objects in this thread auto-register themselves, e.g.
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)
Returns the largest of a and b.
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Comparing floating points.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.