Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGraphBentErrors.cxx
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Dave Morrison 30/06/2003
3
4/*************************************************************************
5 * Copyright (C) 1995-2003, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <cstring>
13#include <iostream>
14
15#include "TROOT.h"
16#include "TGraphBentErrors.h"
17#include "TMath.h"
18#include "TVirtualPad.h"
19#include "TH1.h"
20#include "TF1.h"
21
22
23
24////////////////////////////////////////////////////////////////////////////////
25
26/** \class TGraphBentErrors
27 \ingroup Graphs
28A TGraphBentErrors is a TGraph with bent, asymmetric error bars.
29
30The TGraphBentErrors painting is performed thanks to the TGraphPainter
31class. All details about the various painting options are given in this class.
32
33The picture below gives an example:
34Begin_Macro(source)
35{
36 auto c1 = new TCanvas("c1","A Simple Graph with bent error bars",200,10,700,500);
37 const Int_t n = 10;
38 Double_t x[n] = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95};
39 Double_t y[n] = {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1};
40 Double_t exl[n] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05};
41 Double_t eyl[n] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8};
42 Double_t exh[n] = {.02,.08,.05,.05,.03,.03,.04,.05,.06,.03};
43 Double_t eyh[n] = {.6,.5,.4,.3,.2,.2,.3,.4,.5,.6};
44 Double_t exld[n] = {.0,.0,.0,.0,.0,.0,.0,.0,.0,.0};
45 Double_t eyld[n] = {.0,.0,.05,.0,.0,.0,.0,.0,.0,.0};
46 Double_t exhd[n] = {.0,.0,.0,.0,.0,.0,.0,.0,.0,.0};
47 Double_t eyhd[n] = {.0,.0,.0,.0,.0,.0,.0,.0,.05,.0};
48 auto gr = new TGraphBentErrors(n,x,y,exl,exh,eyl,eyh,exld,exhd,eyld,eyhd);
49 gr->SetTitle("TGraphBentErrors Example");
50 gr->SetMarkerColor(4);
51 gr->SetMarkerStyle(21);
52 gr->Draw("ALP");
53}
54End_Macro
55*/
56
57
58////////////////////////////////////////////////////////////////////////////////
59/// TGraphBentErrors default constructor.
60
65
66
67////////////////////////////////////////////////////////////////////////////////
68/// TGraphBentErrors copy constructor
69
71 : TGraph(gr)
72{
73 if (!CtorAllocate()) return;
74 Int_t n = fNpoints*sizeof(Double_t);
75 memcpy(fEXlow, gr.fEXlow, n);
76 memcpy(fEYlow, gr.fEYlow, n);
77 memcpy(fEXhigh, gr.fEXhigh, n);
78 memcpy(fEYhigh, gr.fEYhigh, n);
79 memcpy(fEXlowd, gr.fEXlowd, n);
80 memcpy(fEYlowd, gr.fEYlowd, n);
81 memcpy(fEXhighd, gr.fEXhighd, n);
82 memcpy(fEYhighd, gr.fEYhighd, n);
83}
84
85
86////////////////////////////////////////////////////////////////////////////////
87/// TGraphBentErrors normal constructor.
88///
89/// the arrays are preset to zero
90
97
98
99////////////////////////////////////////////////////////////////////////////////
100/// TGraphBentErrors normal constructor.
101///
102/// if exl,h or eyl,h are null, the corresponding arrays are preset to zero
103
105 const Float_t *x, const Float_t *y,
106 const Float_t *exl, const Float_t *exh,
107 const Float_t *eyl, const Float_t *eyh,
108 const Float_t *exld, const Float_t *exhd,
109 const Float_t *eyld, const Float_t *eyhd)
110 : TGraph(n,x,y)
111{
112 if (!CtorAllocate()) return;
113
114 for (Int_t i=0;i<n;i++) {
115 if (exl) fEXlow[i] = exl[i];
116 else fEXlow[i] = 0;
117 if (exh) fEXhigh[i] = exh[i];
118 else fEXhigh[i] = 0;
119 if (eyl) fEYlow[i] = eyl[i];
120 else fEYlow[i] = 0;
121 if (eyh) fEYhigh[i] = eyh[i];
122 else fEYhigh[i] = 0;
123
124 if (exld) fEXlowd[i] = exld[i];
125 else fEXlowd[i] = 0;
126 if (exhd) fEXhighd[i] = exhd[i];
127 else fEXhighd[i] = 0;
128 if (eyld) fEYlowd[i] = eyld[i];
129 else fEYlowd[i] = 0;
130 if (eyhd) fEYhighd[i] = eyhd[i];
131 else fEYhighd[i] = 0;
132 }
133}
134
135
136////////////////////////////////////////////////////////////////////////////////
137/// TGraphBentErrors normal constructor.
138///
139/// if exl,h or eyl,h are null, the corresponding arrays are preset to zero
140
142 const Double_t *x, const Double_t *y,
143 const Double_t *exl, const Double_t *exh,
144 const Double_t *eyl, const Double_t *eyh,
145 const Double_t *exld, const Double_t *exhd,
146 const Double_t *eyld, const Double_t *eyhd)
147 : TGraph(n,x,y)
148{
149 if (!CtorAllocate()) return;
150 auto memsz = sizeof(Double_t)*fNpoints;
151
152 if (exl) memcpy(fEXlow, exl, memsz);
153 else memset(fEXlow, 0, memsz);
154 if (exh) memcpy(fEXhigh, exh, memsz);
155 else memset(fEXhigh, 0, memsz);
156 if (eyl) memcpy(fEYlow, eyl, memsz);
157 else memset(fEYlow, 0, memsz);
158 if (eyh) memcpy(fEYhigh, eyh, memsz);
159 else memset(fEYhigh, 0, memsz);
160
161 if (exld) memcpy(fEXlowd, exld, memsz);
162 else memset(fEXlowd, 0, memsz);
163 if (exhd) memcpy(fEXhighd, exhd, memsz);
164 else memset(fEXhighd, 0, memsz);
165 if (eyld) memcpy(fEYlowd, eyld, memsz);
166 else memset(fEYlowd, 0, memsz);
167 if (eyhd) memcpy(fEYhighd, eyhd, memsz);
168 else memset(fEYhighd, 0, memsz);
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// TGraphBentErrors default destructor.
174
176{
177 delete [] fEXlow;
178 delete [] fEXhigh;
179 delete [] fEYlow;
180 delete [] fEYhigh;
181
182 delete [] fEXlowd;
183 delete [] fEXhighd;
184 delete [] fEYlowd;
185 delete [] fEYhighd;
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Add a point with bent errors to the graph.
190
197
198////////////////////////////////////////////////////////////////////////////////
199/// Apply a function to all data points \f$ y = f(x,y) \f$.
200///
201/// Errors are calculated as \f$ eyh = f(x,y+eyh)-f(x,y) \f$ and
202/// \f$ eyl = f(x,y)-f(x,y-eyl) \f$.
203///
204/// Special treatment has to be applied for the functions where the
205/// role of "up" and "down" is reversed.
206///
207/// Function suggested/implemented by Miroslav Helbich <helbich@mail.desy.de>
208
210{
212
213 if (fHistogram) {
214 delete fHistogram;
215 fHistogram = nullptr;
216 }
217 for (Int_t i = 0; i < GetN(); i++) {
218 GetPoint(i, x, y);
219 exl = GetErrorXlow(i);
220 exh = GetErrorXhigh(i);
221 eyl = GetErrorYlow(i);
222 eyh = GetErrorYhigh(i);
223
224 fxy = f->Eval(x, y);
225 SetPoint(i, x, fxy);
226
227 // in the case of the functions like y-> -1*y the roles of the
228 // upper and lower error bars is reversed
229 if (f->Eval(x,y-eyl) < f->Eval(x,y+eyh)) {
230 eyl_new = TMath::Abs(fxy - f->Eval(x,y-eyl));
231 eyh_new = TMath::Abs(f->Eval(x,y+eyh) - fxy);
232 } else {
233 eyh_new = TMath::Abs(fxy - f->Eval(x,y-eyl));
234 eyl_new = TMath::Abs(f->Eval(x,y+eyh) - fxy);
235 }
236
237 //error on x doesn't change
239 }
240 if (gPad) gPad->Modified();
241}
242
243
244////////////////////////////////////////////////////////////////////////////////
245/// Compute range.
246
248{
250
251 for (Int_t i=0;i<fNpoints;i++) {
252 if (fX[i] -fEXlow[i] < xmin) {
253 if (gPad && gPad->GetLogx()) {
254 if (fEXlow[i] < fX[i]) xmin = fX[i]-fEXlow[i];
255 else xmin = TMath::Min(xmin,fX[i]/3);
256 } else {
257 xmin = fX[i]-fEXlow[i];
258 }
259 }
260 if (fX[i] +fEXhigh[i] > xmax) xmax = fX[i]+fEXhigh[i];
261 if (fY[i] -fEYlow[i] < ymin) {
262 if (gPad && gPad->GetLogy()) {
263 if (fEYlow[i] < fY[i]) ymin = fY[i]-fEYlow[i];
264 else ymin = TMath::Min(ymin,fY[i]/3);
265 } else {
266 ymin = fY[i]-fEYlow[i];
267 }
268 }
269 if (fY[i] +fEYhigh[i] > ymax) ymax = fY[i]+fEYhigh[i];
270 }
271}
272
273
274////////////////////////////////////////////////////////////////////////////////
275/// Copy and release.
276
279{
281 if (newarrays) {
282 delete[] fEXlow;
283 fEXlow = newarrays[0];
284 delete[] fEXhigh;
285 fEXhigh = newarrays[1];
286 delete[] fEYlow;
287 fEYlow = newarrays[2];
288 delete[] fEYhigh;
289 fEYhigh = newarrays[3];
290 delete[] fEXlowd;
291 fEXlowd = newarrays[4];
292 delete[] fEXhighd;
293 fEXhighd = newarrays[5];
294 delete[] fEYlowd;
295 fEYlowd = newarrays[6];
296 delete[] fEYhighd;
297 fEYhighd = newarrays[7];
298 delete[] fX;
299 fX = newarrays[8];
300 delete[] fY;
301 fY = newarrays[9];
302 delete[] newarrays;
303 }
304}
305
306
307////////////////////////////////////////////////////////////////////////////////
308/// Copy errors from `fE*** `to `arrays[***]`
309/// or to `f***` Copy points.
310
313{
314 if (TGraph::CopyPoints(arrays ? arrays+8 : nullptr, ibegin, iend, obegin)) {
315 Int_t n = (iend - ibegin)*sizeof(Double_t);
316 if (arrays) {
325 } else {
334 }
335 return kTRUE;
336 } else {
337 return kFALSE;
338 }
339}
340
341
342////////////////////////////////////////////////////////////////////////////////
343/// Should be called from ctors after `fNpoints` has been set.
344
346{
347 if (!fNpoints) {
348 fEXlow = fEYlow = fEXhigh = fEYhigh = nullptr;
349 fEXlowd = fEYlowd = fEXhighd = fEYhighd = nullptr;
350 return kFALSE;
351 }
352 fEXlow = new Double_t[fMaxSize];
353 fEYlow = new Double_t[fMaxSize];
360 return kTRUE;
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Protected function to perform the merge operation of a graph with asymmetric errors.
365
367{
368 if (g->GetN() == 0) return kFALSE;
369
370 Double_t *exl = g->GetEXlow();
371 Double_t *exh = g->GetEXhigh();
372 Double_t *eyl = g->GetEYlow();
373 Double_t *eyh = g->GetEYhigh();
374
375 Double_t *exld = g->GetEXlowd();
376 Double_t *exhd = g->GetEXhighd();
377 Double_t *eyld = g->GetEYlowd();
378 Double_t *eyhd = g->GetEYhighd();
379
380 if (!exl || !exh || !eyl || !eyh ||
381 !exld || !exhd || !eyld || !eyhd) {
382 if (g->IsA() != TGraph::Class() )
383 Warning("DoMerge", "Merging a %s is not compatible with a TGraphBentErrors - errors will be ignored", g->IsA()->GetName());
384 return TGraph::DoMerge(g);
385 }
386 for (Int_t i = 0 ; i < g->GetN(); i++) {
387 Int_t ipoint = GetN();
388 Double_t x = g->GetX()[i];
389 Double_t y = g->GetY()[i];
390 SetPoint(ipoint, x, y);
391 SetPointError(ipoint, exl[i], exh[i], eyl[i], eyh[i],
392 exld[i], exhd[i], eyld[i], eyhd[i]);
393 }
394
395 return kTRUE;
396
397}
398////////////////////////////////////////////////////////////////////////////////
399/// It returns the error along X at point `i`.
400
402{
403 if (i < 0 || i >= fNpoints) return -1;
404 if (!fEXlow && !fEXhigh) return -1;
405 Double_t elow = 0, ehigh = 0;
406 if (fEXlow) elow = fEXlow[i];
407 if (fEXhigh) ehigh = fEXhigh[i];
408 return TMath::Sqrt(0.5*(elow*elow + ehigh*ehigh));
409}
410
411
412////////////////////////////////////////////////////////////////////////////////
413/// It returns the error along Y at point `i`.
414
416{
417 if (i < 0 || i >= fNpoints) return -1;
418 if (!fEYlow && !fEYhigh) return -1;
419 Double_t elow=0, ehigh=0;
420 if (fEYlow) elow = fEYlow[i];
421 if (fEYhigh) ehigh = fEYhigh[i];
422 return TMath::Sqrt(0.5*(elow*elow + ehigh*ehigh));
423}
424
425
426////////////////////////////////////////////////////////////////////////////////
427/// Get high error on X[i].
428
430{
431 if (i<0 || i>fNpoints) return -1;
432 if (fEXhigh) return fEXhigh[i];
433 return -1;
434}
435
436
437////////////////////////////////////////////////////////////////////////////////
438/// Get low error on X[i].
439
441{
442 if (i<0 || i>fNpoints) return -1;
443 if (fEXlow) return fEXlow[i];
444 return -1;
445}
446
447
448////////////////////////////////////////////////////////////////////////////////
449/// Get high error on Y[i].
450
452{
453 if (i<0 || i>fNpoints) return -1;
454 if (fEYhigh) return fEYhigh[i];
455 return -1;
456}
457
458
459////////////////////////////////////////////////////////////////////////////////
460/// Get low error on Y[i].
461
463{
464 if (i<0 || i>fNpoints) return -1;
465 if (fEYlow) return fEYlow[i];
466 return -1;
467}
468
469
470////////////////////////////////////////////////////////////////////////////////
471/// Set zero values for point arrays in the range `[begin, end]`
472
475{
476 if (!from_ctor) {
477 TGraph::FillZero(begin, end, from_ctor);
478 }
479 Int_t n = (end - begin)*sizeof(Double_t);
480 memset(fEXlow + begin, 0, n);
481 memset(fEXhigh + begin, 0, n);
482 memset(fEYlow + begin, 0, n);
483 memset(fEYhigh + begin, 0, n);
484 memset(fEXlowd + begin, 0, n);
485 memset(fEXhighd + begin, 0, n);
486 memset(fEYlowd + begin, 0, n);
487 memset(fEYhighd + begin, 0, n);
488}
489
490
491////////////////////////////////////////////////////////////////////////////////
492/// Print graph and errors values.
493
495{
496 for (Int_t i=0;i<fNpoints;i++) {
497 printf("x[%d]=%g, y[%d]=%g, exl[%d]=%g, exh[%d]=%g, eyl[%d]=%g, eyh[%d]=%g\n"
498 ,i,fX[i],i,fY[i],i,fEXlow[i],i,fEXhigh[i],i,fEYlow[i],i,fEYhigh[i]);
499 }
500}
501
502////////////////////////////////////////////////////////////////////////////////
503/// Multiply the values and errors of a TGraphBentErrors by a constant c1.
504///
505/// If option contains "x" the x values and errors are scaled
506/// If option contains "y" the y values and errors are scaled
507/// If option contains "xy" both x and y values and errors are scaled
508
510{
512 TString opt = option; opt.ToLower();
513 if (opt.Contains("x") && GetEXlow()) {
514 for (Int_t i=0; i<GetN(); i++)
515 GetEXlow()[i] *= c1;
516 }
517 if (opt.Contains("x") && GetEXhigh()) {
518 for (Int_t i=0; i<GetN(); i++)
519 GetEXhigh()[i] *= c1;
520 }
521 if (opt.Contains("y") && GetEYlow()) {
522 for (Int_t i=0; i<GetN(); i++)
523 GetEYlow()[i] *= c1;
524 }
525 if (opt.Contains("y") && GetEYhigh()) {
526 for (Int_t i=0; i<GetN(); i++)
527 GetEYhigh()[i] *= c1;
528 }
529 if (opt.Contains("x") && GetEXlowd()) {
530 for (Int_t i=0; i<GetN(); i++)
531 GetEXlowd()[i] *= c1;
532 }
533 if (opt.Contains("x") && GetEXhighd()) {
534 for (Int_t i=0; i<GetN(); i++)
535 GetEXhighd()[i] *= c1;
536 }
537 if (opt.Contains("y") && GetEYlowd()) {
538 for (Int_t i=0; i<GetN(); i++)
539 GetEYlowd()[i] *= c1;
540 }
541 if (opt.Contains("y") && GetEYhighd()) {
542 for (Int_t i=0; i<GetN(); i++)
543 GetEYhighd()[i] *= c1;
544 }
545}
546
547////////////////////////////////////////////////////////////////////////////////
548/// Save primitive as a C++ statement(s) on output stream out.
549
550void TGraphBentErrors::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
551{
552 auto xname = SavePrimitiveVector(out, "grbe_fx", fNpoints, fX, kTRUE);
553 auto yname = SavePrimitiveVector(out, "grbe_fy", fNpoints, fY);
554 auto exlname = SavePrimitiveVector(out, "grbe_fexl", fNpoints, fEXlow);
555 auto exhname = SavePrimitiveVector(out, "grbe_fexh", fNpoints, fEXhigh);
556 auto eylname = SavePrimitiveVector(out, "grbe_feyl", fNpoints, fEYlow);
557 auto eyhname = SavePrimitiveVector(out, "grbe_feyh", fNpoints, fEYhigh);
558 auto exldname = SavePrimitiveVector(out, "grbe_fexld", fNpoints, fEXlowd);
559 auto exhdname = SavePrimitiveVector(out, "grbe_fexhd", fNpoints, fEXhighd);
560 auto eyldname = SavePrimitiveVector(out, "grbe_feyld", fNpoints, fEYlowd);
561 auto eyhdname = SavePrimitiveVector(out, "grbe_feyhd", fNpoints, fEYhighd);
562
563 SavePrimitiveConstructor(out, Class(), "grbe",
564 TString::Format("%d, %s.data(), %s.data(), %s.data(), %s.data(), %s.data(), %s.data(), "
565 "%s.data(), %s.data(), %s.data(), %s.data()",
566 fNpoints, xname.Data(), yname.Data(), exlname.Data(), exhname.Data(),
567 eylname.Data(), eyhname.Data(), exldname.Data(), exhdname.Data(),
568 eyldname.Data(), eyhdname.Data()),
569 kFALSE);
570
571 SaveHistogramAndFunctions(out, "grbe", option);
572}
573
574
575////////////////////////////////////////////////////////////////////////////////
576/// Set ex and ey values for point pointed by the mouse.
577
580{
581 if (!gPad) {
582 Error("SetPointError", "Cannot be used without gPad, requires last mouse position");
583 return;
584 }
585
586 Int_t px = gPad->GetEventX();
587 Int_t py = gPad->GetEventY();
588
589 //localize point to be deleted
590 Int_t ipoint = -2;
591 // start with a small window (in case the mouse is very close to one point)
592 for (Int_t i = 0; i < fNpoints; i++) {
593 Int_t dpx = px - gPad->XtoAbsPixel(gPad->XtoPad(fX[i]));
594 Int_t dpy = py - gPad->YtoAbsPixel(gPad->YtoPad(fY[i]));
595 if (dpx*dpx+dpy*dpy < 25) {ipoint = i; break;}
596 }
597 if (ipoint == -2) return;
598
599 fEXlow[ipoint] = exl;
600 fEYlow[ipoint] = eyl;
601 fEXhigh[ipoint] = exh;
602 fEYhigh[ipoint] = eyh;
607
608 gPad->Modified();
609}
610
611
612////////////////////////////////////////////////////////////////////////////////
613/// Set ex and ey values for point number `i`.
614
617{
618 if (i < 0) return;
619 if (i >= fNpoints) {
620 // re-allocate the object
622 }
623 fEXlow[i] = exl;
624 fEYlow[i] = eyl;
625 fEXhigh[i] = exh;
626 fEYhigh[i] = eyh;
627 fEXlowd[i] = exld;
628 fEXhighd[i] = exhd;
629 fEYlowd[i] = eyld;
630 fEYhighd[i] = eyhd;
631}
632
633
634////////////////////////////////////////////////////////////////////////////////
635/// Swap points.
636
651
652////////////////////////////////////////////////////////////////////////////////
653/// Update the fX, fY, fEXlow, fEXhigh, fEXlowd, fEXhighd, fEYlow, fEYhigh, fEYlowd,
654/// and fEYhighd arrays with the sorted values.
655
657{
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);
662
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);
667
668 // Fill the sorted X and Y error values based on the sorted indices
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++]]; });
677
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++]]; });
686
687 // Copy the sorted X and Y error values back to the original arrays
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);
692
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);
697
699}
#define f(i)
Definition RSha256.hxx:104
#define g(i)
Definition RSha256.hxx:105
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t option
float xmin
float ymin
float xmax
float ymax
#define gPad
const_iterator begin() const
const_iterator end() const
1-Dim function class
Definition TF1.h:182
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 arrays ...
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
static TClass * Class()
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.
Definition TGraph.h:41
static TClass * Class()
virtual void AddPoint(Double_t x, Double_t y)
Append a new point to the graph.
Definition TGraph.h:97
Int_t fNpoints
Number of points <= fMaxSize.
Definition TGraph.h:46
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition TGraph.cxx:2290
Int_t fMaxSize
!Current dimension of arrays fX and fY
Definition TGraph.h:45
TH1F * fHistogram
Pointer to histogram used for drawing axis.
Definition TGraph.h:50
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.
Definition TGraph.cxx:2540
Int_t GetN() const
Definition TGraph.h:131
Double_t * fY
[fNpoints] array of Y points
Definition TGraph.h:48
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.
Definition TGraph.cxx:732
virtual void Scale(Double_t c1=1., Option_t *option="y")
Multiply the values of a TGraph by a constant c1.
Definition TGraph.cxx:2207
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
Definition TGraph.cxx:2559
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
Definition TGraph.cxx:2624
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
Definition TGraph.cxx:2531
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.
Definition TGraph.cxx:1103
void SaveHistogramAndFunctions(std::ostream &out, const char *varname, Option_t *option)
Save histogram and list of functions of TGraph as C++ statement Used in all TGraph-derived classes.
Definition TGraph.cxx:2163
Double_t * fX
[fNpoints] array of X points
Definition TGraph.h:47
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
Definition TGraph.cxx:1533
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 !...
Definition TGraph.cxx:780
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Bool_t empty_line=kFALSE)
Save array in the output stream "out" as vector.
Definition TObject.cxx:788
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
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".
Definition TObject.cxx:771
Basic string class.
Definition TString.h:138
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2384
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:640
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TGraphErrors * gr
Definition legend1.C:25
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:199
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124