Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
rf209_anaconv.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_roofit
3## \notebook
4## Addition and convolution: decay function pdfs with optional B physics effects (mixing
5## and CP violation) that can be analytically convolved with e.g. Gaussian resolution functions
6##
7## ```
8## pdf1 = decay(t,tau) (x) delta(t)
9## pdf2 = decay(t,tau) (x) gauss(t,m,s)
10## pdf3 = decay(t,tau) (x) (f*gauss1(t,m1,s1) + (1-f)*gauss2(t,m1,s1))
11## ```
12##
13## \macro_code
14##
15## \date February 2018
16## \authors Clemens Lange, Wouter Verkerke (C++ version)
17
18import ROOT
19
20# B-physics pdf with truth resolution
21# ---------------------------------------------------------------------
22
23# Variables of decay pdf
24dt = ROOT.RooRealVar("dt", "dt", -10, 10)
25tau = ROOT.RooRealVar("tau", "tau", 1.548)
26
27# Build a truth resolution model (delta function)
28tm = ROOT.RooTruthModel("tm", "truth model", dt)
29
30# Construct decay(t) (x) delta(t)
31decay_tm = ROOT.RooDecay("decay_tm", "decay", dt, tau, tm, type="DoubleSided")
32
33# Plot pdf (dashed)
34frame = dt.frame(Title="Bdecay (x) resolution")
35decay_tm.plotOn(frame, LineStyle="--")
36
37# B-physics pdf with Gaussian resolution
38# ----------------------------------------------------------------------------
39
40# Build a gaussian resolution model
41bias1 = ROOT.RooRealVar("bias1", "bias1", 0)
42sigma1 = ROOT.RooRealVar("sigma1", "sigma1", 1)
43gm1 = ROOT.RooGaussModel("gm1", "gauss model 1", dt, bias1, sigma1)
44
45# Construct decay(t) (x) gauss1(t)
46decay_gm1 = ROOT.RooDecay("decay_gm1", "decay", dt, tau, gm1, type="DoubleSided")
47
48# Plot pdf
49decay_gm1.plotOn(frame)
50
51# B-physics pdf with double Gaussian resolution
52# ------------------------------------------------------------------------------------------
53
54# Build another gaussian resolution model
55bias2 = ROOT.RooRealVar("bias2", "bias2", 0)
56sigma2 = ROOT.RooRealVar("sigma2", "sigma2", 5)
57gm2 = ROOT.RooGaussModel("gm2", "gauss model 2", dt, bias2, sigma2)
58
59# Build a composite resolution model f*gm1+(1-f)*gm2
60gm1frac = ROOT.RooRealVar("gm1frac", "fraction of gm1", 0.5)
61gmsum = ROOT.RooAddModel("gmsum", "sum of gm1 and gm2", [gm1, gm2], [gm1frac])
62
63# Construct decay(t) (x) (f*gm1 + (1-f)*gm2)
64decay_gmsum = ROOT.RooDecay("decay_gmsum", "decay", dt, tau, gmsum, ROOT.RooDecay.DoubleSided)
65
66# Plot pdf (red)
67decay_gmsum.plotOn(frame, LineColor="r")
68
69# Draw all frames on canvas
70c = ROOT.TCanvas("rf209_anaconv", "rf209_anaconv", 600, 600)
71ROOT.gPad.SetLeftMargin(0.15)
72frame.GetYaxis().SetTitleOffset(1.6)
73frame.Draw()
74
75c.SaveAs("rf209_anaconv.png")