Logo ROOT  
Reference Guide
rf708_bphysics.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_roofit
3 ## \notebook
4 ## Special pdf's: special decay pdf for B physics with mixing and/or CP violation
5 ##
6 ## \macro_code
7 ##
8 ## \date February 2018
9 ## \authors Clemens Lange, Wouter Verkerke (C++ version)
10 
11 import ROOT
12 
13 
14 # B-decay with mixing
15 # -------------------------
16 
17 # Construct pdf
18 # -------------------------
19 
20 # Observable
21 dt = ROOT.RooRealVar("dt", "dt", -10, 10)
22 dt.setBins(40)
23 
24 # Parameters
25 dm = ROOT.RooRealVar("dm", "delta m(B0)", 0.472)
26 tau = ROOT.RooRealVar("tau", "tau (B0)", 1.547)
27 w = ROOT.RooRealVar("w", "flavour mistag rate", 0.1)
28 dw = ROOT.RooRealVar("dw", "delta mistag rate for B0/B0bar", 0.1)
29 
30 mixState = ROOT.RooCategory("mixState", "B0/B0bar mixing state")
31 mixState.defineType("mixed", -1)
32 mixState.defineType("unmixed", 1)
33 
34 tagFlav = ROOT.RooCategory("tagFlav", "Flavour of the tagged B0")
35 tagFlav.defineType("B0", 1)
36 tagFlav.defineType("B0bar", -1)
37 
38 # Use delta function resolution model
39 tm = ROOT.RooTruthModel("tm", "truth model", dt)
40 
41 # Construct Bdecay with mixing
42 bmix = ROOT.RooBMixDecay(
43  "bmix",
44  "decay",
45  dt,
46  mixState,
47  tagFlav,
48  tau,
49  dm,
50  w,
51  dw,
52  tm,
53  ROOT.RooBMixDecay.DoubleSided)
54 
55 # Plot pdf in various slices
56 # ---------------------------------------------------
57 
58 # Generate some data
59 data = bmix.generate(ROOT.RooArgSet(dt, mixState, tagFlav), 10000)
60 
61 # Plot B0 and B0bar tagged data separately
62 # For all plots below B0 and B0 tagged data will look somewhat differently
63 # if the flavor tagging mistag rate for B0 and B0 is different (i.e. dw!=0)
64 frame1 = dt.frame(ROOT.RooFit.Title(
65  "B decay distribution with mixing (B0/B0bar)"))
66 
67 data.plotOn(frame1, ROOT.RooFit.Cut("tagFlav==tagFlav::B0"))
68 bmix.plotOn(frame1, ROOT.RooFit.Slice(tagFlav, "B0"))
69 
70 data.plotOn(frame1, ROOT.RooFit.Cut("tagFlav==tagFlav::B0bar"),
71  ROOT.RooFit.MarkerColor(ROOT.kCyan))
72 bmix.plotOn(frame1, ROOT.RooFit.Slice(tagFlav, "B0bar"),
73  ROOT.RooFit.LineColor(ROOT.kCyan))
74 
75 # Plot mixed slice for B0 and B0bar tagged data separately
76 frame2 = dt.frame(ROOT.RooFit.Title(
77  "B decay distribution of mixed events (B0/B0bar)"))
78 
79 data.plotOn(frame2, ROOT.RooFit.Cut(
80  "mixState==mixState::mixed&&tagFlav==tagFlav::B0"))
81 bmix.plotOn(frame2, ROOT.RooFit.Slice(tagFlav, "B0"),
82  ROOT.RooFit.Slice(mixState, "mixed"))
83 
84 data.plotOn(
85  frame2,
86  ROOT.RooFit.Cut("mixState==mixState::mixed&&tagFlav==tagFlav::B0bar"),
87  ROOT.RooFit.MarkerColor(
88  ROOT.kCyan))
89 bmix.plotOn(frame2, ROOT.RooFit.Slice(tagFlav, "B0bar"), ROOT.RooFit.Slice(
90  mixState, "mixed"), ROOT.RooFit.LineColor(ROOT.kCyan))
91 
92 # Plot unmixed slice for B0 and B0bar tagged data separately
93 frame3 = dt.frame(ROOT.RooFit.Title(
94  "B decay distribution of unmixed events (B0/B0bar)"))
95 
96 data.plotOn(frame3, ROOT.RooFit.Cut(
97  "mixState==mixState::unmixed&&tagFlav==tagFlav::B0"))
98 bmix.plotOn(frame3, ROOT.RooFit.Slice(tagFlav, "B0"),
99  ROOT.RooFit.Slice(mixState, "unmixed"))
100 
101 data.plotOn(
102  frame3,
103  ROOT.RooFit.Cut("mixState==mixState::unmixed&&tagFlav==tagFlav::B0bar"),
104  ROOT.RooFit.MarkerColor(
105  ROOT.kCyan))
106 bmix.plotOn(frame3, ROOT.RooFit.Slice(tagFlav, "B0bar"), ROOT.RooFit.Slice(
107  mixState, "unmixed"), ROOT.RooFit.LineColor(ROOT.kCyan))
108 
109 # B-decay with CP violation
110 # -------------------------
111 
112 # Construct pdf
113 # -------------------------
114 
115 # Additional parameters needed for B decay with CPV
116 CPeigen = ROOT.RooRealVar("CPeigen", "CP eigen value", -1)
117 absLambda = ROOT.RooRealVar("absLambda", "|lambda|", 1, 0, 2)
118 argLambda = ROOT.RooRealVar("absLambda", "|lambda|", 0.7, -1, 1)
119 effR = ROOT.RooRealVar("effR", "B0/B0bar reco efficiency ratio", 1)
120 
121 # Construct Bdecay with CP violation
122 bcp = ROOT.RooBCPEffDecay(
123  "bcp",
124  "bcp",
125  dt,
126  tagFlav,
127  tau,
128  dm,
129  w,
130  CPeigen,
131  absLambda,
132  argLambda,
133  effR,
134  dw,
135  tm,
136  ROOT.RooBCPEffDecay.DoubleSided)
137 
138 # Plot scenario 1 - sin(2b)=0.7, |l|=1
139 # ---------------------------------------------------------------------------
140 
141 # Generate some data
142 data2 = bcp.generate(ROOT.RooArgSet(dt, tagFlav), 10000)
143 
144 # Plot B0 and B0bar tagged data separately
145 frame4 = dt.frame(ROOT.RooFit.Title(
146  "B decay distribution with CPV(|l|=1,Im(l)=0.7) (B0/B0bar)"))
147 
148 data2.plotOn(frame4, ROOT.RooFit.Cut("tagFlav==tagFlav::B0"))
149 bcp.plotOn(frame4, ROOT.RooFit.Slice(tagFlav, "B0"))
150 
151 data2.plotOn(frame4, ROOT.RooFit.Cut("tagFlav==tagFlav::B0bar"),
152  ROOT.RooFit.MarkerColor(ROOT.kCyan))
153 bcp.plotOn(frame4, ROOT.RooFit.Slice(tagFlav, "B0bar"),
154  ROOT.RooFit.LineColor(ROOT.kCyan))
155 
156 # # Plot scenario 2 - sin(2b)=0.7, |l|=0.7
157 # -------------------------------------------------------------------------------
158 
159 absLambda.setVal(0.7)
160 
161 # Generate some data
162 data3 = bcp.generate(ROOT.RooArgSet(dt, tagFlav), 10000)
163 
164 # Plot B0 and B0bar tagged data separately (sin2b = 0.7 plus direct CPV
165 # |l|=0.5)
166 frame5 = dt.frame(ROOT.RooFit.Title(
167  "B decay distribution with CPV(|l|=0.7,Im(l)=0.7) (B0/B0bar)"))
168 
169 data3.plotOn(frame5, ROOT.RooFit.Cut("tagFlav==tagFlav::B0"))
170 bcp.plotOn(frame5, ROOT.RooFit.Slice(tagFlav, "B0"))
171 
172 data3.plotOn(frame5, ROOT.RooFit.Cut("tagFlav==tagFlav::B0bar"),
173  ROOT.RooFit.MarkerColor(ROOT.kCyan))
174 bcp.plotOn(frame5, ROOT.RooFit.Slice(tagFlav, "B0bar"),
175  ROOT.RooFit.LineColor(ROOT.kCyan))
176 
177 
178 # Generic B-decay with user coefficients
179 # -------------------------
180 
181 # Construct pdf
182 # -------------------------
183 
184 # Model parameters
185 DGbG = ROOT.RooRealVar("DGbG", "DGamma/GammaAvg", 0.5, -1, 1)
186 Adir = ROOT.RooRealVar("Adir", "-[1-abs(l)**2]/[1+abs(l)**2]", 0)
187 Amix = ROOT.RooRealVar("Amix", "2Im(l)/[1+abs(l)**2]", 0.7)
188 Adel = ROOT.RooRealVar("Adel", "2Re(l)/[1+abs(l)**2]", 0.7)
189 
190 # Derived input parameters for pdf
191 DG = ROOT.RooFormulaVar("DG", "Delta Gamma", "@1/@0",
192  ROOT.RooArgList(tau, DGbG))
193 
194 # Construct coefficient functions for sin,cos, modulations of decay
195 # distribution
196 fsin = ROOT.RooFormulaVar(
197  "fsin", "fsin", "@0*@1*(1-2*@2)", ROOT.RooArgList(Amix, tagFlav, w))
198 fcos = ROOT.RooFormulaVar(
199  "fcos", "fcos", "@0*@1*(1-2*@2)", ROOT.RooArgList(Adir, tagFlav, w))
200 fsinh = ROOT.RooFormulaVar("fsinh", "fsinh", "@0", ROOT.RooArgList(Adel))
201 
202 # Construct generic B decay pdf using above user coefficients
203 bcpg = ROOT.RooBDecay("bcpg", "bcpg", dt, tau, DG, ROOT.RooFit.RooConst(
204  1), fsinh, fcos, fsin, dm, tm, ROOT.RooBDecay.DoubleSided)
205 
206 # Plot - Im(l)=0.7, e(l)=0.7 |l|=1, G/G=0.5
207 # -------------------------------------------------------------------------------------
208 
209 # Generate some data
210 data4 = bcpg.generate(ROOT.RooArgSet(dt, tagFlav), 10000)
211 
212 # Plot B0 and B0bar tagged data separately
213 frame6 = dt.frame(ROOT.RooFit.Title(
214  "B decay distribution with CPV(Im(l)=0.7,Re(l)=0.7,|l|=1,dG/G=0.5) (B0/B0bar)"))
215 
216 data4.plotOn(frame6, ROOT.RooFit.Cut("tagFlav==tagFlav::B0"))
217 bcpg.plotOn(frame6, ROOT.RooFit.Slice(tagFlav, "B0"))
218 
219 data4.plotOn(frame6, ROOT.RooFit.Cut("tagFlav==tagFlav::B0bar"),
220  ROOT.RooFit.MarkerColor(ROOT.kCyan))
221 bcpg.plotOn(frame6, ROOT.RooFit.Slice(tagFlav, "B0bar"),
222  ROOT.RooFit.LineColor(ROOT.kCyan))
223 
224 c = ROOT.TCanvas("rf708_bphysics", "rf708_bphysics", 1200, 800)
225 c.Divide(3, 2)
226 c.cd(1)
227 ROOT.gPad.SetLeftMargin(0.15)
228 frame1.GetYaxis().SetTitleOffset(1.6)
229 frame1.Draw()
230 c.cd(2)
231 ROOT.gPad.SetLeftMargin(0.15)
232 frame2.GetYaxis().SetTitleOffset(1.6)
233 frame2.Draw()
234 c.cd(3)
235 ROOT.gPad.SetLeftMargin(0.15)
236 frame3.GetYaxis().SetTitleOffset(1.6)
237 frame3.Draw()
238 c.cd(4)
239 ROOT.gPad.SetLeftMargin(0.15)
240 frame4.GetYaxis().SetTitleOffset(1.6)
241 frame4.Draw()
242 c.cd(5)
243 ROOT.gPad.SetLeftMargin(0.15)
244 frame5.GetYaxis().SetTitleOffset(1.6)
245 frame5.Draw()
246 c.cd(6)
247 ROOT.gPad.SetLeftMargin(0.15)
248 frame6.GetYaxis().SetTitleOffset(1.6)
249 frame6.Draw()
250 
251 c.SaveAs("rf708_bphysics.png")