Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist034_TRatioPlot_fit_margin.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_hist
3/// \notebook
4/// \preview Example showing a fit residual plot, where the separation margin has been set to 0.
5/// The last label of the lower plot's y axis is hidden automatically.
6///
7/// \macro_image
8/// \macro_code
9///
10/// \date January 2020
11/// \author Paul Gessinger
12
13void hist034_TRatioPlot_fit_margin()
14{
16 auto c1 = new TCanvas("c1", "fit residual simple");
17 gPad->SetFrameFillStyle(0);
18 auto h1 = new TH1D("h1", "h1", 50, -5, 5);
19 h1->FillRandom("gaus", 5000);
20 TFitResultPtr fitres = h1->Fit("gaus", "S0");
21 h1->Sumw2();
22 h1->GetXaxis()->SetTitle("x");
23 h1->GetYaxis()->SetTitle("y");
24 auto rp1 = new TRatioPlot(h1, "errfunc");
25 rp1->SetGraphDrawOpt("L");
26 rp1->SetSeparationMargin(0.0);
27 rp1->Draw();
28 rp1->GetLowerRefGraph()->SetMinimum(-2);
29 rp1->GetLowerRefGraph()->SetMaximum(2);
30}
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define gPad
The Canvas class.
Definition TCanvas.h:23
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:698
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
Definition TH1.cxx:3500
TAxis * GetXaxis()
Definition TH1.h:344
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
Definition TH1.cxx:3876
TAxis * GetYaxis()
Definition TH1.h:345
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9016
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:174
Class for displaying ratios, differences and fit residuals.
Definition TRatioPlot.h:44
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition TStyle.cxx:1642
return c1
Definition legend1.C:41
TH1F * h1
Definition legend1.C:5