138 for (
Int_t i = 0; i <
n; i++) {
156 for (
Int_t i = 0; i <
n; i++) {
175 for (
Int_t i = 0; i <
n; i++) {
176 fX[i] = start+i*step;
236 TAttLine::operator=(
gr);
237 TAttFill::operator=(
gr);
238 TAttMarker::operator=(
gr);
272 if (
fX)
delete []
fX;
273 if (
fY)
delete []
fY;
305 fX[i] = vx(i + ivxlow);
306 fY[i] = vy(i + ivylow);
324 fX[i] = vx(i + ivxlow);
325 fY[i] = vy(i + ivylow);
336 Error(
"TGraph",
"Pointer to histogram is null");
340 if (
h->GetDimension() != 1) {
341 Error(
"TGraph",
"Histogram must be 1-D; h %s is %d-D",
h->GetName(),
h->GetDimension());
352 fY[i] =
h->GetBinContent(i + 1);
354 h->TAttLine::Copy(*
this);
355 h->TAttFill::Copy(*
this);
356 h->TAttMarker::Copy(*
this);
358 std::string gname =
"Graph_from_" + std::string(
h->GetName());
379 Error(
"TGraph",
"Pointer to function is null");
384 if (coption ==
'i' || coption ==
'I')
fNpoints++;
394 if (coption ==
'i' || coption ==
'I') {
396 if (i == 0)
fY[i] = 0;
397 else fY[i] = integ + ((
TF1*)
f)->Integral(
fX[i] - dx,
fX[i]);
399 }
else if (coption ==
'd' || coption ==
'D') {
400 fX[i] =
xmin + (i + 0.5) * dx;
401 fY[i] = ((
TF1*)
f)->Derivative(
fX[i]);
403 fX[i] =
xmin + (i + 0.5) * dx;
407 if (integ != 0 && coption ==
'I') {
408 for (i = 1; i <
fNpoints; i++)
fY[i] /= integ;
411 f->TAttLine::Copy(*
this);
412 f->TAttFill::Copy(*
this);
413 f->TAttMarker::Copy(*
this);
445 std::ifstream infile(fname.
Data());
446 if (!infile.good()) {
448 Error(
"TGraph",
"Cannot open file: %s, TGraph is Zombie",
filename);
459 if (strcmp(
option,
"") == 0) {
461 while (std::getline(infile,
line,
'\n')) {
482 Error(
"TGraph",
"Incorrect input format! Allowed formats are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
487 Error(
"TGraph",
"Incorrect input format! Only %d tag(s) in format whereas 2 \"%%lg\" tags are expected!", ntokens);
490 Int_t ntokensToBeSaved = 0 ;
492 for (
Int_t idx = 0; idx < ntokens; idx++) {
494 if (isTokenToBeSaved[idx] == 1) {
498 if (ntokens >= 2 && ntokensToBeSaved != 2) {
499 Error(
"TGraph",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2 and only 2 are expected!", ntokensToBeSaved);
500 delete [] isTokenToBeSaved ;
506 char * token = nullptr ;
508 Int_t token_idx = 0 ;
510 Int_t value_idx = 0 ;
514 while (std::getline(infile,
line,
'\n')) {
516 if (
line[
line.size() - 1] ==
char(13)) {
520 token = R__STRTOK_R(
const_cast<char *
>(
line.c_str()),
option, &rest);
521 while (token !=
nullptr && value_idx < 2) {
522 if (isTokenToBeSaved[token_idx]) {
526 isLineToBeSkipped =
kTRUE ;
533 token = R__STRTOK_R(
nullptr,
option, &rest);
536 if (!isLineToBeSkipped && value_idx == 2) {
543 isLineToBeSkipped =
kFALSE ;
551 delete [] isTokenToBeSaved ;
600 for (
Int_t i = 0; i < Narrays; ++i)
601 newarrays[i] =
nullptr;
603 for (
Int_t i = 0; i < Narrays; ++i)
604 newarrays[i] =
new Double_t[arraySize];
633 opt =
b ?
b->GetDrawOption() :
"alp";
634 opt = (opt ==
"") ?
"alp" : opt.
Data();
658 Error(
"Chisquare",
"Function pointer is Null - return -1");
674 Double_t xl = 0, yl = 0, xr = 0, yr = 0;
685 return gr->
fX[left] >
gr->
fX[right];
693 return gr->
fY[left] >
gr->
fY[right];
760 if (ibegin < 0 || iend <= ibegin || obegin < 0) {
763 if (!arrays && ibegin == obegin) {
768 memmove(&arrays[0][obegin], &
fX[ibegin],
n);
769 memmove(&arrays[1][obegin], &
fY[ibegin],
n);
771 memmove(&
fX[obegin], &
fX[ibegin],
n);
772 memmove(&
fY[obegin], &
fY[ibegin],
n);
830 if (!
gPad->GetListOfPrimitives()->FindObject(
"TFrame")) opt =
"alp";
837 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
843 gPad->IncrementPaletteColor(1, opt);
932 return spline->
Eval(
x);
945 std::vector<Double_t> xsort(
fNpoints);
946 std::vector<Double_t> ysort(
fNpoints);
947 std::vector<Int_t> indxsort(
fNpoints);
950 xsort[i] =
fX[ indxsort[i] ];
951 ysort[i] =
fY[ indxsort[i] ];
973 if (
fX[low] ==
x)
return fY[low];
988 if (low == -1 ||
fX[i] >
fX[low]) {
991 }
else if (low2 == -1) low2 = i;
992 }
else if (
fX[i] >
x) {
993 if (up == -1 ||
fX[i] <
fX[up]) {
996 }
else if (up2 == -1) up2 = i;
1012 assert(low != -1 && up != -1);
1014 if (
fX[low] ==
fX[up])
return fY[low];
1054 Double_t **ps =
Allocate(step * (newsize / step + (newsize % step ? 1 : 0)));
1078 memset(
fX + begin, 0, (end - begin)*
sizeof(
Double_t));
1079 memset(
fY + begin, 0, (end - begin)*
sizeof(
Double_t));
1230 const char *linear = fname ? strstr(fname,
"++") :
nullptr;
1237 Printf(
"Unknown function: %s", fname);
1251 gROOT->MakeDefCanvas();
1254 Error(
"FitPanel",
"Unable to create a default canvas");
1260 if (handler && handler->
LoadPlugin() != -1) {
1262 Error(
"FitPanel",
"Unable to crate the FitPanel");
1264 Error(
"FitPanel",
"Unable to find the FitPanel plug-in");
1273 if (rms1 == 0)
return 0;
1275 if (rms2 == 0)
return 0;
1290 sumxy +=
fX[i] *
fY[i];
1292 return sumxy /
sum - sumx /
sum * sumy /
sum;
1300 if (axis < 1 || axis > 2)
return 0;
1304 if (axis == 1) sumx +=
fX[i];
1315 if (axis < 1 || axis > 2)
return 0;
1321 sumx2 +=
fX[i] *
fX[i];
1324 sumx2 +=
fY[i] *
fY[i];
1404 Double_t rwxmin, rwxmax, rwymin, rwymax, maximum, minimum, dx, dy;
1415 TH1F *historg =
nullptr;
1420 }
else if (
gPad &&
gPad->GetLogy()) {
1431 if (rwxmin == rwxmax) rwxmax += 1.;
1432 if (rwymin == rwymax) rwymax += 1.;
1433 dx = 0.1 * (rwxmax - rwxmin);
1434 dy = 0.1 * (rwymax - rwymin);
1435 uxmin = rwxmin - dx;
1436 uxmax = rwxmax + dx;
1437 minimum = rwymin - dy;
1438 maximum = rwymax + dy;
1445 if (uxmin < 0 && rwxmin >= 0) {
1446 if (
gPad &&
gPad->GetLogx()) uxmin = 0.9 * rwxmin;
1449 if (uxmax > 0 && rwxmax <= 0) {
1450 if (
gPad &&
gPad->GetLogx()) uxmax = 1.1 * rwxmax;
1454 if (minimum < 0 && rwymin >= 0) minimum = 0.9 * rwymin;
1456 if (minimum <= 0 && gPad && gPad->GetLogy()) minimum = 0.001 * maximum;
1457 if (uxmin <= 0 && gPad && gPad->GetLogx()) {
1458 if (uxmax > 1000) uxmin = 1;
1459 else uxmin = 0.001 * uxmax;
1466 const char *gname =
GetName();
1467 if (!gname[0]) gname =
"Graph";
1543 return h ?
h->GetXaxis() :
nullptr;
1552 return h ?
h->GetYaxis() :
nullptr;
1562 Error(
"GetObjectInfo",
"Cannot be used without gPad");
1573 if (dpx * dpx + dpy * dpy < 25) {
1583 return Form(
"x=%g, y=%g",
x,
y);
1588 return Form(
"x=%g, y=%g, point=%d, xval=%g, yval=%g",
x,
y, ipoint, xval, yval);
1596 Double_t allcha, sumx, sumx2,
x, val, rms, mean;
1606 allcha = sumx = sumx2 = 0;
1607 for (bin = 0; bin <
fNpoints; bin++) {
1609 if (x < xmin || x >
xmax)
continue;
1613 sumx2 += val *
x *
x;
1616 if (
np == 0 || allcha == 0)
return;
1617 mean = sumx / allcha;
1620 if (rms == 0) rms = 1;
1676 Error(
"InsertPoint",
"Cannot be used without gPad, requires last mouse position");
1687 for (i = 0; i <
fNpoints - 1; i++) {
1696 for (i = 0; i <
fNpoints - 1; i++) {
1708 if (dpx * dpx + dpy * dpy < 25) ipoint = 0;
1726 Error(
"TGraph",
"Inserted point index should be >= 0");
1731 Error(
"TGraph",
"Inserted point index should be <= %d",
fNpoints);
1787 if (
first >= last)
return 0;
1834 const Int_t idim = 20;
1850 if (
m > idim ||
m >
n)
return;
1852 for (
l = 2;
l <=
m; ++
l) {
1854 b[
m +
l*20 - 21] = zero;
1860 if (xk < xmin || xk >
xmax)
continue;
1865 for (
l = 2;
l <=
m; ++
l) {
1868 da[
l-1] += power * yk;
1870 for (
l = 2;
l <=
m; ++
l) {
1872 b[
m +
l*20 - 21] += power;
1876 for (i = 3; i <=
m; ++i) {
1877 for (k = i; k <=
m; ++k) {
1878 b[k - 1 + (i-1)*20 - 21] =
b[k + (i-2)*20 - 21];
1885 for (i = 1; i <
m; ++i)
a[i] = 0;
1888 for (i = 0; i <
m; ++i)
a[i] = da[i];
1918 xbar = ybar = x2bar = xybar = 0;
1922 if (xk < xmin || xk >
xmax)
continue;
1926 if (yk <= 0) yk = 1
e-9;
1935 det = fn * x2bar - xbar * xbar;
1938 if (fn > 0) a0 = ybar / fn;
1944 a0 = (x2bar * ybar - xbar * xybar) / det;
1945 a1 = (fn * xybar - xbar * ybar) / det;
1963 if (painter) painter->
PaintGraph(
this, npoints,
x,
y, chopt);
1990 printf(
"x[%d]=%g, y[%d]=%g\n", i,
fX[i], i,
fY[i]);
2014 Error(
"RemovePoint",
"Cannot be used without gPad, requires last mouse position");
2027 if (dpx * dpx + dpy * dpy < 100) {
2041 if ((ipoint < 0) || (ipoint >=
fNpoints))
2075 if (fname.
EndsWith(
".csv")) {
del =
','; ext =
"csv";}
2076 else if (fname.
EndsWith(
".tsv")) {
del =
'\t'; ext =
"tsv";}
2077 else if (fname.
EndsWith(
".txt")) {
del =
' '; ext =
"txt";}
2101 out <<
fX[i] <<
del << (exl?exl[i]:0) <<
del << (exh?exh[i]:0) <<
del <<
fY[i] <<
del << (eyl?eyl[i]:0) <<
del << (eyh?eyh[i]:0) << std::endl;
2106 out <<
fX[i] <<
del <<
fY[i] << std::endl;
2121 out <<
" " << std::endl;
2122 static Int_t frameNumber = 0;
2138 out <<
"graph = new TGraph(" <<
fNpoints <<
"," << fXName <<
"," << fYName <<
");" << std::endl;
2140 out <<
"graph = new TGraph();" << std::endl;
2156 out <<
" Double_t " << arrname <<
"[" <<
fNpoints <<
"] = { ";
2158 out << arr[i] <<
",";
2159 if (i && (i % 16 == 0))
2160 out << std::endl <<
" ";
2164 out << arr[
fNpoints-1] <<
" };" << std::endl;
2177 out <<
" "<<varname<<
"->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
2178 out <<
" "<<varname<<
"->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
2188 out <<
" "<<varname<<
"->SetHistogram(" <<
fHistogram->
GetName() <<
");" << std::endl;
2189 out <<
" " << std::endl;
2195 while (
auto obj = next()) {
2196 obj->SavePrimitive(out,
TString::Format(
"nodraw #%d\n", ++frameNumber).Data());
2197 if (obj->InheritsFrom(
"TPaveStats")) {
2198 out <<
" "<<varname<<
"->GetListOfFunctions()->Add(ptstats);" << std::endl;
2199 out <<
" ptstats->SetParent("<<varname<<
"->GetListOfFunctions());" << std::endl;
2202 if (obj->InheritsFrom(
"TF1")) {
2203 out <<
" " << objname <<
"->SetParent("<<varname<<
");\n";
2205 out <<
" "<<varname<<
"->GetListOfFunctions()->Add(" << objname <<
");" << std::endl;
2210 const char *
l = strstr(soption,
"multigraph");
2212 out <<
" multigraph->Add("<<varname<<
"," << quote <<
l + 10 << quote <<
");" << std::endl;
2215 l = strstr(soption,
"th2poly");
2217 out <<
" " <<
l + 7 <<
"->AddBin("<<varname<<
");" << std::endl;
2220 out <<
" "<<varname<<
"->Draw(" << quote << soption << quote <<
");" << std::endl;
2289 if (!painter)
return;
2463 if (greaterfunc ==
TGraph::CompareX && ascending && low == 0 && high == -1111)
2472 std::vector<Int_t> sorting_indices(
fNpoints);
2473 std::iota(sorting_indices.begin(), sorting_indices.end(), 0);
2479 std::stable_sort(sorting_indices.begin() + low, sorting_indices.begin() + high + 1,
2480 [&](
const auto &left,
const auto &right) { return greaterfunc(this, left, right) != ascending; });
2482 Int_t numSortedPoints = high - low + 1;
2491 if (
b.IsReading()) {
2493 Version_t R__v =
b.ReadVersion(&R__s, &R__c);
2499 while ((obj = next())) {
2567 std::vector<Double_t> fXSorted(numSortedPoints);
2568 std::vector<Double_t> fYSorted(numSortedPoints);
2571 std::generate(fXSorted.begin(), fXSorted.end(),
2572 [begin = low, &sorting_indices,
this]()
mutable { return fX[sorting_indices[begin++]]; });
2573 std::generate(fYSorted.begin(), fYSorted.end(),
2574 [begin = low, &sorting_indices,
this]()
mutable { return fY[sorting_indices[begin++]]; });
2577 std::copy(fXSorted.begin(), fXSorted.end(),
fX + low);
2578 std::copy(fYSorted.begin(), fYSorted.end(),
fY + low);
2587 arr[pos1] = arr[pos2];
2622 while ((obj = next())) {
2638 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
2652 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
2653 g->GetPoint(i,
x,
y);
2691 ,
Int_t maxiterations)
2694 static Int_t j1, it, j3, j2;
2727 if (j1 != 2)
goto L100;
2728 if (ya * Y < 0)
goto L120;
2737 if (it >= maxiterations) k = j1;
2745 if (j1 > 3)
goto L170;
2761 if (it >= maxiterations) k = j1;
2794 if ((
x2 -
a)*(
x2 -
b) < 0) {
2796 if (it >= maxiterations) k = j1;
2807 if ((
x2 -
a)*(
x2 -
b) >= 0) {
2812 if (it >= maxiterations) k = j1;
2820 if (j1 != 4)
return;
2831 if (ytest <= 0)
goto L130;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t SetLineWidth
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t del
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t SetLineColor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t SetFillColor
Option_t Option_t SetMarkerStyle
Option_t Option_t TPoint TPoint const char y1
void H1LeastSquareSeqnd(Int_t n, Double_t *a, Int_t idim, Int_t &ifail, Int_t k, Double_t *b)
Extracted from CERN Program library routine DSEQN.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
class describing the range in the coordinates it supports multiple range in a coordinate.
Fill Area Attributes class.
virtual void Streamer(TBuffer &)
virtual Color_t GetFillColor() const
Return the fill area color.
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
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)
Save fill attributes as C++ statement(s) on output stream out.
virtual void Streamer(TBuffer &)
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 Style_t GetLineStyle() const
Return the line style.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Int_t DistancetoLine(Int_t px, Int_t py, Double_t xp1, Double_t yp1, Double_t xp2, Double_t yp2)
Compute distance from point px,py to a line.
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.
void Copy(TAttMarker &attmarker) const
Copy this marker attributes to a new TAttMarker.
virtual void Streamer(TBuffer &)
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Class to manage histogram axis.
virtual Bool_t GetTimeDisplay() const
Bool_t GetRotateTitle() const
const char * GetTitle() const override
Returns title of object.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Bool_t GetCenterTitle() const
Bool_t GetNoExponent() const
virtual void SetTimeDisplay(Int_t value)
void RotateTitle(Bool_t rotate=kTRUE)
Rotate title by 180 degrees.
void CenterTitle(Bool_t center=kTRUE)
Center axis title.
void SetNoExponent(Bool_t noExponent=kTRUE)
Set the NoExponent flag By default, an exponent of the form 10^N is used when the label value are eit...
virtual void SetLimits(Double_t xmin, Double_t xmax)
virtual const char * GetTimeFormat() const
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Using a TBrowser one can browse all ROOT objects.
Buffer base class used for serializing objects.
Collection abstract base class.
virtual Bool_t IsEmpty() const
TObject * Clone(const char *newname="") const override
Make a clone of an collection using the Streamer facility.
TDirectory::TContext keeps track and restore the current directory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual Int_t GetNpar() const
virtual void SetParent(TObject *p=nullptr)
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set lower and upper limits for parameter ipar.
virtual void SetParameter(Int_t param, Double_t value)
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
A TGraph is an object made of two arrays X and Y with npoints each.
virtual Double_t GetPointX(Int_t i) const
Get x value for point i.
virtual Double_t Integral(Int_t first=0, Int_t last=-1) const
Integrate the TGraph data within a given (index) range.
Int_t fNpoints
Number of points <= fMaxSize.
virtual Int_t IsInside(Double_t x, Double_t y) const
Return 1 if the point (x,y) is inside the polygon defined by the graph vertices 0 otherwise.
virtual void LeastSquareFit(Int_t m, Double_t *a, Double_t xmin=0, Double_t xmax=0)
Least squares polynomial fitting without weights.
virtual Double_t Chisquare(TF1 *f1, Option_t *option="") const
Return the chisquare of this graph with respect to f1.
void UseCurrentStyle() override
Set current style settings in this graph This function is called when either TCanvas::UseCurrentStyle...
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
virtual Int_t Merge(TCollection *list)
Adds all graphs from the collection to this graph.
Int_t fMaxSize
!Current dimension of arrays fX and fY
void SaveHistogramAndFunctions(std::ostream &out, const char *varname, Int_t &frameNumber, Option_t *option)
Save histogram and list of functions of TGraph as C++ statement Used in all TGraph-derived classes.
~TGraph() override
Graph default destructor.
Double_t ** ShrinkAndCopy(Int_t size, Int_t iend)
if size*2 <= fMaxSize allocate new arrays of size points, copy points [0,oend).
virtual Double_t GetRMS(Int_t axis=1) const
Return RMS of X (axis=1) or Y (axis=2)
TH1F * fHistogram
Pointer to histogram used for drawing axis.
void Paint(Option_t *chopt="") override
Draw this graph with its current attributes.
@ kNotEditable
Bit set if graph is non editable.
@ kIsHighlight
Bit set if graph is highlight.
@ kIsSortedX
Graph is sorted in X points.
@ kClipFrame
Clip to the frame boundary.
@ kResetHisto
fHistogram must be reset in GetHistogram
@ kNoStats
Don't draw stats box.
virtual Double_t GetErrorXlow(Int_t bin) const
It always returns a negative value.
virtual void MovePoints(Double_t dx, Double_t dy, Bool_t logx=kFALSE, Bool_t logy=kFALSE)
Move all graph points on specified values dx,dy If log argument specified, calculation done in logari...
virtual Double_t GetErrorYlow(Int_t bin) const
It always returns a negative value.
virtual void UpdateArrays(const std::vector< Int_t > &sorting_indices, Int_t numSortedPoints, Int_t low)
Update the fX and fY arrays with the sorted values.
virtual void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy points from fX and fY to arrays[0] and arrays[1] or to fX and fY if arrays == 0 and ibegin !...
Double_t GetMinimum() const
void Print(Option_t *chopt="") const override
Print graph values.
virtual Double_t * GetEYlow() const
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum of the graph.
virtual Double_t * GetEX() const
static Bool_t CompareY(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if fY[left] > fY[right]. Can be used by Sort.
static Bool_t CompareRadius(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if point number "left"'s distance to origin is bigger than that of point number "right".
virtual Double_t GetErrorYhigh(Int_t bin) const
It always returns a negative value.
TClass * IsA() const override
static Bool_t CompareX(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if fX[left] > fX[right]. Can be used by Sort.
void SaveAs(const char *filename, Option_t *option="") const override
Save the graph as .csv, .tsv or .txt.
TF1 * GetFunction(const char *name) const
Return pointer to function with name.
virtual void LeastSquareLinearFit(Int_t n, Double_t &a0, Double_t &a1, Int_t &ifail, Double_t xmin=0, Double_t xmax=0)
Least square linear fit without weights.
Double_t * fY
[fNpoints] array of Y points
Bool_t CtorAllocate()
In constructors set fNpoints than call this method.
TString SaveArray(std::ostream &out, const char *suffix, Int_t frameNumber, Double_t *arr)
Save array as C++ code Returns name of created array.
virtual void DrawGraph(Int_t n, const Int_t *x, const Int_t *y, Option_t *option="")
Draw this graph with new attributes.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
Fit this graph with function with name fname.
virtual void Sort(Bool_t(*greater)(const TGraph *, Int_t, Int_t)=&TGraph::CompareX, Bool_t ascending=kTRUE, Int_t low=0, Int_t high=-1111)
Sorts the points of this TGraph using in-place quicksort (see e.g.
static Bool_t CompareArg(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if point number "left"'s argument (angle with respect to positive x-axis) is bigger than...
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute the x/y range of the points in this graph.
char * GetObjectInfo(Int_t px, Int_t py) const override
Implementation to get information on point of graph at cursor position Adapted from class TH1.
Double_t ** AllocateArrays(Int_t Narrays, Int_t arraySize)
Allocate arrays.
virtual void Scale(Double_t c1=1., Option_t *option="y")
Multiply the values of a TGraph by a constant c1.
TList * fFunctions
Pointer to list of functions (fits and user)
virtual Double_t GetCovariance() const
Return covariance of vectors x,y.
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
void Streamer(TBuffer &) override
Stream an object of class TGraph.
void Zero(Int_t &k, Double_t AZ, Double_t BZ, Double_t E2, Double_t &X, Double_t &Y, Int_t maxiterations)
Find zero of a continuous function.
virtual Double_t ** Allocate(Int_t newsize)
Allocate internal data structures for newsize points.
virtual void FitPanel()
Display a GUI panel with all graph fit options.
void Browse(TBrowser *b) override
Browse.
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
virtual void InsertPointBefore(Int_t ipoint, Double_t x, Double_t y)
Insert a new point with coordinates (x,y) before the point number ipoint.
TList * GetListOfFunctions() const
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
virtual Double_t Eval(Double_t x, TSpline *spline=nullptr, Option_t *option="") const
Interpolate points in this graph at x using a TSpline.
virtual void InitExpo(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for an exponential.
virtual Int_t RemovePoint()
Delete point close to the mouse position Returns index of removed point (or -1 if nothing was changed...
virtual void InitGaus(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for a gaussian.
virtual Bool_t IsHighlight() const
virtual void Apply(TF1 *f)
Apply function f to all the data points f may be a 1-D function TF1 or 2-d function TF2 The Y values ...
void SetName(const char *name="") override
Set graph name.
virtual void SetHighlight(Bool_t set=kTRUE)
Set highlight (enable/disble) mode for the graph by default highlight mode is disable.
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
TAxis * GetXaxis() const
Get x axis of the graph.
Bool_t GetEditable() const
Return kTRUE if kNotEditable bit is not set, kFALSE otherwise.
virtual Double_t * GetEXhigh() const
virtual Double_t GetCorrelationFactor() const
Return graph correlation factor.
virtual void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE)
Set zero values for point arrays in the range [begin, end) Should be redefined in descendant classes.
virtual Double_t * GetEYhigh() const
Double_t ** ExpandAndCopy(Int_t size, Int_t iend)
if size > fMaxSize allocate new arrays of 2*size points and copy iend first points.
virtual void Expand(Int_t newsize)
If array sizes <= newsize, expand storage to 2*newsize.
virtual Double_t GetMean(Int_t axis=1) const
Return mean value of X (axis=1) or Y (axis=2)
Double_t * fX
[fNpoints] array of X points
virtual void PaintStats(TF1 *fit)
Draw the stats.
TAxis * GetYaxis() const
Get y axis of the graph.
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
virtual TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
virtual Double_t GetErrorY(Int_t bin) const
It always returns a negative value. Real implementation in TGraphErrors.
virtual Double_t * GetEY() const
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
virtual Double_t GetPointY(Int_t i) const
Get y value for point i.
Double_t fMinimum
Minimum value for plotting along y.
void PaintGraph(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
Draw the (x,y) as a graph.
void SetTitle(const char *title="") override
Change (i.e.
virtual Int_t InsertPoint()
Insert a new point at the mouse position.
virtual Double_t * GetEXlow() const
void RecursiveRemove(TObject *obj) override
Recursively remove object from the list of functions.
virtual void SetPointY(Int_t i, Double_t y)
Set y value for point i.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a graph.
virtual void DrawPanel()
Display a panel with all graph drawing options.
void PaintGrapHist(Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)
Draw the (x,y) as a histogram.
void SetNameTitle(const char *name="", const char *title="") override
Set graph name and title.
virtual void SetPointX(Int_t i, Double_t x)
Set x value for point i.
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
virtual void SetEditable(Bool_t editable=kTRUE)
if editable=kFALSE, the graph cannot be modified with the mouse by default a TGraph is editable
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum of the graph.
TGraph()
Graph default constructor.
virtual Bool_t CopyPoints(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy points from fX and fY to arrays[0] and arrays[1] or to fX and fY if arrays == 0 and ibegin !...
Double_t fMaximum
Maximum value for plotting along y.
virtual Double_t GetErrorXhigh(Int_t bin) const
It always returns a negative value.
TGraph & operator=(const TGraph &)
Equal operator for this graph.
virtual void InitPolynom(Double_t xmin=0, Double_t xmax=0)
Compute Initial values of parameters for a polynom.
virtual Double_t GetErrorX(Int_t bin) const
It always returns a negative value. Real implementation in TGraphErrors.
1-D histogram with a float per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
void SetTitle(const char *title) override
Change/set the title.
void UseCurrentStyle() override
Copy current attributes from/to current style.
@ kNoStats
Don't draw stats box.
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetMinimum(Double_t minimum=-1111)
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void SetName(const char *name) override
Change the name of this histogram.
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
void Streamer(TBuffer &) override
Stream an object of class TObject.
const char * GetTitle() const override
Returns title of object.
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void UseCurrentStyle()
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyl...
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
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
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Longptr_t ExecPlugin(int nargs)
Int_t LoadPlugin()
Load the plugin library for this handler.
Class to create third splines to interpolate knots Arbitrary conditions can be introduced for first a...
Double_t Eval(Double_t x) const override
Eval this spline at x.
Base class for spline implementation containing the Draw/Paint methods.
virtual Double_t Eval(Double_t x) const =0
void ToLower()
Change string to lower-case.
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified 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.
void Clear()
Clear string without changing its capacity.
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
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)
void ToUpper()
Change string to upper case.
TString & Remove(Ssiz_t pos)
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
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void SetHistFillColor(Color_t color=1)
Color_t GetHistLineColor() const
void SetHistLineStyle(Style_t styl=0)
Style_t GetHistFillStyle() const
Color_t GetHistFillColor() const
void SetHistLineColor(Color_t color=1)
Style_t GetHistLineStyle() const
void SetHistFillStyle(Style_t styl=0)
Width_t GetHistLineWidth() const
void SetHistLineWidth(Width_t width=1)
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Abstract Base Class for Fitting.
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual TObject * GetUserFunc() const
Abstract interface to a histogram painter.
virtual void DrawPanelHelper(TGraph *theGraph)=0
virtual void ExecuteEventHelper(TGraph *theGraph, Int_t event, Int_t px, Int_t py)=0
virtual void SetHighlight(TGraph *theGraph)=0
virtual void PaintGrapHist(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)=0
virtual Int_t DistancetoPrimitiveHelper(TGraph *theGraph, Int_t px, Int_t py)=0
virtual void PaintGraph(TGraph *theGraph, Int_t npoints, const Double_t *x, const Double_t *y, Option_t *chopt)=0
virtual void PaintStats(TGraph *theGraph, TF1 *fit)=0
virtual void PaintHelper(TGraph *theGraph, Option_t *option)=0
static TVirtualGraphPainter * GetPainter()
Static function returning a pointer to the current graph painter.
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)
double Chisquare(const TH1 &h1, TF1 &f1, bool useRange, EChisquareType type)
compute the chi2 value for an histogram given a function (see TH1::Chisquare for the documentation)
void FitOptionsMake(EFitObjectType type, const char *option, Foption_t &fitOption)
Decode list of options into fitOption.
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Function which returns kTRUE if point xp,yp lies inside the polygon defined by the np points in array...
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t ATan2(Double_t y, Double_t x)
Returns the principal value of the arc tangent of y/x, expressed in radians.
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
static uint64_t sum(uint64_t i)