15from __future__
import print_function
23x = ROOT.RooRealVar(
"x",
"x", 0, 10)
27mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5)
28sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5)
29sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1)
31sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
32sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
35a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0.0, 1.0)
36a1 = ROOT.RooRealVar(
"a1",
"a1", 0.2, 0.0, 1.0)
37bkg = ROOT.RooChebychev(
"bkg",
"Background", x, [a0, a1])
40sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
41sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], [sig1frac])
44bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0.0, 1.0)
45model = ROOT.RooAddPdf(
"model",
"g1+g2+a", [bkg, sig], [bkgfrac])
50d = model.generate({x}, 10000)
58ll = ROOT.RooLinkedList()
59model.chi2FitTo(dh, ll)
67dsmall = d.reduce(ROOT.RooFit.EventRange(1, 100))
68dhsmall = dsmall.binnedClone()
69chi2_lowstat = model.createChi2(dhsmall)
70print(chi2_lowstat.getVal())