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);
203 Double_t x,
y,exl,exh,eyl,eyh,eyl_new,eyh_new,fxy;
221 if (
f->Eval(
x,
y-eyl) <
f->Eval(
x,
y+eyh)) {
309 memmove(&arrays[0][obegin], &
fEXlow[ibegin],
n);
310 memmove(&arrays[1][obegin], &
fEXhigh[ibegin],
n);
311 memmove(&arrays[2][obegin], &
fEYlow[ibegin],
n);
312 memmove(&arrays[3][obegin], &
fEYhigh[ibegin],
n);
313 memmove(&arrays[4][obegin], &
fEXlowd[ibegin],
n);
314 memmove(&arrays[5][obegin], &
fEXhighd[ibegin],
n);
315 memmove(&arrays[6][obegin], &
fEYlowd[ibegin],
n);
316 memmove(&arrays[7][obegin], &
fEYhighd[ibegin],
n);
360 if (
g->GetN() == 0)
return kFALSE;
372 if (!exl || !exh || !eyl || !eyh ||
373 !exld || !exhd || !eyld || !eyhd) {
375 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphBentErrors - errors will be ignored",
g->IsA()->GetName());
378 for (
Int_t i = 0 ; i <
g->GetN(); i++) {
384 exld[i], exhd[i], eyld[i], eyhd[i]);
395 if (i < 0 || i >=
fNpoints)
return -1;
409 if (i < 0 || i >=
fNpoints)
return -1;
489 printf(
"x[%d]=%g, y[%d]=%g, exl[%d]=%g, exh[%d]=%g, eyl[%d]=%g, eyh[%d]=%g\n"
490 ,i,
fX[i],i,
fY[i],i,
fEXlow[i],i,
fEXhigh[i],i,
fEYlow[i],i,
fEYhigh[i]);
544 out <<
" " << std::endl;
545 static Int_t frameNumber = 2000;
548 auto fXName =
SaveArray(out,
"fx", frameNumber,
fX);
549 auto fYName =
SaveArray(out,
"fy", frameNumber,
fY);
562 out <<
" TGraphBentErrors *";
563 out <<
"grbe = new TGraphBentErrors("<<
fNpoints <<
","
564 << fXName <<
"," << fYName <<
","
565 << fElXName <<
"," << fEhXName <<
","
566 << fElYName <<
"," << fEhYName <<
","
567 << fEldXName <<
"," << fEhdXName <<
","
568 << fEldYName <<
"," << fEhdYName <<
");"
582 Error(
"SetPointError",
"Cannot be used without gPad, requires last mouse position");
595 if (dpx*dpx+dpy*dpy < 25) {ipoint = i;
break;}
597 if (ipoint == -2)
return;
658 std::vector<Double_t> fEXlowSorted(numSortedPoints);
659 std::vector<Double_t> fEXhighSorted(numSortedPoints);
660 std::vector<Double_t> fEXlowdSorted(numSortedPoints);
661 std::vector<Double_t> fEXhighdSorted(numSortedPoints);
663 std::vector<Double_t> fEYlowSorted(numSortedPoints);
664 std::vector<Double_t> fEYhighSorted(numSortedPoints);
665 std::vector<Double_t> fEYlowdSorted(numSortedPoints);
666 std::vector<Double_t> fEYhighdSorted(numSortedPoints);
669 std::generate(fEXlowSorted.begin(), fEXlowSorted.end(),
670 [begin = low, &sorting_indices,
this]()
mutable { return fEXlow[sorting_indices[begin++]]; });
671 std::generate(fEXhighSorted.begin(), fEXhighSorted.end(),
672 [begin = low, &sorting_indices,
this]()
mutable { return fEXhigh[sorting_indices[begin++]]; });
673 std::generate(fEXlowdSorted.begin(), fEXlowdSorted.end(),
674 [begin = low, &sorting_indices,
this]()
mutable { return fEXlowd[sorting_indices[begin++]]; });
675 std::generate(fEXhighdSorted.begin(), fEXhighdSorted.end(),
676 [begin = low, &sorting_indices,
this]()
mutable { return fEXhighd[sorting_indices[begin++]]; });
678 std::generate(fEYlowSorted.begin(), fEYlowSorted.end(),
679 [begin = low, &sorting_indices,
this]()
mutable { return fEYlow[sorting_indices[begin++]]; });
680 std::generate(fEYhighSorted.begin(), fEYhighSorted.end(),
681 [begin = low, &sorting_indices,
this]()
mutable { return fEYhigh[sorting_indices[begin++]]; });
682 std::generate(fEYlowdSorted.begin(), fEYlowdSorted.end(),
683 [begin = low, &sorting_indices,
this]()
mutable { return fEYlowd[sorting_indices[begin++]]; });
684 std::generate(fEYhighdSorted.begin(), fEYhighdSorted.end(),
685 [begin = low, &sorting_indices,
this]()
mutable { return fEYhighd[sorting_indices[begin++]]; });
688 std::copy(fEXlowSorted.begin(), fEXlowSorted.end(),
fEXlow + low);
689 std::copy(fEXhighSorted.begin(), fEXhighSorted.end(),
fEXhigh + low);
690 std::copy(fEXlowdSorted.begin(), fEXlowdSorted.end(),
fEXlowd + low);
691 std::copy(fEXhighdSorted.begin(), fEXhighdSorted.end(),
fEXhighd + low);
693 std::copy(fEYlowSorted.begin(), fEYlowSorted.end(),
fEYlow + low);
694 std::copy(fEYhighSorted.begin(), fEYhighSorted.end(),
fEYhigh + low);
695 std::copy(fEYlowdSorted.begin(), fEYlowdSorted.end(),
fEYlowd + low);
696 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 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.
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.