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)
26sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
27sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
30sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
31sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], [sig1frac])
34a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0.0, 1.0)
35a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2, 0.0, 1.0)
36bkg1 = ROOT.RooChebychev(
"bkg1",
"Background 1", x, [a0, a1])
39alpha = ROOT.RooRealVar(
"alpha",
"alpha", -1)
40bkg2 = ROOT.RooExponential(
"bkg2",
"Background 2", x, alpha)
43bkg1frac = ROOT.RooRealVar(
"bkg1frac",
"fraction of component 1 in background", 0.8, 0.0, 1.0)
44bkg = ROOT.RooAddPdf(
"bkg",
"Total background", [bkg1, bkg2], [bkg1frac])
47bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0.0, 1.0)
48model = ROOT.RooAddPdf(
"model",
"g1+g2+a", [bkg, sig], [bkgfrac])
54data = model.generate({x}, 1000)
57xframe = x.frame(Title=
"Component plotting of pdf=(sig1+sig2)+(bkg1+bkg2)")
62xframe2 = xframe.Clone(
"xframe2")
69model.plotOn(xframe, Components=ras_bkg, LineColor=
"r")
73model.plotOn(xframe, Components=ras_bkg2, LineStyle=
"--", LineColor=
"r")
78ras_bkg_sig2 = {bkg, sig2}
79model.plotOn(xframe, Components=ras_bkg_sig2, LineStyle=
":")
85model.plotOn(xframe2, Components=
"bkg", LineColor=
"c")
88model.plotOn(xframe2, Components=
"bkg1,sig2", LineStyle=
":", LineColor=
"c")
92model.plotOn(xframe2, Components=
"sig*", LineStyle=
"--", LineColor=
"c")
96model.plotOn(xframe2, Invisible=
True, Components=
"bkg1,sig*", LineStyle=
"--", LineColor=
"y")
99c = ROOT.TCanvas(
"rf205_compplot",
"rf205_compplot", 800, 400)
102ROOT.gPad.SetLeftMargin(0.15)
103xframe.GetYaxis().SetTitleOffset(1.4)
106ROOT.gPad.SetLeftMargin(0.15)
107xframe2.GetYaxis().SetTitleOffset(1.4)
110c.SaveAs(
"rf205_compplot.png")