Logo ROOT  
Reference Guide
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#include <iostream>
29
30/** \class TRatioPlot
31 \ingroup gpad
32Class for displaying ratios, differences and fit residuals.
33
34TRatioPlot has two constructors, one which accepts two histograms, and is responsible
35for setting up the calculation of ratios and differences. This calculation is in part
36delegated to `TEfficiency`. A single option can be given as a parameter, that is
37used to determine which procedure is chosen. The remaining option string is then
38passed through to the calculation, if applicable. The other constructor uses a
39fitted histogram to calculate the fit residual and plot it with the histogram
40and the fit function.
41
42## Ratios and differences
43The simplest case is passing two histograms without specifying any options. This defaults to using
44`TGraphAsymmErrors::Divide`. The `option` variable is passed through, as are the parameters
45`c1` and `c2`, that you can set via `TRatioPlot::SetC1` and `TRatioPlot::SetC1`. If you set the
46`option` to `divsym` the method `TH1::Divide` will be used instead, also receiving all the parameters.
47
48Using the `option` `diff` or `diffsig`, both histograms will be subtracted, and in the case of diffsig,
49the difference will be divided by the uncertainty. `c1` and `c2` will only be used to
50scale the histograms using `TH1::Scale` prior to subtraction.
51
52Available options are for `option`:
53| Option | Description |
54| ---------- | ------------------------------------------------------------ |
55| divsym | uses the histogram `TH1::Divide` method, yields symmetric errors |
56| diff | subtracts the histograms |
57| diffsig | subtracts the histograms and divides by the uncertainty |
58
59Begin_Macro(source)
60../../../tutorials/hist/ratioplot1.C
61End_Macro
62
63## Fit residuals
64A second constructor only accepts a single histogram, but expects it to have a fitted
65function. The function is used to calculate the residual between the fit and the
66histogram. Here, it is expected that h1 has a fit function in it's list of functions. The class calculates the
67difference between the histogram and the fit function at each point and divides it by the uncertainty. There
68are a few option to steer which error is used (as is the case for `diffsig`). The default is to use
69the statistical uncertainty from h1 using `TH1::GetBinError`. If the `option` string contains `errasym`, asymmetric
70errors will be used. The type of error can be steered by `TH1::SetBinErrorOption`. The corresponding error will be used,
71depending on if the function is below or above the bin content. The third option `errfunc` uses the square root of
72the function value as the error.
73
74
75Begin_Macro(source)
76../../../tutorials/hist/ratioplot2.C
77End_Macro
78
79## Error options for difference divided by uncertainty and fit residual
80The uncertainty that is used in the calculation can be steered by providing
81options to the `option` argument.
82
83| Option | Description |
84| ---------- | ------------------------------------------------------------ |
85| errasym | Uses calculated asymmetric errors from `TH1::GetBinErrorUp`/`TH1::GetBinErrorLow`. Note that you need to set `TH1::SetBinErrorOption` first |
86| errfunc | Uses \f$ \sqrt{f(x)} \f$ as the error |
87
88The asymmetric error case uses the upper or lower error depending on the relative size
89of the bin contents, or the bin content and the function value.
90
91## Access to internal parts
92You can access the internal objects that are used to construct the plot via a series of
93methods. `TRatioPlot::GetUpperPad` and `TRatioPlot::GetLowerPad` can be used to draw additional
94elements on top of the existing ones.
95`TRatioPlot::GetLowerRefGraph` returns a reference to the lower pad's graph that
96is responsible for the range, which enables you to modify the range.
97
98\image html gpad_ratioplot.png
99*/
100
101////////////////////////////////////////////////////////////////////////////////
102/// TRatioPlot default constructor
103
105{
106}
107
108////////////////////////////////////////////////////////////////////////////////
109/// Destructor
110
112{
113
114 gROOT->GetListOfCleanups()->Remove(this);
115
119
120 for (unsigned int i=0;i<fGridlines.size();++i) {
121 delete (fGridlines[i]);
122 }
123
133
136}
137
138////////////////////////////////////////////////////////////////////////////////
139/// Internal method that shares constructor logic
140
141void TRatioPlot::Init(TH1* h1, TH1* h2,Option_t *option)
142{
143
144 fH1 = h1;
145 fH2 = h2;
146
147 SetupPads();
148
149 TString optionString = TString(option);
150
151 if (optionString.Contains("divsym")) {
152 optionString.ReplaceAll("divsym", "");
153 fMode = TRatioPlot::CalculationMode::kDivideHist;
154 } else if (optionString.Contains("diffsig")) {
155 optionString.ReplaceAll("diffsig", "");
156 fMode = TRatioPlot::CalculationMode::kDifferenceSign;
157
158 // determine which error style
159 if (optionString.Contains("errasym")) {
160 fErrorMode = TRatioPlot::ErrorMode::kErrorAsymmetric;
161 optionString.ReplaceAll("errasym", "");
162 }
163
164 if (optionString.Contains("errfunc")) {
165 fErrorMode = TRatioPlot::ErrorMode::kErrorFunc;
166 optionString.ReplaceAll("errfunc", "");
167 }
168 } else if (optionString.Contains("diff")) {
169 optionString.ReplaceAll("diff", "");
170 fMode = TRatioPlot::CalculationMode::kDifference;
171 } else {
172 fMode = TRatioPlot::CalculationMode::kDivideGraph; // <- default
173 }
174
175 fOption = optionString;
176
177
178 fH1DrawOpt = "hist";
179 fH2DrawOpt = "E";
180 fGraphDrawOpt = "AP";
181
182
183 // build ratio, everything is ready
184 if (!BuildLowerPlot()) return;
185
186 // taking x axis information from h1 by cloning it x axis
187 fSharedXAxis = (TAxis*)(fH1->GetXaxis()->Clone());
188 fUpYaxis = (TAxis*)(fH1->GetYaxis()->Clone());
190}
191
192////////////////////////////////////////////////////////////////////////////////
193/// Constructor for two histograms
194///
195/// \param h1 First histogram
196/// \param h2 Second histogram
197/// \param option Steers the error calculation, as well as ratio / difference
198
200 : fGridlines()
201{
202 gROOT->GetListOfCleanups()->Add(this);
203
204 if (!h1 || !h2) {
205 Warning("TRatioPlot", "Need two histograms.");
206 return;
207 }
208
209 Bool_t h1IsTH1=h1->IsA()->InheritsFrom(TH1::Class());
210 Bool_t h2IsTH1=h2->IsA()->InheritsFrom(TH1::Class());
211
212 if (!h1IsTH1 && !h2IsTH1) {
213 Warning("TRatioPlot", "Need two histograms deriving from TH2 or TH3.");
214 return;
215 }
216
218
219 Init(h1, h2, option);
220
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Constructor which accepts a `THStack` and a histogram. Converts the
225/// stack to a regular sum of its containing histograms for processing.
226///
227/// \param st The THStack object
228/// \param h2 The other histogram
229/// \param option Steers the calculation of the lower plot
230
232{
233 if (!st || !h2) {
234 Warning("TRatioPlot", "Need a histogram and a stack");
235 return;
236 }
237
238 TList *stackHists = st->GetHists();
239
240 if (stackHists->GetSize() == 0) {
241 Warning("TRatioPlot", "Stack does not have histograms");
242 return;
243 }
244
245 TH1* tmpHist = (TH1*)stackHists->At(0)->Clone();
246 tmpHist->Reset();
247
248 for (int i=0;i<stackHists->GetSize();++i) {
249 tmpHist->Add((TH1*)stackHists->At(i));
250 }
251
252 fHistDrawProxy = st;
253
254 Init(tmpHist, h2, option);
255
256}
257
258////////////////////////////////////////////////////////////////////////////////
259/// Constructor for one histogram and a fit.
260///
261/// \param h1 The histogram
262/// \param option Steers the error calculation
263/// \param fitres Explicit fit result to be used for calculation. Uses last fit if left empty
264
266 : fH1(h1),
267 fGridlines()
268{
269 gROOT->GetListOfCleanups()->Add(this);
270
271 if (!fH1) {
272 Warning("TRatioPlot", "Need a histogram.");
273 return;
274 }
275
276 Bool_t h1IsTH1=fH1->IsA()->InheritsFrom(TH1::Class());
277
278 if (!h1IsTH1) {
279 Warning("TRatioPlot", "Need a histogram deriving from TH2 or TH3.");
280 return;
281 }
282
283 TList *h1Functions = fH1->GetListOfFunctions();
284
285 if (h1Functions->GetSize() < 1) {
286 Warning("TRatioPlot", "Histogram given needs to have a (fit) function associated with it");
287 return;
288 }
289
290
292
293 fFitResult = fitres;
294
295 fMode = TRatioPlot::CalculationMode::kFitResidual;
296
297 TString optionString = TString(option);
298
299 // determine which error style
300 if (optionString.Contains("errasym")) {
301 fErrorMode = TRatioPlot::ErrorMode::kErrorAsymmetric;
302 optionString.ReplaceAll("errasym", "");
303 }
304
305 if (optionString.Contains("errfunc")) {
306 fErrorMode = TRatioPlot::ErrorMode::kErrorFunc;
307 optionString.ReplaceAll("errfunc", "");
308 }
309
310 fOption = optionString;
311
312 if (!BuildLowerPlot()) return;
313
314 // emulate option behaviour of TH1
315 if (fH1->GetSumw2N() > 0) {
316 fH1DrawOpt = "E";
317 } else {
318 fH1DrawOpt = "hist";
319 }
320 fGraphDrawOpt = "LX"; // <- default
321
322 fSharedXAxis = (TAxis*)(fH1->GetXaxis()->Clone());
323 fUpYaxis = (TAxis*)(fH1->GetYaxis()->Clone());
325
326 //SyncAxesRanges();
327
328 SetupPads();
329
330}
331
332////////////////////////////////////////////////////////////////////////////////
333/// Sets the drawing option for h1
334
336{
337 fH1DrawOpt = opt;
338}
339
340////////////////////////////////////////////////////////////////////////////////
341/// Sets the drawing option for h2
342
344{
345 TString optString = TString(opt);
346 optString.ReplaceAll("same", "");
347 optString.ReplaceAll("SAME", "");
348
349 fH2DrawOpt = optString;
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Sets the drawing option for the lower graph
354
356{
357 fGraphDrawOpt = opt;
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Sets the drawing option for the fit in the fit residual case
362
364{
365 fFitDrawOpt = opt;
366}
367
368////////////////////////////////////////////////////////////////////////////////
369/// Setup the pads.
370
372
373 // this method will delete all the pads before recreating them
374
375 if (fUpperPad != 0) {
376 delete fUpperPad;
377 fUpperPad = 0;
378 }
379
380 if (fLowerPad != 0) {
381 delete fLowerPad;
382 fLowerPad = 0;
383 }
384
385 if (!gPad) {
386 Error("SetupPads", "need to create a canvas first");
387 return;
388 }
389
390 double pm = fInsetWidth;
391 double width = gPad->GetWNDC();
392 double height = gPad->GetHNDC();
393 double f = height/width;
394
395 fUpperPad = new TPad("upper_pad", "", pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
396 fLowerPad = new TPad("lower_pad", "", pm*f, pm, 1.-pm*f, fSplitFraction);
397
399
400 // connect to the pads signal
401 fUpperPad->Connect("RangeAxisChanged()", "TRatioPlot", this, "RangeAxisChanged()");
402 fLowerPad->Connect("RangeAxisChanged()", "TRatioPlot", this, "RangeAxisChanged()");
403
404 fUpperPad->Connect("UnZoomed()", "TRatioPlot", this, "UnZoomed()");
405 fLowerPad->Connect("UnZoomed()", "TRatioPlot", this, "UnZoomed()");
406
407 fUpperPad->Connect("Resized()", "TRatioPlot", this, "SubPadResized()");
408 fLowerPad->Connect("Resized()", "TRatioPlot", this, "SubPadResized()");
409
410 if (fTopPad != 0) {
411 delete fTopPad;
412 fTopPad = 0;
413 }
414
415 fTopPad = new TPad("top_pad", "", pm*f, pm, 1-pm*f, 1-pm);
416
418
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// Browse.
423
425{
426 Draw(b ? b->GetDrawOption() : "");
427 gPad->Update();
428}
429
430////////////////////////////////////////////////////////////////////////////////
431/// Sets the top margin of the upper pad.
432///
433/// \param margin The new margin
434
436{
437 fUpTopMargin = margin;
439}
440
441////////////////////////////////////////////////////////////////////////////////
442/// Sets the bottom margin of the upper pad.
443///
444/// \param margin The new margin
445
447{
448 fUpBottomMargin = margin;
450}
451
452////////////////////////////////////////////////////////////////////////////////
453/// Sets the top margin of the lower pad.
454///
455/// \param margin The new margin
456
458{
459 fLowTopMargin = margin;
461}
462
463////////////////////////////////////////////////////////////////////////////////
464/// Sets the bottom margin of the lower pad.
465///
466/// \param margin The new margin
467
469{
470 fLowBottomMargin = margin;
472}
473
474////////////////////////////////////////////////////////////////////////////////
475/// Sets the left margin of both pads.
476/// \param margin The new margin
477
479{
480 fLeftMargin = margin;
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Sets the right margin of both pads.
486///
487/// \param margin The new margin
488
490{
491 fRightMargin = margin;
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Sets the margin that separates the two pads. The margin is split according
497/// to the relative sizes of the pads
498///
499/// \param margin The new margin
500///
501/// Begin_Macro(source)
502/// ../../../tutorials/hist/ratioplot6.C
503/// End_Macro
504
506{
508 fUpBottomMargin = margin/2./(1-sf);
509 fLowTopMargin = margin/2./sf;
511}
512
513////////////////////////////////////////////////////////////////////////////////
514/// Return the separation margin value.
515
517{
519 Float_t up = fUpBottomMargin * (1-sf);
520 Float_t down = fLowTopMargin * sf;
521 return up+down;
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Draws the ratio plot to the currently active pad. Therefore it requires that
526/// a TCanvas has been created first.
527///
528/// It takes the following options
529///
530/// | Option | Description |
531/// | ---------- | ------------------------------------------------------------ |
532/// | grid / nogrid | enable (default) or disable drawing of dashed lines on lower plot |
533/// | hideup | hides the first label of the upper axis if there is not enough space |
534/// | fhideup | always hides the first label of the upper axis |
535/// | hidelow (default) | hides the last label of the lower axis if there is not enough space |
536/// | fhidelow | always hides the last label of the lower axis |
537/// | nohide | does not hide a label if there is not enough space |
538/// | noconfint | does not draw the confidence interval bands in the fit residual case |
539/// | confint | draws the confidence interval bands in the fit residual case (default) |
540
542{
543
544 TString drawOpt = option;
545
546 if (drawOpt.Contains("nogrid")) {
547 drawOpt.ReplaceAll("nogrid", "");
549 } else if (drawOpt.Contains("grid")) {
550 drawOpt.ReplaceAll("grid", "");
552 }
553
554 if (drawOpt.Contains("noconfint")) {
555 drawOpt.ReplaceAll("noconfint", "");
557 } else if (drawOpt.Contains("confint")) {
558 drawOpt.ReplaceAll("confint", "");
559 fShowConfidenceIntervals = kTRUE; // <- default
560 }
561
562 if (drawOpt.Contains("fhideup")) {
563 fHideLabelMode = TRatioPlot::HideLabelMode::kForceHideUp;
564 } else if (drawOpt.Contains("fhidelow")) {
565 fHideLabelMode = TRatioPlot::HideLabelMode::kForceHideLow;
566 } else if (drawOpt.Contains("hideup")) {
567 fHideLabelMode = TRatioPlot::HideLabelMode::kHideUp;
568 } else if (drawOpt.Contains("hidelow")) {
569 fHideLabelMode = TRatioPlot::HideLabelMode::kHideLow;
570 } else if (drawOpt.Contains("nohide")) {
571 fHideLabelMode = TRatioPlot::HideLabelMode::kNoHide;
572 } else {
573 fHideLabelMode = TRatioPlot::HideLabelMode::kHideLow; // <- default
574 }
575
576 if (!gPad) {
577 Error("Draw", "need to create a canvas first");
578 return;
579 }
580
581 TVirtualPad *padsav = gPad;
583
587
592
593 // we are a TPad
594
595 fUpperPad->Draw();
596 fLowerPad->Draw();
597
599 fTopPad->Draw();
600
601 fUpperPad->cd();
602
605
606 if (fMode == TRatioPlot::CalculationMode::kFitResidual) {
607 TF1 *func = dynamic_cast<TF1*>(fH1->GetListOfFunctions()->At(0));
608
609 if (func == 0) {
610 // this is checked in constructor and should thus not occur
611 Error("BuildLowerPlot", "h1 does not have a fit function");
612 return;
613 }
614
615 fH1->Draw("A"+fH1DrawOpt);
616 func->Draw(fFitDrawOpt+"same");
617
618 fLowerPad->cd();
619
624 } else {
625 fRatioGraph->Draw("IA"+fGraphDrawOpt+"SAME");
626 }
627 } else {
628
629 if (fHistDrawProxy) {
631 ((TH1*)fHistDrawProxy)->Draw("A"+fH1DrawOpt);
633 ((THStack*)fHistDrawProxy)->Draw("A"+fH1DrawOpt);
634 } else {
635 Warning("Draw", "Draw proxy not of type TH1 or THStack, not drawing it");
636 }
637 }
638
639 fH2->Draw("A"+fH2DrawOpt+"same");
640
641 fLowerPad->cd();
642
645
646 }
647
648 // assign same axis ranges to lower pad as in upper pad
649 // the visual axes will be created on paint
651
653
654 padsav->cd();
655 AppendPad();
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 == 0) {
673 Error("GetLowerRefGraph", "Lower pad has not been defined");
674 return 0;
675 }
676
677 TList *primlist = fLowerPad->GetListOfPrimitives();
678 if (primlist->GetSize() == 0) {
679 Error("GetLowerRefGraph", "Lower pad does not have primitives");
680 return 0;
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 (TGraph*)obj;
690 }
691
692 lnk = lnk->Next();
693 }
694
695 Error("GetLowerRefGraph", "Did not find graph in list");
696 return 0;
697}
698
699////////////////////////////////////////////////////////////////////////////////
700/// Return the reference object. Its the first TH1 or THStack type object
701/// in the upper pads list of primitives.
702/// Note that it returns a `TObject`, so you need to test and cast it to use it.
703
705{
706 TList *primlist = fUpperPad->GetListOfPrimitives();
707 TObject *refobj = 0;
708 for (Int_t i=0;i<primlist->GetSize();++i) {
709 refobj = primlist->At(i);
710 if (refobj->InheritsFrom(TH1::Class()) || refobj->InheritsFrom(THStack::Class())) {
711 return refobj;
712 }
713 }
714
715 Error("GetUpperRefObject", "No upper ref object of TH1 or THStack type found");
716 return 0;
717}
718
719////////////////////////////////////////////////////////////////////////////////
720/// Gets the x axis of the object returned by `TRatioPlot::GetUpperRefObject`.
721
723{
724 TObject *refobj = GetUpperRefObject();
725
726 if (!refobj) return 0;
727
728 if (refobj->InheritsFrom(TH1::Class())) {
729 return ((TH1*)refobj)->GetXaxis();
730 } else if (refobj->InheritsFrom(THStack::Class())) {
731 return ((THStack*)refobj)->GetXaxis();
732 }
733
734 return 0;
735}
736
737////////////////////////////////////////////////////////////////////////////////
738/// Gets the y axis of the object returned by `TRatioPlot::GetUpperRefObject`.
739
741{
742 TObject *refobj = GetUpperRefObject();
743
744 if (!refobj) return 0;
745
746 if (refobj->InheritsFrom(TH1::Class())) {
747 return ((TH1*)refobj)->GetYaxis();
748 } else if (refobj->InheritsFrom(THStack::Class())) {
749 return ((THStack*)refobj)->GetYaxis();
750 }
751
752 return 0;
753}
754
755////////////////////////////////////////////////////////////////////////////////
756/// Create a grid line
757
759{
760
761 if (!fShowGridlines) {
762 return; // don't draw them
763 }
764
765 TVirtualPad *padsav = gPad;
766
767 fLowerPad->cd();
768
769 unsigned int dest = fGridlinePositions.size();
770
771 Double_t lowYFirst = fLowerPad->GetUymin();
772 Double_t lowYLast = fLowerPad->GetUymax();
773
774 double y;
775 int outofrange = 0;
776 for (unsigned int i=0;i<fGridlinePositions.size();++i) {
777 y = fGridlinePositions.at(i);
778
779 if (y < lowYFirst || lowYLast < y) {
780 ++outofrange;
781 }
782
783 }
784
785 dest = dest - outofrange;
786
787 // clear all
788 for (unsigned int i=0;i<fGridlines.size();++i) {
789 delete fGridlines.at(i);
790 }
791
792 fGridlines.erase(fGridlines.begin(), fGridlines.end());
793
794 for (unsigned int i=0;i<dest;++i) {
795 TLine *newline = new TLine(0, 0, 0, 0);
796 newline->SetLineStyle(2);
797 newline->Draw();
798 fGridlines.push_back(newline);
799 }
800
803
804 TLine *line;
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 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 padsav->cd();
824}
825
826////////////////////////////////////////////////////////////////////////////////
827/// Creates the visual axes when painting.
828
830{
831 // create the visual axes
834
836}
837
838////////////////////////////////////////////////////////////////////////////////
839/// Syncs the axes ranges from the shared ones to the actual ones.
840
842{
843 // get ranges from the shared axis clone
846
847 // set range on computed graph, have to set it twice because
848 // TGraph's axis looks strange otherwise
849 TAxis *ref = GetLowerRefXaxis();
850 ref->SetLimits(first, last);
851 ref->SetRangeUser(first, last);
852
854
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Build the lower plot according to which constructor was called, and
859/// which options were passed.
860
862{
863 // Clear and delete the graph if not exists
864 if (fRatioGraph != 0) {
865 fRatioGraph->IsA()->Destructor(fRatioGraph);
866 fRatioGraph = 0;
867 }
868
869 if (fConfidenceInterval1 == 0) {
871 }
872
873 if (fConfidenceInterval2 == 0) {
875 }
876
877 static Double_t divideGridlines[] = {0.7, 1.0, 1.3};
878 static Double_t diffGridlines[] = {0.0};
879 static Double_t signGridlines[] = {1.0, 0.0, -1.0};
880
881 // Determine the divide mode and create the lower graph accordingly
882 // Pass divide options given in constructor
883 if (fMode == TRatioPlot::CalculationMode::kDivideGraph) {
884 // use TGraphAsymmErrors Divide method to create
885
886 SetGridlines(divideGridlines, 3);
887
888 TH1 *tmpH1 = (TH1*)fH1->Clone();
889 TH1 *tmpH2 = (TH1*)fH2->Clone();
890
891 tmpH1->Scale(fC1);
892 tmpH2->Scale(fC2);
893
894 TGraphAsymmErrors *ratioGraph = new TGraphAsymmErrors();
895 ratioGraph->Divide(tmpH1, tmpH2, fOption.Data());
896 fRatioGraph = ratioGraph;
897
898 delete tmpH1;
899 delete tmpH2;
900
901 } else if (fMode == TRatioPlot::CalculationMode::kDifference) {
902 SetGridlines(diffGridlines, 3);
903
904 TH1 *tmpHist = (TH1*)fH1->Clone();
905
906 tmpHist->Reset();
907
908 tmpHist->Add(fH1, fH2, fC1, -1*fC2);
909 fRatioGraph = new TGraphErrors(tmpHist);
910
911 delete tmpHist;
912 } else if (fMode == TRatioPlot::CalculationMode::kDifferenceSign) {
913
914 SetGridlines(signGridlines, 3);
915
917 Int_t ipoint = 0;
918 Double_t res;
919 Double_t error;
920
921 Double_t val;
922 Double_t val2;
923
924 for (Int_t i=0; i<=fH1->GetNbinsX();++i) {
925 val = fH1->GetBinContent(i);
926 val2 = fH2->GetBinContent(i);
927
928 if (fErrorMode == TRatioPlot::ErrorMode::kErrorAsymmetric) {
929
930 Double_t errUp = fH1->GetBinErrorUp(i);
931 Double_t errLow = fH1->GetBinErrorLow(i);
932
933 if (val - val2 > 0) {
934 // h1 > h2
935 error = errLow;
936 } else {
937 // h1 < h2
938 error = errUp;
939 }
940
941 } else if (fErrorMode == TRatioPlot::ErrorMode::kErrorSymmetric) {
942 error = fH1->GetBinError(i);
943 } else {
944 Warning("BuildLowerPlot", "error mode is invalid");
945 error = 0;
946 }
947
948 if (error != 0) {
949
950 res = (val - val2) / error;
951
952 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
953 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
954
955 ++ipoint;
956
957 }
958 }
959
960 } else if (fMode == TRatioPlot::CalculationMode::kFitResidual) {
961
962 SetGridlines(signGridlines, 3);
963
964 TF1 *func = dynamic_cast<TF1*>(fH1->GetListOfFunctions()->At(0));
965
966 if (func == 0) {
967 // this is checked in constructor and should thus not occur
968 Error("BuildLowerPlot", "h1 does not have a fit function");
969 return 0;
970 }
971
973 Int_t ipoint = 0;
974
975 Double_t res;
976 Double_t error;
977
978 std::vector<double> ci1;
979 std::vector<double> ci2;
980
981 Double_t *x_arr = new Double_t[fH1->GetNbinsX()];
982 std::fill_n(x_arr, fH1->GetNbinsX(), 0);
983 Double_t *ci_arr1 = new Double_t[fH1->GetNbinsX()];
984 std::fill_n(ci_arr1, fH1->GetNbinsX(), 0);
985 Double_t *ci_arr2 = new Double_t[fH1->GetNbinsX()];
986 std::fill_n(ci_arr2, fH1->GetNbinsX(), 0);
987 for (Int_t i=0; i<fH1->GetNbinsX();++i) {
988 x_arr[i] = fH1->GetBinCenter(i+1);
989 }
990
991 Double_t cl1 = fCl1;
992 Double_t cl2 = fCl2;
993
994 if (fFitResult != 0) {
995 // use this to get conf int
996
997 fFitResult->GetConfidenceIntervals(fH1->GetNbinsX(), 1, 1, x_arr, ci_arr1, cl1);
998 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
999 ci1.push_back(ci_arr1[i-1]);
1000 }
1001
1002 fFitResult->GetConfidenceIntervals(fH1->GetNbinsX(), 1, 1, x_arr, ci_arr2, cl2);
1003 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1004 ci2.push_back(ci_arr2[i-1]);
1005 }
1006 } else {
1007 (TVirtualFitter::GetFitter())->GetConfidenceIntervals(fH1->GetNbinsX(), 1, x_arr, ci_arr1, cl1);
1008 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1009 ci1.push_back(ci_arr1[i-1]);
1010 }
1011 (TVirtualFitter::GetFitter())->GetConfidenceIntervals(fH1->GetNbinsX(), 1, x_arr, ci_arr2, cl2);
1012 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1013 ci2.push_back(ci_arr2[i-1]);
1014 }
1015
1016 }
1017
1018 Double_t x;
1019 Double_t val;
1020
1021 for (Int_t i=0; i<=fH1->GetNbinsX();++i) {
1022 val = fH1->GetBinContent(i);
1023 x = fH1->GetBinCenter(i+1);
1024
1025 if (fErrorMode == TRatioPlot::ErrorMode::kErrorAsymmetric) {
1026
1027 Double_t errUp = fH1->GetBinErrorUp(i);
1028 Double_t errLow = fH1->GetBinErrorLow(i);
1029
1030 if (val - func->Eval(fH1->GetBinCenter(i)) > 0) {
1031 // h1 > fit
1032 error = errLow;
1033 } else {
1034 // h1 < fit
1035 error = errUp;
1036 }
1037
1038 } else if (fErrorMode == TRatioPlot::ErrorMode::kErrorSymmetric) {
1039 error = fH1->GetBinError(i);
1040 } else if (fErrorMode == TRatioPlot::ErrorMode::kErrorFunc) {
1041
1042 error = sqrt(func->Eval(x));
1043
1044 } else {
1045 Warning("BuildLowerPlot", "error mode is invalid");
1046 error = 0;
1047 }
1048
1049 if (error != 0) {
1050
1051 res = (fH1->GetBinContent(i)- func->Eval(fH1->GetBinCenter(i) ) ) / error;
1052 //__("x="<< x << " y=" << res << " err=" << error);
1053
1054 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
1055 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
1056
1057 fConfidenceInterval1->SetPoint(ipoint, x, 0);
1058 fConfidenceInterval1->SetPointError(ipoint, x, i < (Int_t)ci1.size() ? ci1[i] / error : 0);
1059 fConfidenceInterval2->SetPoint(ipoint, x, 0);
1060 fConfidenceInterval2->SetPointError(ipoint, x, i < (Int_t)ci2.size() ? ci2[i] / error : 0);
1061
1062 ++ipoint;
1063
1064 }
1065
1066 }
1067 delete [] x_arr;
1068 delete [] ci_arr1;
1069 delete [] ci_arr2;
1070 } else if (fMode == TRatioPlot::CalculationMode::kDivideHist){
1071 SetGridlines(divideGridlines, 3);
1072
1073 // Use TH1's Divide method
1074 TH1 *tmpHist = (TH1*)fH1->Clone();
1075 tmpHist->Reset();
1076
1077 tmpHist->Divide(fH1, fH2, fC1, fC2, fOption.Data());
1078 fRatioGraph = new TGraphErrors(tmpHist);
1079
1080 delete tmpHist;
1081 } else {
1082 // this should not occur
1083 Error("BuildLowerPlot", "Invalid fMode value");
1084 return 0;
1085 }
1086
1087 // need to set back to "" since recreation. we don't ever want
1088 // title on lower graph
1089
1090 if (fRatioGraph == 0) {
1091 Error("BuildLowerPlot", "Error creating lower graph");
1092 return 0;
1093 }
1094
1095 fRatioGraph->SetTitle("");
1098
1099 return 1;
1100}
1101
1102////////////////////////////////////////////////////////////////////////////////
1103/// (Re-)Creates the TGAxis objects that are used for consistent display of the
1104/// axes.
1105
1107{
1108 TVirtualPad *padsav = gPad;
1109 fTopPad->cd();
1110
1111 // this is for errors
1112 TString thisfunc = "CreateVisualAxes";
1113
1114 // figure out where the axis has to go.
1115 // Implicit assumption is, that the top pad spans the full other pads
1120
1121 Double_t lowTM = fLowerPad->GetTopMargin();
1123 Double_t lowLM = fLowerPad->GetLeftMargin();
1125
1128
1129 Double_t upYFirst = fUpperPad->GetUymin();
1130 Double_t upYLast = fUpperPad->GetUymax();
1131 Double_t lowYFirst = fLowerPad->GetUymin();
1132 Double_t lowYLast = fLowerPad->GetUymax();
1133
1135
1136 // check if gPad has the all sides axis set
1137 Bool_t mirroredAxes = fParentPad->GetFrameFillStyle() == 0;
1138 Bool_t axistop = fParentPad->GetTickx() == 1 || mirroredAxes;
1139 Bool_t axisright = fParentPad->GetTicky() == 1 || mirroredAxes;
1140
1141 Bool_t logx = fUpperPad->GetLogx() || fLowerPad->GetLogx();
1142 Bool_t uplogy = fUpperPad->GetLogy();
1143 Bool_t lowlogy = fLowerPad->GetLogy();
1144
1145 if (uplogy) {
1146
1147 upYFirst = TMath::Power(10, upYFirst);
1148 upYLast = TMath::Power(10, upYLast);
1149
1150 if (upYFirst <= 0 || upYLast <= 0) {
1151 Error(thisfunc, "Cannot set upper Y axis to log scale");
1152 }
1153 }
1154
1155 if (lowlogy) {
1156 lowYFirst = TMath::Power(10, lowYFirst);
1157 lowYLast = TMath::Power(10, lowYLast);
1158
1159 if (lowYFirst <= 0 || lowYLast <= 0) {
1160 Error(thisfunc, "Cannot set lower Y axis to log scale");
1161 }
1162
1163 }
1164
1165 // this is different than in y, y already has pad coords converted, x not...
1166 if (logx) {
1167 if (first <= 0 || last <= 0) {
1168 Error(thisfunc, "Cannot set X axis to log scale");
1169 }
1170 }
1171
1172 // determine axes options to create log axes if needed
1173 TString xopt = "";
1174 if (logx) xopt.Append("G");
1175 TString upyopt = "";
1176 if (uplogy) upyopt.Append("G");
1177 TString lowyopt = "";
1178 if (lowlogy) lowyopt.Append("G");
1179
1180 // only actually create them once, reuse otherwise b/c memory
1181 if (fUpperGXaxis == 0) {
1182 fUpperGXaxis = new TGaxis(0, 0, 1, 1, 0, 1, 510, "+U"+xopt);
1183 fUpperGXaxis->Draw();
1184 }
1185
1186 if (fUpperGYaxis == 0) {
1187 fUpperGYaxis = new TGaxis(0, 0, 1, 1, upYFirst, upYLast, 510, "S"+upyopt);
1188 fUpperGYaxis->Draw();
1189 }
1190
1191 if (fLowerGXaxis == 0) {
1192 fLowerGXaxis = new TGaxis(0, 0, 1, 1, first, last, 510, "+S"+xopt);
1193 fLowerGXaxis->Draw();
1194 }
1195
1196 if (fLowerGYaxis == 0) {
1197 fLowerGYaxis = new TGaxis(0, 0, 1, 1, lowYFirst, lowYLast, 510, "-S"+lowyopt);
1198 fLowerGYaxis->Draw();
1199 }
1200
1201 // import infos from TAxis
1206
1207 // lower x axis needs to get title from upper x
1209
1210 // (re)set all the axes properties to what we want them
1212
1213 fUpperGXaxis->SetX1(upLM);
1214 fUpperGXaxis->SetX2(1-upRM);
1215 fUpperGXaxis->SetY1(upBM*(1-sf)+sf);
1216 fUpperGXaxis->SetY2(upBM*(1-sf)+sf);
1218 fUpperGXaxis->SetWmax(last);
1219
1220 fUpperGYaxis->SetX1(upLM);
1221 fUpperGYaxis->SetX2(upLM);
1222 fUpperGYaxis->SetY1(upBM*(1-sf)+sf);
1223 fUpperGYaxis->SetY2( (1-upTM)*(1-sf)+sf );
1224 fUpperGYaxis->SetWmin(upYFirst);
1225 fUpperGYaxis->SetWmax(upYLast);
1226
1227 fLowerGXaxis->SetX1(lowLM);
1228 fLowerGXaxis->SetX2(1-lowRM);
1229 fLowerGXaxis->SetY1(lowBM*sf);
1230 fLowerGXaxis->SetY2(lowBM*sf);
1232 fLowerGXaxis->SetWmax(last);
1233
1234 fLowerGYaxis->SetX1(lowLM);
1235 fLowerGYaxis->SetX2(lowLM);
1236 fLowerGYaxis->SetY1(lowBM*sf);
1237 fLowerGYaxis->SetY2((1-lowTM)*sf);
1238 fLowerGYaxis->SetWmin(lowYFirst);
1239 fLowerGYaxis->SetWmax(lowYLast);
1240
1245
1246 fUpperGXaxis->SetOption("+U"+xopt);
1247 fUpperGYaxis->SetOption("S"+upyopt);
1248 fLowerGXaxis->SetOption("+S"+xopt);
1249 fLowerGYaxis->SetOption("-S"+lowyopt);
1250
1251 // normalize the tick sizes. y axis ticks should be consistent
1252 // even if their length is different
1253 Double_t ratio = ( (upBM-(1-upTM))*(1-sf) ) / ( (lowBM-(1-lowTM))*sf ) ;
1255 Double_t ticksize = fUpperGYaxis->GetTickSize()*ratio;
1256 fLowerGYaxis->SetTickSize(ticksize);
1257
1258 if (fHideLabelMode == TRatioPlot::HideLabelMode::kForceHideUp) {
1259
1260 fUpperGYaxis->ChangeLabel(1, -1, 0);
1261
1262 } else if (fHideLabelMode == TRatioPlot::HideLabelMode::kForceHideLow) {
1263
1264 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1265
1266 } else {
1267 if (GetSeparationMargin() < 0.025) {
1268
1269 if (fHideLabelMode != TRatioPlot::HideLabelMode::kNoHide) {
1270 if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideUp) {
1271 fUpperGYaxis->ChangeLabel(1, -1, 0);
1272 } else if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideLow) {
1273 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1274 }
1275 }
1276
1277 } else {
1278 // reset
1279 if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideUp) {
1281 } else if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideLow) {
1283 }
1284
1285 }
1286 }
1287
1288 // Create the axes on the other sides of the graphs
1289 // This is steered by an option on the containing pad or self
1290 if (axistop || axisright) {
1291
1292 // only actually create them once, reuse otherwise b/c memory
1293 if (fUpperGXaxisMirror == 0) {
1295 if (axistop) fUpperGXaxisMirror->Draw();
1296 }
1297
1298 if (fLowerGXaxisMirror == 0) {
1300 if (axistop) fLowerGXaxisMirror->Draw();
1301 }
1302
1303 if (fUpperGYaxisMirror == 0) {
1305 if (axisright) fUpperGYaxisMirror->Draw();
1306 }
1307
1308 if (fLowerGYaxisMirror == 0) {
1310 if (axisright) fLowerGYaxisMirror->Draw();
1311 }
1312
1313 // import attributes from shared axes
1318
1319 // remove titles
1324
1325 // move them about and set required positions
1327 fUpperGXaxisMirror->SetX2(1-upRM);
1328 fUpperGXaxisMirror->SetY1((1-upTM)*(1-sf)+sf);
1329 fUpperGXaxisMirror->SetY2((1-upTM)*(1-sf)+sf);
1332
1333 fUpperGYaxisMirror->SetX1(1-upRM);
1334 fUpperGYaxisMirror->SetX2(1-upRM);
1335 fUpperGYaxisMirror->SetY1(upBM*(1-sf)+sf);
1336 fUpperGYaxisMirror->SetY2( (1-upTM)*(1-sf)+sf );
1337 fUpperGYaxisMirror->SetWmin(upYFirst);
1338 fUpperGYaxisMirror->SetWmax(upYLast);
1339
1340 fLowerGXaxisMirror->SetX1(lowLM);
1341 fLowerGXaxisMirror->SetX2(1-lowRM);
1342 fLowerGXaxisMirror->SetY1((1-lowTM)*sf);
1343 fLowerGXaxisMirror->SetY2((1-lowTM)*sf);
1346
1347 fLowerGYaxisMirror->SetX1(1-lowRM);
1348 fLowerGYaxisMirror->SetX2(1-lowRM);
1349 fLowerGYaxisMirror->SetY1(lowBM*sf);
1350 fLowerGYaxisMirror->SetY2((1-lowTM)*sf);
1351 fLowerGYaxisMirror->SetWmin(lowYFirst);
1352 fLowerGYaxisMirror->SetWmax(lowYLast);
1353
1354 // also needs normalized tick size
1356
1357 fUpperGXaxisMirror->SetOption("-S"+xopt);
1358 fUpperGYaxisMirror->SetOption("+S"+upyopt);
1359 fLowerGXaxisMirror->SetOption("-S"+xopt);
1360 fLowerGYaxisMirror->SetOption("+S"+lowyopt);
1361
1366
1371 }
1372
1373 padsav->cd();
1374
1375}
1376
1377////////////////////////////////////////////////////////////////////////////////
1378/// Sets the margins of all the pads to the value specified in class members.
1379/// This one is called whenever those are changed, e.g. in setters
1380
1382{
1391}
1392
1393////////////////////////////////////////////////////////////////////////////////
1394/// Figures out which pad margin has deviated from the stored ones,
1395/// to figure out what the new nominal is and set the other pad to it
1396/// subsequently.
1397
1399{
1400
1401 Bool_t changed = kFALSE;
1402
1405 changed = kTRUE;
1406 }
1407 else if (fLowerPad->GetLeftMargin() != fLeftMargin) {
1409 changed = kTRUE;
1410 }
1411
1414 changed = kTRUE;
1415 }
1416 else if (fLowerPad->GetRightMargin() != fRightMargin) {
1418 changed = kTRUE;
1419 }
1420
1421 // only reset margins, if any of the margins changed
1422 if (changed) {
1423 SetPadMargins();
1424 }
1425
1426 Bool_t verticalChanged = kFALSE;
1427
1429
1430 verticalChanged = kTRUE;
1432
1433 }
1434
1436
1437 verticalChanged = kTRUE;
1439
1440 }
1441
1443
1445
1446 }
1447
1449
1451
1452 }
1453
1454 // only reset margins, if any of the margins changed
1455 if (verticalChanged) {
1456 SetPadMargins();
1457 }
1458
1459 return changed || verticalChanged;
1460
1461}
1462
1463////////////////////////////////////////////////////////////////////////////////
1464/// Slot that receives the RangeAxisChanged signal from any of the pads and
1465/// reacts correspondingly.
1466
1468{
1469 // check if the ratio plot is already drawn.
1470 if (!IsDrawn()) {
1471 // not drawn yet
1472 return;
1473 }
1474
1475 // Only run this concurrently once, in case it's called async
1476 if (fIsUpdating) {
1477 return;
1478 }
1479
1481
1482 // find out if logx has changed
1483 if (fParentPad->GetLogx()) {
1484 if (!fUpperPad->GetLogx() || !fLowerPad->GetLogx()) {
1486 }
1487 } else {
1488 if (fUpperPad->GetLogx() || fLowerPad->GetLogx()) {
1490 }
1491 }
1492
1493 // set log to pad
1496
1497 // get axis ranges for upper and lower
1498 TAxis *uprefx = GetUpperRefXaxis();
1499 Double_t upFirst = uprefx->GetBinLowEdge(uprefx->GetFirst());
1500 Double_t upLast = uprefx->GetBinUpEdge(uprefx->GetLast());
1501
1502 TAxis *lowrefx = GetLowerRefXaxis();
1503 Double_t lowFirst = lowrefx->GetBinLowEdge(lowrefx->GetFirst());
1504 Double_t lowLast = lowrefx->GetBinUpEdge(lowrefx->GetLast());
1505
1508
1509 Bool_t upChanged = kFALSE;
1510 Bool_t lowChanged = kFALSE;
1511
1512 // determine which one has changed
1513 if (upFirst != globFirst || upLast != globLast) {
1514 fSharedXAxis->SetRangeUser(upFirst, upLast);
1515 upChanged = kTRUE;
1516 }
1517 else if (lowFirst != globFirst || lowLast != globLast) {
1518 fSharedXAxis->SetRangeUser(lowFirst, lowLast);
1519 lowChanged = kTRUE;
1520 }
1521
1522 if (upChanged || lowChanged) {
1526
1527 // @TODO: Updating is not working when zooming on the lower plot. Axes update, but upper hist only on resize
1530 fTopPad->Modified();
1532 }
1533
1534 // sync the margins in case the user has dragged one of them
1535 Bool_t marginsChanged = SyncPadMargins();
1536
1537 if (marginsChanged) {
1540 fTopPad->Modified();
1542 }
1543
1547}
1548
1549////////////////////////////////////////////////////////////////////////////////
1550/// Slot for the UnZoomed signal that was introduced to TAxis.
1551/// Unzoom both pads
1552
1554{
1555 // this is what resets the range
1556 fSharedXAxis->SetRange(0, 0);
1558
1559 // Flushing
1562 fTopPad->Modified();
1564}
1565
1566////////////////////////////////////////////////////////////////////////////////
1567/// Slot that handles common resizing of upper and lower pad.
1568
1570{
1571
1572 if (fIsPadUpdating) {
1573 return;
1574 }
1575
1577
1578 Float_t upylow = fUpperPad->GetYlowNDC();
1579 Float_t lowylow = fLowerPad->GetYlowNDC();
1580 Float_t lowh = fLowerPad->GetHNDC();
1581 Float_t lowyup = lowylow + lowh;
1582
1583 Bool_t changed = kFALSE;
1584
1585 if (upylow != fSplitFraction) {
1586 // up changed
1587 SetSplitFraction(upylow);
1588 changed = kTRUE;
1589 }
1590 else if (lowyup != fSplitFraction) {
1591 // low changed
1592 SetSplitFraction(lowyup);
1593 changed = kTRUE;
1594 }
1595
1596 if (changed) {
1598 }
1599
1601
1602}
1603
1604////////////////////////////////////////////////////////////////////////////////
1605/// Check if ... is drawn.
1606
1608{
1609 TList *siblings = fParentPad->GetListOfPrimitives();
1610 return siblings->FindObject(this) != 0;
1611}
1612
1613////////////////////////////////////////////////////////////////////////////////
1614/// Set the fraction of the parent pad, at which the to sub pads should meet
1615
1617{
1618 if (fParentPad == 0) {
1619 Warning("SetSplitFraction", "Can only be used after TRatioPlot has been drawn.");
1620 return;
1621 }
1622
1623 fSplitFraction = sf;
1624 double pm = fInsetWidth;
1625 double width = fParentPad->GetWNDC();
1626 double height = fParentPad->GetHNDC();
1627 double f = height/width;
1628
1629 fUpperPad->SetPad(pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
1630 fLowerPad->SetPad(pm*f, pm, 1.-pm*f, fSplitFraction);
1631}
1632
1633////////////////////////////////////////////////////////////////////////////////
1634/// Set the inset on the outer sides of all the pads. It's used to make the outer
1635/// pad draggable.
1636
1638{
1639 if (fParentPad == 0) {
1640 Warning("SetInsetWidth", "Can only be used after TRatioPlot has been drawn.");
1641 return;
1642 }
1643
1646
1647 double pm = fInsetWidth;
1648 double w = fParentPad->GetWNDC();
1649 double h = fParentPad->GetHNDC();
1650 double f = h/w;
1651 fTopPad->SetPad(pm*f, pm, 1-pm*f, 1-pm);
1652}
1653
1654////////////////////////////////////////////////////////////////////////////////
1655/// Sets the confidence levels used to calculate the bands in the fit residual
1656/// case. Defaults to 1 and 2 sigma.
1657
1659{
1660 fCl1 = c1;
1661 fCl2 = c2;
1662 if (!BuildLowerPlot()) return;
1663}
1664
1665////////////////////////////////////////////////////////////////////////////////
1666/// Set where horizontal, dashed lines are drawn on the lower pad.
1667/// Can be used to override existing default lines (or disable them).
1668///
1669/// \param gridlines Vector of y positions for the dashes lines
1670///
1671/// Begin_Macro(source)
1672/// ../../../tutorials/hist/ratioplot4.C
1673/// End_Macro
1674
1675void TRatioPlot::SetGridlines(std::vector<double> gridlines)
1676{
1677 fGridlinePositions = gridlines;
1678}
1679
1680////////////////////////////////////////////////////////////////////////////////
1681/// Set where horizontal, dashed lines are drawn on the lower pad.
1682/// Can be used to override existing default lines (or disable them).
1683///
1684/// \param gridlines Double_t array of y positions for the dashed lines
1685/// \param numGridlines Length of gridlines
1686
1687void TRatioPlot::SetGridlines(Double_t *gridlines, Int_t numGridlines)
1688{
1689 fGridlinePositions.clear();
1690
1691 for (Int_t i=0;i<numGridlines;++i) {
1692 fGridlinePositions.push_back(gridlines[i]);
1693 }
1694}
1695
1696////////////////////////////////////////////////////////////////////////////////
1697/// Set the confidence interval colors.
1698///
1699/// \param ci1 Color of the 1 sigma band
1700/// \param ci2 Color of the 2 sigma band
1701/// Sets the color of the 1 and 2 sigma bands in the fit residual case.
1702/// Begin_Macro(source)
1703/// ../../../tutorials/hist/ratioplot5.C
1704/// End_Macro
1705
1707{
1708 fCi1Color = ci1;
1709 fCi2Color = ci2;
1710}
1711
1712////////////////////////////////////////////////////////////////////////////////
1713/// Internal method to import TAxis attributes to a TGaxis. Copied from
1714/// `TGaxis::ImportAxisAttributes`
1715
1717{
1718 gaxis->SetLineColor(axis->GetAxisColor());
1719 gaxis->SetTextColor(axis->GetTitleColor());
1720 gaxis->SetTextFont(axis->GetTitleFont());
1721 gaxis->SetLabelColor(axis->GetLabelColor());
1722 gaxis->SetLabelFont(axis->GetLabelFont());
1723 gaxis->SetLabelSize(axis->GetLabelSize());
1724 gaxis->SetLabelOffset(axis->GetLabelOffset());
1725 gaxis->SetTickSize(axis->GetTickLength());
1726 gaxis->SetTitle(axis->GetTitle());
1727 gaxis->SetTitleOffset(axis->GetTitleOffset());
1728 gaxis->SetTitleSize(axis->GetTitleSize());
1736 if (axis->GetDecimals()) gaxis->SetBit(TAxis::kDecimals); //the bit is in TAxis::fAxis2
1737 gaxis->SetTimeFormat(axis->GetTimeFormat());
1738}
void Class()
Definition: Class.C:29
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
bool Bool_t
Definition: RtypesCore.h:61
double Double_t
Definition: RtypesCore.h:57
short Color_t
Definition: RtypesCore.h:81
float Float_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
double sqrt(double)
#define gROOT
Definition: TROOT.h:406
#define gPad
Definition: TVirtualPad.h:287
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.
Definition: FitResult.cxx:545
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:100
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:110
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:120
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:130
Float_t GetTopMargin() const
Definition: TAttPad.h:46
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:43
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
Class to manage histogram axis.
Definition: TAxis.h:30
@ 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
Definition: TAxis.h:63
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition: TAxis.cxx:515
Bool_t GetDecimals() const
Definition: TAxis.h:116
Int_t GetLast() const
Return last bin on the axis i.e.
Definition: TAxis.cxx:466
virtual void SetLimits(Double_t xmin, Double_t xmax)
Definition: TAxis.h:154
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates).
Definition: TAxis.cxx:939
virtual const char * GetTimeFormat() const
Definition: TAxis.h:127
const char * GetTitle() const
Returns title of object.
Definition: TAxis.h:129
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis from bin first to last.
Definition: TAxis.cxx:914
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:525
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:455
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
1-Dim function class
Definition: TF1.h:210
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF1.cxx:1320
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:1432
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
Definition: TFitResult.h:32
The axis painter class.
Definition: TGaxis.h:24
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition: TGaxis.cxx:2721
void SetTitleOffset(Float_t titleoffset=1)
Definition: TGaxis.h:125
void SetLabelFont(Int_t labelfont)
Definition: TGaxis.h:106
void SetTitleSize(Float_t titlesize)
Definition: TGaxis.h:126
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition: TGaxis.cxx:2694
void SetLabelOffset(Float_t labeloffset)
Definition: TGaxis.h:107
virtual const char * GetTitle() const
Returns title of object.
Definition: TGaxis.h:87
virtual void SetNdivisions(Int_t ndiv)
Definition: TGaxis.h:115
void SetWmax(Double_t wmax)
Definition: TGaxis.h:130
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:2559
void SetLabelColor(Int_t labelcolor)
Definition: TGaxis.h:105
Float_t GetTickSize() const
Definition: TGaxis.h:92
void SetWmin(Double_t wmin)
Definition: TGaxis.h:129
void SetTickSize(Float_t ticksize)
Definition: TGaxis.h:119
void SetLabelSize(Float_t labelsize)
Definition: TGaxis.h:108
void SetOption(Option_t *option="")
To set axis options.
Definition: TGaxis.cxx:2686
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.
Definition: TGraphErrors.h:26
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
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition: TGraph.cxx:2269
virtual void SetTitle(const char *title="")
Change (i.e.
Definition: TGraph.cxx:2324
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:760
TAxis * GetYaxis() const
Get y axis of the graph.
Definition: TGraph.cxx:1636
The TH1 histogram class.
Definition: TH1.h:56
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
Definition: TH1.cxx:8597
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition: TH1.cxx:8519
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition: TH1.cxx:6736
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:316
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
Definition: TH1.cxx:2665
virtual Int_t GetNbinsX() const
Definition: TH1.h:292
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:778
TAxis * GetYaxis()
Definition: TH1.h:317
virtual Double_t GetBinErrorLow(Int_t bin) const
Return lower error associated to bin number bin.
Definition: TH1.cxx:8535
TList * GetListOfFunctions() const
Definition: TH1.h:239
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2998
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition: TH1.cxx:4907
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
Definition: TH1.cxx:8619
virtual Double_t GetBinErrorUp(Int_t bin) const
Return upper error associated to bin number bin.
Definition: TH1.cxx:8566
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition: TH1.cxx:6246
virtual Int_t GetSumw2N() const
Definition: TH1.h:310
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:2753
The Histogram stack class.
Definition: THStack.h:31
TList * GetHists() const
Definition: THStack.h:60
A simple line.
Definition: TLine.h:23
virtual void SetY2(Double_t y2)
Definition: TLine.h:69
virtual void SetX2(Double_t x2)
Definition: TLine.h:67
virtual void SetX1(Double_t x1)
Definition: TLine.h:66
virtual void SetY1(Double_t y1)
Definition: TLine.h:68
A doubly linked list.
Definition: TList.h:44
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:577
virtual TObjLink * FirstLink() const
Definition: TList.h:108
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:356
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TNamed.cxx:74
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:187
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:144
@ kNotDeleted
object has not been deleted
Definition: TObject.h:78
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:877
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:105
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:891
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
@ kCannotPick
if object in a pad cannot be picked
Definition: TObject.h:63
The most important graphics class in the ROOT system.
Definition: TPad.h:29
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
Definition: TPad.cxx:5904
virtual void SetGridx(Int_t value=1)
Definition: TPad.h:331
Double_t GetYlowNDC() const
Definition: TPad.h:210
Double_t GetUymin() const
Returns the minimum y-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition: TPad.h:227
Int_t GetLogx() const
Definition: TPad.h:253
virtual void SetGridy(Int_t value=1)
Definition: TPad.h:332
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
Definition: TPad.cxx:5890
Double_t GetUymax() const
Returns the maximum y-coordinate value visible on the pad. If log axis the returned value is in decad...
Definition: TPad.h:231
Double_t GetHNDC() const
Get height of pad along Y in Normalized Coordinates (NDC)
Definition: TPad.h:214
virtual 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)
Set all pad parameters.
Definition: TPad.cxx:5957
void Modified(Bool_t flag=1)
Definition: TPad.h:417
TList * GetListOfPrimitives() const
Definition: TPad.h:242
Int_t GetLogy() const
Definition: TPad.h:254
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1284
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:593
virtual void SetFillStyle(Style_t fstyle)
Override TAttFill::FillStyle for TPad because we want to handle style=0 as style 4000.
Definition: TPad.cxx:5878
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:866
void SubPadResized()
Slot that handles common resizing of upper and lower pad.
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.
Definition: TRatioPlot.cxx:740
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.
Definition: TRatioPlot.cxx:861
void SetUpBottomMargin(Float_t margin)
Sets the bottom margin of the upper pad.
Definition: TRatioPlot.cxx:446
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.
Definition: TRatioPlot.cxx:343
virtual void Draw(Option_t *chopt="")
Draws the ratio plot to the currently active pad.
Definition: TRatioPlot.cxx:541
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.
Definition: TRatioPlot.cxx:468
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.
Definition: TRatioPlot.cxx:435
TGaxis * fLowerGXaxis
Lower graphical x axis.
Definition: TRatioPlot.h:111
TRatioPlot()
TRatioPlot default constructor.
Definition: TRatioPlot.cxx:104
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.
Definition: TRatioPlot.cxx:355
Double_t fCl1
Stores the confidence level for the inner confidence interval band.
Definition: TRatioPlot.h:101
virtual ~TRatioPlot()
Destructor.
Definition: TRatioPlot.cxx:111
Float_t GetSeparationMargin() const
Return the separation margin value.
Definition: TRatioPlot.cxx:516
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.
Definition: TRatioPlot.cxx:363
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.
void SetConfidenceIntervalColors(Color_t ci1=kGreen, Color_t ci2=kYellow)
Set the confidence interval colors.
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.
Definition: TRatioPlot.cxx:371
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.
Definition: TRatioPlot.cxx:335
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 ...
Definition: TRatioPlot.cxx:670
virtual void Browse(TBrowser *b)
Browse.
Definition: TRatioPlot.cxx:424
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.
Definition: TRatioPlot.cxx:758
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.
Definition: TRatioPlot.cxx:841
void RangeAxisChanged()
Slot that receives the RangeAxisChanged signal from any of the pads and reacts correspondingly.
void UnZoomed()
Slot for the UnZoomed signal that was introduced to TAxis.
virtual void Paint(Option_t *opt="")
Creates the visual axes when painting.
Definition: TRatioPlot.cxx:829
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.
Definition: TRatioPlot.cxx:457
void SetSeparationMargin(Float_t)
Sets the margin that separates the two pads.
Definition: TRatioPlot.cxx:505
Float_t fInsetWidth
Definition: TRatioPlot.h:137
void SetLeftMargin(Float_t margin)
Sets the left margin of both pads.
Definition: TRatioPlot.cxx:478
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.
Definition: TRatioPlot.cxx:722
Float_t fSplitFraction
Stores the fraction at which the upper and lower pads meet.
Definition: TRatioPlot.h:91
virtual TObject * GetUpperRefObject() const
Return the reference object.
Definition: TRatioPlot.cxx:704
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.
Definition: TRatioPlot.cxx:141
Bool_t fShowGridlines
Stores whether to show the gridlines at all.
Definition: TRatioPlot.h:124
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.
Definition: TRatioPlot.cxx:489
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:131
const char * Data() const
Definition: TString.h:364
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
TString & Append(const char *cs)
Definition: TString.h:559
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
static TVirtualFitter * GetFitter()
static: return the current Fitter
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
return c1
Definition: legend1.C:41
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TH1F * h1
Definition: legend1.C:5
return c2
Definition: legend2.C:14
bool GetConfidenceIntervals(const TH1 *h1, const ROOT::Fit::FitResult &r, TGraphErrors *gr, double cl=0.95)
compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Definition: TMath.h:725
Definition: first.py:1
#define dest(otri, vertexptr)
Definition: triangle.c:1040