import ROOT
dt = ROOT.RooRealVar("dt", "dt", -10, 10)
tau = ROOT.RooRealVar("tau", "tau", 1.548)
tm = ROOT.RooTruthModel("tm", "truth model", dt)
decay_tm = ROOT.RooDecay("decay_tm", "decay", dt, tau, tm, type="DoubleSided")
frame = dt.frame(Title="Bdecay (x) resolution")
decay_tm.plotOn(frame, LineStyle="--")
bias1 = ROOT.RooRealVar("bias1", "bias1", 0)
sigma1 = ROOT.RooRealVar("sigma1", "sigma1", 1)
gm1 = ROOT.RooGaussModel("gm1", "gauss model 1", dt, bias1, sigma1)
decay_gm1 = ROOT.RooDecay("decay_gm1", "decay", dt, tau, gm1, type="DoubleSided")
decay_gm1.plotOn(frame)
bias2 = ROOT.RooRealVar("bias2", "bias2", 0)
sigma2 = ROOT.RooRealVar("sigma2", "sigma2", 5)
gm2 = ROOT.RooGaussModel("gm2", "gauss model 2", dt, bias2, sigma2)
gm1frac = ROOT.RooRealVar("gm1frac", "fraction of gm1", 0.5)
gmsum = ROOT.RooAddModel("gmsum", "sum of gm1 and gm2", [gm1, gm2], [gm1frac])
decay_gmsum = ROOT.RooDecay("decay_gmsum", "decay", dt, tau, gmsum, ROOT.RooDecay.DoubleSided)
decay_gmsum.plotOn(frame, LineColor="r")
c = ROOT.TCanvas("rf209_anaconv", "rf209_anaconv", 600, 600)
ROOT.gPad.SetLeftMargin(0.15)
frame.GetYaxis().SetTitleOffset(1.6)
frame.Draw()
c.SaveAs("rf209_anaconv.png")