19x = ROOT.RooRealVar(
"x",
"x", -10, 10)
22mx = ROOT.RooRealVar(
"mx",
"mx", 0, -10, 10)
23gx = ROOT.RooGaussian(
"gx",
"gx", x, mx, 1.0)
26px = ROOT.RooPolynomial(
"px",
"px", x)
29f = ROOT.RooRealVar(
"f",
"f", 0.0, 1.0)
30model = ROOT.RooAddPdf(
"model",
"model", [gx, px], [f])
33modelData = model.generate({x}, 10000)
39r_full = model.fitTo(modelData, Save=
True, PrintLevel=-1)
45x.setRange(
"signal", -3, 3)
48r_sig = model.fitTo(modelData, Save=
True, Range=
"signal", PrintLevel=-1)
54frame = x.frame(Title=
"Fitting a sub range")
55modelData.plotOn(frame)
56model.plotOn(frame, Range=
"Full", LineColor=
"r", LineStyle=
"--")
60print(
"result of fit on all data ")
62print(
"result of fit in in signal region (note increased error on signal fraction)")
66c = ROOT.TCanvas(
"rf203_ranges",
"rf203_ranges", 600, 600)
67ROOT.gPad.SetLeftMargin(0.15)
68frame.GetYaxis().SetTitleOffset(1.4)
71c.SaveAs(
"rf203_ranges.png")