22x = ROOT.RooRealVar(
"x",
"x", 0, 10)
26mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5)
27sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5)
28sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1)
30sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
31sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
34a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0., 1.)
35a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2, 0., 1.)
36bkg = ROOT.RooChebychev(
"bkg",
"Background", x, ROOT.RooArgList(a0, a1))
44sig1frac = ROOT.RooRealVar(
45 "sig1frac",
"fraction of component 1 in signal", 0.8, 0., 1.)
46sig = ROOT.RooAddPdf(
"sig",
"Signal", ROOT.RooArgList(
47 sig1, sig2), ROOT.RooArgList(sig1frac))
53bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0., 1.)
54model = ROOT.RooAddPdf(
55 "model",
"g1+g2+a", ROOT.RooArgList(bkg, sig), ROOT.RooArgList(bkgfrac))
61data = model.generate(ROOT.RooArgSet(x), 1000)
67xframe = x.frame(ROOT.RooFit.Title(
68 "Example of composite pdf=(sig1+sig2)+bkg"))
73ras_bkg = ROOT.RooArgSet(bkg)
74model.plotOn(xframe, ROOT.RooFit.Components(ras_bkg),
75 ROOT.RooFit.LineStyle(ROOT.kDashed))
78ras_bkg_sig2 = ROOT.RooArgSet(bkg, sig2)
79model.plotOn(xframe, ROOT.RooFit.Components(ras_bkg_sig2),
80 ROOT.RooFit.LineStyle(ROOT.kDotted))
92model2 = ROOT.RooAddPdf(
113model2.plotOn(xframe, ROOT.RooFit.LineColor(ROOT.kRed),
114 ROOT.RooFit.LineStyle(ROOT.kDashed))
117 ROOT.RooFit.Components(ras_bkg_sig2),
118 ROOT.RooFit.LineColor(
120 ROOT.RooFit.LineStyle(
125c = ROOT.TCanvas(
"rf201_composite",
"rf201_composite", 600, 600)
126ROOT.gPad.SetLeftMargin(0.15)
127xframe.GetYaxis().SetTitleOffset(1.4)
130c.SaveAs(
"rf201_composite.png")