Dear Experts,
I try to to fit some data, where the signal is a slim gauss and the background is exponential. Furthermore, some data is blinded so I have to use RooFit.Range to not fit this data window. My problem now is that the fit never converges when I state the ranges in the fit. Below is a minimal example where this behavior is also present. I experienced with it that the fit converges when the width of the Gaussian is 14 or above, so maybe it has to do with the step width in the fit.
My Root-version is 6.05/02 built for linuxx8664gcc.
Thanks in advance,
Jasper
# Create observables
x = R.RooRealVar("x", "x", 5100, 6200)
werte = 5000
bkg = 500
left = 5337
right = 5397
# Construct signal pdf
mean = R.RooRealVar("mean", "mean", 5280, 5250, 5300)
sigma = R.RooRealVar("sigma", "sigma", 13, 0, 20)
gx = R.RooGaussian("gx", "gx", x, mean, sigma)
sig_yield = R.RooRealVar('sig_yield', '', werte-bkg, 0, werte)
exp = R.RooRealVar('exp', '', -2e-3, -4e-3, -0.01e-3)
combinatorial = R.RooExponential('combinatorial', '', x, exp)
bkg_yield = R.RooRealVar('bkg_yield', '', bkg, 0, werte)
pdf_gaussWithExp = R.RooAddPdf(
'pdf_gaussWithExp',
'',
R.RooArgList(gx, combinatorial),
R.RooArgList(sig_yield, bkg_yield)
)
x.setRange("low", 5100, left)
x.setRange("high", right, 6200)
x.setRange("full", 5100, 6200)
data = R.RooDataSet(pdf_gaussWithExp.generate(R.RooArgSet(x), werte))
data_red = data.reduce("x<{}||x>{}".format(left, right))
pdf_gaussWithExp.fitTo(data_red, R.RooFit.Range("low,high"), R.RooFit.NumCPU(4), R.RooFit.Save(True), R.RooFit.Extended())
my_plot = x.frame()
data_red.plotOn(my_plot)
pdf_gaussWithExp.plotOn(my_plot)
can = R.TCanvas()
can.SetLogy()
my_plot.Draw()
can.SaveAs("blind_test_ranges.pdf")```