12 #ifndef ROOT_TRatioPlot
13 #define ROOT_TRatioPlot
33 class TGraphAsymmErrors;
43 class TRatioPlot :
public TObject {
46 TRatioPlot& operator=(
const TRatioPlot&) =
delete;
47 TRatioPlot(
const TRatioPlot &hrp) =
delete;
49 enum CalculationMode {
74 TVirtualPad *fParentPad = 0;
81 TObject *fHistDrawProxy = 0;
84 Int_t fErrorMode = TRatioPlot::ErrorMode::kErrorSymmetric;
86 TString fH1DrawOpt =
"";
87 TString fH2DrawOpt =
"";
88 TString fGraphDrawOpt =
"";
89 TString fFitDrawOpt =
"";
91 Float_t fSplitFraction = 0.3;
93 TGraph *fRatioGraph = 0;
94 TGraphErrors *fConfidenceInterval1 = 0;
95 TGraphErrors *fConfidenceInterval2 = 0;
96 Color_t fCi1Color = kGreen;
97 Color_t fCi2Color = kYellow;
99 Bool_t fShowConfidenceIntervals = kTRUE;
101 Double_t fCl1 = 0.6827;
102 Double_t fCl2 = 0.9545;
107 TFitResult *fFitResult = 0;
109 TAxis *fSharedXAxis = 0;
110 TGaxis *fUpperGXaxis = 0;
111 TGaxis *fLowerGXaxis = 0;
112 TGaxis *fUpperGYaxis = 0;
113 TGaxis *fLowerGYaxis = 0;
114 TGaxis *fUpperGXaxisMirror = 0;
115 TGaxis *fLowerGXaxisMirror = 0;
116 TGaxis *fUpperGYaxisMirror = 0;
117 TGaxis *fLowerGYaxisMirror = 0;
120 TAxis *fLowYaxis = 0;
122 std::vector<TLine*> fGridlines;
123 std::vector<double> fGridlinePositions;
124 Bool_t fShowGridlines = kTRUE;
125 Int_t fHideLabelMode = TRatioPlot::HideLabelMode::kHideLow;
129 Float_t fUpTopMargin = 0.1;
130 Float_t fUpBottomMargin = 0.05;
131 Float_t fLowTopMargin = 0.05;
132 Float_t fLowBottomMargin = 0.3;
134 Float_t fLeftMargin = 0.1;
135 Float_t fRightMargin = 0.1;
137 Float_t fInsetWidth = 0.0025;
139 Bool_t fIsUpdating = kFALSE;
140 Bool_t fIsPadUpdating = kFALSE;
142 virtual void SyncAxesRanges();
143 virtual void SetupPads();
144 virtual void CreateVisualAxes();
145 virtual Bool_t SyncPadMargins();
146 void SetPadMargins();
147 void CreateGridline();
148 Int_t BuildLowerPlot();
150 void ImportAxisAttributes(TGaxis* gaxis, TAxis* axis);
154 virtual void Init(TH1* h1, TH1* h2, Option_t *option =
"");
159 virtual ~TRatioPlot();
160 TRatioPlot(TH1* h1, TH1* h2, Option_t *option =
"pois");
162 TRatioPlot(THStack* st, TH1* h2, Option_t *option =
"pois");
164 TRatioPlot(TH1* h1, Option_t *option =
"", TFitResult *fitres = 0);
166 void SetH1DrawOpt(Option_t *opt);
167 void SetH2DrawOpt(Option_t *opt);
168 void SetGraphDrawOpt(Option_t *opt);
169 void SetFitDrawOpt(Option_t *opt);
171 void SetInsetWidth(Double_t width);
173 virtual void Draw(Option_t *chopt=
"");
174 virtual void Browse(TBrowser *b);
177 virtual void Paint(Option_t *opt =
"");
181 void RangeAxisChanged();
182 void SubPadResized();
185 TAxis *GetXaxis()
const {
return fSharedXAxis; }
186 TAxis *GetUpYaxis()
const {
return fUpYaxis; }
187 TAxis *GetLowYaxis()
const {
return fLowYaxis; }
189 virtual TGraph *GetLowerRefGraph()
const;
198 TAxis *GetLowerRefXaxis()
const {
return GetLowerRefGraph()->GetXaxis(); }
207 TAxis *GetLowerRefYaxis()
const {
return GetLowerRefGraph()->GetYaxis(); }
209 virtual TObject *GetUpperRefObject()
const;
210 TAxis *GetUpperRefXaxis()
const;
211 TAxis *GetUpperRefYaxis()
const;
217 TGraph *GetCalculationOutputGraph()
const {
return fRatioGraph; }
222 TGraphErrors *GetConfidenceInterval1()
const {
return fConfidenceInterval1; }
227 TGraphErrors *GetConfidenceInterval2()
const {
return fConfidenceInterval2; }
229 TPad * GetUpperPad()
const {
return fUpperPad; }
230 TPad * GetLowerPad()
const {
return fLowerPad; }
241 void SetFitResult(TFitResultPtr fitres) { fFitResult = fitres.Get(); }
244 void SetUpTopMargin(Float_t margin);
245 void SetUpBottomMargin(Float_t margin);
246 void SetLowTopMargin(Float_t margin);
247 void SetLowBottomMargin(Float_t margin);
248 void SetLeftMargin(Float_t margin);
249 void SetRightMargin(Float_t margin);
251 void SetSeparationMargin(Float_t);
252 Float_t GetSeparationMargin()
const;
253 void SetSplitFraction(Float_t sf);
254 void SetConfidenceLevels(Double_t cl1, Double_t cl2);
256 virtual void SetGridlines(Double_t *gridlines, Int_t numGridlines);
257 virtual void SetGridlines(std::vector<double> gridlines);
259 void SetConfidenceIntervalColors(Color_t ci1 = kGreen, Color_t ci2 = kYellow);
261 void SetC1(Double_t c1) { fC1 = c1; }
262 void SetC2(Double_t c2) { fC2 = c2; }
264 ClassDef(TRatioPlot, 1)