17x = ROOT.RooRealVar(
"x",
"x", 0, 10)
21mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5)
22sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5)
23sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1)
24sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
25sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
28sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
29sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], [sig1frac])
32a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0.0, 1.0)
33a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2, 0.0, 1.0)
34bkg1 = ROOT.RooChebychev(
"bkg1",
"Background 1", x, [a0, a1])
37alpha = ROOT.RooRealVar(
"alpha",
"alpha", -1)
38bkg2 = ROOT.RooExponential(
"bkg2",
"Background 2", x, alpha)
41bkg1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in background", 0.2, 0.0, 1.0)
42bkg = ROOT.RooAddPdf(
"bkg",
"Signal", [bkg1, bkg2], [sig1frac])
45bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0.0, 1.0)
46model = ROOT.RooAddPdf(
"model",
"g1+g2+a", [bkg, sig], [bkgfrac])
52data = model.generate({x}, 1000)
55xframe = x.frame(Title=
"Component plotting of pdf=(sig1+sig2)+(bkg1+bkg2)")
60xframe2 = xframe.Clone(
"xframe2")
67model.plotOn(xframe, Components=ras_bkg, LineColor=
"r")
71model.plotOn(xframe, Components=ras_bkg2, LineStyle=
"--", LineColor=
"r")
76ras_bkg_sig2 = {bkg, sig2}
77model.plotOn(xframe, Components=ras_bkg_sig2, LineStyle=
":")
83model.plotOn(xframe2, Components=
"bkg", LineColor=
"c")
86model.plotOn(xframe2, Components=
"bkg1,sig2", LineStyle=
":", LineColor=
"c")
90model.plotOn(xframe2, Components=
"sig*", LineStyle=
"--", LineColor=
"c")
94model.plotOn(xframe2, Invisible=
True, Components=
"bkg1,sig*", LineStyle=
"--", LineColor=
"y")
97c = ROOT.TCanvas(
"rf205_compplot",
"rf205_compplot", 800, 400)
100ROOT.gPad.SetLeftMargin(0.15)
101xframe.GetYaxis().SetTitleOffset(1.4)
104ROOT.gPad.SetLeftMargin(0.15)
105xframe2.GetYaxis().SetTitleOffset(1.4)
108c.SaveAs(
"rf205_compplot.png")