97 for (
Int_t i = 0; i <
n; i++) {
118 else memset(
fEX, 0,
n);
120 else memset(
fEY, 0,
n);
133 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
139 fEX[i] = vex(i + ivexlow);
140 fEY[i] = vey(i + iveylow);
154 :
TGraph(
TMath::Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
160 fEX[i] = vex(i + ivexlow);
161 fEY[i] = vey(i + iveylow);
209 fEX[i] =
h->GetBinWidth(i + 1) *
gStyle->GetErrorX();
210 fEY[i] =
h->GetBinError(i + 1);
242 gSystem->ExpandPathName(fname);
243 std::ifstream infile(fname.
Data());
244 if (!infile.good()) {
246 Error(
"TGraphErrors",
"Cannot open file: %s, TGraphErrors is Zombie",
filename);
260 format_ =
"%lg %lg %lg %lg";
262 format_ =
"%lg\t%lg\t%lg\t%lg";
264 format_ =
"%lg,%lg,%lg,%lg";
269 while (std::getline(infile,
line,
'\n')) {
272 res = sscanf(
line.c_str(), format_.
Data(), &
x, &
y);
273 }
else if (ncol < 4) {
274 res = sscanf(
line.c_str(), format_.
Data(), &
x, &
y, &
ey);
297 Error(
"TGraphErrors",
"Incorrect input format! Allowed format tags are {\"%%lg\",\"%%*lg\" or \"%%*s\"}");
302 Error(
"TGraphErrors",
"Incorrect input format! Only %d tag(s) in format whereas at least 2 \"%%lg\" tags are expected!", ntokens);
305 Int_t ntokensToBeSaved = 0 ;
307 for (
Int_t idx = 0; idx < ntokens; idx++) {
309 if (isTokenToBeSaved[idx] == 1) {
313 if (ntokens >= 2 && (ntokensToBeSaved < 2 || ntokensToBeSaved > 4)) {
314 Error(
"TGraphErrors",
"Incorrect input format! There are %d \"%%lg\" tag(s) in format whereas 2,3 or 4 are expected!", ntokensToBeSaved);
315 delete [] isTokenToBeSaved ;
321 char *token =
nullptr;
325 for (
Int_t k = 0; k < 4; k++)
331 while (std::getline(infile,
line,
'\n')) {
333 if (
line[
line.size() - 1] ==
char(13)) {
336 token = R__STRTOK_R(
const_cast<char *
>(
line.c_str()),
option, &rest);
337 while (token !=
nullptr && value_idx < ntokensToBeSaved) {
338 if (isTokenToBeSaved[token_idx]) {
342 isLineToBeSkipped =
kTRUE ;
349 token = R__STRTOK_R(
nullptr,
option, &rest);
352 if (!isLineToBeSkipped && value_idx > 1) {
362 isLineToBeSkipped =
kFALSE;
370 delete [] isTokenToBeSaved;
464 while ((fmt = strchr(fmt,
'%'))) {
468 if (*++fmt &&
'^' == *fmt) ++fmt;
469 if (*++fmt &&
']' == *fmt) ++fmt;
470 while (*fmt && *fmt !=
']')
475 if (
'%' == *fmt)
break;
478 }
else if (strchr(
"dDiouxXxfegEscpn", *fmt)) {
550 memmove(&arrays[0][obegin], &
fEX[ibegin],
n);
551 memmove(&arrays[1][obegin], &
fEY[ibegin],
n);
553 memmove(&
fEX[obegin], &
fEX[ibegin],
n);
554 memmove(&
fEY[obegin], &
fEY[ibegin],
n);
587 if (
g->GetN() == 0)
return kFALSE;
591 if (
ex ==
nullptr ||
ey ==
nullptr) {
593 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphErrors - errors will be ignored",
g->IsA()->GetName());
596 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
616 memset(
fEX + begin, 0,
n);
617 memset(
fEY + begin, 0,
n);
626 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;
685 if (i < 0 || i >=
fNpoints)
return -1;
701 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
705 int n1 = n0+
g->GetN();
711 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
726 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]);
743 TString::Format(
"%d, %s.data(), %s.data(), %s, %s",
fNpoints, xname.Data(), yname.Data(), exname.Data(), eyname.Data()),
kFALSE);
775 Error(
"SetPointError",
"Cannot be used without gPad, requires last mouse position");
789 if (dpx * dpx + dpy * dpy < 25) {
794 if (ipoint == -2)
return;
871 std::vector<Double_t> fEXSorted(numSortedPoints);
872 std::vector<Double_t> fEYSorted(numSortedPoints);
875 std::generate(fEXSorted.begin(), fEXSorted.end(),
876 [begin = low, &sorting_indices,
this]()
mutable { return fEX[sorting_indices[begin++]]; });
877 std::generate(fEYSorted.begin(), fEYSorted.end(),
878 [begin = low, &sorting_indices,
this]()
mutable { return fEY[sorting_indices[begin++]]; });
881 std::copy(fEXSorted.begin(), fEXSorted.end(),
fEX + low);
882 std::copy(fEYSorted.begin(), fEYSorted.end(),
fEY + low);
bool Bool_t
Boolean (0=false, 1=true) (bool).
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).
float Float_t
Float 4 bytes (float).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
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
TVectorT< Double_t > TVectorD
TVectorT< Float_t > TVectorF
Buffer base class used for serializing objects.
Collection abstract base class.
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.
virtual void AddPoint(Double_t x, Double_t y)
Append a new point to the graph.
Int_t fNpoints
Number of points <= fMaxSize.
Int_t fMaxSize
!Current dimension of arrays fX and fY
virtual void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE)
TH1F * fHistogram
Pointer to histogram used for drawing axis.
virtual Bool_t DoMerge(const TGraph *g)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual void Scale(Double_t c1=1., Option_t *option="y")
Double_t * fY
[fNpoints] array of Y points
virtual void Set(Int_t n)
void Streamer(TBuffer &) override
Stream an object of class TObject.
virtual void SwapPoints(Int_t pos1, Int_t pos2)
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
virtual Bool_t CopyPoints(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
void SaveHistogramAndFunctions(std::ostream &out, const char *varname, Option_t *option)
Double_t * fX
[fNpoints] array of X points
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
virtual void UpdateArrays(const std::vector< Int_t > &sorting_indices, Int_t numSortedPoints, Int_t low)
TGraph & operator=(const TGraph &)
TH1 is the base class of all histogram classes in ROOT.
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.
TObject()
TObject constructor.
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.
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.
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
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.