import ROOT
dt = ROOT.RooRealVar("dt", "dt", -10, 10)
dterr = ROOT.RooRealVar("dterr", "per-event error on dt", 0.01, 10)
bias = ROOT.RooRealVar("bias", "bias", 0, -10, 10)
sigma = ROOT.RooRealVar(
"sigma", "per-event error scale factor", 1, 0.1, 10)
gm = ROOT.RooGaussModel(
"gm1", "gauss model scaled bt per-event error", dt, bias, sigma, dterr)
tau = ROOT.RooRealVar("tau", "tau", 1.548)
decay_gm = ROOT.RooDecay("decay_gm", "decay", dt,
tau, gm, ROOT.RooDecay.DoubleSided)
pdfDtErr = ROOT.RooLandau("pdfDtErr", "pdfDtErr", dterr, ROOT.RooFit.RooConst(
1), ROOT.RooFit.RooConst(0.25))
expDataDterr = pdfDtErr.generate(ROOT.RooArgSet(dterr), 10000)
data = decay_gm.generate(ROOT.RooArgSet(
dt), ROOT.RooFit.ProtoData(expDataDterr))
decay_gm.fitTo(data, ROOT.RooFit.ConditionalObservables(
ROOT.RooArgSet(dterr)))
hh_decay = decay_gm.createHistogram("hh_decay", dt, ROOT.RooFit.Binning(
50), ROOT.RooFit.YVar(dterr, ROOT.RooFit.Binning(50)))
hh_decay.SetLineColor(ROOT.kBlue)
frame = dt.frame(ROOT.RooFit.Title(
"Slices of decay(dt|dterr) at various dterr"))
for ibin in range(0, 100, 20):
dterr.setBin(ibin)
decay_gm.plotOn(frame, ROOT.RooFit.Normalization(5.))
frame2 = dt.frame(ROOT.RooFit.Title("Projection of decay(dt|dterr) on dt"))
data.plotOn(frame2)
decay_gm.plotOn(frame2, ROOT.RooFit.ProjWData(expDataDterr, ROOT.kTRUE))
c = ROOT.TCanvas("rf306_condpereventerrors",
"rf306_condperventerrors", 1200, 400)
c.Divide(3)
c.cd(1)
ROOT.gPad.SetLeftMargin(0.20)
hh_decay.GetZaxis().SetTitleOffset(2.5)
hh_decay.Draw("surf")
c.cd(2)
ROOT.gPad.SetLeftMargin(0.15)
frame.GetYaxis().SetTitleOffset(1.6)
frame.Draw()
c.cd(3)
ROOT.gPad.SetLeftMargin(0.15)
frame2.GetYaxis().SetTitleOffset(1.6)
frame2.Draw()
c.SaveAs("rf306_condpereventerrors.png")