19x = ROOT.RooRealVar(
"x",
"x", 0, 10)
23mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5)
24sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5)
25sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1)
27sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
28sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
31a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0., 1.)
32a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2, 0., 1.)
33bkg = ROOT.RooChebychev(
"bkg",
"Background", x, ROOT.RooArgList(a0, a1))
36sig1frac = ROOT.RooRealVar(
37 "sig1frac",
"fraction of component 1 in signal", 0.8, 0., 1.)
39 "sig",
"Signal", ROOT.RooArgList(sig1, sig2), ROOT.RooArgList(sig1frac))
46nsig = ROOT.RooRealVar(
"nsig",
"number of signal events", 500, 0., 10000)
47nbkg = ROOT.RooRealVar(
48 "nbkg",
"number of background events", 500, 0, 10000)
49model = ROOT.RooAddPdf(
50 "model",
"(g1+g2)+a", ROOT.RooArgList(bkg, sig), ROOT.RooArgList(nbkg, nsig))
57data = model.generate(ROOT.RooArgSet(x))
64xframe = x.frame(ROOT.RooFit.Title(
"extended ML fit example"))
66model.plotOn(xframe, ROOT.RooFit.Normalization(
67 1.0, ROOT.RooAbsReal.RelativeExpected))
70ras_bkg = ROOT.RooArgSet(bkg)
71model.plotOn(xframe, ROOT.RooFit.Components(ras_bkg), ROOT.RooFit.LineStyle(ROOT.kDashed),
72 ROOT.RooFit.Normalization(1.0, ROOT.RooAbsReal.RelativeExpected))
75ras_bkg_sig2 = ROOT.RooArgSet(bkg, sig2)
76model.plotOn(xframe, ROOT.RooFit.Components(ras_bkg_sig2), ROOT.RooFit.LineStyle(
77 ROOT.kDotted), ROOT.RooFit.Normalization(1.0, ROOT.RooAbsReal.RelativeExpected))
87esig = ROOT.RooExtendPdf(
"esig",
"extended signal p.d.f", sig, nsig)
88ebkg = ROOT.RooExtendPdf(
"ebkg",
"extended background p.d.f", bkg, nbkg)
94model2 = ROOT.RooAddPdf(
"model2",
"(g1+g2)+a", ROOT.RooArgList(ebkg, esig))
97c = ROOT.TCanvas(
"rf202_extendedmlfit",
"rf202_extendedmlfit", 600, 600)
98ROOT.gPad.SetLeftMargin(0.15)
99xframe.GetYaxis().SetTitleOffset(1.4)
102c.SaveAs(
"rf202_extendedmlfit.png")