_ROOT Version: 6.30/04
Platform: Windows10
Compiler: Precompiled, downloaded from official site
Hello everyone!
I’m trying to better understand the TRatioPlot class. I’m interested in the case of fitting a histogram with a function then constructing the plot. I’ve slightly modified the ratioplot2.C tutorial so I can see the difference between different fits.
My code:
void ratioplot2()
{
auto h1 = new TH1D("h1", "histoFit", 100, 5, 5);
h1>FillRandom("gaus", 1e7);
auto h2 = (TH1 *)h1>Clone();
auto h3 = (TH1 *)h1>Clone();
auto pol1 = new TF1("total", "pol1(0)", 2, 2);
auto pol2 = new TF1("total", "pol2(0)", 2, 2);
auto gauss = new TF1("total", "gaus(0)", 2, 2);
h1>Fit(pol1, "OLR");
auto rp1 = new TRatioPlot(h1);
h2>Fit(pol2, "OLR");
auto rp2 = new TRatioPlot(h2);
h3>Fit(gauss, "OLR");
auto rp3 = new TRatioPlot(h3);
auto c1 = new TCanvas("c1", "Fit residuals");
c1>Divide(3, 1);
c1>cd(1);
rp1>Draw();
c1>cd(2);
rp2>Draw();
c1>cd(3);
rp3>Draw();
}
I simply fill a histogram with a Gaussian (randomly) then clone it twice so I fit the same histogram with 3 different functions on a limited [2,2] range. I use: pol1
, pol2
, gaus
fitting functions.
The continuous line at the bottom (TGraphAsymmErrors
class if I understand correctly) is perfect: it shows the difference between the histogram and the fit function at each point and divides it by the uncertainty. So far I’ve seen the residual defined by the difference between the values without dividing, but it makes sense. The line doesn’t fluctuate around 0 in case of the first two bad fits BUT to my surprise the confidence intervals on the lower panel are pretty narrow for the fitted range.
My questions:

Why do I have confidence bands & difference lines outside of my [2,2] fitting range? How can I limit them to my fitting range?

According to my knowledge better fits should have narrower bands, but around 0
pol1
andpol2
has narrower bands than thegaus
even though they’re obviously bad fits. What’s the reason behind that? 
Why do I have asymmetric confidence intervals? It seems like that on negative side the intervals are larger.
Thank you in advance!