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
116 if (fRatioGraph != 0) delete fRatioGraph;
119
120 for (unsigned int i=0;i<fGridlines.size();++i) {
121 delete (fGridlines[i]);
122 }
123
124 if (fSharedXAxis != 0) delete fSharedXAxis;
125 if (fUpperGXaxis != 0) delete fUpperGXaxis;
126 if (fLowerGXaxis != 0) delete fLowerGXaxis;
127 if (fUpperGYaxis != 0) delete fUpperGYaxis;
128 if (fLowerGYaxis != 0) delete fLowerGYaxis;
129 if (fUpperGXaxisMirror != 0) delete fUpperGXaxisMirror;
130 if (fLowerGXaxisMirror != 0) delete fLowerGXaxisMirror;
131 if (fUpperGYaxisMirror != 0) delete fUpperGYaxisMirror;
132 if (fLowerGYaxisMirror != 0) delete fLowerGYaxisMirror;
133
134 if (fUpYaxis != 0) delete fUpYaxis;
135 if (fLowYaxis != 0) delete fLowYaxis;
136
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Internal method that shares constructor logic
141
142void TRatioPlot::Init(TH1* h1, TH1* h2,Option_t *option)
143{
144
145 fH1 = h1;
146 fH2 = h2;
147
148 SetupPads();
149
150 TString optionString = TString(option);
151
152 if (optionString.Contains("divsym")) {
153 optionString.ReplaceAll("divsym", "");
154 fMode = TRatioPlot::CalculationMode::kDivideHist;
155 } else if (optionString.Contains("diffsig")) {
156 optionString.ReplaceAll("diffsig", "");
157 fMode = TRatioPlot::CalculationMode::kDifferenceSign;
158
159 // determine which error style
160 if (optionString.Contains("errasym")) {
161 fErrorMode = TRatioPlot::ErrorMode::kErrorAsymmetric;
162 optionString.ReplaceAll("errasym", "");
163 }
164
165 if (optionString.Contains("errfunc")) {
166 fErrorMode = TRatioPlot::ErrorMode::kErrorFunc;
167 optionString.ReplaceAll("errfunc", "");
168 }
169 } else if (optionString.Contains("diff")) {
170 optionString.ReplaceAll("diff", "");
171 fMode = TRatioPlot::CalculationMode::kDifference;
172 } else {
173 fMode = TRatioPlot::CalculationMode::kDivideGraph; // <- default
174 }
175
176 fOption = optionString;
177
178
179 fH1DrawOpt = "hist";
180 fH2DrawOpt = "E";
181 fGraphDrawOpt = "AP";
182
183
184 // build ratio, everything is ready
185 if (!BuildLowerPlot()) return;
186
187 // taking x axis information from h1 by cloning it x axis
188 fSharedXAxis = (TAxis*)(fH1->GetXaxis()->Clone());
189 fUpYaxis = (TAxis*)(fH1->GetYaxis()->Clone());
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Constructor for two histograms
195///
196/// \param h1 First histogram
197/// \param h2 Second histogram
198/// \param option Steers the error calculation, as well as ratio / difference
199
201 : fGridlines()
202{
203 gROOT->GetListOfCleanups()->Add(this);
204
205 if (!h1 || !h2) {
206 Warning("TRatioPlot", "Need two histograms.");
207 return;
208 }
209
210 Bool_t h1IsTH1=h1->IsA()->InheritsFrom(TH1::Class());
211 Bool_t h2IsTH1=h2->IsA()->InheritsFrom(TH1::Class());
212
213 if (!h1IsTH1 && !h2IsTH1) {
214 Warning("TRatioPlot", "Need two histograms deriving from TH2 or TH3.");
215 return;
216 }
217
219
220 Init(h1, h2, option);
221
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Constructor which accepts a `THStack` and a histogram. Converts the
226/// stack to a regular sum of its containing histograms for processing.
227///
228/// \param st The THStack object
229/// \param h2 The other histogram
230/// \param option Steers the calculation of the lower plot
231
233{
234 if (!st || !h2) {
235 Warning("TRatioPlot", "Need a histogram and a stack");
236 return;
237 }
238
239 TList *stackHists = st->GetHists();
240
241 if (stackHists->GetSize() == 0) {
242 Warning("TRatioPlot", "Stack does not have histograms");
243 return;
244 }
245
246 TH1* tmpHist = (TH1*)stackHists->At(0)->Clone();
247 tmpHist->Reset();
248
249 for (int i=0;i<stackHists->GetSize();++i) {
250 tmpHist->Add((TH1*)stackHists->At(i));
251 }
252
253 fHistDrawProxy = st;
254
255 Init(tmpHist, h2, option);
256
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// Constructor for one histogram and a fit.
261///
262/// \param h1 The histogram
263/// \param option Steers the error calculation
264/// \param fitres Explicit fit result to be used for calculation. Uses last fit if left empty
265
267 : fH1(h1),
268 fGridlines()
269{
270 gROOT->GetListOfCleanups()->Add(this);
271
272 if (!fH1) {
273 Warning("TRatioPlot", "Need a histogram.");
274 return;
275 }
276
277 Bool_t h1IsTH1=fH1->IsA()->InheritsFrom(TH1::Class());
278
279 if (!h1IsTH1) {
280 Warning("TRatioPlot", "Need a histogram deriving from TH2 or TH3.");
281 return;
282 }
283
284 TList *h1Functions = fH1->GetListOfFunctions();
285
286 if (h1Functions->GetSize() < 1) {
287 Warning("TRatioPlot", "Histogram given needs to have a (fit) function associated with it");
288 return;
289 }
290
291
293
294 fFitResult = fitres;
295
296 fMode = TRatioPlot::CalculationMode::kFitResidual;
297
298 TString optionString = TString(option);
299
300 // determine which error style
301 if (optionString.Contains("errasym")) {
302 fErrorMode = TRatioPlot::ErrorMode::kErrorAsymmetric;
303 optionString.ReplaceAll("errasym", "");
304 }
305
306 if (optionString.Contains("errfunc")) {
307 fErrorMode = TRatioPlot::ErrorMode::kErrorFunc;
308 optionString.ReplaceAll("errfunc", "");
309 }
310
311 fOption = optionString;
312
313 if (!BuildLowerPlot()) return;
314
315 // emulate option behaviour of TH1
316 if (fH1->GetSumw2N() > 0) {
317 fH1DrawOpt = "E";
318 } else {
319 fH1DrawOpt = "hist";
320 }
321 fGraphDrawOpt = "LX"; // <- default
322
323 fSharedXAxis = (TAxis*)(fH1->GetXaxis()->Clone());
324 fUpYaxis = (TAxis*)(fH1->GetYaxis()->Clone());
326
327 //SyncAxesRanges();
328
329 SetupPads();
330
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Sets the drawing option for h1
335
337{
338 fH1DrawOpt = opt;
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// Sets the drawing option for h2
343
345{
346 TString optString = TString(opt);
347 optString.ReplaceAll("same", "");
348 optString.ReplaceAll("SAME", "");
349
350 fH2DrawOpt = optString;
351}
352
353////////////////////////////////////////////////////////////////////////////////
354/// Sets the drawing option for the lower graph
355
357{
358 fGraphDrawOpt = opt;
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Sets the drawing option for the fit in the fit residual case
363
365{
366 fFitDrawOpt = opt;
367}
368
369////////////////////////////////////////////////////////////////////////////////
370/// Setup the pads.
371
373
374 // this method will delete all the pads before recreating them
375
376 if (fUpperPad != 0) {
377 delete fUpperPad;
378 fUpperPad = 0;
379 }
380
381 if (fLowerPad != 0) {
382 delete fLowerPad;
383 fLowerPad = 0;
384 }
385
386 if (!gPad) {
387 Error("SetupPads", "need to create a canvas first");
388 return;
389 }
390
391 double pm = fInsetWidth;
392 double width = gPad->GetWNDC();
393 double height = gPad->GetHNDC();
394 double f = height/width;
395
396 fUpperPad = new TPad("upper_pad", "", pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
397 fLowerPad = new TPad("lower_pad", "", pm*f, pm, 1.-pm*f, fSplitFraction);
398
400
401 // connect to the pads signal
402 fUpperPad->Connect("RangeAxisChanged()", "TRatioPlot", this, "RangeAxisChanged()");
403 fLowerPad->Connect("RangeAxisChanged()", "TRatioPlot", this, "RangeAxisChanged()");
404
405 fUpperPad->Connect("UnZoomed()", "TRatioPlot", this, "UnZoomed()");
406 fLowerPad->Connect("UnZoomed()", "TRatioPlot", this, "UnZoomed()");
407
408 fUpperPad->Connect("Resized()", "TRatioPlot", this, "SubPadResized()");
409 fLowerPad->Connect("Resized()", "TRatioPlot", this, "SubPadResized()");
410
411 if (fTopPad != 0) {
412 delete fTopPad;
413 fTopPad = 0;
414 }
415
416 fTopPad = new TPad("top_pad", "", pm*f, pm, 1-pm*f, 1-pm);
417
419
420}
421
422////////////////////////////////////////////////////////////////////////////////
423/// Browse.
424
426{
427 Draw(b ? b->GetDrawOption() : "");
428 gPad->Update();
429}
430
431////////////////////////////////////////////////////////////////////////////////
432/// Sets the top margin of the upper pad.
433///
434/// \param margin The new margin
435
437{
438 fUpTopMargin = margin;
440}
441
442////////////////////////////////////////////////////////////////////////////////
443/// Sets the bottom margin of the upper pad.
444///
445/// \param margin The new margin
446
448{
449 fUpBottomMargin = margin;
451}
452
453////////////////////////////////////////////////////////////////////////////////
454/// Sets the top margin of the lower pad.
455///
456/// \param margin The new margin
457
459{
460 fLowTopMargin = margin;
462}
463
464////////////////////////////////////////////////////////////////////////////////
465/// Sets the bottom margin of the lower pad.
466///
467/// \param margin The new margin
468
470{
471 fLowBottomMargin = margin;
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// Sets the left margin of both pads.
477/// \param margin The new margin
478
480{
481 fLeftMargin = margin;
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// Sets the right margin of both pads.
487///
488/// \param margin The new margin
489
491{
492 fRightMargin = margin;
494}
495
496////////////////////////////////////////////////////////////////////////////////
497/// Sets the margin that separates the two pads. The margin is split according
498/// to the relative sizes of the pads
499///
500/// \param margin The new margin
501///
502/// Begin_Macro(source)
503/// ../../../tutorials/hist/ratioplot6.C
504/// End_Macro
505
507{
509 fUpBottomMargin = margin/2./(1-sf);
510 fLowTopMargin = margin/2./sf;
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Return the separation margin value.
516
518{
520 Float_t up = fUpBottomMargin * (1-sf);
521 Float_t down = fLowTopMargin * sf;
522 return up+down;
523}
524
525////////////////////////////////////////////////////////////////////////////////
526/// Draws the ratio plot to the currently active pad. Therefore it requires that
527/// a TCanvas has been created first.
528///
529/// It takes the following options
530///
531/// | Option | Description |
532/// | ---------- | ------------------------------------------------------------ |
533/// | grid / nogrid | enable (default) or disable drawing of dashed lines on lower plot |
534/// | hideup | hides the first label of the upper axis if there is not enough space |
535/// | fhideup | always hides the first label of the upper axis |
536/// | hidelow (default) | hides the last label of the lower axis if there is not enough space |
537/// | fhidelow | always hides the last label of the lower axis |
538/// | nohide | does not hide a label if there is not enough space |
539/// | noconfint | does not draw the confidence interval bands in the fit residual case |
540/// | confint | draws the confidence interval bands in the fit residual case (default) |
541
543{
544
545 TString drawOpt = option;
546
547 if (drawOpt.Contains("nogrid")) {
548 drawOpt.ReplaceAll("nogrid", "");
550 } else if (drawOpt.Contains("grid")) {
551 drawOpt.ReplaceAll("grid", "");
553 }
554
555 if (drawOpt.Contains("noconfint")) {
556 drawOpt.ReplaceAll("noconfint", "");
558 } else if (drawOpt.Contains("confint")) {
559 drawOpt.ReplaceAll("confint", "");
560 fShowConfidenceIntervals = kTRUE; // <- default
561 }
562
563 if (drawOpt.Contains("fhideup")) {
564 fHideLabelMode = TRatioPlot::HideLabelMode::kForceHideUp;
565 } else if (drawOpt.Contains("fhidelow")) {
566 fHideLabelMode = TRatioPlot::HideLabelMode::kForceHideLow;
567 } else if (drawOpt.Contains("hideup")) {
568 fHideLabelMode = TRatioPlot::HideLabelMode::kHideUp;
569 } else if (drawOpt.Contains("hidelow")) {
570 fHideLabelMode = TRatioPlot::HideLabelMode::kHideLow;
571 } else if (drawOpt.Contains("nohide")) {
572 fHideLabelMode = TRatioPlot::HideLabelMode::kNoHide;
573 } else {
574 fHideLabelMode = TRatioPlot::HideLabelMode::kHideLow; // <- default
575 }
576
577 if (!gPad) {
578 Error("Draw", "need to create a canvas first");
579 return;
580 }
581
582 TVirtualPad *padsav = gPad;
584
588
593
594 // we are a TPad
595
596 fUpperPad->Draw();
597 fLowerPad->Draw();
598
600 fTopPad->Draw();
601
602 fUpperPad->cd();
603
606
607 if (fMode == TRatioPlot::CalculationMode::kFitResidual) {
608 TF1 *func = dynamic_cast<TF1*>(fH1->GetListOfFunctions()->At(0));
609
610 if (func == 0) {
611 // this is checked in constructor and should thus not occur
612 Error("BuildLowerPlot", "h1 does not have a fit function");
613 return;
614 }
615
616 fH1->Draw("A"+fH1DrawOpt);
617 func->Draw(fFitDrawOpt+"same");
618
619 fLowerPad->cd();
620
625 } else {
626 fRatioGraph->Draw("IA"+fGraphDrawOpt+"SAME");
627 }
628 } else {
629
630 if (fHistDrawProxy) {
632 ((TH1*)fHistDrawProxy)->Draw("A"+fH1DrawOpt);
634 ((THStack*)fHistDrawProxy)->Draw("A"+fH1DrawOpt);
635 } else {
636 Warning("Draw", "Draw proxy not of type TH1 or THStack, not drawing it");
637 }
638 }
639
640 fH2->Draw("A"+fH2DrawOpt+"same");
641
642 fLowerPad->cd();
643
646
647 }
648
649 // assign same axis ranges to lower pad as in upper pad
650 // the visual axes will be created on paint
652
654
655 padsav->cd();
656 AppendPad();
657}
658
659////////////////////////////////////////////////////////////////////////////////
660/// Returns the reference graph for the lower pad, which means the graph that
661/// is responsible for setting the coordinate system. It is the first graph
662/// added to the primitive list of the lower pad.
663/// This reference can be used to set the minimum and maximum of the lower pad.
664/// Note that `TRatioPlot::Draw` needs to have been called first, since the
665/// graphs are only created then.
666///
667/// Begin_Macro(source)
668/// ../../../tutorials/hist/ratioplot3.C
669/// End_Macro
670
672{
673 if (fLowerPad == 0) {
674 Error("GetLowerRefGraph", "Lower pad has not been defined");
675 return 0;
676 }
677
678 TList *primlist = fLowerPad->GetListOfPrimitives();
679 if (primlist->GetSize() == 0) {
680 Error("GetLowerRefGraph", "Lower pad does not have primitives");
681 return 0;
682 }
683
684 TObjLink *lnk = primlist->FirstLink();
685
686 while (lnk) {
687 TObject *obj = lnk->GetObject();
688
689 if (obj->InheritsFrom(TGraph::Class())) {
690 return (TGraph*)obj;
691 }
692
693 lnk = lnk->Next();
694 }
695
696 Error("GetLowerRefGraph", "Did not find graph in list");
697 return 0;
698}
699
700////////////////////////////////////////////////////////////////////////////////
701/// Return the reference object. Its the first TH1 or THStack type object
702/// in the upper pads list of primitives.
703/// Note that it returns a `TObject`, so you need to test and cast it to use it.
704
706{
707 TList *primlist = fUpperPad->GetListOfPrimitives();
708 TObject *refobj = 0;
709 for (Int_t i=0;i<primlist->GetSize();++i) {
710 refobj = primlist->At(i);
711 if (refobj->InheritsFrom(TH1::Class()) || refobj->InheritsFrom(THStack::Class())) {
712 return refobj;
713 }
714 }
715
716 Error("GetUpperRefObject", "No upper ref object of TH1 or THStack type found");
717 return 0;
718}
719
720////////////////////////////////////////////////////////////////////////////////
721/// Gets the x axis of the object returned by `TRatioPlot::GetUpperRefObject`.
722
724{
725 TObject *refobj = GetUpperRefObject();
726
727 if (!refobj) return 0;
728
729 if (refobj->InheritsFrom(TH1::Class())) {
730 return ((TH1*)refobj)->GetXaxis();
731 } else if (refobj->InheritsFrom(THStack::Class())) {
732 return ((THStack*)refobj)->GetXaxis();
733 }
734
735 return 0;
736}
737
738////////////////////////////////////////////////////////////////////////////////
739/// Gets the y axis of the object returned by `TRatioPlot::GetUpperRefObject`.
740
742{
743 TObject *refobj = GetUpperRefObject();
744
745 if (!refobj) return 0;
746
747 if (refobj->InheritsFrom(TH1::Class())) {
748 return ((TH1*)refobj)->GetYaxis();
749 } else if (refobj->InheritsFrom(THStack::Class())) {
750 return ((THStack*)refobj)->GetYaxis();
751 }
752
753 return 0;
754}
755
756////////////////////////////////////////////////////////////////////////////////
757/// Create a grid line
758
760{
761
762 if (!fShowGridlines) {
763 return; // don't draw them
764 }
765
766 TVirtualPad *padsav = gPad;
767
768 fLowerPad->cd();
769
770 unsigned int dest = fGridlinePositions.size();
771
772 Double_t lowYFirst = fLowerPad->GetUymin();
773 Double_t lowYLast = fLowerPad->GetUymax();
774
775 double y;
776 int outofrange = 0;
777 for (unsigned int i=0;i<fGridlinePositions.size();++i) {
778 y = fGridlinePositions.at(i);
779
780 if (y < lowYFirst || lowYLast < y) {
781 ++outofrange;
782 }
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 TLine *line;
806 unsigned int skipped = 0;
807 for (unsigned int i=0;i<fGridlinePositions.size();++i) {
809
810 if (y < lowYFirst || lowYLast < y) {
811 // this is one of the ones that was out of range
812 ++skipped;
813 continue;
814 }
815
816 line = fGridlines.at(i-skipped);
817
818 line->SetX1(first);
819 line->SetX2(last);
820 line->SetY1(y);
821 line->SetY2(y);
822 }
823
824 padsav->cd();
825}
826
827////////////////////////////////////////////////////////////////////////////////
828/// Creates the visual axes when painting.
829
831{
832 // create the visual axes
835
837}
838
839////////////////////////////////////////////////////////////////////////////////
840/// Syncs the axes ranges from the shared ones to the actual ones.
841
843{
844 // get ranges from the shared axis clone
847
848 // set range on computed graph, have to set it twice because
849 // TGraph's axis looks strange otherwise
850 TAxis *ref = GetLowerRefXaxis();
851 ref->SetLimits(first, last);
852 ref->SetRangeUser(first, last);
853
855
856}
857
858////////////////////////////////////////////////////////////////////////////////
859/// Build the lower plot according to which constructor was called, and
860/// which options were passed.
861
863{
864 // Clear and delete the graph if not exists
865 if (fRatioGraph != 0) {
866 fRatioGraph->IsA()->Destructor(fRatioGraph);
867 fRatioGraph = 0;
868 }
869
870 if (fConfidenceInterval1 == 0) {
872 }
873
874 if (fConfidenceInterval2 == 0) {
876 }
877
878 static Double_t divideGridlines[] = {0.7, 1.0, 1.3};
879 static Double_t diffGridlines[] = {0.0};
880 static Double_t signGridlines[] = {1.0, 0.0, -1.0};
881
882 // Determine the divide mode and create the lower graph accordingly
883 // Pass divide options given in constructor
884 if (fMode == TRatioPlot::CalculationMode::kDivideGraph) {
885 // use TGraphAsymmErrors Divide method to create
886
887 SetGridlines(divideGridlines, 3);
888
889 TH1 *tmpH1 = (TH1*)fH1->Clone();
890 TH1 *tmpH2 = (TH1*)fH2->Clone();
891
892 tmpH1->Scale(fC1);
893 tmpH2->Scale(fC2);
894
895 TGraphAsymmErrors *ratioGraph = new TGraphAsymmErrors();
896 ratioGraph->Divide(tmpH1, tmpH2, fOption.Data());
897 fRatioGraph = ratioGraph;
898
899 delete tmpH1;
900 delete tmpH2;
901
902 } else if (fMode == TRatioPlot::CalculationMode::kDifference) {
903 SetGridlines(diffGridlines, 3);
904
905 TH1 *tmpHist = (TH1*)fH1->Clone();
906
907 tmpHist->Reset();
908
909 tmpHist->Add(fH1, fH2, fC1, -1*fC2);
910 fRatioGraph = new TGraphErrors(tmpHist);
911
912 delete tmpHist;
913 } else if (fMode == TRatioPlot::CalculationMode::kDifferenceSign) {
914
915 SetGridlines(signGridlines, 3);
916
918 Int_t ipoint = 0;
919 Double_t res;
920 Double_t error;
921
922 Double_t val;
923 Double_t val2;
924
925 for (Int_t i=0; i<=fH1->GetNbinsX();++i) {
926 val = fH1->GetBinContent(i);
927 val2 = fH2->GetBinContent(i);
928
929 if (fErrorMode == TRatioPlot::ErrorMode::kErrorAsymmetric) {
930
931 Double_t errUp = fH1->GetBinErrorUp(i);
932 Double_t errLow = fH1->GetBinErrorLow(i);
933
934 if (val - val2 > 0) {
935 // h1 > h2
936 error = errLow;
937 } else {
938 // h1 < h2
939 error = errUp;
940 }
941
942 } else if (fErrorMode == TRatioPlot::ErrorMode::kErrorSymmetric) {
943 error = fH1->GetBinError(i);
944 } else {
945 Warning("BuildLowerPlot", "error mode is invalid");
946 error = 0;
947 }
948
949 if (error != 0) {
950
951 res = (val - val2) / error;
952
953 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
954 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
955
956 ++ipoint;
957
958 }
959 }
960
961 } else if (fMode == TRatioPlot::CalculationMode::kFitResidual) {
962
963 SetGridlines(signGridlines, 3);
964
965 TF1 *func = dynamic_cast<TF1*>(fH1->GetListOfFunctions()->At(0));
966
967 if (func == 0) {
968 // this is checked in constructor and should thus not occur
969 Error("BuildLowerPlot", "h1 does not have a fit function");
970 return 0;
971 }
972
974 Int_t ipoint = 0;
975
976 Double_t res;
977 Double_t error;
978
979 std::vector<double> ci1;
980 std::vector<double> ci2;
981
982 Double_t *x_arr = new Double_t[fH1->GetNbinsX()];
983 std::fill_n(x_arr, fH1->GetNbinsX(), 0);
984 Double_t *ci_arr1 = new Double_t[fH1->GetNbinsX()];
985 std::fill_n(ci_arr1, fH1->GetNbinsX(), 0);
986 Double_t *ci_arr2 = new Double_t[fH1->GetNbinsX()];
987 std::fill_n(ci_arr2, fH1->GetNbinsX(), 0);
988 for (Int_t i=0; i<fH1->GetNbinsX();++i) {
989 x_arr[i] = fH1->GetBinCenter(i+1);
990 }
991
992 Double_t cl1 = fCl1;
993 Double_t cl2 = fCl2;
994
995 if (fFitResult != 0) {
996 // use this to get conf int
997
998 fFitResult->GetConfidenceIntervals(fH1->GetNbinsX(), 1, 1, x_arr, ci_arr1, cl1);
999 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1000 ci1.push_back(ci_arr1[i-1]);
1001 }
1002
1003 fFitResult->GetConfidenceIntervals(fH1->GetNbinsX(), 1, 1, x_arr, ci_arr2, cl2);
1004 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1005 ci2.push_back(ci_arr2[i-1]);
1006 }
1007 } else {
1008 (TVirtualFitter::GetFitter())->GetConfidenceIntervals(fH1->GetNbinsX(), 1, x_arr, ci_arr1, cl1);
1009 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1010 ci1.push_back(ci_arr1[i-1]);
1011 }
1012 (TVirtualFitter::GetFitter())->GetConfidenceIntervals(fH1->GetNbinsX(), 1, x_arr, ci_arr2, cl2);
1013 for (Int_t i=1; i<=fH1->GetNbinsX();++i) {
1014 ci2.push_back(ci_arr2[i-1]);
1015 }
1016
1017 }
1018
1019 Double_t x;
1020 Double_t val;
1021
1022 for (Int_t i=0; i<=fH1->GetNbinsX();++i) {
1023 val = fH1->GetBinContent(i);
1024 x = fH1->GetBinCenter(i+1);
1025
1026 if (fErrorMode == TRatioPlot::ErrorMode::kErrorAsymmetric) {
1027
1028 Double_t errUp = fH1->GetBinErrorUp(i);
1029 Double_t errLow = fH1->GetBinErrorLow(i);
1030
1031 if (val - func->Eval(fH1->GetBinCenter(i)) > 0) {
1032 // h1 > fit
1033 error = errLow;
1034 } else {
1035 // h1 < fit
1036 error = errUp;
1037 }
1038
1039 } else if (fErrorMode == TRatioPlot::ErrorMode::kErrorSymmetric) {
1040 error = fH1->GetBinError(i);
1041 } else if (fErrorMode == TRatioPlot::ErrorMode::kErrorFunc) {
1042
1043 error = sqrt(func->Eval(x));
1044
1045 } else {
1046 Warning("BuildLowerPlot", "error mode is invalid");
1047 error = 0;
1048 }
1049
1050 if (error != 0) {
1051
1052 res = (fH1->GetBinContent(i)- func->Eval(fH1->GetBinCenter(i) ) ) / error;
1053 //__("x="<< x << " y=" << res << " err=" << error);
1054
1055 ((TGraphAsymmErrors*)fRatioGraph)->SetPoint(ipoint, fH1->GetBinCenter(i), res);
1056 ((TGraphAsymmErrors*)fRatioGraph)->SetPointError(ipoint, fH1->GetBinWidth(i)/2., fH1->GetBinWidth(i)/2., 0.5, 0.5);
1057
1058 fConfidenceInterval1->SetPoint(ipoint, x, 0);
1059 fConfidenceInterval1->SetPointError(ipoint, x, i < (Int_t)ci1.size() ? ci1[i] / error : 0);
1060 fConfidenceInterval2->SetPoint(ipoint, x, 0);
1061 fConfidenceInterval2->SetPointError(ipoint, x, i < (Int_t)ci2.size() ? ci2[i] / error : 0);
1062
1063 ++ipoint;
1064
1065 }
1066
1067 }
1068 delete [] x_arr;
1069 delete [] ci_arr1;
1070 delete [] ci_arr2;
1071 } else if (fMode == TRatioPlot::CalculationMode::kDivideHist){
1072 SetGridlines(divideGridlines, 3);
1073
1074 // Use TH1's Divide method
1075 TH1 *tmpHist = (TH1*)fH1->Clone();
1076 tmpHist->Reset();
1077
1078 tmpHist->Divide(fH1, fH2, fC1, fC2, fOption.Data());
1079 fRatioGraph = new TGraphErrors(tmpHist);
1080
1081 delete tmpHist;
1082 } else {
1083 // this should not occur
1084 Error("BuildLowerPlot", "Invalid fMode value");
1085 return 0;
1086 }
1087
1088 // need to set back to "" since recreation. we don't ever want
1089 // title on lower graph
1090
1091 if (fRatioGraph == 0) {
1092 Error("BuildLowerPlot", "Error creating lower graph");
1093 return 0;
1094 }
1095
1096 fRatioGraph->SetTitle("");
1099
1100 return 1;
1101}
1102
1103////////////////////////////////////////////////////////////////////////////////
1104/// (Re-)Creates the TGAxis objects that are used for consistent display of the
1105/// axes.
1106
1108{
1109 TVirtualPad *padsav = gPad;
1110 fTopPad->cd();
1111
1112 // this is for errors
1113 TString thisfunc = "CreateVisualAxes";
1114
1115 // figure out where the axis has to go.
1116 // Implicit assumption is, that the top pad spans the full other pads
1121
1122 Double_t lowTM = fLowerPad->GetTopMargin();
1124 Double_t lowLM = fLowerPad->GetLeftMargin();
1126
1129
1130 Double_t upYFirst = fUpperPad->GetUymin();
1131 Double_t upYLast = fUpperPad->GetUymax();
1132 Double_t lowYFirst = fLowerPad->GetUymin();
1133 Double_t lowYLast = fLowerPad->GetUymax();
1134
1136
1137 // check if gPad has the all sides axis set
1138 Bool_t mirroredAxes = fParentPad->GetFrameFillStyle() == 0;
1139 Bool_t axistop = fParentPad->GetTickx() == 1 || mirroredAxes;
1140 Bool_t axisright = fParentPad->GetTicky() == 1 || mirroredAxes;
1141
1142 Bool_t logx = fUpperPad->GetLogx() || fLowerPad->GetLogx();
1143 Bool_t uplogy = fUpperPad->GetLogy();
1144 Bool_t lowlogy = fLowerPad->GetLogy();
1145
1146 if (uplogy) {
1147
1148 upYFirst = TMath::Power(10, upYFirst);
1149 upYLast = TMath::Power(10, upYLast);
1150
1151 if (upYFirst <= 0 || upYLast <= 0) {
1152 Error(thisfunc, "Cannot set upper Y axis to log scale");
1153 }
1154 }
1155
1156 if (lowlogy) {
1157 lowYFirst = TMath::Power(10, lowYFirst);
1158 lowYLast = TMath::Power(10, lowYLast);
1159
1160 if (lowYFirst <= 0 || lowYLast <= 0) {
1161 Error(thisfunc, "Cannot set lower Y axis to log scale");
1162 }
1163
1164 }
1165
1166 // this is different than in y, y already has pad coords converted, x not...
1167 if (logx) {
1168 if (first <= 0 || last <= 0) {
1169 Error(thisfunc, "Cannot set X axis to log scale");
1170 }
1171 }
1172
1173 // determine axes options to create log axes if needed
1174 TString xopt = "";
1175 if (logx) xopt.Append("G");
1176 TString upyopt = "";
1177 if (uplogy) upyopt.Append("G");
1178 TString lowyopt = "";
1179 if (lowlogy) lowyopt.Append("G");
1180
1181 // only actually create them once, reuse otherwise b/c memory
1182 if (fUpperGXaxis == 0) {
1183 fUpperGXaxis = new TGaxis(0, 0, 1, 1, 0, 1, 510, "+U"+xopt);
1184 fUpperGXaxis->Draw();
1185 }
1186
1187 if (fUpperGYaxis == 0) {
1188 fUpperGYaxis = new TGaxis(0, 0, 1, 1, upYFirst, upYLast, 510, "S"+upyopt);
1189 fUpperGYaxis->Draw();
1190 }
1191
1192 if (fLowerGXaxis == 0) {
1193 fLowerGXaxis = new TGaxis(0, 0, 1, 1, first, last, 510, "+S"+xopt);
1194 fLowerGXaxis->Draw();
1195 }
1196
1197 if (fLowerGYaxis == 0) {
1198 fLowerGYaxis = new TGaxis(0, 0, 1, 1, lowYFirst, lowYLast, 510, "-S"+lowyopt);
1199 fLowerGYaxis->Draw();
1200 }
1201
1202 // import infos from TAxis
1207
1208 // lower x axis needs to get title from upper x
1210
1211 // (re)set all the axes properties to what we want them
1213
1214 fUpperGXaxis->SetX1(upLM);
1215 fUpperGXaxis->SetX2(1-upRM);
1216 fUpperGXaxis->SetY1(upBM*(1-sf)+sf);
1217 fUpperGXaxis->SetY2(upBM*(1-sf)+sf);
1219 fUpperGXaxis->SetWmax(last);
1220
1221 fUpperGYaxis->SetX1(upLM);
1222 fUpperGYaxis->SetX2(upLM);
1223 fUpperGYaxis->SetY1(upBM*(1-sf)+sf);
1224 fUpperGYaxis->SetY2( (1-upTM)*(1-sf)+sf );
1225 fUpperGYaxis->SetWmin(upYFirst);
1226 fUpperGYaxis->SetWmax(upYLast);
1227
1228 fLowerGXaxis->SetX1(lowLM);
1229 fLowerGXaxis->SetX2(1-lowRM);
1230 fLowerGXaxis->SetY1(lowBM*sf);
1231 fLowerGXaxis->SetY2(lowBM*sf);
1233 fLowerGXaxis->SetWmax(last);
1234
1235 fLowerGYaxis->SetX1(lowLM);
1236 fLowerGYaxis->SetX2(lowLM);
1237 fLowerGYaxis->SetY1(lowBM*sf);
1238 fLowerGYaxis->SetY2((1-lowTM)*sf);
1239 fLowerGYaxis->SetWmin(lowYFirst);
1240 fLowerGYaxis->SetWmax(lowYLast);
1241
1246
1247 fUpperGXaxis->SetOption("+U"+xopt);
1248 fUpperGYaxis->SetOption("S"+upyopt);
1249 fLowerGXaxis->SetOption("+S"+xopt);
1250 fLowerGYaxis->SetOption("-S"+lowyopt);
1251
1252 // normalize the tick sizes. y axis ticks should be consistent
1253 // even if their length is different
1254 Double_t ratio = ( (upBM-(1-upTM))*(1-sf) ) / ( (lowBM-(1-lowTM))*sf ) ;
1256 Double_t ticksize = fUpperGYaxis->GetTickSize()*ratio;
1257 fLowerGYaxis->SetTickSize(ticksize);
1258
1259 if (fHideLabelMode == TRatioPlot::HideLabelMode::kForceHideUp) {
1260
1261 fUpperGYaxis->ChangeLabel(1, -1, 0);
1262
1263 } else if (fHideLabelMode == TRatioPlot::HideLabelMode::kForceHideLow) {
1264
1265 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1266
1267 } else {
1268 if (GetSeparationMargin() < 0.025) {
1269
1270 if (fHideLabelMode != TRatioPlot::HideLabelMode::kNoHide) {
1271 if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideUp) {
1272 fUpperGYaxis->ChangeLabel(1, -1, 0);
1273 } else if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideLow) {
1274 fLowerGYaxis->ChangeLabel(-1, -1, 0);
1275 }
1276 }
1277
1278 } else {
1279 // reset
1280 if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideUp) {
1282 } else if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideLow) {
1284 }
1285
1286 }
1287 }
1288
1289 // Create the axes on the other sides of the graphs
1290 // This is steered by an option on the containing pad or self
1291 if (axistop || axisright) {
1292
1293 // only actually create them once, reuse otherwise b/c memory
1294 if (fUpperGXaxisMirror == 0) {
1296 if (axistop) fUpperGXaxisMirror->Draw();
1297 }
1298
1299 if (fLowerGXaxisMirror == 0) {
1301 if (axistop) fLowerGXaxisMirror->Draw();
1302 }
1303
1304 if (fUpperGYaxisMirror == 0) {
1306 if (axisright) fUpperGYaxisMirror->Draw();
1307 }
1308
1309 if (fLowerGYaxisMirror == 0) {
1311 if (axisright) fLowerGYaxisMirror->Draw();
1312 }
1313
1314 // import attributes from shared axes
1319
1320 // remove titles
1325
1326 // move them about and set required positions
1328 fUpperGXaxisMirror->SetX2(1-upRM);
1329 fUpperGXaxisMirror->SetY1((1-upTM)*(1-sf)+sf);
1330 fUpperGXaxisMirror->SetY2((1-upTM)*(1-sf)+sf);
1333
1334 fUpperGYaxisMirror->SetX1(1-upRM);
1335 fUpperGYaxisMirror->SetX2(1-upRM);
1336 fUpperGYaxisMirror->SetY1(upBM*(1-sf)+sf);
1337 fUpperGYaxisMirror->SetY2( (1-upTM)*(1-sf)+sf );
1338 fUpperGYaxisMirror->SetWmin(upYFirst);
1339 fUpperGYaxisMirror->SetWmax(upYLast);
1340
1341 fLowerGXaxisMirror->SetX1(lowLM);
1342 fLowerGXaxisMirror->SetX2(1-lowRM);
1343 fLowerGXaxisMirror->SetY1((1-lowTM)*sf);
1344 fLowerGXaxisMirror->SetY2((1-lowTM)*sf);
1347
1348 fLowerGYaxisMirror->SetX1(1-lowRM);
1349 fLowerGYaxisMirror->SetX2(1-lowRM);
1350 fLowerGYaxisMirror->SetY1(lowBM*sf);
1351 fLowerGYaxisMirror->SetY2((1-lowTM)*sf);
1352 fLowerGYaxisMirror->SetWmin(lowYFirst);
1353 fLowerGYaxisMirror->SetWmax(lowYLast);
1354
1355 // also needs normalized tick size
1357
1358 fUpperGXaxisMirror->SetOption("-S"+xopt);
1359 fUpperGYaxisMirror->SetOption("+S"+upyopt);
1360 fLowerGXaxisMirror->SetOption("-S"+xopt);
1361 fLowerGYaxisMirror->SetOption("+S"+lowyopt);
1362
1367
1372 }
1373
1374 padsav->cd();
1375
1376}
1377
1378////////////////////////////////////////////////////////////////////////////////
1379/// Sets the margins of all the pads to the value specified in class members.
1380/// This one is called whenever those are changed, e.g. in setters
1381
1383{
1392}
1393
1394////////////////////////////////////////////////////////////////////////////////
1395/// Figures out which pad margin has deviated from the stored ones,
1396/// to figure out what the new nominal is and set the other pad to it
1397/// subsequently.
1398
1400{
1401
1402 Bool_t changed = kFALSE;
1403
1406 changed = kTRUE;
1407 }
1408 else if (fLowerPad->GetLeftMargin() != fLeftMargin) {
1410 changed = kTRUE;
1411 }
1412
1415 changed = kTRUE;
1416 }
1417 else if (fLowerPad->GetRightMargin() != fRightMargin) {
1419 changed = kTRUE;
1420 }
1421
1422 // only reset margins, if any of the margins changed
1423 if (changed) {
1424 SetPadMargins();
1425 }
1426
1427 Bool_t verticalChanged = kFALSE;
1428
1430
1431 verticalChanged = kTRUE;
1433
1434 }
1435
1437
1438 verticalChanged = kTRUE;
1440
1441 }
1442
1444
1446
1447 }
1448
1450
1452
1453 }
1454
1455 // only reset margins, if any of the margins changed
1456 if (verticalChanged) {
1457 SetPadMargins();
1458 }
1459
1460 return changed || verticalChanged;
1461
1462}
1463
1464////////////////////////////////////////////////////////////////////////////////
1465/// Slot that receives the RangeAxisChanged signal from any of the pads and
1466/// reacts correspondingly.
1467
1469{
1470 // check if the ratio plot is already drawn.
1471 if (!IsDrawn()) {
1472 // not drawn yet
1473 return;
1474 }
1475
1476 // Only run this concurrently once, in case it's called async
1477 if (fIsUpdating) {
1478 return;
1479 }
1480
1482
1483 // find out if logx has changed
1484 if (fParentPad->GetLogx()) {
1485 if (!fUpperPad->GetLogx() || !fLowerPad->GetLogx()) {
1487 }
1488 } else {
1489 if (fUpperPad->GetLogx() || fLowerPad->GetLogx()) {
1491 }
1492 }
1493
1494 // set log to pad
1497
1498 // get axis ranges for upper and lower
1499 TAxis *uprefx = GetUpperRefXaxis();
1500 Double_t upFirst = uprefx->GetBinLowEdge(uprefx->GetFirst());
1501 Double_t upLast = uprefx->GetBinUpEdge(uprefx->GetLast());
1502
1503 TAxis *lowrefx = GetLowerRefXaxis();
1504 Double_t lowFirst = lowrefx->GetBinLowEdge(lowrefx->GetFirst());
1505 Double_t lowLast = lowrefx->GetBinUpEdge(lowrefx->GetLast());
1506
1509
1510 Bool_t upChanged = kFALSE;
1511 Bool_t lowChanged = kFALSE;
1512
1513 // determine which one has changed
1514 if (upFirst != globFirst || upLast != globLast) {
1515 fSharedXAxis->SetRangeUser(upFirst, upLast);
1516 upChanged = kTRUE;
1517 }
1518 else if (lowFirst != globFirst || lowLast != globLast) {
1519 fSharedXAxis->SetRangeUser(lowFirst, lowLast);
1520 lowChanged = kTRUE;
1521 }
1522
1523 if (upChanged || lowChanged) {
1527
1528 // @TODO: Updating is not working when zooming on the lower plot. Axes update, but upper hist only on resize
1531 fTopPad->Modified();
1533 }
1534
1535 // sync the margins in case the user has dragged one of them
1536 Bool_t marginsChanged = SyncPadMargins();
1537
1538 if (marginsChanged) {
1541 fTopPad->Modified();
1543 }
1544
1548}
1549
1550////////////////////////////////////////////////////////////////////////////////
1551/// Slot for the UnZoomed signal that was introduced to TAxis.
1552/// Unzoom both pads
1553
1555{
1556 // this is what resets the range
1557 fSharedXAxis->SetRange(0, 0);
1559
1560 // Flushing
1563 fTopPad->Modified();
1565}
1566
1567////////////////////////////////////////////////////////////////////////////////
1568/// Slot that handles common resizing of upper and lower pad.
1569
1571{
1572
1573 if (fIsPadUpdating) {
1574 return;
1575 }
1576
1578
1579 Float_t upylow = fUpperPad->GetYlowNDC();
1580 Float_t lowylow = fLowerPad->GetYlowNDC();
1581 Float_t lowh = fLowerPad->GetHNDC();
1582 Float_t lowyup = lowylow + lowh;
1583
1584 Bool_t changed = kFALSE;
1585
1586 if (upylow != fSplitFraction) {
1587 // up changed
1588 SetSplitFraction(upylow);
1589 changed = kTRUE;
1590 }
1591 else if (lowyup != fSplitFraction) {
1592 // low changed
1593 SetSplitFraction(lowyup);
1594 changed = kTRUE;
1595 }
1596
1597 if (changed) {
1599 }
1600
1602
1603}
1604
1605////////////////////////////////////////////////////////////////////////////////
1606/// Check if ... is drawn.
1607
1609{
1610 TList *siblings = fParentPad->GetListOfPrimitives();
1611 return siblings->FindObject(this) != 0;
1612}
1613
1614////////////////////////////////////////////////////////////////////////////////
1615/// Set the fraction of the parent pad, at which the to sub pads should meet
1616
1618{
1619 if (fParentPad == 0) {
1620 Warning("SetSplitFraction", "Can only be used after TRatioPlot has been drawn.");
1621 return;
1622 }
1623
1624 fSplitFraction = sf;
1625 double pm = fInsetWidth;
1626 double width = fParentPad->GetWNDC();
1627 double height = fParentPad->GetHNDC();
1628 double f = height/width;
1629
1630 fUpperPad->SetPad(pm*f, fSplitFraction, 1.-pm*f, 1.-pm);
1631 fLowerPad->SetPad(pm*f, pm, 1.-pm*f, fSplitFraction);
1632}
1633
1634////////////////////////////////////////////////////////////////////////////////
1635/// Set the inset on the outer sides of all the pads. It's used to make the outer
1636/// pad draggable.
1637
1639{
1640 if (fParentPad == 0) {
1641 Warning("SetInsetWidth", "Can only be used after TRatioPlot has been drawn.");
1642 return;
1643 }
1644
1647
1648 double pm = fInsetWidth;
1649 double w = fParentPad->GetWNDC();
1650 double h = fParentPad->GetHNDC();
1651 double f = h/w;
1652 fTopPad->SetPad(pm*f, pm, 1-pm*f, 1-pm);
1653}
1654
1655////////////////////////////////////////////////////////////////////////////////
1656/// Sets the confidence levels used to calculate the bands in the fit residual
1657/// case. Defaults to 1 and 2 sigma.
1658
1660{
1661 fCl1 = c1;
1662 fCl2 = c2;
1663 if (!BuildLowerPlot()) return;
1664}
1665
1666////////////////////////////////////////////////////////////////////////////////
1667/// Set where horizontal, dashed lines are drawn on the lower pad.
1668/// Can be used to override existing default lines (or disable them).
1669///
1670/// \param gridlines Vector of y positions for the dashes lines
1671///
1672/// Begin_Macro(source)
1673/// ../../../tutorials/hist/ratioplot4.C
1674/// End_Macro
1675
1676void TRatioPlot::SetGridlines(std::vector<double> gridlines)
1677{
1678 fGridlinePositions = gridlines;
1679}
1680
1681////////////////////////////////////////////////////////////////////////////////
1682/// Set where horizontal, dashed lines are drawn on the lower pad.
1683/// Can be used to override existing default lines (or disable them).
1684///
1685/// \param gridlines Double_t array of y positions for the dashed lines
1686/// \param numGridlines Length of gridlines
1687
1688void TRatioPlot::SetGridlines(Double_t *gridlines, Int_t numGridlines)
1689{
1690 fGridlinePositions.clear();
1691
1692 for (Int_t i=0;i<numGridlines;++i) {
1693 fGridlinePositions.push_back(gridlines[i]);
1694 }
1695}
1696
1697////////////////////////////////////////////////////////////////////////////////
1698/// Set the confidence interval colors.
1699///
1700/// \param ci1 Color of the 1 sigma band
1701/// \param ci2 Color of the 2 sigma band
1702/// Sets the color of the 1 and 2 sigma bands in the fit residual case.
1703/// Begin_Macro(source)
1704/// ../../../tutorials/hist/ratioplot5.C
1705/// End_Macro
1706
1708{
1709 fCi1Color = ci1;
1710 fCi2Color = ci2;
1711}
1712
1713////////////////////////////////////////////////////////////////////////////////
1714/// Internal method to import TAxis attributes to a TGaxis. Copied from
1715/// `TGaxis::ImportAxisAttributes`
1716
1718{
1719 gaxis->SetLineColor(axis->GetAxisColor());
1720 gaxis->SetTextColor(axis->GetTitleColor());
1721 gaxis->SetTextFont(axis->GetTitleFont());
1722 gaxis->SetLabelColor(axis->GetLabelColor());
1723 gaxis->SetLabelFont(axis->GetLabelFont());
1724 gaxis->SetLabelSize(axis->GetLabelSize());
1725 gaxis->SetLabelOffset(axis->GetLabelOffset());
1726 gaxis->SetTickSize(axis->GetTickLength());
1727 gaxis->SetTitle(axis->GetTitle());
1728 gaxis->SetTitleOffset(axis->GetTitleOffset());
1729 gaxis->SetTitleSize(axis->GetTitleSize());
1737 if (axis->GetDecimals()) gaxis->SetBit(TAxis::kDecimals); //the bit is in TAxis::fAxis2
1738 gaxis->SetTimeFormat(axis->GetTimeFormat());
1739}
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:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
short Color_t
Definition: RtypesCore.h:79
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
double sqrt(double)
#define gROOT
Definition: TROOT.h:415
#define gPad
Definition: TVirtualPad.h:286
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:553
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:504
Bool_t GetDecimals() const
Definition: TAxis.h:116
Int_t GetLast() const
Return last bin on the axis i.e.
Definition: TAxis.cxx:455
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:928
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:903
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:514
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:444
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:211
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF1.cxx:1317
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:1429
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:2723
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:2696
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:2561
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:2688
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 Graph is a graphics 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:2257
virtual void SetTitle(const char *title="")
Change (i.e.
Definition: TGraph.cxx:2312
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:753
TAxis * GetYaxis() const
Get y axis of the graph.
Definition: TGraph.cxx:1629
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:8585
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
Definition: TH1.cxx:8507
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
Definition: TH1.cxx:6724
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:8523
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:4899
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
Definition: TH1.cxx:8607
virtual Double_t GetBinErrorUp(Int_t bin) const
Return upper error associated to bin number bin.
Definition: TH1.cxx:8554
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
Definition: TH1.cxx:6234
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:575
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:354
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:172
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:144
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
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:880
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:5864
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:5850
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:5917
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:1282
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:591
virtual void SetFillStyle(Style_t fstyle)
Override TAttFill::FillStyle for TPad because we want to handle style=0 as style 4000.
Definition: TPad.cxx:5838
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:867
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:741
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:862
void SetUpBottomMargin(Float_t margin)
Sets the bottom margin of the upper pad.
Definition: TRatioPlot.cxx:447
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:344
virtual void Draw(Option_t *chopt="")
Draws the ratio plot to the currently active pad.
Definition: TRatioPlot.cxx:542
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:469
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:436
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:356
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:517
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:364
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:372
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:336
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:671
virtual void Browse(TBrowser *b)
Browse.
Definition: TRatioPlot.cxx:425
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:759
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:842
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:830
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:458
void SetSeparationMargin(Float_t)
Sets the margin that separates the two pads.
Definition: TRatioPlot.cxx:506
Float_t fInsetWidth
Definition: TRatioPlot.h:137
void SetLeftMargin(Float_t margin)
Sets the left margin of both pads.
Definition: TRatioPlot.cxx:479
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:723
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:705
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:142
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:490
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:50
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