diff --git a/graf2d/gpad/inc/TRatioPlot.h b/graf2d/gpad/inc/TRatioPlot.h index dfa67ce9d7480..ee137c934e89c 100644 --- a/graf2d/gpad/inc/TRatioPlot.h +++ b/graf2d/gpad/inc/TRatioPlot.h @@ -21,21 +21,30 @@ // // ////////////////////////////////////////////////////////////////////////// -#include "TH1.h" -#include "TPad.h" -#include "TGraphAsymmErrors.h" -#include "TGraphErrors.h" -#include "TGraph.h" -#include "TAxis.h" -#include "TGaxis.h" -#include "TH1F.h" -#include "TFitResultPtr.h" -#include "THStack.h" +#ifndef ROOT_TObject +#include "TObject.h" +#endif + +#ifndef ROOT_TString +#include "TString.h" +#endif +class TH1; +class TPad; +class TVirtualPad; +class TGraphAsymmErrors; +class TGraphErrors; +class TGraph; +class TAxis; +class TGaxis; +class TLine; +class TFitResultPtr; +class TFitResult; +class THStack; class TBrowser; class TFileMergeInfo; -class TRatioPlot : public TPad { +class TRatioPlot : public TObject { private: TRatioPlot& operator=(const TRatioPlot&); // Not implemented @@ -135,59 +144,59 @@ class TRatioPlot : public TPad { virtual void SetupPads(); virtual void CreateVisualAxes(); virtual Bool_t SyncPadMargins(); - virtual void SetPadMargins(); - virtual void CreateGridline(); + void SetPadMargins(); + void CreateGridline(); + void BuildLowerPlot(); - virtual void ImportAxisAttributes(TGaxis* gaxis, TAxis* axis); + void ImportAxisAttributes(TGaxis* gaxis, TAxis* axis); - virtual Bool_t IsDrawn(); + Bool_t IsDrawn(); - virtual void Init(TH1* h1, TH1* h2, Option_t *option = "", Option_t *h1DrawOpt = "hist", Option_t *h2DrawOpt = "E", Option_t *graphDrawOpt = "AP"); + virtual void Init(TH1* h1, TH1* h2, Option_t *option = ""); public: TRatioPlot(); virtual ~TRatioPlot(); - TRatioPlot(TH1* h1, TH1* h2, Option_t *option = "pois", Option_t *h1DrawOpt = "hist", Option_t *h2DrawOpt = "E", Option_t *graphDrawOpt = "AP", const char *name = "RatioPlot", const char *title = "RatioPlot", Double_t xlow = 0, Double_t ylow = 0, Double_t xup = 1, Double_t yup = 1); + TRatioPlot(TH1* h1, TH1* h2, Option_t *option = "pois"); - TRatioPlot(THStack* st, TH1* h2, Option_t *option = "pois", Option_t *h1DrawOpt = "hist", Option_t *h2DrawOpt = "E", Option_t *graphDrawOpt = "AP", const char *name = "RatioPlot", const char *title = "RatioPlot", Double_t xlow = 0, Double_t ylow = 0, Double_t xup = 1, Double_t yup = 1); - - TRatioPlot(TH1* h1, Option_t *option = "", Option_t *h1DrawOpt = "", Option_t *graphDrawOpt = "LX", TFitResult *fitres = 0, const char *name = "RatioPlot", const char *title = "RatioPlot", Double_t xlow = 0, Double_t ylow = 0, Double_t xup = 1, Double_t yup = 1); + TRatioPlot(THStack* st, TH1* h2, Option_t *option = "pois"); + TRatioPlot(TH1* h1, Option_t *option = "", TFitResult *fitres = 0); + void SetH1DrawOpt(Option_t *opt); + void SetH2DrawOpt(Option_t *opt); + void SetGraphDrawOpt(Option_t *opt); virtual void Draw(Option_t *chopt=""); virtual void Browse(TBrowser *b); - virtual void BuildLowerPlot(); virtual void Paint(Option_t *opt = ""); - virtual void PaintModified(); // Slots for signal receiving - virtual void UnZoomed(); - virtual void RangeAxisChanged(); - virtual void SubPadResized(); + void UnZoomed(); + void RangeAxisChanged(); + void SubPadResized(); // Getters - virtual TAxis *GetXaxis() { return fSharedXAxis; } - virtual TAxis *GetUpYaxis() { return fUpYaxis; } - virtual TAxis *GetLowYaxis() { return fLowYaxis; } + TAxis *GetXaxis() const { return fSharedXAxis; } + TAxis *GetUpYaxis() const { return fUpYaxis; } + TAxis *GetLowYaxis() const { return fLowYaxis; } - virtual TGraph *GetLowerRefGraph(); - virtual TAxis *GetLowerRefXaxis(); - virtual TAxis *GetLowerRefYaxis(); + virtual TGraph *GetLowerRefGraph() const; + TAxis *GetLowerRefXaxis() const; + TAxis *GetLowerRefYaxis() const; - virtual TObject *GetUpperRefObject(); - virtual TAxis *GetUpperRefXaxis(); - virtual TAxis *GetUpperRefYaxis(); + virtual TObject *GetUpperRefObject() const; + TAxis *GetUpperRefXaxis() const; + TAxis *GetUpperRefYaxis() const; - virtual TPad * GetUpperPad() { return fUpperPad; } - virtual TPad * GetLowerPad() { return fLowerPad; } + TPad * GetUpperPad() const { return fUpperPad; } + TPad * GetLowerPad() const { return fLowerPad; } // Setters - virtual void SetFitResult(TFitResultPtr fitres); - virtual void SetFitResult(TFitResult *fitres); + void SetFitResult(TFitResultPtr fitres); // Setters for margins void SetUpTopMargin(Float_t margin); @@ -197,21 +206,18 @@ class TRatioPlot : public TPad { void SetLeftMargin(Float_t margin); void SetRightMargin(Float_t margin); - virtual void SetSeparationMargin(Float_t); - virtual Float_t GetSeparationMargin(); - virtual void SetSplitFraction(Float_t sf); - virtual void SetConfidenceLevels(Double_t cl1, Double_t cl2); - - virtual void SetLogx(Int_t value = 1); // *TOGGLE* - virtual void SetLogy(Int_t value = 1); // *TOGGLE* + void SetSeparationMargin(Float_t); + Float_t GetSeparationMargin() const; + void SetSplitFraction(Float_t sf); + void SetConfidenceLevels(Double_t cl1, Double_t cl2); virtual void SetGridlines(Double_t *gridlines, Int_t numGridlines); virtual void SetGridlines(std::vector gridlines); - virtual void SetConfidenceIntervalColors(Color_t ci1 = kGreen, Color_t ci2 = kYellow); + void SetConfidenceIntervalColors(Color_t ci1 = kGreen, Color_t ci2 = kYellow); - virtual void SetC1(Double_t c1) { fC1 = c1; } - virtual void SetC2(Double_t c2) { fC2 = c2; } + void SetC1(Double_t c1) { fC1 = c1; } + void SetC2(Double_t c2) { fC2 = c2; } ClassDef(TRatioPlot, 1) //A ratio of histograms }; diff --git a/graf2d/gpad/src/TRatioPlot.cxx b/graf2d/gpad/src/TRatioPlot.cxx index f0a3f79bafca9..45db6feebc887 100644 --- a/graf2d/gpad/src/TRatioPlot.cxx +++ b/graf2d/gpad/src/TRatioPlot.cxx @@ -9,30 +9,74 @@ * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ -#include +#include "TRatioPlot.h" + +#ifndef ROOT_TROOT #include "TROOT.h" +#endif + +#ifndef ROOT_TClassRef #include "TClassRef.h" +#endif + +#ifndef ROOT_TVirtualPad #include "TVirtualPad.h" -#include "TRatioPlot.h" +#endif + +#ifndef ROOT_TBrowser #include "TBrowser.h" +#endif + +#ifndef ROOT_TH1 #include "TH1.h" +#endif + +#ifndef ROOT_TF1 #include "TF1.h" +#endif + +#ifndef ROOT_TPad #include "TPad.h" +#endif + +#ifndef ROOT_TString #include "TString.h" +#endif + +#ifndef ROOT_TMath +#include "TMath.h" +#endif + +#ifndef ROOT_TGraphAsymmErrors #include "TGraphAsymmErrors.h" +#endif + +#ifndef ROOT_TGraphErrors #include "TGraphErrors.h" +#endif + +#ifndef ROOT_TGaxis #include "TGaxis.h" -#include "TCanvas.h" -#include "TFrame.h" -#include "TMath.h" +#endif + +#ifndef ROOT_TLine #include "TLine.h" +#endif + +#ifndef ROOT_TVirtualFitter #include "TVirtualFitter.h" +#endif + +#ifndef ROOT_TFitResult #include "TFitResult.h" +#endif + +#ifndef ROOT_THStack #include "THStack.h" +#endif + +#include -#define _(x) std::cout << #x; -#define __(x) std::cout << "[" << std::string(__FILE__).substr(std::string(__FILE__).find_last_of("/\\") + 1) << ":" <<__LINE__ << "] " << x << std::endl ; -#define var_dump(v) __(#v << "=" << (v)); /** \class TRatioPlot \ingroup gpad @@ -105,7 +149,6 @@ the function value as the error. /// TRatioPlot default constructor TRatioPlot::TRatioPlot() - : TPad() { } @@ -147,15 +190,12 @@ TRatioPlot::~TRatioPlot() //////////////////////////////////////////////////////////////////////////////// /// Internal method that shares constructor logic -void TRatioPlot::Init(TH1* h1, TH1* h2, - Option_t *option, Option_t *h1DrawOpt, Option_t *h2DrawOpt, Option_t *graphDrawOpt) +void TRatioPlot::Init(TH1* h1, TH1* h2,Option_t *option) { fH1 = h1; fH2 = h2; - TVirtualPad *padsav = padsav; - SetupPads(); TString optionString = TString(option); @@ -186,16 +226,10 @@ void TRatioPlot::Init(TH1* h1, TH1* h2, fOption = optionString; - TString h1DrawOptString = TString(h1DrawOpt); - TString h2DrawOptString = TString(h2DrawOpt); - TString graphDrawOptString = TString(graphDrawOpt); - h2DrawOptString.ReplaceAll("same", ""); - h2DrawOptString.ReplaceAll("SAME", ""); - - fH1DrawOpt = h1DrawOptString; - fH2DrawOpt = h2DrawOptString; - fGraphDrawOpt = graphDrawOptString; + fH1DrawOpt = "hist"; + fH2DrawOpt = "E"; + fGraphDrawOpt = "AP"; // build ratio, everything is ready @@ -213,23 +247,9 @@ void TRatioPlot::Init(TH1* h1, TH1* h2, /// \param h1 First histogram /// \param h2 Second histogram /// \param option Steers the error calculation, as well as ratio / difference -/// \param h1DrawOpt Drawing option for first histogram -/// \param h2DrawOpt Drawing option for second histogram -/// \param graphDrawOpt Drawing option the lower graph -/// \param name Name for the object -/// \param title Title for the object -/// \param xlow [0,1] is the position of the bottom left point of the pad -/// expressed in the mother pad reference system -/// \param ylow [0,1] is the Y position of this point. -/// \param xup [0,1] is the x position of the top right point of the pad -/// expressed in the mother pad reference system -/// \param yup [0,1] is the Y position of this point. - -TRatioPlot::TRatioPlot(TH1* h1, TH1* h2, Option_t *option, Option_t *h1DrawOpt, Option_t *h2DrawOpt, - Option_t *graphDrawOpt, const char *name, const char *title, Double_t xlow, Double_t ylow, - Double_t xup, Double_t yup) - : TPad(name, title, xlow, ylow, xup, yup), - fGridlines() + +TRatioPlot::TRatioPlot(TH1* h1, TH1* h2, Option_t *option) + : fGridlines() { gROOT->GetListOfCleanups()->Add(this); @@ -248,7 +268,7 @@ TRatioPlot::TRatioPlot(TH1* h1, TH1* h2, Option_t *option, Option_t *h1DrawOpt, fHistDrawProxy = h1; - Init(h1, h2, option, h1DrawOpt, h2DrawOpt, graphDrawOpt); + Init(h1, h2, option); } @@ -259,22 +279,8 @@ TRatioPlot::TRatioPlot(TH1* h1, TH1* h2, Option_t *option, Option_t *h1DrawOpt, /// \param st The THStack object /// \param h2 The other histogram /// \param option Steers the calculation of the lower plot -/// \param h1DrawOpt Drawing option for the stack -/// \param h2DrawOpt Drawing options for the other histogram -/// \param graphDrawOpt Drawing option for the lower plot graph -/// \param name The name of the object -/// \param title The title of the object -/// \param xlow [0,1] is the position of the bottom left point of the pad -/// expressed in the mother pad reference system -/// \param ylow [0,1] is the Y position of this point. -/// \param xup [0,1] is the x position of the top right point of the pad -/// expressed in the mother pad reference system -/// \param yup [0,1] is the Y position of this point. - -TRatioPlot::TRatioPlot(THStack* st, TH1* h2, Option_t *option, Option_t *h1DrawOpt, Option_t *h2DrawOpt, - Option_t *graphDrawOpt, const char *name, const char *title, Double_t xlow, Double_t ylow, - Double_t xup, Double_t yup) - : TPad(name, title, xlow, ylow, xup, yup) + +TRatioPlot::TRatioPlot(THStack* st, TH1* h2, Option_t *option) { if (!st || !h2) { Warning("TRatioPlot", "Need a histogram and a stack"); @@ -297,7 +303,7 @@ TRatioPlot::TRatioPlot(THStack* st, TH1* h2, Option_t *option, Option_t *h1DrawO fHistDrawProxy = st; - Init(tmpHist, h2, option, h1DrawOpt, h2DrawOpt, graphDrawOpt); + Init(tmpHist, h2, option); } @@ -305,23 +311,10 @@ TRatioPlot::TRatioPlot(THStack* st, TH1* h2, Option_t *option, Option_t *h1DrawO /// Constructor for one histogram and a fit. /// \param h1 The histogram /// \param option Steers the error calculation -/// \param h1DrawOpt Drawing option for the histogram -/// \param graphDrawOpt Drawing option the lower graph /// \param fitres Explicit fit result to be used for calculation. Uses last fit if left empty -/// \param name Name for the object -/// \param title Title for the object -/// \param xlow [0,1] is the position of the bottom left point of the pad -/// expressed in the mother pad reference system -/// \param ylow [0,1] is the Y position of this point. -/// \param xup [0,1] is the x position of the top right point of the pad -/// expressed in the mother pad reference system -/// \param yup [0,1] is the Y position of this point. - -TRatioPlot::TRatioPlot(TH1* h1, Option_t *option, Option_t *h1DrawOpt, Option_t *graphDrawOpt, - TFitResult *fitres, const char *name, const char *title, Double_t xlow, Double_t ylow, - Double_t xup, Double_t yup) - : TPad(name, title, xlow, ylow, xup, yup), - fH1(h1), + +TRatioPlot::TRatioPlot(TH1* h1, Option_t *option, TFitResult *fitres) + : fH1(h1), fGridlines() { gROOT->GetListOfCleanups()->Add(this); @@ -369,8 +362,7 @@ TRatioPlot::TRatioPlot(TH1* h1, Option_t *option, Option_t *h1DrawOpt, Option_t BuildLowerPlot(); - fH1DrawOpt = h1DrawOpt; - fGraphDrawOpt = graphDrawOpt; + fGraphDrawOpt = "LX"; // <- default fSharedXAxis = (TAxis*)(fH1->GetXaxis()->Clone()); fUpYaxis = (TAxis*)(fH1->GetYaxis()->Clone()); @@ -382,6 +374,34 @@ TRatioPlot::TRatioPlot(TH1* h1, Option_t *option, Option_t *h1DrawOpt, Option_t } +//////////////////////////////////////////////////////////////////////////////// +/// Sets the drawing option for h1 + +void TRatioPlot::SetH1DrawOpt(Option_t *opt) +{ + fH1DrawOpt = opt; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Sets the drawing option for h2 + +void TRatioPlot::SetH2DrawOpt(Option_t *opt) +{ + TString optString = TString(opt); + optString.ReplaceAll("same", ""); + optString.ReplaceAll("SAME", ""); + + fH2DrawOpt = optString; +} + +//////////////////////////////////////////////////////////////////////////////// +/// Sets the drawing option for the lower graph + +void TRatioPlot::SetGraphDrawOpt(Option_t *opt) +{ + fGraphDrawOpt = opt; +} + //////////////////////////////////////////////////////////////////////////////// /// Setup the pads. @@ -399,8 +419,8 @@ void TRatioPlot::SetupPads() { fLowerPad = 0; } - fUpperPad = new TPad(TString::Format("%s_%s", fName.Data(), "upper_pad"), "", 0., fSplitFraction, 1., 1.); - fLowerPad = new TPad(TString::Format("%s_%s", fName.Data(), "lower_pad"), "", 0., 0., 1., fSplitFraction); + fUpperPad = new TPad("upper_pad", "", 0., fSplitFraction, 1., 1.); + fLowerPad = new TPad("lower_pad", "", 0., 0., 1., fSplitFraction); SetPadMargins(); @@ -421,7 +441,7 @@ void TRatioPlot::SetupPads() { } Double_t margin = 0; - fTopPad = new TPad(TString::Format("%s_%s", fName.Data(), "top_pad"), "", margin, margin, 1-margin, 1-margin); + fTopPad = new TPad("top_pad", "", margin, margin, 1-margin, 1-margin); fTopPad->SetBit(kCannotPick); @@ -531,7 +551,7 @@ void TRatioPlot::SetSeparationMargin(Float_t margin) //////////////////////////////////////////////////////////////////////////////// /// Return the separation margin value. -Float_t TRatioPlot::GetSeparationMargin() +Float_t TRatioPlot::GetSeparationMargin() const { Float_t sf = fSplitFraction; Float_t up = fUpBottomMargin * (1-sf); @@ -591,26 +611,26 @@ void TRatioPlot::Draw(Option_t *option) TVirtualPad *padsav = gPad; fParentPad = gPad; - SetLogx(fParentPad->GetLogx()); - SetLogy(fParentPad->GetLogy()); + //SetLogx(fParentPad->GetLogx()); + //SetLogy(fParentPad->GetLogy()); - fUpperPad->SetLogy(GetLogy()); - fUpperPad->SetLogx(GetLogx()); - fLowerPad->SetLogx(GetLogx()); + fUpperPad->SetLogy(fParentPad->GetLogy()); + fUpperPad->SetLogx(fParentPad->GetLogx()); + fLowerPad->SetLogx(fParentPad->GetLogx()); - SetGridx(fParentPad->GetGridx()); - SetGridy(fParentPad->GetGridy()); + //SetGridx(fParentPad->GetGridx()); + //SetGridy(fParentPad->GetGridy()); - fUpperPad->SetGridx(GetGridx()); - fUpperPad->SetGridy(GetGridy()); - fLowerPad->SetGridx(GetGridx()); - fLowerPad->SetGridy(GetGridy()); + fUpperPad->SetGridx(fParentPad->GetGridx()); + fUpperPad->SetGridy(fParentPad->GetGridy()); + fLowerPad->SetGridx(fParentPad->GetGridx()); + fLowerPad->SetGridy(fParentPad->GetGridy()); - TPad::Draw(option); + //TPad::Draw(option); // we are a TPad - cd(); + //cd(); fUpperPad->Draw(); fLowerPad->Draw(); @@ -661,6 +681,7 @@ void TRatioPlot::Draw(Option_t *option) CreateGridline(); padsav->cd(); + AppendPad(); } //////////////////////////////////////////////////////////////////////////////// @@ -675,7 +696,7 @@ void TRatioPlot::Draw(Option_t *option) /// ../../../tutorials/hist/ratioplot3.C /// End_Macro -TGraph* TRatioPlot::GetLowerRefGraph() +TGraph* TRatioPlot::GetLowerRefGraph() const { if (fLowerPad == 0) { Error("GetLowerRefGraph", "Lower pad has not been defined"); @@ -711,7 +732,7 @@ TGraph* TRatioPlot::GetLowerRefGraph() /// rp->GetLowerRefGraph()->GetXaxis(); /// ~~~ -TAxis* TRatioPlot::GetLowerRefXaxis() +TAxis* TRatioPlot::GetLowerRefXaxis() const { return GetLowerRefGraph()->GetXaxis(); } @@ -723,7 +744,7 @@ TAxis* TRatioPlot::GetLowerRefXaxis() /// rp->GetLowerRefGraph()->GetYaxis(); /// ~~~ -TAxis* TRatioPlot::GetLowerRefYaxis() +TAxis* TRatioPlot::GetLowerRefYaxis() const { return GetLowerRefGraph()->GetYaxis(); } @@ -733,7 +754,7 @@ TAxis* TRatioPlot::GetLowerRefYaxis() /// in the upper pads list of primitives. /// Note that it returns a `TObject`, so you need to test and cast it to use it. -TObject* TRatioPlot::GetUpperRefObject() +TObject* TRatioPlot::GetUpperRefObject() const { TList *primlist = fUpperPad->GetListOfPrimitives(); TObject *refobj = 0; @@ -751,7 +772,7 @@ TObject* TRatioPlot::GetUpperRefObject() //////////////////////////////////////////////////////////////////////////////// /// Gets the x axis of the object returned by `TRatioPlot::GetUpperRefObject`. -TAxis* TRatioPlot::GetUpperRefXaxis() +TAxis* TRatioPlot::GetUpperRefXaxis() const { TObject *refobj = GetUpperRefObject(); @@ -769,7 +790,7 @@ TAxis* TRatioPlot::GetUpperRefXaxis() //////////////////////////////////////////////////////////////////////////////// /// Gets the y axis of the object returned by `TRatioPlot::GetUpperRefObject`. -TAxis* TRatioPlot::GetUpperRefYaxis() +TAxis* TRatioPlot::GetUpperRefYaxis() const { TObject *refobj = GetUpperRefObject(); @@ -862,20 +883,11 @@ void TRatioPlot::CreateGridline() padsav->cd(); } -//////////////////////////////////////////////////////////////////////////////// -/// Does not really do anything right now, other than call super - -void TRatioPlot::Paint(Option_t *opt) -{ - TPad::Paint(opt); -} - //////////////////////////////////////////////////////////////////////////////// /// Creates the visual axes when painting. -void TRatioPlot::PaintModified() +void TRatioPlot::Paint(Option_t * /*opt*/) { - // this might be a problem, if the first one is not really a hist (or the like) if (GetUpperRefObject()) { @@ -914,7 +926,7 @@ void TRatioPlot::PaintModified() CreateVisualAxes(); CreateGridline(); - TPad::PaintModified(); + //TPad::PaintModified(); if (fIsUpdating) fIsUpdating = kFALSE; } @@ -1002,14 +1014,12 @@ void TRatioPlot::BuildLowerPlot() Double_t res; Double_t error; - Double_t x; Double_t val; Double_t val2; for (Int_t i=0; i<=fH1->GetNbinsX();++i) { val = fH1->GetBinContent(i); val2 = fH2->GetBinContent(i); - x = fH1->GetBinCenter(i+1); if (fErrorMode == TRatioPlot::ErrorMode::kErrorAsymmetric) { @@ -1197,9 +1207,9 @@ void TRatioPlot::CreateVisualAxes() Float_t sf = fSplitFraction; // check if gPad has the all sides axis set - Bool_t mirroredAxes = fParentPad->GetFrameFillStyle() == 0 || GetFrameFillStyle() == 0; - Bool_t axistop = fTickx == 1 || mirroredAxes; - Bool_t axisright = fTicky == 1 || mirroredAxes; + Bool_t mirroredAxes = fParentPad->GetFrameFillStyle() == 0; + Bool_t axistop = fParentPad->GetTickx() == 1 || mirroredAxes; + Bool_t axisright = fParentPad->GetTicky() == 1 || mirroredAxes; Bool_t logx = fUpperPad->GetLogx() || fLowerPad->GetLogx(); Bool_t uplogy = fUpperPad->GetLogy(); @@ -1549,19 +1559,19 @@ void TRatioPlot::RangeAxisChanged() //var_dump(fLowerPad->GetLogx()); //var_dump(fLowerPad->GetLogy()); - if (GetLogx()) { + if (fParentPad->GetLogx()) { if (!fUpperPad->GetLogx() || !fLowerPad->GetLogx()) { - SetLogx(kFALSE); + fParentPad->SetLogx(kFALSE); } } else { if (fUpperPad->GetLogx() || fLowerPad->GetLogx()) { - SetLogx(kTRUE); + fParentPad->SetLogx(kTRUE); } } // set log to pad - fUpperPad->SetLogx(GetLogx()); - fLowerPad->SetLogx(GetLogx()); + fUpperPad->SetLogx(fParentPad->GetLogx()); + fLowerPad->SetLogx(fParentPad->GetLogx()); // copy logy from rp to upper pad //if (GetLogy() != @@ -1601,9 +1611,7 @@ void TRatioPlot::RangeAxisChanged() fUpperPad->Modified(); fLowerPad->Modified(); fTopPad->Modified(); - Modified(); - fCanvas->Modified(); - fCanvas->Update(); + fParentPad->Modified(); } // sync the margins in case the user has dragged one of them @@ -1613,9 +1621,7 @@ void TRatioPlot::RangeAxisChanged() fUpperPad->Modified(); fLowerPad->Modified(); fTopPad->Modified(); - Modified(); - fCanvas->Modified(); - fCanvas->Update(); + fParentPad->Modified(); } CreateVisualAxes(); @@ -1637,9 +1643,7 @@ void TRatioPlot::UnZoomed() fUpperPad->Modified(); fLowerPad->Modified(); fTopPad->Modified(); - Modified(); - fCanvas->Modified(); - fCanvas->Update(); + fParentPad->Modified(); } //////////////////////////////////////////////////////////////////////////////// @@ -1700,32 +1704,13 @@ void TRatioPlot::SetSplitFraction(Float_t sf) { //////////////////////////////////////////////////////////////////////////////// /// Sets the confidence levels used to calculate the bands in the fit residual -/// case. Defaults to 1 and 2 sigma. You have to call TRatioPlot::BuildLowerPlot -/// to rebuild the bands. +/// case. Defaults to 1 and 2 sigma. void TRatioPlot::SetConfidenceLevels(Double_t c1, Double_t c2) { fCl1 = c1; fCl2 = c2; -} - -//////////////////////////////////////////////////////////////////////////////// -/// Set logx for both of the pads - -void TRatioPlot::SetLogx(Int_t value ) -{ - TPad::SetLogx(value); - fUpperPad->SetLogx(value); - fLowerPad->SetLogx(value); -} - -//////////////////////////////////////////////////////////////////////////////// -/// Sets logy for the upper pad. - -void TRatioPlot::SetLogy(Int_t value) -{ - TPad::SetLogy(value); - fUpperPad->SetLogy(value); + BuildLowerPlot(); } //////////////////////////////////////////////////////////////////////////////// @@ -1784,18 +1769,6 @@ void TRatioPlot::SetFitResult(TFitResultPtr fitres) fFitResult = fitres.Get(); } -//////////////////////////////////////////////////////////////////////////////// -/// Explicitly specify the fit result that is to be used for fit residual calculation. -/// If it is not provided, the last fit registered in the global fitter is used. -/// The fit result can also be specified in the constructor. -/// -/// \param fitres The fit result coming from the fit function call - -void TRatioPlot::SetFitResult(TFitResult* fitres) -{ - fFitResult = fitres; -} - //////////////////////////////////////////////////////////////////////////////// /// Internal method to import TAxis attributes to a TGaxis. Copied from /// `TGaxis::ImportAxisAttributes` diff --git a/tutorials/hist/ratioplot1.C b/tutorials/hist/ratioplot1.C index 3a423a2973ecb..1b1f0eab818ad 100644 --- a/tutorials/hist/ratioplot1.C +++ b/tutorials/hist/ratioplot1.C @@ -23,7 +23,7 @@ h1->Sumw2(); h2->Scale(1.9 / 2.); auto rp = new TRatioPlot(h1, h2); - rp->SetTicks(0, 1); + c1->SetTicks(0, 1); rp->Draw(); c1->Update(); return c1; diff --git a/tutorials/hist/ratioplot6.C b/tutorials/hist/ratioplot6.C index c46d4a235c2c8..8365a4bbc22eb 100644 --- a/tutorials/hist/ratioplot6.C +++ b/tutorials/hist/ratioplot6.C @@ -20,7 +20,8 @@ c1->Clear(); - auto rp1 = new TRatioPlot(h1, "errfunc", "", "L"); + auto rp1 = new TRatioPlot(h1, "errfunc"); + rp1->SetGraphDrawOpt("L"); rp1->SetSeparationMargin(0.0); rp1->Draw(); rp1->GetLowerRefGraph()->SetMinimum(-2);