25 x = ROOT.RooRealVar(
"x",
"x", 0, 10)
29 mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5, 0, 10)
30 sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5)
31 sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1)
33 sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
34 sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
37 a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0.0, 1.0)
38 a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2, 0.0, 1.0)
39 bkg = ROOT.RooChebychev(
"bkg",
"Background", x, [a0, a1])
42 sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
43 sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], [sig1frac])
46 bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0.0, 1.0)
47 model = ROOT.RooAddPdf(
"model",
"g1+g2+a", [bkg, sig], [bkgfrac])
62 params = model.getParameters({x})
63 w.defineSet(
"parameters", params)
64 w.defineSet(
"observables", {x})
79 refData = model.generate({x}, 10000)
80 model.fitTo(refData, PrintLevel=-1)
84 w.saveSnapshot(
"reference_fit", params,
True)
90 bkgfrac.setConstant(
True)
92 model.fitTo(refData, PrintLevel=-1)
94 w.saveSnapshot(
"reference_fit_bkgonly", params,
True)
100w = ROOT.RooWorkspace(
"w")
108data = model.generate(w.set(
"observables"), 1000)
114frame = (w.set(
"observables").
first()).frame()
119w.loadSnapshot(
"reference_fit")
120model.plotOn(frame, LineColor=
"r")
121w.loadSnapshot(
"reference_fit_bkgonly")
122model.plotOn(frame, LineColor=
"r", LineStyle=
"--")
125c = ROOT.TCanvas(
"rf510_wsnamedsets",
"rf503_wsnamedsets", 600, 600)
126ROOT.gPad.SetLeftMargin(0.15)
127frame.GetYaxis().SetTitleOffset(1.4)
130c.SaveAs(
"rf510_wsnamedsets.png")
136ROOT.gDirectory.Add(w)