Hello Experts,
I try to fit some data with a pdf consisting of two combined Crystal Ball functions for the signal and an exponential for the combinatorial background. In addition a data window is blinded. Therefore I use RooFit.Range to specify the range on which the pdf should be fitted.
Now the problem is that the fit only converges if I fit on the full range which is of course not right in the present of this blinded window.
I found out that it works when using a gaussian as a signal like in my previous question: roofitranges with a gaussian.
My Code is here:
import ROOT as R
# Create observables
x = R.RooRealVar("x", "x", 5100, 5700)
werte = 5000
bkg = 500
left = 5350
right = 5400
# Construct signal pdf
mean = R.RooRealVar('mean', '', 5280, 5250, 5300)
sigma = R.RooRealVar('sigma', '', 6, 0, 40)
alpha_1 = R.RooRealVar('alpha_1', '', 1, 0, 100)
alpha_2 = R.RooRealVar('alpha_2', '', 1, 0, 100)
n_1 = R.RooRealVar('n_1', '', 3, 1, 100)
n_2 = R.RooRealVar('n_2', '', 3, 1, 100)
cbs_1 = R.RooCBShape("CrystallBall_1", "CrystallBall_1", x, mean, sigma, alpha_1, n_1)
cbs_2 = R.RooCBShape("CrystallBall_2", "CrystallBall_2", x, mean, sigma, alpha_2, n_2)
mc_frac = R.RooRealVar('mc_frac', '', 0.5)
sig = R.RooAddPdf('sig', '', R.RooArgList(cbs_1, cbs_2), R.RooArgList(mc_frac))
sig_yield = R.RooRealVar('sig_yield', '', 1794.4, 0, 100000)
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_cbWithExp = R.RooAddPdf(
'pdf_cbWithExp',
'',
R.RooArgList(sig, combinatorial),
R.RooArgList(sig_yield, bkg_yield)
)
x.setRange("low", 5100, left)
x.setRange("high", right, 5700)
x.setRange("full", 5100, 5700)
fit_range = "low,high"
data = R.RooDataSet(pdf_cbWithExp.generate(R.RooArgSet(x), werte))
data_red = data.reduce("x<{}||x>{}".format(left, right))
pdf_cbWithExp.fitTo(data_red, R.RooFit.Range(fit_range), R.RooFit.NumCPU(4), R.RooFit.Save(True), R.RooFit.Extended())
my_plot = x.frame()
data_red.plotOn(my_plot)
pdf_cbWithExp.plotOn(my_plot, R.RooFit.Range(fit_range), R.RooFit.NormRange(fit_range))
pdf_cbWithExp.getParameters(data).writeToFile("results.txt")
can = R.TCanvas()
can.SetLogy()
my_plot.Draw()
can.SaveAs("blind_test_ranges.pdf")
The results are:
alpha_1 = 2.2282 +/- 21.297 L(0 - 100)
alpha_2 = 1.0000 +/- 22.525 L(0 - 100)
bkg_yield = 500.00 +/- 1262.2 L(0 - 5000)
exp = -0.00200000 +/- 0.0016787 L(-0.004 - -1e-05)
mc_frac = 0.50000 C L(-INF - +INF)
mean = 5280.0 +/- 20.612 L(5250 - 5300)
n_1 = 3.0000 +/- 21.836 L(1 - 100)
n_2 = 3.0000 +/- 21.836 L(1 - 100)
sig_yield = 1794.4 +/- 22160 L(0 - 100000)
sigma = 6.0000 +/- 12.019 L(0 - 40)
and the terminal output is given here: terminal_output.txt (1.7 MB).
The plot looks like this: blind_test_ranges.pdf (23.9 KB).
My root version is 6.17/01 built for linuxx8664gcc on Feb 01 2019.
Thanks in advance,
Jasper