98 for (
Int_t i = 0; i <
n; i++) {
119 else memset(
fEX, 0,
n);
121 else memset(
fEY, 0,
n);
134 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
140 fEX[i] = vex(i + ivexlow);
141 fEY[i] = vey(i + iveylow);
155 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
161 fEX[i] = vex(i + ivexlow);
162 fEY[i] = vey(i + iveylow);
211 fEY[i] =
h->GetBinError(i + 1);
242 std::ifstream infile(fname.
Data());
243 if (!infile.good()) {
245 Error(
"TGraphErrors",
"Cannot open file: %s, TGraphErrors is Zombie",
filename);
252 if (strcmp(
option,
"") == 0) {
256 while (std::getline(infile,
line,
'\n')) {
260 }
else if (ncol < 4) {
285 Error(
"TGraphErrors",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
290 Error(
"TGraphErrors",
"Incorrect input format! Only %d tag(s) in format whereas at least 2 \"%%lg\" tags are expected!", ntokens);
293 Int_t ntokensToBeSaved = 0 ;
295 for (
Int_t idx = 0; idx < ntokens; idx++) {
297 if (isTokenToBeSaved[idx] == 1) {
301 if (ntokens >= 2 && (ntokensToBeSaved < 2 || ntokensToBeSaved > 4)) {
302 Error(
"TGraphErrors",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2,3 or 4 are expected!", ntokensToBeSaved);
303 delete [] isTokenToBeSaved ;
309 char *token =
nullptr;
313 for (
Int_t k = 0; k < 4; k++)
319 while (std::getline(infile,
line,
'\n')) {
321 if (
line[
line.size() - 1] ==
char(13)) {
324 token = R__STRTOK_R(
const_cast<char *
>(
line.c_str()),
option, &rest);
325 while (token !=
nullptr && value_idx < ntokensToBeSaved) {
326 if (isTokenToBeSaved[token_idx]) {
330 isLineToBeSkipped =
kTRUE ;
337 token = R__STRTOK_R(
nullptr,
option, &rest);
340 if (!isLineToBeSkipped && value_idx > 1) {
350 isLineToBeSkipped =
kFALSE;
358 delete [] isTokenToBeSaved;
452 while ((fmt = strchr(fmt,
'%'))) {
456 if (*++fmt &&
'^' == *fmt) ++fmt;
457 if (*++fmt &&
']' == *fmt) ++fmt;
458 while (*fmt && *fmt !=
']')
463 if (
'%' == *fmt)
break;
466 }
else if (strchr(
"dDiouxXxfegEscpn", *fmt)) {
538 memmove(&arrays[0][obegin], &
fEX[ibegin],
n);
539 memmove(&arrays[1][obegin], &
fEY[ibegin],
n);
541 memmove(&
fEX[obegin], &
fEX[ibegin],
n);
542 memmove(&
fEY[obegin], &
fEY[ibegin],
n);
575 if (
g->GetN() == 0)
return kFALSE;
579 if (
ex ==
nullptr ||
ey ==
nullptr) {
581 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphErrors - errors will be ignored",
g->IsA()->GetName());
584 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
604 memset(
fEX + begin, 0,
n);
605 memset(
fEY + begin, 0,
n);
614 if (i < 0 || i >=
fNpoints)
return -1;
625 if (i < 0 || i >=
fNpoints)
return -1;
637 if (i < 0 || i >=
fNpoints)
return -1;
649 if (i < 0 || i >=
fNpoints)
return -1;
661 if (i < 0 || i >=
fNpoints)
return -1;
673 if (i < 0 || i >=
fNpoints)
return -1;
689 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
693 int n1 = n0+
g->GetN();
699 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
714 printf(
"x[%d]=%g, y[%d]=%g, ex[%d]=%g, ey[%d]=%g\n", i,
fX[i], i,
fY[i], i,
fEX[i], i,
fEY[i]);
724 out <<
" " << std::endl;
725 static Int_t frameNumber = 1000;
728 auto fXName =
SaveArray(out,
"fx", frameNumber,
fX);
729 auto fYName =
SaveArray(out,
"fy", frameNumber,
fY);
736 out <<
" TGraphErrors *";
737 out <<
"gre = new TGraphErrors(" <<
fNpoints <<
","
738 << fXName <<
"," << fYName <<
","
739 << fEXName <<
"," << fEYName <<
");"
772 Error(
"SetPointError",
"Cannot be used without gPad, requires last mouse position");
786 if (dpx * dpx + dpy * dpy < 25) {
791 if (ipoint == -2)
return;
868 std::vector<Double_t> fEXSorted(numSortedPoints);
869 std::vector<Double_t> fEYSorted(numSortedPoints);
872 std::generate(fEXSorted.begin(), fEXSorted.end(),
873 [begin = low, &sorting_indices,
this]()
mutable { return fEX[sorting_indices[begin++]]; });
874 std::generate(fEYSorted.begin(), fEYSorted.end(),
875 [begin = low, &sorting_indices,
this]()
mutable { return fEY[sorting_indices[begin++]]; });
878 std::copy(fEXSorted.begin(), fEXSorted.end(),
fEX + low);
879 std::copy(fEYSorted.begin(), fEYSorted.end(),
fEY + low);
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 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 value
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
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
Buffer base class used for serializing objects.
Collection abstract base class.
A TGraphErrors is a TGraph with error bars.
void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Compute range.
void UpdateArrays(const std::vector< Int_t > &sorting_indices, Int_t numSortedPoints, Int_t low) override
Update the fX, fY, fEX, and fEY arrays with the sorted values.
Double_t GetErrorY(Int_t bin) const override
It returns the error along Y at point i.
Double_t * GetEX() const override
Double_t GetErrorX(Int_t bin) const override
It returns the error along X at point i.
Double_t * fEY
[fNpoints] array of Y errors
~TGraphErrors() override
TGraphErrors default destructor.
void Scale(Double_t c1=1., Option_t *option="y") override
Multiply the values and errors of a TGraphErrors by a constant c1.
static Int_t CalculateScanfFields(const char *fmt)
Calculate scan fields.
void Streamer(TBuffer &) override
Stream an object of class TGraphErrors.
void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE) override
Set zero values for point arrays in the range [begin, end].
virtual void AddPointError(Double_t x, Double_t y, Double_t ex=0., Double_t ey=0.)
Add a point with errorbars to the graph.
Double_t * fEX
[fNpoints] array of X errors
void Print(Option_t *chopt="") const override
Print graph and errors values.
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
Bool_t DoMerge(const TGraph *g) override
Protected function to perform the merge operation of a graph with errors.
Double_t * GetEY() const override
void SwapPoints(Int_t pos1, Int_t pos2) override
Swap points.
virtual void ApplyX(TF1 *f)
Apply function to all the data points .
Double_t GetErrorXhigh(Int_t bin) const override
It returns the error along X at point i.
Double_t GetErrorYlow(Int_t bin) const override
It returns the error along Y at point i.
Double_t GetErrorYhigh(Int_t bin) const override
It returns the error along Y at point i.
TGraphErrors & operator=(const TGraphErrors &gr)
TGraphErrors assignment operator.
Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy errors from fEX and fEY to arrays[0] and arrays[1] or to fEX and fEY if arrays == 0 and ibegin !...
TClass * IsA() const override
Int_t Merge(TCollection *list) override
Adds all graphs with errors from the collection to this graph.
void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy and release.
TGraphErrors()
TGraphErrors default constructor.
Double_t GetErrorXlow(Int_t bin) const override
It returns the error along X at point i.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void Apply(TF1 *f) override
Apply function to all the data points .
Bool_t CtorAllocate()
Constructor allocate.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void AddPoint(Double_t x, Double_t y)
Append a new point to the graph.
Int_t fNpoints
Number of points <= fMaxSize.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
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.
TH1F * fHistogram
Pointer to histogram used for drawing axis.
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.
Double_t * fY
[fNpoints] array of Y points
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 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.
virtual void Scale(Double_t c1=1., Option_t *option="y")
Multiply the values of a TGraph by a constant c1.
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
void Streamer(TBuffer &) override
Stream an object of class TGraph.
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
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.
Double_t * fX
[fNpoints] array of X points
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 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 !...
TGraph & operator=(const TGraph &)
Equal operator for this graph.
TH1 is the base class of all histogram classes in ROOT.
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
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)
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
Float_t GetErrorX() const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.