Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TRatioPlot.cxx
Go to the documentation of this file.
1// @(#)root/gpad:$Id$
2// Author: Paul Gessinger 25/08/2016
3
4/*************************************************************************
5 * Copyright (C) 1995-2024, 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 "TRatioPlot.h"
13#include "TROOT.h"
14#include "TBrowser.h"
15#include "TH1.h"
16#include "TF1.h"
17#include "TPad.h"
18#include "TString.h"
19#include "TMath.h"
20#include "TGraphAsymmErrors.h"
21#include "TGraphErrors.h"
22#include "TGaxis.h"
23#include "TLine.h"
24#include "TVirtualFitter.h"
25#include "TFitResult.h"
26#include "THStack.h"
27
28/** \class TRatioPlot
29 \ingroup gpad
30Class for displaying ratios, differences and fit residuals.
31
32TRatioPlot has two constructors, one which accepts two histograms, and is responsible
33for setting up the calculation of ratios and differences. This calculation is in part
34delegated to `TEfficiency`. A single option can be given as a parameter, that is
35used to determine which procedure is chosen. The remaining option string is then
36passed through to the calculation, if applicable. The other constructor uses a
37fitted histogram to calculate the fit residual and plot it with the histogram
38and the fit function.
39
40## Ratios and differences
41The simplest case is passing two histograms without specifying any options. This defaults to using
42`TGraphAsymmErrors::Divide`. The `option` variable is passed through, as are the parameters
43`c1` and `c2`, that you can set via `TRatioPlot::SetC1` and `TRatioPlot::SetC1`. If you set the
44`option` to `divsym` the method `TH1::Divide` will be used instead, also receiving all the parameters.
45
46Using the `option` `diff` or `diffsig`, both histograms will be subtracted, and in the case of diffsig,
47the difference will be divided by the uncertainty. `c1` and `c2` will only be used to
48scale the histograms using `TH1::Scale` prior to subtraction.
49
50Available options are for `option`:
51| Option | Description |
52| ---------- | ------------------------------------------------------------ |
53| divsym | uses the histogram `TH1::Divide` method, yields symmetric errors |
54| diff | subtracts the histograms |
55| diffsig | subtracts the histograms and divides by the uncertainty |
56
57Begin_Macro(source)
58../../../tutorials/hist/ratioplot1.C
59End_Macro
60
61## Fit residuals
62A second constructor only accepts a single histogram, but expects it to have a fitted
63function. The function is used to calculate the residual between the fit and the
64histogram. Here, it is expected that h1 has a fit function in it's list of functions. The class calculates the
65difference between the histogram and the fit function at each point and divides it by the uncertainty. There
66are a few option to steer which error is used (as is the case for `diffsig`). The default is to use
67the statistical uncertainty from h1 using `TH1::GetBinError`. If the `option` string contains `errasym`, asymmetric
68errors will be used. The type of error can be steered by `TH1::SetBinErrorOption`. The corresponding error will be used,
69depending on if the function is below or above the bin content. The third option `errfunc` uses the square root of
70the function value as the error.
71
72
73Begin_Macro(source)
74../../../tutorials/hist/ratioplot2.C
75End_Macro
76
77## Error options for difference divided by uncertainty and fit residual
78The uncertainty that is used in the calculation can be steered by providing
79options to the `option` argument.
80
81| Option | Description |
82| ---------- | ------------------------------------------------------------ |
83| errasym | Uses calculated asymmetric errors from `TH1::GetBinErrorUp`/`TH1::GetBinErrorLow`. Note that you need to set `TH1::SetBinErrorOption` first |
84| errfunc | Uses \f$ \sqrt{f(x)} \f$ as the error |
85
86The asymmetric error case uses the upper or lower error depending on the relative size
87of the bin contents, or the bin content and the function value.
88
89## Access to internal parts
90You can access the internal objects that are used to construct the plot via a series of
91methods. `TRatioPlot::GetUpperPad` and `TRatioPlot::GetLowerPad` can be used to draw additional
92elements on top of the existing ones.
93`TRatioPlot::GetLowerRefGraph` returns a reference to the lower pad's graph that
94is responsible for the range, which enables you to modify the range.
95
96\image html gpad_ratioplot.png
97*/
98
99
100////////////////////////////////////////////////////////////////////////////////
101/// TRatioPlot default constructor
102
104{
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// Destructor
109
111{
112 delete fSharedXAxis;
113 delete fUpYaxis;
114 delete fLowYaxis;
115
119 }
120
121 // special case when fH1 created from the stack but not drawn - need to delete it
123 delete fH1;
124}
125
126////////////////////////////////////////////////////////////////////////////////
127/// Internal method that shares constructor logic
128
130{
131
132 fH1 = h1;
133 fH2 = h2;
134
135 SetupPads();
136
137 TString optionString = option;
138
139 if (optionString.Contains("divsym")) {
140 optionString.ReplaceAll("divsym", "");
142 } else if (optionString.Contains("diffsig")) {
143 optionString.ReplaceAll("diffsig", "");
145
146 // determine which error style
147 if (optionString.Contains("errasym")) {
149 optionString.ReplaceAll("errasym", "");
150 }
151
152 if (optionString.Contains("errfunc")) {
154 optionString.ReplaceAll("errfunc", "");
155 }
156 } else if (optionString.Contains("diff")) {
157 optionString.ReplaceAll("diff", "");
159 } else {
160 fMode = CalculationMode::kDivideGraph; // <- default
161 }
162
163 fOption = optionString;
164
165
166 fH1DrawOpt = "hist";
167 fH2DrawOpt = "E";
168 fGraphDrawOpt = "AP";
169
170
171 // build ratio, everything is ready
172 if (!BuildLowerPlot()) return;
173
174 // taking x axis information from h1 by cloning it x axis
175 fSharedXAxis = static_cast<TAxis *>(fH1->GetXaxis()->Clone());
176 fUpYaxis = static_cast<TAxis *>(fH1->GetYaxis()->Clone());
177 fLowYaxis = static_cast<TAxis *>(fRatioGraph->GetYaxis()->Clone());
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Constructor for two histograms
182///
183/// \param h1 First histogram
184/// \param h2 Second histogram
185/// \param option Steers the error calculation, as well as ratio / difference
186
188{
189 if (!h1 || !h2) {
190 Warning("TRatioPlot", "Need two histograms.");
191 return;
192 }
193
194 Bool_t h1IsTH1 = h1->InheritsFrom(TH1::Class());
195 Bool_t h2IsTH1 = h2->InheritsFrom(TH1::Class());
196
197 if (!h1IsTH1 && !h2IsTH1) {
198 Warning("TRatioPlot", "Need two histograms deriving from TH2 or TH3.");
199 return;
200 }
201
203
204 Init(h1, h2, option);
205
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Constructor which accepts a `THStack` and a histogram. Converts the
210/// stack to a regular sum of its containing histograms for processing.
211///
212/// \param st The THStack object
213/// \param h2 The other histogram
214/// \param option Steers the calculation of the lower plot
215
217{
218 if (!st || !h2) {
219 Warning("TRatioPlot", "Need a histogram and a stack");
220 return;
221 }
222
223 TList *stackHists = st->GetHists();
224
225 if (stackHists->GetSize() == 0) {
226 Warning("TRatioPlot", "Stack does not have histograms");
227 return;
228 }
229
230 auto tmpHist = static_cast<TH1 *>(stackHists->At(0)->Clone());
231 tmpHist->Reset();
232
233 for (int i = 0; i < stackHists->GetSize(); ++i) {
234 tmpHist->Add(static_cast<TH1 *>(stackHists->At(i)));
235 }
236
237 fHistDrawProxy = st;
239
240 Init(tmpHist, h2, option);
241
242}
243
244////////////////////////////////////////////////////////////////////////////////
245/// Constructor for one histogram and a fit.
246///
247/// \param h1 The histogram
248/// \param option Steers the error calculation
249/// \param fitres Explicit fit result to be used for calculation. Uses last fit if left empty
250
252 : fH1(h1)
253{
254 if (!fH1) {
255 Warning("TRatioPlot", "Need a histogram.");
256 return;
257 }
258
259 Bool_t h1IsTH1 = fH1->InheritsFrom(TH1::Class());
260
261 if (!h1IsTH1) {
262 Warning("TRatioPlot", "Need a histogram deriving from TH2 or TH3.");
263 return;
264 }
265
266 TList *h1Functions = fH1->GetListOfFunctions();
267
268 if (h1Functions->GetSize() < 1) {
269 Warning("TRatioPlot", "Histogram given needs to have a (fit) function associated with it");
270 return;
271 }
272
273
275
276 fFitResult = fitres;
277
279
280 TString optionString = option;
281
282 // determine which error style
283 if (optionString.Contains("errasym")) {
285 optionString.ReplaceAll("errasym", "");
286 }
287
288 if (optionString.Contains("errfunc")) {
290 optionString.ReplaceAll("errfunc", "");
291 }
292
293 fOption = optionString;
294
295 if (!BuildLowerPlot()) return;
296
297 // emulate option behaviour of TH1
298 if (fH1->GetSumw2N() > 0) {
299 fH1DrawOpt = "E";
300 } else {
301 fH1DrawOpt = "hist";
302 }
303 fGraphDrawOpt = "LX"; // <- default
304
305 fSharedXAxis = static_cast<TAxis *>(fH1->GetXaxis()->Clone());
306 fUpYaxis = static_cast<TAxis *>(fH1->GetYaxis()->Clone());
307 fLowYaxis = static_cast<TAxis *>(fRatioGraph->GetYaxis()->Clone());
308
309 //SyncAxesRanges();
310
311 SetupPads();
312
313}
314
315////////////////////////////////////////////////////////////////////////////////
316/// Sets the drawing option for h1
317
319{
320 fH1DrawOpt = opt;
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// Sets the drawing option for h2
325
327{
328 TString optString = opt;
329 optString.ReplaceAll("same", "");
330 optString.ReplaceAll("SAME", "");
331
332 fH2DrawOpt = optString;
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Sets the drawing option for the lower graph
337
339{
340 fGraphDrawOpt = opt;
341}
342
343////////////////////////////////////////////////////////////////////////////////
344/// Sets the drawing option for the fit in the fit residual case
345
347{
348 fFitDrawOpt = opt;
349}
350
351////////////////////////////////////////////////////////////////////////////////
352/// Setup the pads.
353
355{
356 // this method will delete all the pads before recreating them
357
358 if (fUpperPad) {
359 delete fUpperPad;
360 fUpperPad = nullptr;
361 }
362
363 if (fLowerPad) {
364 delete fLowerPad;
365 fLowerPad = nullptr;
366 }
367
368 if (!gPad) {
369 Error("SetupPads", "need to create a canvas first");
370 return;
371 }
372
373 double pm = fInsetWidth;
374 double width = gPad->GetWNDC();
375 double height = gPad->GetHNDC();
376 double f = height/width;
377
378 fUpperPad = new TPad("upper_pad", "", pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
379 fLowerPad = new TPad("lower_pad", "", pm*f, pm, 1.-pm*f, fSplitFraction);
380
382
383 // connect to the pads signal
384
385 if (fTopPad) {
386 delete fTopPad;
387 fTopPad = nullptr;
388 }
389
390 fTopPad = new TPad("top_pad", "", pm*f, pm, 1-pm*f, 1-pm);
391
393}
394
395////////////////////////////////////////////////////////////////////////////////
396/// Connect some signals from the pads to handle them
397/// Allows correctly work also after reading ratioplot from the file
398
400{
401 static const char *rangeSignal = "RangeAxisChanged()";
402
403 if (fUpperPad->HasConnection(rangeSignal) && fLowerPad->HasConnection(rangeSignal))
404 return;
405
406 fUpperPad->Connect(rangeSignal, ClassName(), this, "RangeAxisChanged()");
407 fLowerPad->Connect(rangeSignal, ClassName(), this, "RangeAxisChanged()");
408
409 fUpperPad->Connect("UnZoomed()", ClassName(), this, "UnZoomed()");
410 fLowerPad->Connect("UnZoomed()", ClassName(), this, "UnZoomed()");
411
412 fUpperPad->Connect("Resized()", ClassName(), this, "SubPadResized()");
413 fLowerPad->Connect("Resized()", ClassName(), this, "SubPadResized()");
414
415}
416
417////////////////////////////////////////////////////////////////////////////////
418/// Sets the top margin of the upper pad.
419///
420/// \param margin The new margin
421
423{
424 fUpTopMargin = margin;
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Sets the bottom margin of the upper pad.
430///
431/// \param margin The new margin
432
434{
435 fUpBottomMargin = margin;
437}
438
439////////////////////////////////////////////////////////////////////////////////
440/// Sets the top margin of the lower pad.
441///
442/// \param margin The new margin
443
445{
446 fLowTopMargin = margin;
448}
449
450////////////////////////////////////////////////////////////////////////////////
451/// Sets the bottom margin of the lower pad.
452///
453/// \param margin The new margin
454
456{
457 fLowBottomMargin = margin;
459}
460
461////////////////////////////////////////////////////////////////////////////////
462/// Sets the left margin of both pads.
463/// \param margin The new margin
464
466{
467 fLeftMargin = margin;
469}
470
471////////////////////////////////////////////////////////////////////////////////
472/// Sets the right margin of both pads.
473///
474/// \param margin The new margin
475
477{
478 fRightMargin = margin;
480}
481
482////////////////////////////////////////////////////////////////////////////////
483/// Sets the margin that separates the two pads. The margin is split according
484/// to the relative sizes of the pads
485///
486/// \param margin The new margin
487///
488/// Begin_Macro(source)
489/// ../../../tutorials/hist/ratioplot6.C
490/// End_Macro
491
493{
495 fUpBottomMargin = margin/2./(1-sf);
496 fLowTopMargin = margin/2./sf;
498}
499
500////////////////////////////////////////////////////////////////////////////////
501/// Return the separation margin value.
502
504{
506 Float_t up = fUpBottomMargin * (1-sf);
507 Float_t down = fLowTopMargin * sf;
508 return up+down;
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Draws the ratio plot to the currently active pad. Therefore it requires that
513/// a TCanvas has been created first.
514///
515/// It takes the following options
516///
517/// | Option | Description |
518/// | ---------- | ------------------------------------------------------------ |
519/// | grid / nogrid | enable (default) or disable drawing of dashed lines on lower plot |
520/// | hideup | hides the first label of the upper axis if there is not enough space |
521/// | fhideup | always hides the first label of the upper axis |
522/// | hidelow (default) | hides the last label of the lower axis if there is not enough space |
523/// | fhidelow | always hides the last label of the lower axis |
524/// | nohide | does not hide a label if there is not enough space |
525/// | noconfint | does not draw the confidence interval bands in the fit residual case |
526/// | confint | draws the confidence interval bands in the fit residual case (default) |
527
529{
530
531 TString drawOpt = option;
532
533 if (drawOpt.Contains("nogrid")) {
534 drawOpt.ReplaceAll("nogrid", "");
536 } else if (drawOpt.Contains("grid")) {
537 drawOpt.ReplaceAll("grid", "");
539 }
540
541 if (drawOpt.Contains("noconfint")) {
542 drawOpt.ReplaceAll("noconfint", "");
544 } else if (drawOpt.Contains("confint")) {
545 drawOpt.ReplaceAll("confint", "");
546 fShowConfidenceIntervals = kTRUE; // <- default
547 }
548
549 if (drawOpt.Contains("fhideup")) {
551 } else if (drawOpt.Contains("fhidelow")) {
553 } else if (drawOpt.Contains("hideup")) {
555 } else if (drawOpt.Contains("hidelow")) {
557 } else if (drawOpt.Contains("nohide")) {
559 } else {
561 }
562
563 if (!gPad) {
564 Error("Draw", "need to create a canvas first");
565 return;
566 }
567
569
570 // draw ratio plot as very first object
571 // when painting one can update all attributes before other objects are painted
572 AppendPad();
573
577
582
583 // we are a TPad
584
585 fUpperPad->Draw();
586 fLowerPad->Draw();
587
589 fTopPad->Draw();
590
591 fUpperPad->cd();
592
595
597 // use last function in the list
598 TF1 *func = nullptr;
599 for (int i = fH1->GetListOfFunctions()->GetSize()-1; i >= 0; i--) {
600 auto obj = fH1->GetListOfFunctions()->At(i);
601 if (obj->InheritsFrom(TF1::Class()) ) {
602 func = dynamic_cast<TF1*>(obj);
603 break;
604 }
605 }
606 if (!func) {
607 // this is checked in constructor and should thus not occur
608 Error("Draw", "h1 does not have a fit function");
609 return;
610 }
611
612 fH1->Draw("A"+fH1DrawOpt);
613 func->Draw(fFitDrawOpt+"same");
614
615 fLowerPad->cd();
616
621 } else {
622 fRatioGraph->Draw("IA"+fGraphDrawOpt+"SAME");
623 }
624 } else {
625
626 if (fHistDrawProxy) {
629 } else {
630 Warning("Draw", "Draw proxy not of type TH1 or THStack, not drawing it");
631 }
632 }
633
634 fH2->Draw("A"+fH2DrawOpt+"same");
635
636 fLowerPad->cd();
637
640
641 }
642
643 // assign same axis ranges to lower pad as in upper pad
644 // the visual axes will be created on paint
646
648
650
651 // restore active pad at the end
652 fParentPad->cd();
653
654 // only after object drawn connect signals
656}
657
658////////////////////////////////////////////////////////////////////////////////
659/// Returns the reference graph for the lower pad, which means the graph that
660/// is responsible for setting the coordinate system. It is the first graph
661/// added to the primitive list of the lower pad.
662/// This reference can be used to set the minimum and maximum of the lower pad.
663/// Note that `TRatioPlot::Draw` needs to have been called first, since the
664/// graphs are only created then.
665///
666/// Begin_Macro(source)
667/// ../../../tutorials/hist/ratioplot3.C
668/// End_Macro
669
671{
672 if (!fLowerPad) {
673 Error("GetLowerRefGraph", "Lower pad has not been defined");
674 return nullptr;
675 }
676
677 TList *primlist = fLowerPad->GetListOfPrimitives();
678 if (primlist->GetSize() == 0) {
679 Error("GetLowerRefGraph", "Lower pad does not have primitives");
680 return nullptr;
681 }
682
683 TObjLink *lnk = primlist->FirstLink();
684
685 while (lnk) {
686 TObject *obj = lnk->GetObject();
687
688 if (obj->InheritsFrom(TGraph::Class()))
689 return static_cast<TGraph *>(obj);
690
691 lnk = lnk->Next();
692 }
693
694 Error("GetLowerRefGraph", "Did not find graph in list");
695 return nullptr;
696}
697
698////////////////////////////////////////////////////////////////////////////////
699/// Return the reference object. Its the first TH1 or THStack type object
700/// in the upper pads list of primitives.
701/// Note that it returns a `TObject`, so you need to test and cast it to use it.
702
704{
705 TList *primlist = fUpperPad->GetListOfPrimitives();
706 for (Int_t i = 0; i < primlist->GetSize(); ++i) {
707 auto refobj = primlist->At(i);
708 if (refobj->InheritsFrom(TH1::Class()) || refobj->InheritsFrom(THStack::Class())) {
709 return refobj;
710 }
711 }
712
713 Error("GetUpperRefObject", "No upper ref object of TH1 or THStack type found");
714 return nullptr;
715}
716
717////////////////////////////////////////////////////////////////////////////////
718/// Gets the x axis of the object returned by `TRatioPlot::GetUpperRefObject`.
719
721{
722 TObject *refobj = GetUpperRefObject();
723
724 if (!refobj)
725 return nullptr;
726
727 if (refobj->InheritsFrom(TH1::Class())) {
728 return static_cast<TH1 *>(refobj)->GetXaxis();
729 } else if (refobj->InheritsFrom(THStack::Class())) {
730 return static_cast<THStack *>(refobj)->GetXaxis();
731 }
732
733 return nullptr;
734}
735
736////////////////////////////////////////////////////////////////////////////////
737/// Gets the y axis of the object returned by `TRatioPlot::GetUpperRefObject`.
738
740{
741 TObject *refobj = GetUpperRefObject();
742
743 if (!refobj)
744 return nullptr;
745
746 if (refobj->InheritsFrom(TH1::Class())) {
747 return static_cast<TH1 *>(refobj)->GetYaxis();
748 } else if (refobj->InheritsFrom(THStack::Class())) {
749 return static_cast<THStack *>(refobj)->GetYaxis();
750 }
751
752 return nullptr;
753}
754
755////////////////////////////////////////////////////////////////////////////////
756/// Gets the x axis of the lower ref graph.
757/// Shortcut for:
758///
759/// ~~~{.cpp}
760/// rp->GetLowerRefGraph()->GetXaxis();
761/// ~~~
762
764{
765 auto gr = GetLowerRefGraph();
766 return gr ? gr->GetXaxis() : nullptr;
767}
768
769////////////////////////////////////////////////////////////////////////////////
770/// Gets the y axis of the lower ref graph.
771/// Shortcut for:
772///
773/// ~~~{.cpp}
774/// rp->GetLowerRefGraph()->GetYaxis();
775/// ~~~
776
778{
779 auto gr = GetLowerRefGraph();
780 return gr ? gr->GetYaxis() : nullptr;
781}
782
783////////////////////////////////////////////////////////////////////////////////
784/// Create a grid lines
785
787{
788
789 if (!fShowGridlines)
790 return; // don't draw them
791
792 while (fGridlines.size() < fGridlinePositions.size()) {
793 TLine *newline = new TLine(0, 0, 0, 0);
794 newline->SetLineStyle(2);
795 fLowerPad->GetListOfPrimitives()->Add(newline);
796 fGridlines.emplace_back(newline);
797 }
798
800}
801
802////////////////////////////////////////////////////////////////////////////////
803/// Update positions of grid lines
804
806{
809
810 Double_t lowYFirst = fLowerPad->GetUymin();
811 Double_t lowYLast = fLowerPad->GetUymax();
812
813 for (size_t i = 0; i < fGridlines.size(); ++i) {
814 auto line = fGridlines.at(i);
815 Bool_t visible = kFALSE;
816 Double_t y = 0.;
817 if (i < fGridlinePositions.size()) {
819 visible = (y >= lowYFirst && y <= lowYLast);
820 }
821
822 if (visible) {
823 line->SetX1(first);
824 line->SetX2(last);
825 line->SetY1(y);
826 line->SetY2(y);
827 } else {
828 line->SetX1(first);
829 line->SetX2(first);
830 line->SetY1(lowYFirst);
831 line->SetY2(lowYFirst);
832 }
833 }
834}
835
836
837////////////////////////////////////////////////////////////////////////////////
838/// Update the visual axes and grid lines when painting
839
841{
842 // painting invoked before object drawn to the end - just ignore here
843 if (!fUpperGXaxis)
844 return;
845
847
850
851 // in any case reset flag after painting
853}
854
855////////////////////////////////////////////////////////////////////////////////
856/// Syncs the axes ranges from the shared ones to the actual ones.
857
859{
860 // get ranges from the shared axis clone
863
864 // set range on computed graph, have to set it twice because
865 // TGraph's axis looks strange otherwise
866 TAxis *ref = GetLowerRefXaxis();
867 ref->SetLimits(first, last);
868 ref->SetRangeUser(first, last);
869
870 GetUpperRefXaxis()->SetRangeUser(first, last);
871}
872
873////////////////////////////////////////////////////////////////////////////////
874/// Build the lower plot according to which constructor was called, and
875/// which options were passed.
876
878{
879 static const char *thisMethod = "BuildLowerPlot";
880
881 // Clear and delete the graph if not exists
882 if (fRatioGraph) {
883 delete fRatioGraph;
884 fRatioGraph = nullptr;
885 }
886
889
892
893 static Double_t divideGridlines[] = {0.7, 1.0, 1.3};
894 static Double_t diffGridlines[] = {0.0};
895 static Double_t signGridlines[] = {1.0, 0.0, -1.0};
896
897 // Determine the divide mode and create the lower graph accordingly
898 // Pass divide options given in constructor
900 // use TGraphAsymmErrors Divide method to create
901
902 SetGridlines(divideGridlines, 3);
903
904 TH1 *tmpH1 = static_cast<TH1 *>(fH1->Clone());
905 TH1 *tmpH2 = static_cast<TH1 *>(fH2->Clone());
906
907 tmpH1->Scale(fC1);
908 tmpH2->Scale(fC2);
909
910 TGraphAsymmErrors *ratioGraph = new TGraphAsymmErrors();
911 ratioGraph->Divide(tmpH1, tmpH2, fOption.Data());
912 fRatioGraph = ratioGraph;
913
914 delete tmpH1;
915 delete tmpH2;
916
917 } else if (fMode == CalculationMode::kDifference) {
918 SetGridlines(diffGridlines, 3);
919
920 TH1 *tmpHist = static_cast<TH1 *>(fH1->Clone());
921
922 tmpHist->Reset();
923
924 tmpHist->Add(fH1, fH2, fC1, -1*fC2);
925 fRatioGraph = new TGraphErrors(tmpHist);
926
927 delete tmpHist;
929
930 SetGridlines(signGridlines, 3);
931
933 Int_t ipoint = 0;
934
935 for (Int_t i = 0; i <= fH1->GetNbinsX(); ++i) {
936 Double_t val = fH1->GetBinContent(i);
937 Double_t val2 = fH2->GetBinContent(i);
938 Double_t error = 0.;
939
941
942 Double_t errUp = fH1->GetBinErrorUp(i);
943 Double_t errLow = fH1->GetBinErrorLow(i);
944
945 if (val - val2 > 0) {
946 // h1 > h2
947 error = errLow;
948 } else {
949 // h1 < h2
950 error = errUp;
951 }
952
954 error = fH1->GetBinError(i);
955 } else {
956 Warning(thisMethod, "error mode is invalid");
957 }
958
959 if (error != 0.) {
960
961 Double_t res = (val - val2) / error;
962
963 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
964 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
965
966 ++ipoint;
967
968 }
969 }
970
971 } else if (fMode == CalculationMode::kFitResidual) {
972
973 SetGridlines(signGridlines, 3);
974
975 TF1 *func = dynamic_cast<TF1*>(fH1->GetListOfFunctions()->At(0));
976
977 if (!func) {
978 // this is checked in constructor and should thus not occur
979 Error(thisMethod, "h1 does not have a fit function");
980 return 0;
981 }
982
984 Int_t ipoint = 0;
985
986 std::vector<double> ci1, ci2;
987
988 Int_t nbinsx = fH1->GetNbinsX();
989
990 std::vector<Double_t> x_arr(nbinsx, 0.), ci_arr1(nbinsx, 0.), ci_arr2(nbinsx, 0);
991 for (Int_t i = 0; i < nbinsx; ++i)
992 x_arr[i] = fH1->GetBinCenter(i+1);
993
994 Double_t cl1 = fCl1, cl2 = fCl2;
995
996 if (fFitResult) {
997 // use this to get conf int
998
999 fFitResult->GetConfidenceIntervals(nbinsx, 1, 1, x_arr.data(), ci_arr1.data(), cl1);
1000 for (Int_t i = 1; i <= nbinsx; ++i)
1001 ci1.push_back(ci_arr1[i - 1]);
1002
1003 fFitResult->GetConfidenceIntervals(nbinsx, 1, 1, x_arr.data(), ci_arr2.data(), cl2);
1004 for (Int_t i = 1; i <= nbinsx; ++i)
1005 ci2.push_back(ci_arr2[i - 1]);
1006 } else {
1007 TVirtualFitter::GetFitter()->GetConfidenceIntervals(nbinsx, 1, x_arr.data(), ci_arr1.data(), cl1);
1008 for (Int_t i = 1; i <= nbinsx; ++i)
1009 ci1.push_back(ci_arr1[i - 1]);
1010 TVirtualFitter::GetFitter()->GetConfidenceIntervals(nbinsx, 1, x_arr.data(), ci_arr2.data(), cl2);
1011 for (Int_t i = 1; i <= nbinsx; ++i)
1012 ci2.push_back(ci_arr2[i - 1]);
1013 }
1014
1015 for (Int_t i = 1; i <= nbinsx; ++i) {
1016 Double_t val = fH1->GetBinContent(i);
1017 Double_t x = fH1->GetBinCenter(i);
1018 Double_t error = 0.;
1019
1021
1022 Double_t errUp = fH1->GetBinErrorUp(i);
1023 Double_t errLow = fH1->GetBinErrorLow(i);
1024
1025 if (val - func->Eval(fH1->GetBinCenter(i)) > 0) {
1026 // h1 > fit
1027 error = errLow;
1028 } else {
1029 // h1 < fit
1030 error = errUp;
1031 }
1032
1033 } else if (fErrorMode == ErrorMode::kErrorSymmetric) {
1034
1035 error = fH1->GetBinError(i);
1036
1037 } else if (fErrorMode == ErrorMode::kErrorFunc) {
1038
1039 error = sqrt(func->Eval(x));
1040
1041 } else {
1042
1043 Warning(thisMethod, "error mode is invalid");
1044
1045 }
1046
1047 if (error != 0.) {
1048
1049 Double_t res = (fH1->GetBinContent(i) - func->Eval(fH1->GetBinCenter(i))) / error;
1050
1051 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
1052 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
1053
1054 fConfidenceInterval1->SetPoint(ipoint, x, 0);
1055 fConfidenceInterval1->SetPointError(ipoint, x, i <= (Int_t)ci1.size() ? ci1[i-1] / error : 0);
1056 fConfidenceInterval2->SetPoint(ipoint, x, 0);
1057 fConfidenceInterval2->SetPointError(ipoint, x, i <= (Int_t)ci2.size() ? ci2[i-1] / error : 0);
1058
1059 ++ipoint;
1060
1061 }
1062 }
1063 } else if (fMode == CalculationMode::kDivideHist){
1064 SetGridlines(divideGridlines, 3);
1065
1066 // Use TH1's Divide method
1067 TH1 *tmpHist = static_cast<TH1 *>(fH1->Clone());
1068 tmpHist->Reset();
1069
1070 tmpHist->Divide(fH1, fH2, fC1, fC2, fOption.Data());
1071 fRatioGraph = new TGraphErrors(tmpHist);
1072
1073 delete tmpHist;
1074 } else {
1075 // this should not occur
1076 Error(thisMethod, "Invalid fMode value");
1077 return 0;
1078 }
1079
1080 // need to set back to "" since recreation. we don't ever want
1081 // title on lower graph
1082
1083 if (!fRatioGraph) {
1084 Error(thisMethod, "Error creating lower graph");
1085 return 0;
1086 }
1087
1088 fRatioGraph->SetTitle("");
1091
1092 return 1;
1093}
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// Creates the TGaxis objects that are used for consistent display of the axes.
1097
1099{
1100 Bool_t mirroredAxes = fParentPad->GetFrameFillStyle() == 0;
1101 Bool_t axistop = fParentPad->GetTickx() == 1 || mirroredAxes;
1102 Bool_t axisright = fParentPad->GetTicky() == 1 || mirroredAxes;
1103
1106
1107 Double_t upYFirst = fUpperPad->GetUymin();
1108 Double_t upYLast = fUpperPad->GetUymax();
1109 Double_t lowYFirst = fLowerPad->GetUymin();
1110 Double_t lowYLast = fLowerPad->GetUymax();
1111
1112 if (!fUpperGXaxis) {
1113 fUpperGXaxis = new TGaxis(0, 0, 1, 1, 0, 1, 510, "+U");
1115 }
1116
1117 if (!fUpperGYaxis) {
1118 fUpperGYaxis = new TGaxis(0, 0, 1, 1, upYFirst, upYLast, 510, "S");
1120 }
1121
1122 if (!fLowerGXaxis) {
1123 fLowerGXaxis = new TGaxis(0, 0, 1, 1, first, last, 510, "+S");
1125 }
1126
1127 if (!fLowerGYaxis) {
1128 fLowerGYaxis = new TGaxis(0, 0, 1, 1, lowYFirst, lowYLast, 510, "-S");
1130 }
1131
1132 // Create the axes on the other sides of the graphs
1133 // This is steered by an option on the containing pad or self
1134
1135 if (!fUpperGXaxisMirror && axistop) {
1136 fUpperGXaxisMirror = static_cast<TGaxis *>(fUpperGXaxis->Clone());
1138 }
1139
1140 if (!fLowerGXaxisMirror && axistop) {
1141 fLowerGXaxisMirror = static_cast<TGaxis *>(fLowerGXaxis->Clone());
1143 }
1144
1145 if (!fUpperGYaxisMirror && axisright) {
1146 fUpperGYaxisMirror = static_cast<TGaxis *>(fUpperGYaxis->Clone());
1148 }
1149
1150 if (!fLowerGYaxisMirror && axisright) {
1151 fLowerGYaxisMirror = static_cast<TGaxis *>(fLowerGYaxis->Clone());
1153 }
1154
1156}
1157
1158
1159////////////////////////////////////////////////////////////////////////////////
1160/// Update TGaxis attributes
1161
1163{
1164 // this is for errors
1165 static const char *thisMethod = "UpdateVisualAxes";
1166
1167 // figure out where the axis has to go.
1168 // Implicit assumption is, that the top pad spans the full other pads
1173
1174 Double_t lowTM = fLowerPad->GetTopMargin();
1176 Double_t lowLM = fLowerPad->GetLeftMargin();
1178
1181
1182 Double_t upYFirst = fUpperPad->GetUymin();
1183 Double_t upYLast = fUpperPad->GetUymax();
1184 Double_t lowYFirst = fLowerPad->GetUymin();
1185 Double_t lowYLast = fLowerPad->GetUymax();
1186
1188
1189 Bool_t logx = fUpperPad->GetLogx() || fLowerPad->GetLogx();
1190 Bool_t uplogy = fUpperPad->GetLogy();
1191 Bool_t lowlogy = fLowerPad->GetLogy();
1192
1193 if (uplogy) {
1194
1195 upYFirst = TMath::Power(10, upYFirst);
1196 upYLast = TMath::Power(10, upYLast);
1197
1198 if (upYFirst <= 0 || upYLast <= 0) {
1199 Error(thisMethod, "Cannot set upper Y axis to log scale");
1200 }
1201 }
1202
1203 if (lowlogy) {
1204 lowYFirst = TMath::Power(10, lowYFirst);
1205 lowYLast = TMath::Power(10, lowYLast);
1206
1207 if (lowYFirst <= 0 || lowYLast <= 0) {
1208 Error(thisMethod, "Cannot set lower Y axis to log scale");
1209 }
1210
1211 }
1212
1213 // this is different than in y, y already has pad coords converted, x not...
1214 if (logx) {
1215 if (first <= 0 || last <= 0) {
1216 Error(thisMethod, "Cannot set X axis to log scale");
1217 }
1218 }
1219
1220 // determine axes options to create log axes if needed
1221 TString xopt = logx ? "G" : "";
1222 TString upyopt = uplogy ? "G" : "";
1223 TString lowyopt = lowlogy ? "G" : "";
1224
1225 // import infos from TAxis
1230
1231 // lower x axis needs to get title from upper x
1233
1234 // (re)set all the axes properties to what we want them
1236
1237 fUpperGXaxis->SetX1(upLM);
1238 fUpperGXaxis->SetX2(1-upRM);
1239 fUpperGXaxis->SetY1(upBM*(1-sf)+sf);
1240 fUpperGXaxis->SetY2(upBM*(1-sf)+sf);
1241 fUpperGXaxis->SetWmin(first);
1242 fUpperGXaxis->SetWmax(last);
1243
1244 fUpperGYaxis->SetX1(upLM);
1245 fUpperGYaxis->SetX2(upLM);
1246 fUpperGYaxis->SetY1(upBM*(1-sf)+sf);
1247 fUpperGYaxis->SetY2( (1-upTM)*(1-sf)+sf );
1248 fUpperGYaxis->SetWmin(upYFirst);
1249 fUpperGYaxis->SetWmax(upYLast);
1250
1251 fLowerGXaxis->SetX1(lowLM);
1252 fLowerGXaxis->SetX2(1-lowRM);
1253 fLowerGXaxis->SetY1(lowBM*sf);
1254 fLowerGXaxis->SetY2(lowBM*sf);
1255 fLowerGXaxis->SetWmin(first);
1256 fLowerGXaxis->SetWmax(last);
1257
1258 fLowerGYaxis->SetX1(lowLM);
1259 fLowerGYaxis->SetX2(lowLM);
1260 fLowerGYaxis->SetY1(lowBM*sf);
1261 fLowerGYaxis->SetY2((1-lowTM)*sf);
1262 fLowerGYaxis->SetWmin(lowYFirst);
1263 fLowerGYaxis->SetWmax(lowYLast);
1264
1269
1270 fUpperGXaxis->SetOption("+U"+xopt);
1271 fUpperGYaxis->SetOption("S"+upyopt);
1272 fLowerGXaxis->SetOption("+S"+xopt);
1273 fLowerGYaxis->SetOption("-S"+lowyopt);
1274
1275 // normalize the tick sizes. y axis ticks should be consistent
1276 // even if their length is different
1277 Double_t ratio = ( (upBM-(1-upTM))*(1-sf) ) / ( (lowBM-(1-lowTM))*sf );
1279 Double_t ticksize = fUpperGYaxis->GetTickSize()*ratio;
1280 fLowerGYaxis->SetTickSize(ticksize);
1281
1283
1284 fUpperGYaxis->ChangeLabel(1, -1, 0);
1285
1287
1288 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1289
1290 } else {
1291 if (GetSeparationMargin() < 0.025) {
1292
1295 fUpperGYaxis->ChangeLabel(1, -1, 0);
1297 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1298 }
1299 }
1300
1301 } else {
1302 // reset
1307 }
1308
1309 }
1310 }
1311
1312 // move them about and set required positions
1313 if (fUpperGXaxisMirror) {
1317 fUpperGXaxisMirror->SetX2(1-upRM);
1318 fUpperGXaxisMirror->SetY1((1-upTM)*(1-sf)+sf);
1319 fUpperGXaxisMirror->SetY2((1-upTM)*(1-sf)+sf);
1322 fUpperGXaxisMirror->SetOption("-S"+xopt);
1325 }
1326
1327 if (fUpperGYaxisMirror) {
1330 fUpperGYaxisMirror->SetX1(1-upRM);
1331 fUpperGYaxisMirror->SetX2(1-upRM);
1332 fUpperGYaxisMirror->SetY1(upBM*(1-sf)+sf);
1333 fUpperGYaxisMirror->SetY2( (1-upTM)*(1-sf)+sf );
1334 fUpperGYaxisMirror->SetWmin(upYFirst);
1335 fUpperGYaxisMirror->SetWmax(upYLast);
1336 fUpperGYaxisMirror->SetOption("+S"+upyopt);
1339 }
1340
1341 if (fLowerGXaxisMirror) {
1344 fLowerGXaxisMirror->SetX1(lowLM);
1345 fLowerGXaxisMirror->SetX2(1-lowRM);
1346 fLowerGXaxisMirror->SetY1((1-lowTM)*sf);
1347 fLowerGXaxisMirror->SetY2((1-lowTM)*sf);
1350 fLowerGXaxisMirror->SetOption("-S"+xopt);
1353 }
1354
1355 if (fLowerGYaxisMirror) {
1358 fLowerGYaxisMirror->SetX1(1-lowRM);
1359 fLowerGYaxisMirror->SetX2(1-lowRM);
1360 fLowerGYaxisMirror->SetY1(lowBM*sf);
1361 fLowerGYaxisMirror->SetY2((1-lowTM)*sf);
1362 fLowerGYaxisMirror->SetWmin(lowYFirst);
1363 fLowerGYaxisMirror->SetWmax(lowYLast);
1364 fLowerGYaxisMirror->SetOption("+S"+lowyopt);
1368 }
1369
1370}
1371
1372////////////////////////////////////////////////////////////////////////////////
1373/// Sets the margins of all the pads to the value specified in class members.
1374/// This one is called whenever those are changed, e.g. in setters
1375
1377{
1386}
1387
1388////////////////////////////////////////////////////////////////////////////////
1389/// Figures out which pad margin has deviated from the stored ones,
1390/// to figure out what the new nominal is and set the other pad to it
1391/// subsequently.
1392
1394{
1395 Bool_t horizontalChanged = kFALSE, verticalChanged = kFALSE;
1396
1399 horizontalChanged = kTRUE;
1400 } else if (fLowerPad->GetLeftMargin() != fLeftMargin) {
1402 horizontalChanged = kTRUE;
1403 }
1404
1407 horizontalChanged = kTRUE;
1408 } else if (fLowerPad->GetRightMargin() != fRightMargin) {
1410 horizontalChanged = kTRUE;
1411 }
1412
1413
1416 verticalChanged = kTRUE;
1417 }
1418
1421 verticalChanged = kTRUE;
1422 }
1423
1426 verticalChanged = kTRUE;
1427 }
1428
1431 }
1432
1433 // only reset margins, if any of the margins changed
1434 if (horizontalChanged || verticalChanged)
1435 SetPadMargins();
1436
1437 return horizontalChanged || verticalChanged;
1438}
1439
1440////////////////////////////////////////////////////////////////////////////////
1441/// Slot that receives the RangeAxisChanged signal from any of the pads and
1442/// reacts correspondingly.
1443
1445{
1446 // Only run this concurrently once, in case it's called async
1447 if (fIsUpdating)
1448 return;
1449
1451
1452 // find out if logx has changed
1453 if (fParentPad->GetLogx()) {
1454 if (!fUpperPad->GetLogx() || !fLowerPad->GetLogx()) {
1456 }
1457 } else {
1458 if (fUpperPad->GetLogx() || fLowerPad->GetLogx()) {
1460 }
1461 }
1462
1463 // set log to pads
1464 if (fUpperPad->GetLogx() != fParentPad->GetLogx())
1466 if (fLowerPad->GetLogx() != fParentPad->GetLogx())
1468
1469 // get axis ranges for upper and lower
1470 TAxis *uprefx = GetUpperRefXaxis();
1471 Double_t upFirst = uprefx->GetBinLowEdge(uprefx->GetFirst());
1472 Double_t upLast = uprefx->GetBinUpEdge(uprefx->GetLast());
1473
1474 TAxis *lowrefx = GetLowerRefXaxis();
1475 Double_t lowFirst = lowrefx->GetBinLowEdge(lowrefx->GetFirst());
1476 Double_t lowLast = lowrefx->GetBinUpEdge(lowrefx->GetLast());
1477
1480
1481 Bool_t upChanged = kFALSE;
1482 Bool_t lowChanged = kFALSE;
1483
1484 // determine which one has changed
1485 if (upFirst != globFirst || upLast != globLast) {
1486 fSharedXAxis->SetRangeUser(upFirst, upLast);
1487 upChanged = kTRUE;
1488 } else if (lowFirst != globFirst || lowLast != globLast) {
1489 fSharedXAxis->SetRangeUser(lowFirst, lowLast);
1490 lowChanged = kTRUE;
1491 }
1492
1493 if (upChanged || lowChanged)
1495
1496 // sync the margins in case the user has dragged one of them
1497 Bool_t marginsChanged = SyncPadMargins();
1498
1499 if (upChanged || lowChanged || marginsChanged) {
1502 fTopPad->Modified();
1504 }
1505
1509}
1510
1511////////////////////////////////////////////////////////////////////////////////
1512/// Slot for the UnZoomed signal that was introduced to TPad.
1513/// Unzoom both pads
1514
1516{
1517 if (fIsUpdating)
1518 return;
1519
1521
1522 // this is what resets the range
1523 fSharedXAxis->SetRange(0, 0);
1525
1526 // Flushing
1529 fTopPad->Modified();
1531
1533}
1534
1535////////////////////////////////////////////////////////////////////////////////
1536/// Slot that handles common resizing of upper and lower pad.
1537
1539{
1540 if (fIsUpdating)
1541 return;
1542
1544
1545 Float_t upylow = fUpperPad->GetYlowNDC();
1546 Float_t lowylow = fLowerPad->GetYlowNDC();
1547 Float_t lowh = fLowerPad->GetHNDC();
1548 Float_t lowyup = lowylow + lowh;
1549
1550 Bool_t changed = kFALSE;
1551
1552 if (upylow != fSplitFraction) {
1553 // up changed
1554 SetSplitFraction(upylow);
1555 changed = kTRUE;
1556 } else if (lowyup != fSplitFraction) {
1557 // low changed
1558 SetSplitFraction(lowyup);
1559 changed = kTRUE;
1560 }
1561
1562 if (changed)
1564
1566}
1567
1568////////////////////////////////////////////////////////////////////////////////
1569/// Set the fraction of the parent pad, at which the to sub pads should meet
1570
1572{
1573 if (!fParentPad) {
1574 Warning("SetSplitFraction", "Can only be used after TRatioPlot has been drawn.");
1575 return;
1576 }
1577
1578 if ((sf < 0.0001) || (sf > 0.9999)) {
1579 Warning("SetSplitFraction", "Value %f is out of allowed range", sf);
1580 return;
1581 }
1582
1583 fSplitFraction = sf;
1584 double pm = fInsetWidth;
1585 double width = fParentPad->GetWNDC();
1586 double height = fParentPad->GetHNDC();
1587 double f = height/width;
1588
1589 fUpperPad->SetPad(pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
1590 fLowerPad->SetPad(pm*f, pm, 1.-pm*f, fSplitFraction);
1591}
1592
1593////////////////////////////////////////////////////////////////////////////////
1594/// Set the inset on the outer sides of all the pads. It's used to make the outer
1595/// pad draggable.
1596
1598{
1599 if (!fParentPad) {
1600 Warning("SetInsetWidth", "Can only be used after TRatioPlot has been drawn.");
1601 return;
1602 }
1603
1606
1607 double pm = fInsetWidth;
1608 double w = fParentPad->GetWNDC();
1609 double h = fParentPad->GetHNDC();
1610 double f = h/w;
1611 fTopPad->SetPad(pm*f, pm, 1-pm*f, 1-pm);
1612}
1613
1614////////////////////////////////////////////////////////////////////////////////
1615/// Sets the confidence levels used to calculate the bands in the fit residual
1616/// case. Defaults to 1 and 2 sigma.
1617
1619{
1620 fCl1 = c1;
1621 fCl2 = c2;
1622 if (!BuildLowerPlot()) return;
1623}
1624
1625////////////////////////////////////////////////////////////////////////////////
1626/// Set where horizontal, dashed lines are drawn on the lower pad.
1627/// Can be used to override existing default lines (or disable them).
1628///
1629/// \param gridlines Vector of y positions for the dashes lines
1630///
1631/// Begin_Macro(source)
1632/// ../../../tutorials/hist/ratioplot4.C
1633/// End_Macro
1634
1635void TRatioPlot::SetGridlines(std::vector<double> gridlines)
1636{
1637 fGridlinePositions = gridlines;
1638}
1639
1640////////////////////////////////////////////////////////////////////////////////
1641/// Set where horizontal, dashed lines are drawn on the lower pad.
1642/// Can be used to override existing default lines (or disable them).
1643///
1644/// \param gridlines Double_t array of y positions for the dashed lines
1645/// \param numGridlines Length of gridlines
1646
1647void TRatioPlot::SetGridlines(Double_t *gridlines, Int_t numGridlines)
1648{
1649 fGridlinePositions.clear();
1650
1651 for (Int_t i = 0; i < numGridlines; ++i)
1652 fGridlinePositions.emplace_back(gridlines[i]);
1653}
1654
1655////////////////////////////////////////////////////////////////////////////////
1656/// Set the confidence interval colors.
1657///
1658/// \param ci1 Color of the 1 sigma band
1659/// \param ci2 Color of the 2 sigma band
1660/// Sets the color of the 1 and 2 sigma bands in the fit residual case.
1661/// Begin_Macro(source)
1662/// ../../../tutorials/hist/ratioplot5.C
1663/// End_Macro
1664
1666{
1667 fCi1Color = ci1;
1668 fCi2Color = ci2;
1669}
1670
1671////////////////////////////////////////////////////////////////////////////////
1672/// Internal method to import TAxis attributes to a TGaxis. Copied from
1673/// `TGaxis::ImportAxisAttributes`
1674
1676{
1677 gaxis->SetLineColor(axis->GetAxisColor());
1678 gaxis->SetTextColor(axis->GetTitleColor());
1679 gaxis->SetTextFont(axis->GetTitleFont());
1680 gaxis->SetLabelColor(axis->GetLabelColor());
1681 gaxis->SetLabelFont(axis->GetLabelFont());
1682 gaxis->SetLabelSize(axis->GetLabelSize());
1683 gaxis->SetLabelOffset(axis->GetLabelOffset());
1684 gaxis->SetTickSize(axis->GetTickLength());
1685 gaxis->SetTitle(axis->GetTitle());
1686 gaxis->SetTitleOffset(axis->GetTitleOffset());
1687 gaxis->SetTitleSize(axis->GetTitleSize());
1695 if (axis->GetDecimals()) gaxis->SetBit(TAxis::kDecimals); //the bit is in TAxis::fAxis2
1696 gaxis->SetTimeFormat(axis->GetTimeFormat());
1697}
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
short Color_t
Definition RtypesCore.h:92
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
Option_t Option_t option
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
#define gPad
void GetConfidenceIntervals(unsigned int n, unsigned int stride1, unsigned int stride2, const double *x, double *ci, double cl=0.95, bool norm=false) const
get confidence intervals for an array of n points x.
virtual Color_t GetTitleColor() const
Definition TAttAxis.h:46
virtual Color_t GetLabelColor() const
Definition TAttAxis.h:38
virtual Int_t GetNdivisions() const
Definition TAttAxis.h:36
virtual Color_t GetAxisColor() const
Definition TAttAxis.h:37
virtual Style_t GetTitleFont() const
Definition TAttAxis.h:47
virtual Float_t GetLabelOffset() const
Definition TAttAxis.h:40
virtual Style_t GetLabelFont() const
Definition TAttAxis.h:39
virtual Float_t GetTitleSize() const
Definition TAttAxis.h:44
virtual Float_t GetLabelSize() const
Definition TAttAxis.h:41
virtual Float_t GetTickLength() const
Definition TAttAxis.h:45
virtual Float_t GetTitleOffset() const
Definition TAttAxis.h:43
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:42
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition TAttPad.cxx:99
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition TAttPad.cxx:109
Style_t GetFrameFillStyle() const
Definition TAttPad.h:55
Float_t GetLeftMargin() const
Definition TAttPad.h:44
Float_t GetBottomMargin() const
Definition TAttPad.h:43
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition TAttPad.cxx:119
Float_t GetRightMargin() const
Definition TAttPad.h:45
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition TAttPad.cxx:129
Float_t GetTopMargin() const
Definition TAttPad.h:46
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition TAttText.h:44
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition TAttText.h:46
Class to manage histogram axis.
Definition TAxis.h:31
const char * GetTitle() const override
Returns title of object.
Definition TAxis.h:135
@ kTickMinus
Definition TAxis.h:64
@ kCenterTitle
Definition TAxis.h:66
@ kRotateTitle
Definition TAxis.h:68
@ kNoExponent
Definition TAxis.h:70
@ kMoreLogLabels
Definition TAxis.h:76
@ kTickPlus
Definition TAxis.h:63
@ kDecimals
Definition TAxis.h:62
@ kCenterLabels
Bit 13 is used by TObject.
Definition TAxis.h:67
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:518
Bool_t GetDecimals() const
Definition TAxis.h:120
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:469
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition TAxis.h:164
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates, that is,...
Definition TAxis.cxx:1080
virtual const char * GetTimeFormat() const
Definition TAxis.h:132
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:1052
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:528
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:458
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-Dim function class
Definition TF1.h:233
static TClass * Class()
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition TF1.cxx:1335
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
Definition TF1.cxx:1441
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
Definition TFitResult.h:34
The axis painter class.
Definition TGaxis.h:24
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition TGaxis.cxx:2969
void SetTitleOffset(Float_t titleoffset=1)
Definition TGaxis.h:128
void SetLabelFont(Int_t labelfont)
Definition TGaxis.h:105
void SetTitleSize(Float_t titlesize)
Definition TGaxis.h:129
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition TGaxis.cxx:2942
void SetLabelOffset(Float_t labeloffset)
Definition TGaxis.h:106
const char * GetTitle() const override
Returns title of object.
Definition TGaxis.h:86
virtual void SetNdivisions(Int_t ndiv)
Definition TGaxis.h:118
void SetWmax(Double_t wmax)
Definition TGaxis.h:133
void SetLabelColor(Int_t labelcolor)
Definition TGaxis.h:104
void ChangeLabel(Int_t labNum=0, Double_t labAngle=-1., Double_t labSize=-1., Int_t labAlign=-1, Int_t labColor=-1, Int_t labFont=-1, const TString &labText="")
Define new text attributes for the label number "labNum".
Definition TGaxis.cxx:2734
Float_t GetTickSize() const
Definition TGaxis.h:91
void SetWmin(Double_t wmin)
Definition TGaxis.h:132
void SetTickSize(Float_t ticksize)
Definition TGaxis.h:122
void SetLabelSize(Float_t labelsize)
Definition TGaxis.h:107
void SetOption(Option_t *option="")
To set axis options.
Definition TGaxis.cxx:2934
TGraph with asymmetric error bars.
virtual void Divide(const TH1 *pass, const TH1 *total, Option_t *opt="cp")
Fill this TGraphAsymmErrors by dividing two 1-dimensional histograms pass/total.
A TGraphErrors is a TGraph with error bars.
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
static TClass * Class()
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition TGraph.cxx:2325
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
Definition TGraph.cxx:814
TAxis * GetXaxis() const
Get x axis of the graph.
Definition TGraph.cxx:1549
TAxis * GetYaxis() const
Get y axis of the graph.
Definition TGraph.cxx:1558
void SetTitle(const char *title="") override
Change (i.e.
Definition TGraph.cxx:2380
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
Definition TH1.cxx:9109
static TClass * Class()
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition TH1.cxx:9031
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition TH1.cxx:7071
TAxis * GetXaxis()
Definition TH1.h:324
virtual Int_t GetNbinsX() const
Definition TH1.h:297
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2),...
Definition TH1.cxx:826
TAxis * GetYaxis()
Definition TH1.h:325
virtual Double_t GetBinErrorLow(Int_t bin) const
Return lower error associated to bin number bin.
Definition TH1.cxx:9047
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3066
TList * GetListOfFunctions() const
Definition TH1.h:244
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:5029
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
Definition TH1.cxx:9131
virtual Double_t GetBinErrorUp(Int_t bin) const
Return upper error associated to bin number bin.
Definition TH1.cxx:9078
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition TH1.cxx:6572
virtual Int_t GetSumw2N() const
Definition TH1.h:315
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
Definition TH1.cxx:2752
virtual Bool_t Divide(TF1 *f1, Double_t c1=1)
Performs the operation: this = this/(c1*f1) if errors are defined (see TH1::Sumw2),...
Definition TH1.cxx:2840
The Histogram stack class.
Definition THStack.h:40
TList * GetHists() const
Definition THStack.h:72
static TClass * Class()
Use the TLine constructor to create a simple line.
Definition TLine.h:22
virtual void SetY2(Double_t y2)
Definition TLine.h:68
virtual void SetX2(Double_t x2)
Definition TLine.h:66
virtual void SetX1(Double_t x1)
Definition TLine.h:65
virtual void SetY1(Double_t y1)
Definition TLine.h:67
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:83
virtual TObjLink * FirstLink() const
Definition TList.h:104
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:355
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition TNamed.cxx:74
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:223
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:973
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:184
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:987
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:274
@ kCannotPick
if object in a pad cannot be picked
Definition TObject.h:67
The most important graphics class in the ROOT system.
Definition TPad.h:28
void SetGridx(Int_t value=1) override
Definition TPad.h:333
Double_t GetUymax() const override
Returns the maximum y-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition TPad.h:232
Double_t GetUymin() const override
Returns the minimum y-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition TPad.h:228
TList * GetListOfPrimitives() const override
Definition TPad.h:243
void SetFillStyle(Style_t fstyle) override
Override TAttFill::FillStyle for TPad because we want to handle style=0 as style 4000.
Definition TPad.cxx:5961
void SetPad(const char *name, const char *title, Double_t xlow, Double_t ylow, Double_t xup, Double_t yup, Color_t color=35, Short_t bordersize=5, Short_t bordermode=-1) override
Set all pad parameters.
Definition TPad.cxx:6058
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:5987
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7256
void SetGridy(Int_t value=1) override
Definition TPad.h:334
Double_t GetYlowNDC() const override
Definition TPad.h:211
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition TPad.cxx:597
Int_t GetLogy() const override
Definition TPad.h:255
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
Definition TPad.cxx:1268
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:5973
Int_t GetLogx() const override
Definition TPad.h:254
Double_t GetHNDC() const override
Get height of pad along Y in Normalized Coordinates (NDC)
Definition TPad.h:215
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
virtual Bool_t HasConnection(const char *signal_name) const
Return true if there is any object connected to this signal.
Definition TQObject.cxx:527
void SubPadResized()
Slot that handles common resizing of upper and lower pad.
@ kForceHideUp
Always hide the first label of the upper y axis.
Definition TRatioPlot.h:67
@ kHideUp
Hide the first label of the upper y axis when there is low space.
Definition TRatioPlot.h:64
@ kNoHide
Do not hide labels when there is low space.
Definition TRatioPlot.h:66
@ kHideLow
Hide the last label of the lower y axis when there is low space.
Definition TRatioPlot.h:65
@ kForceHideLow
Always hide the last label of the lower y axis.
Definition TRatioPlot.h:68
TGraphErrors * fConfidenceInterval2
Stores the graph for the 2 sigma band.
Definition TRatioPlot.h:96
TAxis * GetLowerRefXaxis() const
Gets the x axis of the lower ref graph.
Int_t fErrorMode
Stores the error mode, sym, asym or func.
Definition TRatioPlot.h:85
TAxis * GetLowerRefYaxis() const
Gets the y axis of the lower ref graph.
TGaxis * fUpperGXaxisMirror
Upper mirror of the x axis.
Definition TRatioPlot.h:115
TGaxis * fLowerGXaxisMirror
Lower mirror of the x axis.
Definition TRatioPlot.h:116
TAxis * GetUpperRefYaxis() const
Gets the y axis of the object returned by TRatioPlot::GetUpperRefObject.
Float_t fLowBottomMargin
Stores the bottom margin of the lower pad.
Definition TRatioPlot.h:133
void CreateGridlines()
Create a grid lines.
Int_t BuildLowerPlot()
Build the lower plot according to which constructor was called, and which options were passed.
void SetUpBottomMargin(Float_t margin)
Sets the bottom margin of the upper pad.
Float_t fUpBottomMargin
Stores the bottom margin of the upper pad.
Definition TRatioPlot.h:131
TH1 * fH1
Stores the primary histogram.
Definition TRatioPlot.h:79
void SetH2DrawOpt(Option_t *opt)
Sets the drawing option for h2.
TFitResult * fFitResult
Stores the explicit fit result given in the fit residual case. Can be 0.
Definition TRatioPlot.h:108
virtual Bool_t SyncPadMargins()
Figures out which pad margin has deviated from the stored ones, to figure out what the new nominal is...
virtual void UpdateVisualAxes()
Update TGaxis attributes.
Color_t fCi1Color
Stores the color for the 1 sigma band.
Definition TRatioPlot.h:97
TGaxis * fUpperGYaxis
Upper graphical y axis.
Definition TRatioPlot.h:113
Double_t fC2
Stores the scale factor for h2.
Definition TRatioPlot.h:106
void UpdateGridlines()
Update positions of grid lines.
void SetLowBottomMargin(Float_t margin)
Sets the bottom margin of the lower pad.
void SetConfidenceIntervalColors(Color_t ci1=kYellow, Color_t ci2=kGreen)
Set the confidence interval colors.
Double_t fC1
Stores the scale factor for h1 (or THStack sum)
Definition TRatioPlot.h:105
virtual void CreateVisualAxes()
Creates the TGaxis objects that are used for consistent display of the axes.
Float_t fLowTopMargin
Stores the top margin of the lower pad.
Definition TRatioPlot.h:132
TString fH2DrawOpt
Stores draw option for h2 given in constructor.
Definition TRatioPlot.h:88
void SetUpTopMargin(Float_t margin)
Sets the top margin of the upper pad.
TGaxis * fLowerGXaxis
Lower graphical x axis.
Definition TRatioPlot.h:112
TRatioPlot()
TRatioPlot default constructor.
Bool_t fIsUpdating
! Keeps track of whether its currently updating to reject other calls until done
Definition TRatioPlot.h:140
void SetGraphDrawOpt(Option_t *opt)
Sets the drawing option for the lower graph.
Double_t fCl1
Stores the confidence level for the inner confidence interval band.
Definition TRatioPlot.h:102
@ kErrorAsymmetric
Use TH1::GetBinErrorUp and TH1::GetBinErrorLow for the error, depending on y values.
Definition TRatioPlot.h:59
@ kErrorFunc
Use the square root of the function value as the error.
Definition TRatioPlot.h:60
@ kErrorSymmetric
Use the regular TH1::GetBinError as the error.
Definition TRatioPlot.h:58
Float_t GetSeparationMargin() const
Return the separation margin value.
void ImportAxisAttributes(TGaxis *gaxis, TAxis *axis)
Internal method to import TAxis attributes to a TGaxis.
void SetFitDrawOpt(Option_t *opt)
Sets the drawing option for the fit in the fit residual case.
std::vector< TLine * > fGridlines
Keeps TLine objects for the gridlines.
Definition TRatioPlot.h:123
void SetPadMargins()
Sets the margins of all the pads to the value specified in class members.
TPad * fLowerPad
The pad which contains the calculated lower plot part.
Definition TRatioPlot.h:76
TAxis * fSharedXAxis
X axis that stores the range for both plots.
Definition TRatioPlot.h:110
TString fFitDrawOpt
Stores draw option for the fit function in the fit residual case.
Definition TRatioPlot.h:90
virtual void SetGridlines(Double_t *gridlines, Int_t numGridlines)
Set where horizontal, dashed lines are drawn on the lower pad.
TGaxis * fUpperGYaxisMirror
Upper mirror of the y axis.
Definition TRatioPlot.h:117
virtual void SetupPads()
Setup the pads.
TAxis * fUpYaxis
Clone of the upper y axis.
Definition TRatioPlot.h:120
TVirtualPad * fParentPad
Stores the pad the ratio plot was created in.
Definition TRatioPlot.h:74
Float_t fUpTopMargin
Stores the top margin of the upper pad.
Definition TRatioPlot.h:130
void SetH1DrawOpt(Option_t *opt)
Sets the drawing option for h1.
TGraph * fRatioGraph
Stores the lower plot's graph.
Definition TRatioPlot.h:94
virtual TGraph * GetLowerRefGraph() const
Returns the reference graph for the lower pad, which means the graph that is responsible for setting ...
virtual void ConnectPadsSignals()
Connect some signals from the pads to handle them Allows correctly work also after reading ratioplot ...
Int_t fMode
Stores which calculation is supposed to be performed as specified by user option.
Definition TRatioPlot.h:84
void SetSplitFraction(Float_t sf)
Set the fraction of the parent pad, at which the to sub pads should meet.
TObject * fHistDrawProxy
The object which is actually drawn, this might be TH1 or THStack.
Definition TRatioPlot.h:81
Float_t fRightMargin
Stores the common right margin of both pads.
Definition TRatioPlot.h:136
TGaxis * fLowerGYaxisMirror
Lower mirror of the y axis.
Definition TRatioPlot.h:118
Int_t fHideLabelMode
Stores which label to hide if the margin is to narrow, if at all.
Definition TRatioPlot.h:126
TPad * fTopPad
The Pad that drawn on top on the others to have consistent coordinates.
Definition TRatioPlot.h:77
void SetInsetWidth(Double_t width)
Set the inset on the outer sides of all the pads.
virtual void SyncAxesRanges()
Syncs the axes ranges from the shared ones to the actual ones.
void RangeAxisChanged()
Slot that receives the RangeAxisChanged signal from any of the pads and reacts correspondingly.
@ kDifference
Calculate the difference between the histograms.
Definition TRatioPlot.h:52
@ kDivideHist
Use TH1::Divide to create the ratio.
Definition TRatioPlot.h:50
@ kFitResidual
Calculate the fit residual between the histogram and a fit stored within it.
Definition TRatioPlot.h:53
@ kDifferenceSign
Calculate the difference divided by the error.
Definition TRatioPlot.h:54
@ kDivideGraph
Use TGraphAsymmErrors::Divide to create the ratio.
Definition TRatioPlot.h:51
void UnZoomed()
Slot for the UnZoomed signal that was introduced to TPad.
TH1 * fH2
Stores the secondary histogram, if there is one.
Definition TRatioPlot.h:80
Double_t fCl2
Stores the confidence level for the outer confidence interval band.
Definition TRatioPlot.h:103
TAxis * fLowYaxis
Clone of the lower y axis.
Definition TRatioPlot.h:121
TString fOption
Stores the option which is given in the constructor as a string.
Definition TRatioPlot.h:86
TPad * fUpperPad
The pad which contains the upper plot part.
Definition TRatioPlot.h:75
Bool_t fShowConfidenceIntervals
Stores whether to show the confidence interval bands. From Draw option.
Definition TRatioPlot.h:100
void SetLowTopMargin(Float_t margin)
Sets the top margin of the lower pad.
void SetSeparationMargin(Float_t)
Sets the margin that separates the two pads.
Bool_t fHistDrawProxyStack
If stack was assigned as proxy.
Definition TRatioPlot.h:82
Float_t fInsetWidth
Definition TRatioPlot.h:138
TAxis * GetXaxis() const
Definition TRatioPlot.h:184
void SetLeftMargin(Float_t margin)
Sets the left margin of both pads.
Float_t fLeftMargin
Stores the common left margin of both pads.
Definition TRatioPlot.h:135
TAxis * GetUpperRefXaxis() const
Gets the x axis of the object returned by TRatioPlot::GetUpperRefObject.
Float_t fSplitFraction
Stores the fraction at which the upper and lower pads meet.
Definition TRatioPlot.h:92
void Paint(Option_t *opt="") override
Update the visual axes and grid lines when painting.
virtual TObject * GetUpperRefObject() const
Return the reference object.
TGraphErrors * fConfidenceInterval1
Stores the graph for the 1 sigma band.
Definition TRatioPlot.h:95
TGaxis * fUpperGXaxis
Upper graphical x axis.
Definition TRatioPlot.h:111
std::vector< double > fGridlinePositions
Stores the y positions for the gridlines.
Definition TRatioPlot.h:124
TString fH1DrawOpt
Stores draw option for h1 given in constructor.
Definition TRatioPlot.h:87
virtual void Init(TH1 *h1, TH1 *h2, Option_t *option="")
Internal method that shares constructor logic.
Bool_t fShowGridlines
Stores whether to show the gridlines at all.
Definition TRatioPlot.h:125
void Draw(Option_t *chopt="") override
Draws the ratio plot to the currently active pad.
TString fGraphDrawOpt
Stores draw option for the lower plot graph given in constructor.
Definition TRatioPlot.h:89
~TRatioPlot() override
Destructor.
Color_t fCi2Color
Stores the color for the 2 sigma band.
Definition TRatioPlot.h:98
void SetRightMargin(Float_t margin)
Sets the right margin of both pads.
TGaxis * fLowerGYaxis
Lower graphical y axis.
Definition TRatioPlot.h:114
void SetConfidenceLevels(Double_t cl1, Double_t cl2)
Sets the confidence levels used to calculate the bands in the fit residual case.
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
virtual void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95)
return confidence intervals in array x of dimension ndim implemented in TFitter and TLinearFitter
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual void Modified(Bool_t flag=1)=0
virtual void SetLogx(Int_t value=1)=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual Bool_t GetGridx() const =0
virtual Int_t GetTicky() const =0
virtual Int_t GetLogy() const =0
virtual Double_t GetHNDC() const =0
virtual Double_t GetWNDC() const =0
virtual Int_t GetTickx() const =0
virtual Int_t GetLogx() const =0
virtual Bool_t GetGridy() const =0
TLine * line
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
TGraphErrors * gr
Definition legend1.C:25
TH1F * h1
Definition legend1.C:5
return c2
Definition legend2.C:14
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:721