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))
41sig1frac = ROOT.RooRealVar(
42 "sig1frac",
"fraction of component 1 in signal", 0.8, 0., 1.)
43sig = ROOT.RooAddPdf(
"sig",
"Signal", ROOT.RooArgList(
44 sig1, sig2), ROOT.RooArgList(sig1frac))
50bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0., 1.)
51model = ROOT.RooAddPdf(
52 "model",
"g1+g2+a", ROOT.RooArgList(bkg, sig), ROOT.RooArgList(bkgfrac))
58data = model.generate(ROOT.RooArgSet(x), 1000)
64xframe = x.frame(ROOT.RooFit.Title(
65 "Example of composite pdf=(sig1+sig2)+bkg"))
70ras_bkg = ROOT.RooArgSet(bkg)
71model.plotOn(xframe, ROOT.RooFit.Components(ras_bkg),
72 ROOT.RooFit.LineStyle(ROOT.kDashed))
75ras_bkg_sig2 = ROOT.RooArgSet(bkg, sig2)
76model.plotOn(xframe, ROOT.RooFit.Components(ras_bkg_sig2),
77 ROOT.RooFit.LineStyle(ROOT.kDotted))
89model2 = ROOT.RooAddPdf(
110model2.plotOn(xframe, ROOT.RooFit.LineColor(ROOT.kRed),
111 ROOT.RooFit.LineStyle(ROOT.kDashed))
114 ROOT.RooFit.Components(ras_bkg_sig2),
115 ROOT.RooFit.LineColor(
117 ROOT.RooFit.LineStyle(
122c = ROOT.TCanvas(
"rf201_composite",
"rf201_composite", 600, 600)
123ROOT.gPad.SetLeftMargin(0.15)
124xframe.GetYaxis().SetTitleOffset(1.4)
127c.SaveAs(
"rf201_composite.png")