How to fit histogram dataset with negative bin content

Hi all:

I am a beginner of ROOT, I try to fit a hitogram type dataset,which contain some bin content below zero, by ROOFIT. The fit results seems good. But the fit plot have some problems. The error of negative bin are very large. The plot can be found in attachment. I don't know how to deal with this issue.

I am very grateful if anybody can solve this problem.

Best wishes!

I believe you should explicitly set a value for error for all bins with negative number of events. One can’t give you a proper remedy until the organization of your data is unknown (at least I cant understand whether it is a binned or unbinned). For example, for ‘RooDataHist’ there is a ‘set’ function which contains an argument for your estimation of error: … taHist:set

Hi zwe32:
Thank you for your replay.
I can explain the data set explicitly. I want to fit the red dot shape shown in the plot, in which the red dot with error bar represent a resonance superposition on background. The blue dashed line refers to the background shape from sideband. I want extract the resonance shape by cuting away the background shape(named histogram b) from the data shape(red dot named histogram a). The commands used are: b.Scale(-1);a.Add(b). Then, I get the histogram only contain signal shape but with some negative bin. The data set is binned in fit.
Thank you for your suggestion, I am studing the ‘set’ function to see whether can I find the solution for my trouble.
In addition, I worried about the statistical error of the fit. because the PDF should be positive, so the bin below zero will not affect the PDF curve. Althougth the fit seems successful,I am afraid the statistical error will be not right. Am I right?


I would fit directly the red histogram (the one with the signal and background). If you want instead to fit the histogram obtained from the subtraction of S+B and B, which has negative bin content, then you cannot use a Poisson pdf for each bin, but a Skellam distribution, see
By doing this you will treat correctly the bin with negative bin content.

Best Regards