I started to learn RooFit and I am now blocked by the following strange behaviour. Fitting a simple gauss function to a data set once works fine. But when I repeat this exercise, because want to change the fit range for example, things break down. The normalization seems to get screwed up, the fitted curve is much large than data. Trying again, increases further. How can I stop this behaviour? Fit parameters look ok.
mean = ROOT.RooRealVar("mean","Mean of Gaussian",-10,10)
sigma = ROOT.RooRealVar("sigma","Width of Gaussian",3,-10,10)
gauss = ROOT.RooGaussian("gauss","gauss(x,mean,sigma)",x,mean,sigma)
fitResult = gauss.fitTo(data,ROOT.RooFit.Range(1.,5.),ROOT.RooFit.PrintLevel(1))
xframe = x.frame()
data.plotOn(xframe)
gauss.plotOn(xframe)
xframe.Draw()
fitResult = gauss.fitTo(data,ROOT.RooFit.Range(3.,7.),ROOT.RooFit.PrintLevel(1))
gauss.plotOn(xframe)
xframe.Draw()
there is also an error about:
[#0] ERROR:InputArguments – RooArgSet::checkForDup: ERROR argument with name gauss_Int[mcor|fit_nll_gauss_data]_Norm[mcor] is already in this set
We are using 6.14/00. Changing to a newer version is a major enterprise, re-compilation of all experiment software depending on ROOT, with any unforeseen hickup. Maybe it is now the time to do it. I will also study the jira report. Thanks for the fast feedback.
If I remember correctly, the problem is in implicitly setting the either normalisation range or the plotting range if don’t ask for it explicitly.
You could therefore get around the bug by something like this: