Gaussian Fit Converging But Looking Bad

Hello,
I am trying to fit a Gaussian to some MC data. The fitter says it converges but the fit does not visually look like it converges. The MC data I am fitting is the mass of the Bs meson and I would expect that it would be gaussian. I have attached the code I am using to fit it, the output of root when the code is ran and a image of the data with the poor fit. Please let me know what I can do to improve this fit.

Thanks,
Neil McFadden
RooFitGaus.cxx (2.5 KB)



RooFitOutput.txt (6.88 KB)

HI,

Why are you not using the RooGaussian pdf ? Your defined gaussian is ill defined. You have set a constant A=120 that is fixed in the fit, so as you see in the plot this is the best you can get.
Try to use a RooGaussian.

Best Regards

Lorenzo

Hi Lorenzo,

Thanks for the reply. So I tried the RooGaussian and I get a similar fit.


If I remove all the lines in my code that say mean.setConstant(kFALSE); and sigma1.setConstant(kFALSE) I get a better fit.
Still this better fit does not seem to optimize the value of sigma and mean, but instead just plots a Gaussian with those parameters. Is there a way for RooFit to take my initial parameters and optimize them based on the provided histogram?

Thanks,
Neil

Hi,

First of all if you define the RooRealVar without passing a min and max value, like you are doing in the given example for sigma, the variables is by default defined as constant. So you need to do later sigma1.setConstant(kFALSE) to get a better fit.

Your second plot is then probably the best you can get with a gaussian fit to your data. It is clear the data have a larger tails, so you should use a more elaborated model, e.g. a second gaussian or a polynomial (quadratic ?) for the background .

Best Regards

Lorenzo

Hi Lorenzo,

So I tried a double Gaussian and here is what the fit looks like.


.
It looks like the fit is improving, but still not quite there. You also mentioned trying to add a polynomial to model the background. The thing is that this data I am trying to fit is generated with no backgrounds so I can’t imagine that a polynomial would model this. Do you have any other ideas?

Thanks,
Neil

Try a Lorentzian instead of a Gaussian.

The Lorentzian seem to work perfectly.



Thanks for the help everyone.

Neil

Try to fit it using the Loglikelihood method (“L” or “WL” if the histogram is weighted) instead of the default chisquare method.