26 x = ROOT.RooRealVar(
"x",
"x", 0, 10)
30 mean = ROOT.RooRealVar(
"mean",
"mean of gaussians", 5, 0, 10)
31 sigma1 = ROOT.RooRealVar(
"sigma1",
"width of gaussians", 0.5)
32 sigma2 = ROOT.RooRealVar(
"sigma2",
"width of gaussians", 1)
34 sig1 = ROOT.RooGaussian(
"sig1",
"Signal component 1", x, mean, sigma1)
35 sig2 = ROOT.RooGaussian(
"sig2",
"Signal component 2", x, mean, sigma2)
38 a0 = ROOT.RooRealVar(
"a0",
"a0", 0.5, 0.0, 1.0)
39 a1 = ROOT.RooRealVar(
"a1",
"a1", -0.2, 0.0, 1.0)
40 bkg = ROOT.RooChebychev(
"bkg",
"Background", x, [a0, a1])
43 sig1frac = ROOT.RooRealVar(
"sig1frac",
"fraction of component 1 in signal", 0.8, 0.0, 1.0)
44 sig = ROOT.RooAddPdf(
"sig",
"Signal", [sig1, sig2], [sig1frac])
47 bkgfrac = ROOT.RooRealVar(
"bkgfrac",
"fraction of background", 0.5, 0.0, 1.0)
48 model = ROOT.RooAddPdf(
"model",
"g1+g2+a", [bkg, sig], [bkgfrac])
63 params = model.getParameters({x})
64 w.defineSet(
"parameters", params)
65 w.defineSet(
"observables", {x})
80 refData = model.generate({x}, 10000)
81 model.fitTo(refData, PrintLevel=-1)
85 w.saveSnapshot(
"reference_fit", params,
True)
91 bkgfrac.setConstant(
True)
93 model.fitTo(refData, PrintLevel=-1)
95 w.saveSnapshot(
"reference_fit_bkgonly", params,
True)
101w = ROOT.RooWorkspace(
"w")
109data = model.generate(w.set(
"observables"), 1000)
112model.fitTo(data, PrintLevel=-1)
115frame = (w.set(
"observables").
first()).frame()
120w.loadSnapshot(
"reference_fit")
121model.plotOn(frame, LineColor=
"r")
122w.loadSnapshot(
"reference_fit_bkgonly")
123model.plotOn(frame, LineColor=
"r", LineStyle=
"--")
126c = ROOT.TCanvas(
"rf510_wsnamedsets",
"rf503_wsnamedsets", 600, 600)
127ROOT.gPad.SetLeftMargin(0.15)
128frame.GetYaxis().SetTitleOffset(1.4)
131c.SaveAs(
"rf510_wsnamedsets.png")
137ROOT.gDirectory.Add(w)