20x = ROOT.RooRealVar(
"x",
"x", -10, 10)
22m = ROOT.RooRealVar(
"m",
"m", 0, -10, 10)
23s = ROOT.RooRealVar(
"s",
"s", 2, 1, 50)
24sig = ROOT.RooGaussian(
"sig",
"sig", x, m, s)
26m2 = ROOT.RooRealVar(
"m2",
"m2", -1, -10, 10)
27s2 = ROOT.RooRealVar(
"s2",
"s2", 6, 1, 50)
28bkg = ROOT.RooGaussian(
"bkg",
"bkg", x, m2, s2)
30fsig = ROOT.RooRealVar(
"fsig",
"fsig", 0.33, 0, 1)
31model = ROOT.RooAddPdf(
"model",
"model", [sig, bkg], [fsig])
35d = model.generateBinned({x}, 1000)
38r = model.fitTo(d, Save=
True, PrintLevel=-1)
44frame = x.frame(Bins=40, Title=
"P.d.f with visualized 1-sigma error band")
64model.plotOn(frame, VisualizeError=(r, 1), FillColor=
"kOrange")
76model.plotOn(frame, VisualizeError=(r, 1,
False), DrawOption=
"L", LineWidth=2, LineColor=
"r")
81model.plotOn(frame, VisualizeError=(r, 1), FillColor=
"kOrange", Components=
"bkg")
84 VisualizeError=(r, 1,
False),
94model.plotOn(frame, Components=
"bkg", LineStyle=
"--")
102frame2 = x.frame(Bins=40, Title=
"Visualization of 2-sigma partial error from (m,m2)")
116model.plotOn(frame2, VisualizeError=(r, {m, m2}, 2), FillColor=
"c")
117model.plotOn(frame2, Components=
"bkg", VisualizeError=(r, {m, m2}, 2), FillColor=
"c")
120model.plotOn(frame2, Components=
"bkg", LineStyle=
"--")
124frame3 = x.frame(Bins=40, Title=
"Visualization of 2-sigma partial error from (s,s2)")
128model.plotOn(frame3, VisualizeError=(r, {s, s2}, 2), FillColor=
"g")
129model.plotOn(frame3, Components=
"bkg", VisualizeError=(r, {fsig}, 2), FillColor=
"g")
132model.plotOn(frame3, Components=
"bkg", LineStyle=
"--")
136frame4 = x.frame(Bins=40, Title=
"Visualization of 2-sigma partial error from fsig")
140model.plotOn(frame4, VisualizeError=(r, {fsig}, 2), FillColor=
"m")
141model.plotOn(frame4, Components=
"bkg", VisualizeError=(r, {fsig}, 2), FillColor=
"m")
144model.plotOn(frame4, Components=
"bkg", LineStyle=
"--")
147c = ROOT.TCanvas(
"rf610_visualerror",
"rf610_visualerror", 800, 800)
150ROOT.gPad.SetLeftMargin(0.15)
151frame.GetYaxis().SetTitleOffset(1.4)
154ROOT.gPad.SetLeftMargin(0.15)
155frame2.GetYaxis().SetTitleOffset(1.6)
158ROOT.gPad.SetLeftMargin(0.15)
159frame3.GetYaxis().SetTitleOffset(1.6)
162ROOT.gPad.SetLeftMargin(0.15)
163frame4.GetYaxis().SetTitleOffset(1.6)
166c.SaveAs(
"rf610_visualerror.png")