import ROOT
x = ROOT.RooRealVar("x", "x", -10, 10)
m = ROOT.RooRealVar("m", "m", 0, -10, 10)
s = ROOT.RooRealVar("s", "s", 2, 1, 50)
sig = ROOT.RooGaussian("sig", "sig", x, m, s)
m2 = ROOT.RooRealVar("m2", "m2", -1, -10, 10)
s2 = ROOT.RooRealVar("s2", "s2", 6, 1, 50)
bkg = ROOT.RooGaussian("bkg", "bkg", x, m2, s2)
fsig = ROOT.RooRealVar("fsig", "fsig", 0.33, 0, 1)
model = ROOT.RooAddPdf("model", "model", ROOT.RooArgList(
sig, bkg), ROOT.RooArgList(fsig))
x.setBins(25)
d = model.generateBinned(ROOT.RooArgSet(x), 1000)
r = model.fitTo(d, ROOT.RooFit.Save())
frame = x.frame(ROOT.RooFit.Bins(40), ROOT.RooFit.Title(
"P.d.f with visualized 1-sigma error band"))
d.plotOn(frame)
model.plotOn(frame, ROOT.RooFit.VisualizeError(
r, 1), ROOT.RooFit.FillColor(ROOT.kOrange))
model.plotOn(
frame,
ROOT.RooFit.VisualizeError(
r,
1,
ROOT.kFALSE),
ROOT.RooFit.DrawOption("L"),
ROOT.RooFit.LineWidth(2),
ROOT.RooFit.LineColor(
ROOT.kRed))
model.plotOn(
frame, ROOT.RooFit.VisualizeError(
r, 1), ROOT.RooFit.FillColor(
ROOT.kOrange), ROOT.RooFit.Components("bkg"))
model.plotOn(
frame,
ROOT.RooFit.VisualizeError(
r,
1,
ROOT.kFALSE),
ROOT.RooFit.DrawOption("L"),
ROOT.RooFit.LineWidth(2),
ROOT.RooFit.LineColor(
ROOT.kRed),
ROOT.RooFit.Components("bkg"),
ROOT.RooFit.LineStyle(
ROOT.kDashed))
model.plotOn(frame)
model.plotOn(frame, ROOT.RooFit.Components("bkg"),
ROOT.RooFit.LineStyle(ROOT.kDashed))
d.plotOn(frame)
frame.SetMinimum(0)
frame2 = x.frame(ROOT.RooFit.Bins(40), ROOT.RooFit.Title(
"Visualization of 2-sigma partial error from (m,m2)"))
model.plotOn(frame2, ROOT.RooFit.VisualizeError(
r, ROOT.RooArgSet(m, m2), 2), ROOT.RooFit.FillColor(ROOT.kCyan))
model.plotOn(frame2, ROOT.RooFit.Components("bkg"), ROOT.RooFit.VisualizeError(
r, ROOT.RooArgSet(m, m2), 2), ROOT.RooFit.FillColor(ROOT.kCyan))
model.plotOn(frame2)
model.plotOn(frame2, ROOT.RooFit.Components("bkg"),
ROOT.RooFit.LineStyle(ROOT.kDashed))
frame2.SetMinimum(0)
frame3 = x.frame(ROOT.RooFit.Bins(40), ROOT.RooFit.Title(
"Visualization of 2-sigma partial error from (s,s2)"))
model.plotOn(frame3, ROOT.RooFit.VisualizeError(
r, ROOT.RooArgSet(s, s2), 2), ROOT.RooFit.FillColor(ROOT.kGreen))
model.plotOn(frame3, ROOT.RooFit.Components("bkg"), ROOT.RooFit.VisualizeError(
r, ROOT.RooArgSet(s, s2), 2), ROOT.RooFit.FillColor(ROOT.kGreen))
model.plotOn(frame3)
model.plotOn(frame3, ROOT.RooFit.Components("bkg"),
ROOT.RooFit.LineStyle(ROOT.kDashed))
frame3.SetMinimum(0)
frame4 = x.frame(ROOT.RooFit.Bins(40), ROOT.RooFit.Title(
"Visualization of 2-sigma partial error from fsig"))
model.plotOn(frame4, ROOT.RooFit.VisualizeError(
r, ROOT.RooArgSet(fsig), 2), ROOT.RooFit.FillColor(ROOT.kMagenta))
model.plotOn(frame4, ROOT.RooFit.Components("bkg"), ROOT.RooFit.VisualizeError(
r, ROOT.RooArgSet(fsig), 2), ROOT.RooFit.FillColor(ROOT.kMagenta))
model.plotOn(frame4)
model.plotOn(frame4, ROOT.RooFit.Components("bkg"),
ROOT.RooFit.LineStyle(ROOT.kDashed))
frame4.SetMinimum(0)
c = ROOT.TCanvas("rf610_visualerror", "rf610_visualerror", 800, 800)
c.Divide(2, 2)
c.cd(1)
ROOT.gPad.SetLeftMargin(0.15)
frame.GetYaxis().SetTitleOffset(1.4)
frame.Draw()
c.cd(2)
ROOT.gPad.SetLeftMargin(0.15)
frame2.GetYaxis().SetTitleOffset(1.6)
frame2.Draw()
c.cd(3)
ROOT.gPad.SetLeftMargin(0.15)
frame3.GetYaxis().SetTitleOffset(1.6)
frame3.Draw()
c.cd(4)
ROOT.gPad.SetLeftMargin(0.15)
frame4.GetYaxis().SetTitleOffset(1.6)
frame4.Draw()
c.SaveAs("rf610_visualerror.png")