I’m doing a set of toy experiments to produce an expected results. The idea is to generate data according to a very simple uniform distribution, then fit that data with the uniform distribution plus a constrained gaussian (fixed mean, fixed sigma). The result I expect is that the fit will return a signal yield on that gaussian that fluctuates around 0. When I do this experiment for an a mean distribution of 100 or 1000 events, I get that result.

However, when I lower that number to ~10 events I get some inexplicable results from the very sparse datasets. The example.root file I attach here is from one such dataset.

Example.root (5.5 KB)

FitTest.C (1.4 KB)

as far as I can tell it’s either:

- the possible negative yield on the gaussian breaks the positive definiteness roofit needs to fit. I wouldn’t mind constraining the fit to be positive over the range, but I’m not sure how to exactly to impose that constraint. My understanding was that Roofit should do this naturally by returning prohibitive values when the function was negative.
- I just don’t understand the structure of RooAddPdf and am breaking rules by using that when allowing negative coefficients. In the documentation I see some alternative structures to use: RooRealSumFunc / RooRealSumPdf, but subbing either of those in doesn’t seem to make the resulting fit make sense. My understanding of the distinction is that both the components (the polynomial and gaussian) are normalizable and non-negative so RooAddPdf should be the right structure.

Any guidance would be welcome.