116 if (exl)
fEXlow[i] = exl[i];
120 if (eyl)
fEYlow[i] = eyl[i];
125 if (exld)
fEXlowd[i] = exld[i];
129 if (eyld)
fEYlowd[i] = eyld[i];
153 if (exl) memcpy(
fEXlow, exl, memsz);
154 else memset(
fEXlow, 0, memsz);
155 if (exh) memcpy(
fEXhigh, exh, memsz);
156 else memset(
fEXhigh, 0, memsz);
157 if (eyl) memcpy(
fEYlow, eyl, memsz);
158 else memset(
fEYlow, 0, memsz);
159 if (eyh) memcpy(
fEYhigh, eyh, memsz);
160 else memset(
fEYhigh, 0, memsz);
162 if (exld) memcpy(
fEXlowd, exld, memsz);
163 else memset(
fEXlowd, 0, memsz);
164 if (exhd) memcpy(
fEXhighd, exhd, memsz);
166 if (eyld) memcpy(
fEYlowd, eyld, memsz);
167 else memset(
fEYlowd, 0, memsz);
168 if (eyhd) memcpy(
fEYhighd, eyhd, memsz);
212 Double_t x,
y,exl,exh,eyl,eyh,eyl_new,eyh_new,fxy;
230 if (
f->Eval(
x,
y-eyl) <
f->Eval(
x,
y+eyh)) {
318 memmove(&arrays[0][obegin], &
fEXlow[ibegin],
n);
319 memmove(&arrays[1][obegin], &
fEXhigh[ibegin],
n);
320 memmove(&arrays[2][obegin], &
fEYlow[ibegin],
n);
321 memmove(&arrays[3][obegin], &
fEYhigh[ibegin],
n);
322 memmove(&arrays[4][obegin], &
fEXlowd[ibegin],
n);
323 memmove(&arrays[5][obegin], &
fEXhighd[ibegin],
n);
324 memmove(&arrays[6][obegin], &
fEYlowd[ibegin],
n);
325 memmove(&arrays[7][obegin], &
fEYhighd[ibegin],
n);
369 if (
g->GetN() == 0)
return kFALSE;
381 if (!exl || !exh || !eyl || !eyh ||
382 !exld || !exhd || !eyld || !eyhd) {
384 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphBentErrors - errors will be ignored",
g->IsA()->GetName());
387 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
393 exld[i], exhd[i], eyld[i], eyhd[i]);
404 if (i < 0 || i >=
fNpoints)
return -1;
418 if (i < 0 || i >=
fNpoints)
return -1;
498 printf(
"x[%d]=%g, y[%d]=%g, exl[%d]=%g, exh[%d]=%g, eyl[%d]=%g, eyh[%d]=%g\n"
499 ,i,
fX[i],i,
fY[i],i,
fEXlow[i],i,
fEXhigh[i],i,
fEYlow[i],i,
fEYhigh[i]);
553 out <<
" " << std::endl;
554 static Int_t frameNumber = 2000;
557 auto fXName =
SaveArray(out,
"fx", frameNumber,
fX);
558 auto fYName =
SaveArray(out,
"fy", frameNumber,
fY);
571 out <<
" TGraphBentErrors *";
572 out <<
"grbe = new TGraphBentErrors("<<
fNpoints <<
","
573 << fXName <<
"," << fYName <<
","
574 << fElXName <<
"," << fEhXName <<
","
575 << fElYName <<
"," << fEhYName <<
","
576 << fEldXName <<
"," << fEhdXName <<
","
577 << fEldYName <<
"," << fEhdYName <<
");"
591 Error(
"SetPointError",
"Cannot be used without gPad, requires last mouse position");
604 if (dpx*dpx+dpy*dpy < 25) {ipoint = i;
break;}
606 if (ipoint == -2)
return;
667 std::vector<Double_t> fEXlowSorted(numSortedPoints);
668 std::vector<Double_t> fEXhighSorted(numSortedPoints);
669 std::vector<Double_t> fEXlowdSorted(numSortedPoints);
670 std::vector<Double_t> fEXhighdSorted(numSortedPoints);
672 std::vector<Double_t> fEYlowSorted(numSortedPoints);
673 std::vector<Double_t> fEYhighSorted(numSortedPoints);
674 std::vector<Double_t> fEYlowdSorted(numSortedPoints);
675 std::vector<Double_t> fEYhighdSorted(numSortedPoints);
678 std::generate(fEXlowSorted.begin(), fEXlowSorted.end(),
679 [begin = low, &sorting_indices,
this]()
mutable { return fEXlow[sorting_indices[begin++]]; });
680 std::generate(fEXhighSorted.begin(), fEXhighSorted.end(),
681 [begin = low, &sorting_indices,
this]()
mutable { return fEXhigh[sorting_indices[begin++]]; });
682 std::generate(fEXlowdSorted.begin(), fEXlowdSorted.end(),
683 [begin = low, &sorting_indices,
this]()
mutable { return fEXlowd[sorting_indices[begin++]]; });
684 std::generate(fEXhighdSorted.begin(), fEXhighdSorted.end(),
685 [begin = low, &sorting_indices,
this]()
mutable { return fEXhighd[sorting_indices[begin++]]; });
687 std::generate(fEYlowSorted.begin(), fEYlowSorted.end(),
688 [begin = low, &sorting_indices,
this]()
mutable { return fEYlow[sorting_indices[begin++]]; });
689 std::generate(fEYhighSorted.begin(), fEYhighSorted.end(),
690 [begin = low, &sorting_indices,
this]()
mutable { return fEYhigh[sorting_indices[begin++]]; });
691 std::generate(fEYlowdSorted.begin(), fEYlowdSorted.end(),
692 [begin = low, &sorting_indices,
this]()
mutable { return fEYlowd[sorting_indices[begin++]]; });
693 std::generate(fEYhighdSorted.begin(), fEYhighdSorted.end(),
694 [begin = low, &sorting_indices,
this]()
mutable { return fEYhighd[sorting_indices[begin++]]; });
697 std::copy(fEXlowSorted.begin(), fEXlowSorted.end(),
fEXlow + low);
698 std::copy(fEXhighSorted.begin(), fEXhighSorted.end(),
fEXhigh + low);
699 std::copy(fEXlowdSorted.begin(), fEXlowdSorted.end(),
fEXlowd + low);
700 std::copy(fEXhighdSorted.begin(), fEXhighdSorted.end(),
fEXhighd + low);
702 std::copy(fEYlowSorted.begin(), fEYlowSorted.end(),
fEYlow + low);
703 std::copy(fEYhighSorted.begin(), fEYhighSorted.end(),
fEYhigh + low);
704 std::copy(fEYlowdSorted.begin(), fEYlowdSorted.end(),
fEYlowd + low);
705 std::copy(fEYhighdSorted.begin(), fEYhighdSorted.end(),
fEYhighd + low);
A TGraphBentErrors is a TGraph with bent, asymmetric error bars.
void UpdateArrays(const std::vector< Int_t > &sorting_indices, Int_t numSortedPoints, Int_t low) override
Update the fX, fY, fEXlow, fEXhigh, fEXlowd, fEXhighd, fEYlow, fEYhigh, fEYlowd, and fEYhighd array...
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
TGraphBentErrors()
TGraphBentErrors default constructor.
Double_t * GetEXlow() const override
Double_t * fEYhigh
[fNpoints] array of Y high errors
Double_t * fEXlowd
[fNpoints] array of X low displacements
Double_t * fEYlowd
[fNpoints] array of Y low displacements
Bool_t CtorAllocate()
Should be called from ctors after fNpoints has been set.
Bool_t DoMerge(const TGraph *g) override
Protected function to perform the merge operation of a graph with asymmetric errors.
Double_t * GetEYhigh() const override
Double_t GetErrorXlow(Int_t bin) const override
Get low error on X[i].
Double_t * GetEYlow() const override
Double_t * GetEYhighd() const override
void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Compute range.
Double_t * GetEXhigh() const override
Double_t * GetEYlowd() const override
Double_t * fEXhighd
[fNpoints] array of X high displacements
Double_t * GetEXhighd() const override
Double_t GetErrorXhigh(Int_t bin) const override
Get high error on X[i].
virtual void AddPointError(Double_t x, Double_t y, Double_t exl, Double_t exh, Double_t eyl, Double_t eyh, Double_t exld=0, Double_t exhd=0, Double_t eyld=0, Double_t eyhd=0)
Add a point with bent errors to the graph.
virtual void SetPointError(Double_t exl, Double_t exh, Double_t eyl, Double_t eyh, Double_t exld=0, Double_t exhd=0, Double_t eyld=0, Double_t eyhd=0)
Set ex and ey values for point pointed by the mouse.
Double_t * fEXlow
[fNpoints] array of X low errors
Double_t * fEXhigh
[fNpoints] array of X high errors
~TGraphBentErrors() override
TGraphBentErrors default destructor.
void Print(Option_t *chopt="") const override
Print graph and errors values.
void Scale(Double_t c1=1., Option_t *option="y") override
Multiply the values and errors of a TGraphBentErrors by a constant c1.
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]
Double_t * GetEXlowd() const override
Double_t GetErrorY(Int_t bin) const override
It returns the error along Y at point i.
Double_t * fEYlow
[fNpoints] array of Y low errors
Double_t * fEYhighd
[fNpoints] array of Y high displacements
void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy and release.
void SwapPoints(Int_t pos1, Int_t pos2) override
Swap points.
Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy errors from fE***to arrays[***] or to f*** Copy points.
Double_t GetErrorYlow(Int_t bin) const override
Get low error on Y[i].
Double_t GetErrorX(Int_t bin) const override
It returns the error along X at point i.
Double_t GetErrorYhigh(Int_t bin) const override
Get high error on Y[i].
void Apply(TF1 *f) override
Apply a function to all data points .
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.
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 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 !...
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.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.