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-2016, 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/// TRatioPlot default constructor
101
103{
104}
105
106////////////////////////////////////////////////////////////////////////////////
107/// Destructor
108
110{
111
112 gROOT->GetListOfCleanups()->Remove(this);
113
114 auto safeDelete = [](TObject *obj) {
115 if (obj && !ROOT::Detail::HasBeenDeleted(obj))
116 delete obj;
117 };
118
119 safeDelete(fRatioGraph);
120 safeDelete(fConfidenceInterval1);
121 safeDelete(fConfidenceInterval2);
122
123 for (unsigned int i=0;i<fGridlines.size();++i) {
124 delete (fGridlines[i]);
125 }
126
127 safeDelete(fSharedXAxis);
128 safeDelete(fUpperGXaxis);
129 safeDelete(fLowerGXaxis);
130 safeDelete(fUpperGYaxis);
131 safeDelete(fLowerGYaxis);
132 safeDelete(fUpperGXaxisMirror);
133 safeDelete(fLowerGXaxisMirror);
134 safeDelete(fUpperGYaxisMirror);
135 safeDelete(fLowerGYaxisMirror);
136
137 safeDelete(fUpYaxis);
138 safeDelete(fLowYaxis);
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Internal method that shares constructor logic
143
145{
146
147 fH1 = h1;
148 fH2 = h2;
149
150 SetupPads();
151
152 TString optionString = TString(option);
153
154 if (optionString.Contains("divsym")) {
155 optionString.ReplaceAll("divsym", "");
157 } else if (optionString.Contains("diffsig")) {
158 optionString.ReplaceAll("diffsig", "");
160
161 // determine which error style
162 if (optionString.Contains("errasym")) {
164 optionString.ReplaceAll("errasym", "");
165 }
166
167 if (optionString.Contains("errfunc")) {
169 optionString.ReplaceAll("errfunc", "");
170 }
171 } else if (optionString.Contains("diff")) {
172 optionString.ReplaceAll("diff", "");
174 } else {
176 }
177
178 fOption = optionString;
179
180
181 fH1DrawOpt = "hist";
182 fH2DrawOpt = "E";
183 fGraphDrawOpt = "AP";
184
185
186 // build ratio, everything is ready
187 if (!BuildLowerPlot()) return;
188
189 // taking x axis information from h1 by cloning it x axis
190 fSharedXAxis = (TAxis*)(fH1->GetXaxis()->Clone());
191 fUpYaxis = (TAxis*)(fH1->GetYaxis()->Clone());
193}
194
195////////////////////////////////////////////////////////////////////////////////
196/// Constructor for two histograms
197///
198/// \param h1 First histogram
199/// \param h2 Second histogram
200/// \param option Steers the error calculation, as well as ratio / difference
201
203 : fGridlines()
204{
205 gROOT->GetListOfCleanups()->Add(this);
206
207 if (!h1 || !h2) {
208 Warning("TRatioPlot", "Need two histograms.");
209 return;
210 }
211
212 Bool_t h1IsTH1=h1->IsA()->InheritsFrom(TH1::Class());
213 Bool_t h2IsTH1=h2->IsA()->InheritsFrom(TH1::Class());
214
215 if (!h1IsTH1 && !h2IsTH1) {
216 Warning("TRatioPlot", "Need two histograms deriving from TH2 or TH3.");
217 return;
218 }
219
221
222 Init(h1, h2, option);
223
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Constructor which accepts a `THStack` and a histogram. Converts the
228/// stack to a regular sum of its containing histograms for processing.
229///
230/// \param st The THStack object
231/// \param h2 The other histogram
232/// \param option Steers the calculation of the lower plot
233
235{
236 if (!st || !h2) {
237 Warning("TRatioPlot", "Need a histogram and a stack");
238 return;
239 }
240
241 TList *stackHists = st->GetHists();
242
243 if (stackHists->GetSize() == 0) {
244 Warning("TRatioPlot", "Stack does not have histograms");
245 return;
246 }
247
248 TH1* tmpHist = (TH1*)stackHists->At(0)->Clone();
249 tmpHist->Reset();
250
251 for (int i=0;i<stackHists->GetSize();++i) {
252 tmpHist->Add((TH1*)stackHists->At(i));
253 }
254
255 fHistDrawProxy = st;
256
257 Init(tmpHist, h2, option);
258
259}
260
261////////////////////////////////////////////////////////////////////////////////
262/// Constructor for one histogram and a fit.
263///
264/// \param h1 The histogram
265/// \param option Steers the error calculation
266/// \param fitres Explicit fit result to be used for calculation. Uses last fit if left empty
267
269 : fH1(h1),
270 fGridlines()
271{
272 gROOT->GetListOfCleanups()->Add(this);
273
274 if (!fH1) {
275 Warning("TRatioPlot", "Need a histogram.");
276 return;
277 }
278
279 Bool_t h1IsTH1=fH1->IsA()->InheritsFrom(TH1::Class());
280
281 if (!h1IsTH1) {
282 Warning("TRatioPlot", "Need a histogram deriving from TH2 or TH3.");
283 return;
284 }
285
286 TList *h1Functions = fH1->GetListOfFunctions();
287
288 if (h1Functions->GetSize() < 1) {
289 Warning("TRatioPlot", "Histogram given needs to have a (fit) function associated with it");
290 return;
291 }
292
293
295
296 fFitResult = fitres;
297
299
300 TString optionString = TString(option);
301
302 // determine which error style
303 if (optionString.Contains("errasym")) {
305 optionString.ReplaceAll("errasym", "");
306 }
307
308 if (optionString.Contains("errfunc")) {
310 optionString.ReplaceAll("errfunc", "");
311 }
312
313 fOption = optionString;
314
315 if (!BuildLowerPlot()) return;
316
317 // emulate option behaviour of TH1
318 if (fH1->GetSumw2N() > 0) {
319 fH1DrawOpt = "E";
320 } else {
321 fH1DrawOpt = "hist";
322 }
323 fGraphDrawOpt = "LX"; // <- default
324
325 fSharedXAxis = (TAxis*)(fH1->GetXaxis()->Clone());
326 fUpYaxis = (TAxis*)(fH1->GetYaxis()->Clone());
328
329 //SyncAxesRanges();
330
331 SetupPads();
332
333}
334
335////////////////////////////////////////////////////////////////////////////////
336/// Sets the drawing option for h1
337
339{
340 fH1DrawOpt = opt;
341}
342
343////////////////////////////////////////////////////////////////////////////////
344/// Sets the drawing option for h2
345
347{
348 TString optString = TString(opt);
349 optString.ReplaceAll("same", "");
350 optString.ReplaceAll("SAME", "");
351
352 fH2DrawOpt = optString;
353}
354
355////////////////////////////////////////////////////////////////////////////////
356/// Sets the drawing option for the lower graph
357
359{
360 fGraphDrawOpt = opt;
361}
362
363////////////////////////////////////////////////////////////////////////////////
364/// Sets the drawing option for the fit in the fit residual case
365
367{
368 fFitDrawOpt = opt;
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// Setup the pads.
373
375
376 // this method will delete all the pads before recreating them
377
378 if (fUpperPad) {
379 delete fUpperPad;
380 fUpperPad = nullptr;
381 }
382
383 if (fLowerPad) {
384 delete fLowerPad;
385 fLowerPad = nullptr;
386 }
387
388 if (!gPad) {
389 Error("SetupPads", "need to create a canvas first");
390 return;
391 }
392
393 double pm = fInsetWidth;
394 double width = gPad->GetWNDC();
395 double height = gPad->GetHNDC();
396 double f = height/width;
397
398 fUpperPad = new TPad("upper_pad", "", pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
399 fLowerPad = new TPad("lower_pad", "", pm*f, pm, 1.-pm*f, fSplitFraction);
400
402
403 // connect to the pads signal
404 fUpperPad->Connect("RangeAxisChanged()", "TRatioPlot", this, "RangeAxisChanged()");
405 fLowerPad->Connect("RangeAxisChanged()", "TRatioPlot", this, "RangeAxisChanged()");
406
407 fUpperPad->Connect("UnZoomed()", "TRatioPlot", this, "UnZoomed()");
408 fLowerPad->Connect("UnZoomed()", "TRatioPlot", this, "UnZoomed()");
409
410 fUpperPad->Connect("Resized()", "TRatioPlot", this, "SubPadResized()");
411 fLowerPad->Connect("Resized()", "TRatioPlot", this, "SubPadResized()");
412
413 if (fTopPad) {
414 delete fTopPad;
415 fTopPad = nullptr;
416 }
417
418 fTopPad = new TPad("top_pad", "", pm*f, pm, 1-pm*f, 1-pm);
419
421
422}
423
424////////////////////////////////////////////////////////////////////////////////
425/// Browse.
426
428{
429 Draw(b ? b->GetDrawOption() : "");
430 gPad->Update();
431}
432
433////////////////////////////////////////////////////////////////////////////////
434/// Sets the top margin of the upper pad.
435///
436/// \param margin The new margin
437
439{
440 fUpTopMargin = margin;
442}
443
444////////////////////////////////////////////////////////////////////////////////
445/// Sets the bottom margin of the upper pad.
446///
447/// \param margin The new margin
448
450{
451 fUpBottomMargin = margin;
453}
454
455////////////////////////////////////////////////////////////////////////////////
456/// Sets the top margin of the lower pad.
457///
458/// \param margin The new margin
459
461{
462 fLowTopMargin = margin;
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Sets the bottom margin of the lower pad.
468///
469/// \param margin The new margin
470
472{
473 fLowBottomMargin = margin;
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Sets the left margin of both pads.
479/// \param margin The new margin
480
482{
483 fLeftMargin = margin;
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Sets the right margin of both pads.
489///
490/// \param margin The new margin
491
493{
494 fRightMargin = margin;
496}
497
498////////////////////////////////////////////////////////////////////////////////
499/// Sets the margin that separates the two pads. The margin is split according
500/// to the relative sizes of the pads
501///
502/// \param margin The new margin
503///
504/// Begin_Macro(source)
505/// ../../../tutorials/hist/ratioplot6.C
506/// End_Macro
507
509{
511 fUpBottomMargin = margin/2./(1-sf);
512 fLowTopMargin = margin/2./sf;
514}
515
516////////////////////////////////////////////////////////////////////////////////
517/// Return the separation margin value.
518
520{
522 Float_t up = fUpBottomMargin * (1-sf);
523 Float_t down = fLowTopMargin * sf;
524 return up+down;
525}
526
527////////////////////////////////////////////////////////////////////////////////
528/// Draws the ratio plot to the currently active pad. Therefore it requires that
529/// a TCanvas has been created first.
530///
531/// It takes the following options
532///
533/// | Option | Description |
534/// | ---------- | ------------------------------------------------------------ |
535/// | grid / nogrid | enable (default) or disable drawing of dashed lines on lower plot |
536/// | hideup | hides the first label of the upper axis if there is not enough space |
537/// | fhideup | always hides the first label of the upper axis |
538/// | hidelow (default) | hides the last label of the lower axis if there is not enough space |
539/// | fhidelow | always hides the last label of the lower axis |
540/// | nohide | does not hide a label if there is not enough space |
541/// | noconfint | does not draw the confidence interval bands in the fit residual case |
542/// | confint | draws the confidence interval bands in the fit residual case (default) |
543
545{
546
547 TString drawOpt = option;
548
549 if (drawOpt.Contains("nogrid")) {
550 drawOpt.ReplaceAll("nogrid", "");
552 } else if (drawOpt.Contains("grid")) {
553 drawOpt.ReplaceAll("grid", "");
555 }
556
557 if (drawOpt.Contains("noconfint")) {
558 drawOpt.ReplaceAll("noconfint", "");
560 } else if (drawOpt.Contains("confint")) {
561 drawOpt.ReplaceAll("confint", "");
562 fShowConfidenceIntervals = kTRUE; // <- default
563 }
564
565 if (drawOpt.Contains("fhideup")) {
567 } else if (drawOpt.Contains("fhidelow")) {
569 } else if (drawOpt.Contains("hideup")) {
571 } else if (drawOpt.Contains("hidelow")) {
573 } else if (drawOpt.Contains("nohide")) {
575 } else {
577 }
578
579 if (!gPad) {
580 Error("Draw", "need to create a canvas first");
581 return;
582 }
583
584 TVirtualPad *padsav = gPad;
586
590
595
596 // we are a TPad
597
598 fUpperPad->Draw();
599 fLowerPad->Draw();
600
602 fTopPad->Draw();
603
604 fUpperPad->cd();
605
608
610 TF1 *func = dynamic_cast<TF1*>(fH1->GetListOfFunctions()->At(0));
611
612 if (!func) {
613 // this is checked in constructor and should thus not occur
614 Error("BuildLowerPlot", "h1 does not have a fit function");
615 return;
616 }
617
618 fH1->Draw("A"+fH1DrawOpt);
619 func->Draw(fFitDrawOpt+"same");
620
621 fLowerPad->cd();
622
627 } else {
628 fRatioGraph->Draw("IA"+fGraphDrawOpt+"SAME");
629 }
630 } else {
631
632 if (fHistDrawProxy) {
634 ((TH1*)fHistDrawProxy)->Draw("A"+fH1DrawOpt);
636 ((THStack*)fHistDrawProxy)->Draw("A"+fH1DrawOpt);
637 } else {
638 Warning("Draw", "Draw proxy not of type TH1 or THStack, not drawing it");
639 }
640 }
641
642 fH2->Draw("A"+fH2DrawOpt+"same");
643
644 fLowerPad->cd();
645
648
649 }
650
651 // assign same axis ranges to lower pad as in upper pad
652 // the visual axes will be created on paint
654
656
657 padsav->cd();
658 AppendPad();
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// Returns the reference graph for the lower pad, which means the graph that
663/// is responsible for setting the coordinate system. It is the first graph
664/// added to the primitive list of the lower pad.
665/// This reference can be used to set the minimum and maximum of the lower pad.
666/// Note that `TRatioPlot::Draw` needs to have been called first, since the
667/// graphs are only created then.
668///
669/// Begin_Macro(source)
670/// ../../../tutorials/hist/ratioplot3.C
671/// End_Macro
672
674{
675 if (!fLowerPad) {
676 Error("GetLowerRefGraph", "Lower pad has not been defined");
677 return nullptr;
678 }
679
680 TList *primlist = fLowerPad->GetListOfPrimitives();
681 if (primlist->GetSize() == 0) {
682 Error("GetLowerRefGraph", "Lower pad does not have primitives");
683 return nullptr;
684 }
685
686 TObjLink *lnk = primlist->FirstLink();
687
688 while (lnk) {
689 TObject *obj = lnk->GetObject();
690
691 if (obj->InheritsFrom(TGraph::Class())) {
692 return (TGraph*)obj;
693 }
694
695 lnk = lnk->Next();
696 }
697
698 Error("GetLowerRefGraph", "Did not find graph in list");
699 return nullptr;
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Return the reference object. Its the first TH1 or THStack type object
704/// in the upper pads list of primitives.
705/// Note that it returns a `TObject`, so you need to test and cast it to use it.
706
708{
709 TList *primlist = fUpperPad->GetListOfPrimitives();
710 TObject *refobj = nullptr;
711 for (Int_t i = 0; i < primlist->GetSize(); ++i) {
712 refobj = primlist->At(i);
713 if (refobj->InheritsFrom(TH1::Class()) || refobj->InheritsFrom(THStack::Class())) {
714 return refobj;
715 }
716 }
717
718 Error("GetUpperRefObject", "No upper ref object of TH1 or THStack type found");
719 return nullptr;
720}
721
722////////////////////////////////////////////////////////////////////////////////
723/// Gets the x axis of the object returned by `TRatioPlot::GetUpperRefObject`.
724
726{
727 TObject *refobj = GetUpperRefObject();
728
729 if (!refobj)
730 return nullptr;
731
732 if (refobj->InheritsFrom(TH1::Class())) {
733 return ((TH1*)refobj)->GetXaxis();
734 } else if (refobj->InheritsFrom(THStack::Class())) {
735 return ((THStack*)refobj)->GetXaxis();
736 }
737
738 return nullptr;
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// Gets the y axis of the object returned by `TRatioPlot::GetUpperRefObject`.
743
745{
746 TObject *refobj = GetUpperRefObject();
747
748 if (!refobj)
749 return nullptr;
750
751 if (refobj->InheritsFrom(TH1::Class())) {
752 return ((TH1*)refobj)->GetYaxis();
753 } else if (refobj->InheritsFrom(THStack::Class())) {
754 return ((THStack*)refobj)->GetYaxis();
755 }
756
757 return nullptr;
758}
759
760////////////////////////////////////////////////////////////////////////////////
761/// Create a grid line
762
764{
765
766 if (!fShowGridlines)
767 return; // don't draw them
768
770
771 unsigned int dest = fGridlinePositions.size();
772
773 Double_t lowYFirst = fLowerPad->GetUymin();
774 Double_t lowYLast = fLowerPad->GetUymax();
775
776 double y;
777 int outofrange = 0;
778 for (unsigned int i=0;i<fGridlinePositions.size();++i) {
779 y = fGridlinePositions.at(i);
780
781 if (y < lowYFirst || lowYLast < y) {
782 ++outofrange;
783 }
784 }
785
786 dest = dest - outofrange;
787
788 // clear all
789 for (unsigned int i=0;i<fGridlines.size();++i) {
790 delete fGridlines.at(i);
791 }
792
793 fGridlines.erase(fGridlines.begin(), fGridlines.end());
794
795 for (unsigned int i=0;i<dest;++i) {
796 TLine *newline = new TLine(0, 0, 0, 0);
797 newline->SetLineStyle(2);
798 newline->Draw();
799 fGridlines.push_back(newline);
800 }
801
804
805 unsigned int skipped = 0;
806 for (unsigned int i=0;i<fGridlinePositions.size();++i) {
808
809 if (y < lowYFirst || lowYLast < y) {
810 // this is one of the ones that was out of range
811 ++skipped;
812 continue;
813 }
814
815 auto line = fGridlines.at(i-skipped);
816
817 line->SetX1(first);
818 line->SetX2(last);
819 line->SetY1(y);
820 line->SetY2(y);
821 }
822}
823
824////////////////////////////////////////////////////////////////////////////////
825/// Creates the visual axes when painting.
826
828{
829 // create the visual axes
832
834}
835
836////////////////////////////////////////////////////////////////////////////////
837/// Syncs the axes ranges from the shared ones to the actual ones.
838
840{
841 // get ranges from the shared axis clone
844
845 // set range on computed graph, have to set it twice because
846 // TGraph's axis looks strange otherwise
847 TAxis *ref = GetLowerRefXaxis();
848 ref->SetLimits(first, last);
849 ref->SetRangeUser(first, last);
850
852
853}
854
855////////////////////////////////////////////////////////////////////////////////
856/// Build the lower plot according to which constructor was called, and
857/// which options were passed.
858
860{
861 // Clear and delete the graph if not exists
862 if (fRatioGraph) {
864 fRatioGraph = nullptr;
865 }
866
869
872
873 static Double_t divideGridlines[] = {0.7, 1.0, 1.3};
874 static Double_t diffGridlines[] = {0.0};
875 static Double_t signGridlines[] = {1.0, 0.0, -1.0};
876
877 // Determine the divide mode and create the lower graph accordingly
878 // Pass divide options given in constructor
880 // use TGraphAsymmErrors Divide method to create
881
882 SetGridlines(divideGridlines, 3);
883
884 TH1 *tmpH1 = (TH1*)fH1->Clone();
885 TH1 *tmpH2 = (TH1*)fH2->Clone();
886
887 tmpH1->Scale(fC1);
888 tmpH2->Scale(fC2);
889
890 TGraphAsymmErrors *ratioGraph = new TGraphAsymmErrors();
891 ratioGraph->Divide(tmpH1, tmpH2, fOption.Data());
892 fRatioGraph = ratioGraph;
893
894 delete tmpH1;
895 delete tmpH2;
896
898 SetGridlines(diffGridlines, 3);
899
900 TH1 *tmpHist = (TH1*)fH1->Clone();
901
902 tmpHist->Reset();
903
904 tmpHist->Add(fH1, fH2, fC1, -1*fC2);
905 fRatioGraph = new TGraphErrors(tmpHist);
906
907 delete tmpHist;
909
910 SetGridlines(signGridlines, 3);
911
913 Int_t ipoint = 0;
914 Double_t res;
915 Double_t error;
916
917 Double_t val;
918 Double_t val2;
919
920 for (Int_t i=0; i<=fH1->GetNbinsX();++i) {
921 val = fH1->GetBinContent(i);
922 val2 = fH2->GetBinContent(i);
923
925
926 Double_t errUp = fH1->GetBinErrorUp(i);
927 Double_t errLow = fH1->GetBinErrorLow(i);
928
929 if (val - val2 > 0) {
930 // h1 > h2
931 error = errLow;
932 } else {
933 // h1 < h2
934 error = errUp;
935 }
936
938 error = fH1->GetBinError(i);
939 } else {
940 Warning("BuildLowerPlot", "error mode is invalid");
941 error = 0;
942 }
943
944 if (error != 0) {
945
946 res = (val - val2) / error;
947
948 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
949 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
950
951 ++ipoint;
952
953 }
954 }
955
957
958 SetGridlines(signGridlines, 3);
959
960 TF1 *func = dynamic_cast<TF1*>(fH1->GetListOfFunctions()->At(0));
961
962 if (!func) {
963 // this is checked in constructor and should thus not occur
964 Error("BuildLowerPlot", "h1 does not have a fit function");
965 return 0;
966 }
967
969 Int_t ipoint = 0;
970
971 Double_t res;
972 Double_t error;
973
974 std::vector<double> ci1;
975 std::vector<double> ci2;
976
977 Double_t *x_arr = new Double_t[fH1->GetNbinsX()];
978 std::fill_n(x_arr, fH1->GetNbinsX(), 0);
979 Double_t *ci_arr1 = new Double_t[fH1->GetNbinsX()];
980 std::fill_n(ci_arr1, fH1->GetNbinsX(), 0);
981 Double_t *ci_arr2 = new Double_t[fH1->GetNbinsX()];
982 std::fill_n(ci_arr2, fH1->GetNbinsX(), 0);
983 for (Int_t i=0; i<fH1->GetNbinsX();++i) {
984 x_arr[i] = fH1->GetBinCenter(i+1);
985 }
986
987 Double_t cl1 = fCl1;
988 Double_t cl2 = fCl2;
989
990 if (fFitResult) {
991 // use this to get conf int
992
993 fFitResult->GetConfidenceIntervals(fH1->GetNbinsX(), 1, 1, x_arr, ci_arr1, cl1);
994 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
995 ci1.push_back(ci_arr1[i-1]);
996 }
997
998 fFitResult->GetConfidenceIntervals(fH1->GetNbinsX(), 1, 1, x_arr, ci_arr2, cl2);
999 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1000 ci2.push_back(ci_arr2[i-1]);
1001 }
1002 } else {
1003 TVirtualFitter::GetFitter()->GetConfidenceIntervals(fH1->GetNbinsX(), 1, x_arr, ci_arr1, cl1);
1004 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1005 ci1.push_back(ci_arr1[i-1]);
1006 }
1007 TVirtualFitter::GetFitter()->GetConfidenceIntervals(fH1->GetNbinsX(), 1, x_arr, ci_arr2, cl2);
1008 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1009 ci2.push_back(ci_arr2[i-1]);
1010 }
1011
1012 }
1013
1014 Double_t x;
1015 Double_t val;
1016
1017 for (Int_t i=0; i<=fH1->GetNbinsX();++i) {
1018 val = fH1->GetBinContent(i);
1019 x = fH1->GetBinCenter(i+1);
1020
1022
1023 Double_t errUp = fH1->GetBinErrorUp(i);
1024 Double_t errLow = fH1->GetBinErrorLow(i);
1025
1026 if (val - func->Eval(fH1->GetBinCenter(i)) > 0) {
1027 // h1 > fit
1028 error = errLow;
1029 } else {
1030 // h1 < fit
1031 error = errUp;
1032 }
1033
1035 error = fH1->GetBinError(i);
1037
1038 error = sqrt(func->Eval(x));
1039
1040 } else {
1041 Warning("BuildLowerPlot", "error mode is invalid");
1042 error = 0;
1043 }
1044
1045 if (error != 0) {
1046
1047 res = (fH1->GetBinContent(i)- func->Eval(fH1->GetBinCenter(i) ) ) / error;
1048 //__("x="<< x << " y=" << res << " err=" << error);
1049
1050 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
1051 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
1052
1053 fConfidenceInterval1->SetPoint(ipoint, x, 0);
1054 fConfidenceInterval1->SetPointError(ipoint, x, i < (Int_t)ci1.size() ? ci1[i] / error : 0);
1055 fConfidenceInterval2->SetPoint(ipoint, x, 0);
1056 fConfidenceInterval2->SetPointError(ipoint, x, i < (Int_t)ci2.size() ? ci2[i] / error : 0);
1057
1058 ++ipoint;
1059
1060 }
1061
1062 }
1063 delete [] x_arr;
1064 delete [] ci_arr1;
1065 delete [] ci_arr2;
1067 SetGridlines(divideGridlines, 3);
1068
1069 // Use TH1's Divide method
1070 TH1 *tmpHist = (TH1*)fH1->Clone();
1071 tmpHist->Reset();
1072
1073 tmpHist->Divide(fH1, fH2, fC1, fC2, fOption.Data());
1074 fRatioGraph = new TGraphErrors(tmpHist);
1075
1076 delete tmpHist;
1077 } else {
1078 // this should not occur
1079 Error("BuildLowerPlot", "Invalid fMode value");
1080 return 0;
1081 }
1082
1083 // need to set back to "" since recreation. we don't ever want
1084 // title on lower graph
1085
1086 if (!fRatioGraph) {
1087 Error("BuildLowerPlot", "Error creating lower graph");
1088 return 0;
1089 }
1090
1091 fRatioGraph->SetTitle("");
1094
1095 return 1;
1096}
1097
1098////////////////////////////////////////////////////////////////////////////////
1099/// (Re-)Creates the TGAxis objects that are used for consistent display of the
1100/// axes.
1101
1103{
1105
1106 // this is for errors
1107 TString thisfunc = "CreateVisualAxes";
1108
1109 // figure out where the axis has to go.
1110 // Implicit assumption is, that the top pad spans the full other pads
1115
1116 Double_t lowTM = fLowerPad->GetTopMargin();
1118 Double_t lowLM = fLowerPad->GetLeftMargin();
1120
1123
1124 Double_t upYFirst = fUpperPad->GetUymin();
1125 Double_t upYLast = fUpperPad->GetUymax();
1126 Double_t lowYFirst = fLowerPad->GetUymin();
1127 Double_t lowYLast = fLowerPad->GetUymax();
1128
1130
1131 // check if gPad has the all sides axis set
1132 Bool_t mirroredAxes = fParentPad->GetFrameFillStyle() == 0;
1133 Bool_t axistop = fParentPad->GetTickx() == 1 || mirroredAxes;
1134 Bool_t axisright = fParentPad->GetTicky() == 1 || mirroredAxes;
1135
1136 Bool_t logx = fUpperPad->GetLogx() || fLowerPad->GetLogx();
1137 Bool_t uplogy = fUpperPad->GetLogy();
1138 Bool_t lowlogy = fLowerPad->GetLogy();
1139
1140 if (uplogy) {
1141
1142 upYFirst = TMath::Power(10, upYFirst);
1143 upYLast = TMath::Power(10, upYLast);
1144
1145 if (upYFirst <= 0 || upYLast <= 0) {
1146 Error(thisfunc, "Cannot set upper Y axis to log scale");
1147 }
1148 }
1149
1150 if (lowlogy) {
1151 lowYFirst = TMath::Power(10, lowYFirst);
1152 lowYLast = TMath::Power(10, lowYLast);
1153
1154 if (lowYFirst <= 0 || lowYLast <= 0) {
1155 Error(thisfunc, "Cannot set lower Y axis to log scale");
1156 }
1157
1158 }
1159
1160 // this is different than in y, y already has pad coords converted, x not...
1161 if (logx) {
1162 if (first <= 0 || last <= 0) {
1163 Error(thisfunc, "Cannot set X axis to log scale");
1164 }
1165 }
1166
1167 // determine axes options to create log axes if needed
1168 TString xopt = "";
1169 if (logx) xopt.Append("G");
1170 TString upyopt = "";
1171 if (uplogy) upyopt.Append("G");
1172 TString lowyopt = "";
1173 if (lowlogy) lowyopt.Append("G");
1174
1175 // only actually create them once, reuse otherwise b/c memory
1176 if (!fUpperGXaxis) {
1177 fUpperGXaxis = new TGaxis(0, 0, 1, 1, 0, 1, 510, "+U"+xopt);
1178 fUpperGXaxis->Draw();
1179 }
1180
1181 if (!fUpperGYaxis) {
1182 fUpperGYaxis = new TGaxis(0, 0, 1, 1, upYFirst, upYLast, 510, "S"+upyopt);
1183 fUpperGYaxis->Draw();
1184 }
1185
1186 if (!fLowerGXaxis) {
1187 fLowerGXaxis = new TGaxis(0, 0, 1, 1, first, last, 510, "+S"+xopt);
1188 fLowerGXaxis->Draw();
1189 }
1190
1191 if (!fLowerGYaxis) {
1192 fLowerGYaxis = new TGaxis(0, 0, 1, 1, lowYFirst, lowYLast, 510, "-S"+lowyopt);
1193 fLowerGYaxis->Draw();
1194 }
1195
1196 // import infos from TAxis
1201
1202 // lower x axis needs to get title from upper x
1204
1205 // (re)set all the axes properties to what we want them
1207
1208 fUpperGXaxis->SetX1(upLM);
1209 fUpperGXaxis->SetX2(1-upRM);
1210 fUpperGXaxis->SetY1(upBM*(1-sf)+sf);
1211 fUpperGXaxis->SetY2(upBM*(1-sf)+sf);
1213 fUpperGXaxis->SetWmax(last);
1214
1215 fUpperGYaxis->SetX1(upLM);
1216 fUpperGYaxis->SetX2(upLM);
1217 fUpperGYaxis->SetY1(upBM*(1-sf)+sf);
1218 fUpperGYaxis->SetY2( (1-upTM)*(1-sf)+sf );
1219 fUpperGYaxis->SetWmin(upYFirst);
1220 fUpperGYaxis->SetWmax(upYLast);
1221
1222 fLowerGXaxis->SetX1(lowLM);
1223 fLowerGXaxis->SetX2(1-lowRM);
1224 fLowerGXaxis->SetY1(lowBM*sf);
1225 fLowerGXaxis->SetY2(lowBM*sf);
1227 fLowerGXaxis->SetWmax(last);
1228
1229 fLowerGYaxis->SetX1(lowLM);
1230 fLowerGYaxis->SetX2(lowLM);
1231 fLowerGYaxis->SetY1(lowBM*sf);
1232 fLowerGYaxis->SetY2((1-lowTM)*sf);
1233 fLowerGYaxis->SetWmin(lowYFirst);
1234 fLowerGYaxis->SetWmax(lowYLast);
1235
1240
1241 fUpperGXaxis->SetOption("+U"+xopt);
1242 fUpperGYaxis->SetOption("S"+upyopt);
1243 fLowerGXaxis->SetOption("+S"+xopt);
1244 fLowerGYaxis->SetOption("-S"+lowyopt);
1245
1246 // normalize the tick sizes. y axis ticks should be consistent
1247 // even if their length is different
1248 Double_t ratio = ( (upBM-(1-upTM))*(1-sf) ) / ( (lowBM-(1-lowTM))*sf ) ;
1250 Double_t ticksize = fUpperGYaxis->GetTickSize()*ratio;
1251 fLowerGYaxis->SetTickSize(ticksize);
1252
1254
1255 fUpperGYaxis->ChangeLabel(1, -1, 0);
1256
1258
1259 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1260
1261 } else {
1262 if (GetSeparationMargin() < 0.025) {
1263
1266 fUpperGYaxis->ChangeLabel(1, -1, 0);
1268 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1269 }
1270 }
1271
1272 } else {
1273 // reset
1278 }
1279
1280 }
1281 }
1282
1283 // Create the axes on the other sides of the graphs
1284 // This is steered by an option on the containing pad or self
1285 if (axistop || axisright) {
1286
1287 // only actually create them once, reuse otherwise b/c memory
1288 if (!fUpperGXaxisMirror) {
1290 if (axistop) fUpperGXaxisMirror->Draw();
1291 }
1292
1293 if (!fLowerGXaxisMirror) {
1295 if (axistop) fLowerGXaxisMirror->Draw();
1296 }
1297
1298 if (!fUpperGYaxisMirror) {
1300 if (axisright) fUpperGYaxisMirror->Draw();
1301 }
1302
1303 if (!fLowerGYaxisMirror) {
1305 if (axisright) fLowerGYaxisMirror->Draw();
1306 }
1307
1308 // import attributes from shared axes
1313
1314 // remove titles
1319
1320 // move them about and set required positions
1322 fUpperGXaxisMirror->SetX2(1-upRM);
1323 fUpperGXaxisMirror->SetY1((1-upTM)*(1-sf)+sf);
1324 fUpperGXaxisMirror->SetY2((1-upTM)*(1-sf)+sf);
1327
1328 fUpperGYaxisMirror->SetX1(1-upRM);
1329 fUpperGYaxisMirror->SetX2(1-upRM);
1330 fUpperGYaxisMirror->SetY1(upBM*(1-sf)+sf);
1331 fUpperGYaxisMirror->SetY2( (1-upTM)*(1-sf)+sf );
1332 fUpperGYaxisMirror->SetWmin(upYFirst);
1333 fUpperGYaxisMirror->SetWmax(upYLast);
1334
1335 fLowerGXaxisMirror->SetX1(lowLM);
1336 fLowerGXaxisMirror->SetX2(1-lowRM);
1337 fLowerGXaxisMirror->SetY1((1-lowTM)*sf);
1338 fLowerGXaxisMirror->SetY2((1-lowTM)*sf);
1341
1342 fLowerGYaxisMirror->SetX1(1-lowRM);
1343 fLowerGYaxisMirror->SetX2(1-lowRM);
1344 fLowerGYaxisMirror->SetY1(lowBM*sf);
1345 fLowerGYaxisMirror->SetY2((1-lowTM)*sf);
1346 fLowerGYaxisMirror->SetWmin(lowYFirst);
1347 fLowerGYaxisMirror->SetWmax(lowYLast);
1348
1349 // also needs normalized tick size
1351
1352 fUpperGXaxisMirror->SetOption("-S"+xopt);
1353 fUpperGYaxisMirror->SetOption("+S"+upyopt);
1354 fLowerGXaxisMirror->SetOption("-S"+xopt);
1355 fLowerGYaxisMirror->SetOption("+S"+lowyopt);
1356
1361
1366 }
1367
1368}
1369
1370////////////////////////////////////////////////////////////////////////////////
1371/// Sets the margins of all the pads to the value specified in class members.
1372/// This one is called whenever those are changed, e.g. in setters
1373
1375{
1384}
1385
1386////////////////////////////////////////////////////////////////////////////////
1387/// Figures out which pad margin has deviated from the stored ones,
1388/// to figure out what the new nominal is and set the other pad to it
1389/// subsequently.
1390
1392{
1393
1394 Bool_t changed = kFALSE;
1395
1398 changed = kTRUE;
1399 }
1400 else if (fLowerPad->GetLeftMargin() != fLeftMargin) {
1402 changed = kTRUE;
1403 }
1404
1407 changed = kTRUE;
1408 }
1409 else if (fLowerPad->GetRightMargin() != fRightMargin) {
1411 changed = kTRUE;
1412 }
1413
1414 // only reset margins, if any of the margins changed
1415 if (changed) {
1416 SetPadMargins();
1417 }
1418
1419 Bool_t verticalChanged = kFALSE;
1420
1422
1423 verticalChanged = kTRUE;
1425
1426 }
1427
1429
1430 verticalChanged = kTRUE;
1432
1433 }
1434
1436
1438
1439 }
1440
1442
1444
1445 }
1446
1447 // only reset margins, if any of the margins changed
1448 if (verticalChanged) {
1449 SetPadMargins();
1450 }
1451
1452 return changed || verticalChanged;
1453
1454}
1455
1456////////////////////////////////////////////////////////////////////////////////
1457/// Slot that receives the RangeAxisChanged signal from any of the pads and
1458/// reacts correspondingly.
1459
1461{
1462 // check if the ratio plot is already drawn.
1463 if (!IsDrawn()) {
1464 // not drawn yet
1465 return;
1466 }
1467
1468 // Only run this concurrently once, in case it's called async
1469 if (fIsUpdating) {
1470 return;
1471 }
1472
1474
1475 // find out if logx has changed
1476 if (fParentPad->GetLogx()) {
1477 if (!fUpperPad->GetLogx() || !fLowerPad->GetLogx()) {
1479 }
1480 } else {
1481 if (fUpperPad->GetLogx() || fLowerPad->GetLogx()) {
1483 }
1484 }
1485
1486 // set log to pad
1489
1490 // get axis ranges for upper and lower
1491 TAxis *uprefx = GetUpperRefXaxis();
1492 Double_t upFirst = uprefx->GetBinLowEdge(uprefx->GetFirst());
1493 Double_t upLast = uprefx->GetBinUpEdge(uprefx->GetLast());
1494
1495 TAxis *lowrefx = GetLowerRefXaxis();
1496 Double_t lowFirst = lowrefx->GetBinLowEdge(lowrefx->GetFirst());
1497 Double_t lowLast = lowrefx->GetBinUpEdge(lowrefx->GetLast());
1498
1501
1502 Bool_t upChanged = kFALSE;
1503 Bool_t lowChanged = kFALSE;
1504
1505 // determine which one has changed
1506 if (upFirst != globFirst || upLast != globLast) {
1507 fSharedXAxis->SetRangeUser(upFirst, upLast);
1508 upChanged = kTRUE;
1509 }
1510 else if (lowFirst != globFirst || lowLast != globLast) {
1511 fSharedXAxis->SetRangeUser(lowFirst, lowLast);
1512 lowChanged = kTRUE;
1513 }
1514
1515 if (upChanged || lowChanged) {
1519
1520 // @TODO: Updating is not working when zooming on the lower plot. Axes update, but upper hist only on resize
1523 fTopPad->Modified();
1525 }
1526
1527 // sync the margins in case the user has dragged one of them
1528 Bool_t marginsChanged = SyncPadMargins();
1529
1530 if (marginsChanged) {
1533 fTopPad->Modified();
1535 }
1536
1540}
1541
1542////////////////////////////////////////////////////////////////////////////////
1543/// Slot for the UnZoomed signal that was introduced to TAxis.
1544/// Unzoom both pads
1545
1547{
1548 // this is what resets the range
1549 fSharedXAxis->SetRange(0, 0);
1551
1552 // Flushing
1555 fTopPad->Modified();
1557}
1558
1559////////////////////////////////////////////////////////////////////////////////
1560/// Slot that handles common resizing of upper and lower pad.
1561
1563{
1564
1565 if (fIsPadUpdating) {
1566 return;
1567 }
1568
1570
1571 Float_t upylow = fUpperPad->GetYlowNDC();
1572 Float_t lowylow = fLowerPad->GetYlowNDC();
1573 Float_t lowh = fLowerPad->GetHNDC();
1574 Float_t lowyup = lowylow + lowh;
1575
1576 Bool_t changed = kFALSE;
1577
1578 if (upylow != fSplitFraction) {
1579 // up changed
1580 SetSplitFraction(upylow);
1581 changed = kTRUE;
1582 }
1583 else if (lowyup != fSplitFraction) {
1584 // low changed
1585 SetSplitFraction(lowyup);
1586 changed = kTRUE;
1587 }
1588
1589 if (changed) {
1591 }
1592
1594
1595}
1596
1597////////////////////////////////////////////////////////////////////////////////
1598/// Check if ... is drawn.
1599
1601{
1602 TList *siblings = fParentPad->GetListOfPrimitives();
1603 return siblings->FindObject(this) != nullptr;
1604}
1605
1606////////////////////////////////////////////////////////////////////////////////
1607/// Set the fraction of the parent pad, at which the to sub pads should meet
1608
1610{
1611 if (!fParentPad) {
1612 Warning("SetSplitFraction", "Can only be used after TRatioPlot has been drawn.");
1613 return;
1614 }
1615
1616 fSplitFraction = sf;
1617 double pm = fInsetWidth;
1618 double width = fParentPad->GetWNDC();
1619 double height = fParentPad->GetHNDC();
1620 double f = height/width;
1621
1622 fUpperPad->SetPad(pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
1623 fLowerPad->SetPad(pm*f, pm, 1.-pm*f, fSplitFraction);
1624}
1625
1626////////////////////////////////////////////////////////////////////////////////
1627/// Set the inset on the outer sides of all the pads. It's used to make the outer
1628/// pad draggable.
1629
1631{
1632 if (!fParentPad) {
1633 Warning("SetInsetWidth", "Can only be used after TRatioPlot has been drawn.");
1634 return;
1635 }
1636
1639
1640 double pm = fInsetWidth;
1641 double w = fParentPad->GetWNDC();
1642 double h = fParentPad->GetHNDC();
1643 double f = h/w;
1644 fTopPad->SetPad(pm*f, pm, 1-pm*f, 1-pm);
1645}
1646
1647////////////////////////////////////////////////////////////////////////////////
1648/// Sets the confidence levels used to calculate the bands in the fit residual
1649/// case. Defaults to 1 and 2 sigma.
1650
1652{
1653 fCl1 = c1;
1654 fCl2 = c2;
1655 if (!BuildLowerPlot()) return;
1656}
1657
1658////////////////////////////////////////////////////////////////////////////////
1659/// Set where horizontal, dashed lines are drawn on the lower pad.
1660/// Can be used to override existing default lines (or disable them).
1661///
1662/// \param gridlines Vector of y positions for the dashes lines
1663///
1664/// Begin_Macro(source)
1665/// ../../../tutorials/hist/ratioplot4.C
1666/// End_Macro
1667
1668void TRatioPlot::SetGridlines(std::vector<double> gridlines)
1669{
1670 fGridlinePositions = gridlines;
1671}
1672
1673////////////////////////////////////////////////////////////////////////////////
1674/// Set where horizontal, dashed lines are drawn on the lower pad.
1675/// Can be used to override existing default lines (or disable them).
1676///
1677/// \param gridlines Double_t array of y positions for the dashed lines
1678/// \param numGridlines Length of gridlines
1679
1680void TRatioPlot::SetGridlines(Double_t *gridlines, Int_t numGridlines)
1681{
1682 fGridlinePositions.clear();
1683
1684 for (Int_t i=0;i<numGridlines;++i) {
1685 fGridlinePositions.push_back(gridlines[i]);
1686 }
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Set the confidence interval colors.
1691///
1692/// \param ci1 Color of the 1 sigma band
1693/// \param ci2 Color of the 2 sigma band
1694/// Sets the color of the 1 and 2 sigma bands in the fit residual case.
1695/// Begin_Macro(source)
1696/// ../../../tutorials/hist/ratioplot5.C
1697/// End_Macro
1698
1700{
1701 fCi1Color = ci1;
1702 fCi2Color = ci2;
1703}
1704
1705////////////////////////////////////////////////////////////////////////////////
1706/// Internal method to import TAxis attributes to a TGaxis. Copied from
1707/// `TGaxis::ImportAxisAttributes`
1708
1710{
1711 gaxis->SetLineColor(axis->GetAxisColor());
1712 gaxis->SetTextColor(axis->GetTitleColor());
1713 gaxis->SetTextFont(axis->GetTitleFont());
1714 gaxis->SetLabelColor(axis->GetLabelColor());
1715 gaxis->SetLabelFont(axis->GetLabelFont());
1716 gaxis->SetLabelSize(axis->GetLabelSize());
1717 gaxis->SetLabelOffset(axis->GetLabelOffset());
1718 gaxis->SetTickSize(axis->GetTickLength());
1719 gaxis->SetTitle(axis->GetTitle());
1720 gaxis->SetTitleOffset(axis->GetTitleOffset());
1721 gaxis->SetTitleSize(axis->GetTitleSize());
1729 if (axis->GetDecimals()) gaxis->SetBit(TAxis::kDecimals); //the bit is in TAxis::fAxis2
1730 gaxis->SetTimeFormat(axis->GetTimeFormat());
1731}
#define b(i)
Definition RSha256.hxx:100
#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 gROOT
Definition TROOT.h:405
#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:30
const char * GetTitle() const override
Returns title of object.
Definition TAxis.h:130
@ kTickMinus
Definition TAxis.h:60
@ kCenterTitle
Definition TAxis.h:62
@ kRotateTitle
Definition TAxis.h:64
@ kNoExponent
Definition TAxis.h:66
@ kMoreLogLabels
Definition TAxis.h:72
@ kTickPlus
Definition TAxis.h:59
@ kDecimals
Definition TAxis.h:58
@ kCenterLabels
Bit 13 is used by TObject.
Definition TAxis.h:63
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:518
Bool_t GetDecimals() const
Definition TAxis.h:116
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:155
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:978
virtual const char * GetTimeFormat() const
Definition TAxis.h:128
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:952
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
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Definition TClass.cxx:5400
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4874
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-Dim function class
Definition TF1.h:213
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition TF1.cxx:1334
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:1440
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:23
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition TGaxis.cxx:2861
void SetTitleOffset(Float_t titleoffset=1)
Definition TGaxis.h:127
void SetLabelFont(Int_t labelfont)
Definition TGaxis.h:108
void SetTitleSize(Float_t titlesize)
Definition TGaxis.h:128
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition TGaxis.cxx:2834
void SetLabelOffset(Float_t labeloffset)
Definition TGaxis.h:109
const char * GetTitle() const override
Returns title of object.
Definition TGaxis.h:89
virtual void SetNdivisions(Int_t ndiv)
Definition TGaxis.h:117
void SetWmax(Double_t wmax)
Definition TGaxis.h:132
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, TString labText="")
Define new text attributes for the label number "labNum".
Definition TGaxis.cxx:2682
void SetLabelColor(Int_t labelcolor)
Definition TGaxis.h:107
Float_t GetTickSize() const
Definition TGaxis.h:94
void SetWmin(Double_t wmin)
Definition TGaxis.h:131
void SetTickSize(Float_t ticksize)
Definition TGaxis.h:121
void SetLabelSize(Float_t labelsize)
Definition TGaxis.h:110
void SetOption(Option_t *option="")
To set axis options.
Definition TGaxis.cxx:2826
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
TClass * IsA() const override
Definition TGraph.h:199
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
Definition TGraph.cxx:808
TAxis * GetYaxis() const
Get y axis of the graph.
Definition TGraph.cxx:1559
void SetTitle(const char *title="") override
Change (i.e.
Definition TGraph.cxx:2380
TClass * IsA() const override
Definition TH1.h:596
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
Definition TH1.cxx:9007
static TClass * Class()
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition TH1.cxx:8929
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition TH1.cxx:7091
TAxis * GetXaxis()
Definition TH1.h:322
virtual Int_t GetNbinsX() const
Definition TH1.h:295
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:807
TAxis * GetYaxis()
Definition TH1.h:323
virtual Double_t GetBinErrorLow(Int_t bin) const
Return lower error associated to bin number bin.
Definition TH1.cxx:8945
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3060
TList * GetListOfFunctions() const
Definition TH1.h:242
TClass * IsA() const override
Definition TH1.h:440
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:5025
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
Definition TH1.cxx:9029
virtual Double_t GetBinErrorUp(Int_t bin) const
Return upper error associated to bin number bin.
Definition TH1.cxx:8976
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition TH1.cxx:6586
virtual Int_t GetSumw2N() const
Definition TH1.h:313
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
Definition TH1.cxx:2727
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:2815
The Histogram stack class.
Definition THStack.h:38
TList * GetHists() const
Definition THStack.h:70
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
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:578
virtual TObjLink * FirstLink() const
Definition TList.h:102
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:357
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:201
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:223
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:956
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:774
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:970
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:331
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:5908
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:6005
void Modified(Bool_t flag=1) override
Definition TPad.h:417
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:5934
void SetGridy(Int_t value=1) override
Definition TPad.h:332
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:5920
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
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:95
TAxis * GetLowerRefXaxis() const
Shortcut for:
Definition TRatioPlot.h:198
Int_t fErrorMode
Stores the error mode, sym, asym or func.
Definition TRatioPlot.h:84
TAxis * GetLowerRefYaxis() const
Shortcut for:
Definition TRatioPlot.h:207
TGaxis * fUpperGXaxisMirror
Upper mirror of the x axis.
Definition TRatioPlot.h:114
TGaxis * fLowerGXaxisMirror
Lower mirror of the x axis.
Definition TRatioPlot.h:115
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:132
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:130
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:107
virtual Bool_t SyncPadMargins()
Figures out which pad margin has deviated from the stored ones, to figure out what the new nominal is...
Color_t fCi1Color
Stores the color for the 1 sigma band.
Definition TRatioPlot.h:96
TGaxis * fUpperGYaxis
Upper graphical y axis.
Definition TRatioPlot.h:112
Double_t fC2
Stores the scale factor for h2.
Definition TRatioPlot.h:105
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.
Bool_t IsDrawn()
Check if ... is drawn.
Double_t fC1
Stores the scale factor for h1 (or THStack sum)
Definition TRatioPlot.h:104
virtual void CreateVisualAxes()
(Re-)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:131
TString fH2DrawOpt
Stores draw option for h2 given in constructor.
Definition TRatioPlot.h:87
void SetUpTopMargin(Float_t margin)
Sets the top margin of the upper pad.
TGaxis * fLowerGXaxis
Lower graphical x axis.
Definition TRatioPlot.h:111
TRatioPlot()
TRatioPlot default constructor.
Bool_t fIsUpdating
Keeps track of whether its currently updating to reject other calls until done.
Definition TRatioPlot.h:139
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:101
virtual ~TRatioPlot()
Destructor.
@ 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:122
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:109
TString fFitDrawOpt
Stores draw option for the fit function in the fit residual case.
Definition TRatioPlot.h:89
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:116
virtual void SetupPads()
Setup the pads.
TAxis * fUpYaxis
Clone of the upper y axis.
Definition TRatioPlot.h:119
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:129
void SetH1DrawOpt(Option_t *opt)
Sets the drawing option for h1.
TGraph * fRatioGraph
Stores the lower plot's graph.
Definition TRatioPlot.h:93
virtual TGraph * GetLowerRefGraph() const
Returns the reference graph for the lower pad, which means the graph that is responsible for setting ...
Int_t fMode
Stores which calculation is supposed to be performed as specified by user option.
Definition TRatioPlot.h:83
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:135
TGaxis * fLowerGYaxisMirror
Lower mirror of the y axis.
Definition TRatioPlot.h:117
Int_t fHideLabelMode
Stores which label to hide if the margin is to narrow, if at all.
Definition TRatioPlot.h:125
void CreateGridline()
Create a grid line.
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.
void Browse(TBrowser *b) override
Browse.
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 TAxis.
Bool_t fIsPadUpdating
Keeps track whether pads are updating during resizing.
Definition TRatioPlot.h:140
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:102
TAxis * fLowYaxis
Clone of the lower y axis.
Definition TRatioPlot.h:120
TString fOption
Stores the option which is given in the constructor as a string.
Definition TRatioPlot.h:85
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:99
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.
Float_t fInsetWidth
Definition TRatioPlot.h:137
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:134
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:91
void Paint(Option_t *opt="") override
Creates the visual axes when painting.
virtual TObject * GetUpperRefObject() const
Return the reference object.
TGraphErrors * fConfidenceInterval1
Stores the graph for the 1 sigma band.
Definition TRatioPlot.h:94
TGaxis * fUpperGXaxis
Upper graphical x axis.
Definition TRatioPlot.h:110
std::vector< double > fGridlinePositions
Stores the y positions for the gridlines.
Definition TRatioPlot.h:123
TString fH1DrawOpt
Stores draw option for h1 given in constructor.
Definition TRatioPlot.h:86
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:124
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:88
Color_t fCi2Color
Stores the color for the 2 sigma band.
Definition TRatioPlot.h:97
void SetRightMargin(Float_t margin)
Sets the right margin of both pads.
TGaxis * fLowerGYaxis
Lower graphical y axis.
Definition TRatioPlot.h:113
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:380
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
TString & Append(const char *cs)
Definition TString.h:576
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:636
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
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:61
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
virtual void Modified(Bool_t flag=1)=0
virtual void SetLogx(Int_t value=1)=0
virtual TList * GetListOfPrimitives() const =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
TH1F * h1
Definition legend1.C:5
return c2
Definition legend2.C:14
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:404
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Definition TMath.h:719
Definition first.py:1
th1 Draw()
#define dest(otri, vertexptr)
Definition triangle.c:1041