82 if (!CtorAllocate())
return;
83 FillZero(0, fNpoints);
95 if (!CtorAllocate())
return;
97 for (
Int_t i = 0; i <
n; i++) {
98 if (
ex) fEX[i] =
ex[i];
100 if (
ey) fEY[i] =
ey[i];
114 if (!CtorAllocate())
return;
117 if (
ex) memcpy(fEX,
ex,
n);
118 else memset(fEX, 0,
n);
119 if (
ey) memcpy(fEY,
ey,
n);
120 else memset(fEY, 0,
n);
133 :
TGraph(
TMath::
Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
135 if (!CtorAllocate())
return;
138 for (
Int_t i = 0; i < fNpoints; i++) {
139 fEX[i] = vex(i + ivexlow);
140 fEY[i] = vey(i + iveylow);
154 :
TGraph(
TMath::
Min(vx.GetNrows(), vy.GetNrows()), vx.GetMatrixArray(), vy.GetMatrixArray() )
156 if (!CtorAllocate())
return;
159 for (
Int_t i = 0; i < fNpoints; i++) {
160 fEX[i] = vex(i + ivexlow);
161 fEY[i] = vey(i + iveylow);
172 if (!CtorAllocate())
return;
175 memcpy(fEX,
gr.fEX,
n);
176 memcpy(fEY,
gr.fEY,
n);
206 if (!CtorAllocate())
return;
208 for (
Int_t i = 0; i < fNpoints; i++) {
209 fEX[i] =
h->GetBinWidth(i + 1) *
gStyle->GetErrorX();
210 fEY[i] =
h->GetBinError(i + 1);
239 if (!CtorAllocate())
return;
242 gSystem->ExpandPathName(fname);
244 if (!infile.good()) {
246 Error(
"TGraphErrors",
"Cannot open file: %s, TGraphErrors is Zombie", filename);
255 if (!option || !*option) {
260 format_ =
"%lg %lg %lg %lg";
262 format_ =
"%lg\t%lg\t%lg\t%lg";
264 format_ =
"%lg,%lg,%lg,%lg";
266 ncol = CalculateScanfFields(format);
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);
282 SetPointError(np,
ex,
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 ;
345 value[value_idx] = token_str.
Atof() ;
349 token = R__STRTOK_R(
nullptr, option, &rest);
352 if (!isLineToBeSkipped && value_idx > 1) {
358 SetPointError(np,
ex,
ey);
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);
758 TString opt = option; opt.
ToLower();
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);
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)
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
void UpdateArrays(const std::vector< Int_t > &sorting_indices, Int_t numSortedPoints, Int_t low) override
virtual void ApplyX(TF1 *f)
Double_t GetErrorY(Int_t bin) const override
Double_t * GetEX() const override
Double_t GetErrorX(Int_t bin) const override
Double_t * fEY
[fNpoints] array of Y errors
void Scale(Double_t c1=1., Option_t *option="y") override
void Streamer(TBuffer &) override
Stream an object of class TObject.
void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE) override
Double_t * fEX
[fNpoints] array of X errors
void Print(Option_t *chopt="") const override
This method must be overridden when a class wants to print itself.
virtual void AddPointError(Double_t x, Double_t y, Double_t ex=0., Double_t ey=0.)
Bool_t DoMerge(const TGraph *g) override
Double_t * GetEY() const override
void SwapPoints(Int_t pos1, Int_t pos2) override
Double_t GetErrorXhigh(Int_t bin) const override
Double_t GetErrorYlow(Int_t bin) const override
Double_t GetErrorYhigh(Int_t bin) const override
TGraphErrors & operator=(const TGraphErrors &gr)
static Int_t CalculateScanfFields(const char *fmt)
Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin) override
TClass * IsA() const override
Int_t Merge(TCollection *list) override
void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin) override
virtual void SetPointError(Double_t ex, Double_t ey)
Double_t GetErrorXlow(Int_t bin) const override
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void Apply(TF1 *f) override
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.