rf310_sliceplot

Multidimensional models: projecting pdf and data slices in discrete observables

Author: Clemens Lange, Wouter Verkerke (C++ version)
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Sunday, November 27, 2022 at 11:07 AM.

In [1]:
import ROOT
Welcome to JupyROOT 6.27/01

Create B decay pdf with mixing

Decay time observables

In [2]:
dt = ROOT.RooRealVar("dt", "dt", -20, 20)

Discrete observables mixState (B0tag==B0reco?) and tagFlav (B0tag==B0(bar)?) Define state labels of discrete observables

In [3]:
mixState = ROOT.RooCategory("mixState", "B0/B0bar mixing state", {"mixed": -1, "unmixed": 1})
tagFlav = ROOT.RooCategory("tagFlav", "Flavour of the tagged B0", {"B0": 1, "B0bar": -1})

Model parameters

In [4]:
dm = ROOT.RooRealVar("dm", "delta m(B)", 0.472, 0.0, 1.0)
tau = ROOT.RooRealVar("tau", "B0 decay time", 1.547, 1.0, 2.0)
w = ROOT.RooRealVar("w", "Flavor Mistag rate", 0.03, 0.0, 1.0)
dw = ROOT.RooRealVar("dw", "Flavor Mistag rate difference between B0 and B0bar", 0.01)

Build a gaussian resolution model

In [5]:
bias1 = ROOT.RooRealVar("bias1", "bias1", 0)
sigma1 = ROOT.RooRealVar("sigma1", "sigma1", 0.01)
gm1 = ROOT.RooGaussModel("gm1", "gauss model 1", dt, bias1, sigma1)

Construct a decay pdf, with single gaussian resolution model

In [6]:
bmix_gm1 = ROOT.RooBMixDecay("bmix", "decay", dt, mixState, tagFlav, tau, dm, w, dw, gm1, type="DoubleSided")

Generate BMixing data with above set of event errors

In [7]:
data = bmix_gm1.generate({dt, tagFlav, mixState}, 20000)

Plot full decay distribution

Create frame, data and pdf projection (integrated over tagFlav and mixState)

In [8]:
frame = dt.frame(Title="Inclusive decay distribution")
data.plotOn(frame)
bmix_gm1.plotOn(frame)
Out[8]:
<cppyy.gbl.RooPlot object at 0x960e7a0>
[#1] INFO:Plotting -- RooAbsReal::plotOn(bmix) plot on dt integrates over variables (tagFlav,mixState)

Plot decay distribution for mixed and unmixed slice of mixState

Create frame, data (mixed only)

In [9]:
frame2 = dt.frame(Title="Decay distribution of mixed events")
data.plotOn(frame2, Cut="mixState==mixState::mixed")
Out[9]:
<cppyy.gbl.RooPlot object at 0x954ec80>
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 3787 events out of 20000 total events

Position slice in mixState at "mixed" and plot slice of pdf in mixstate over data (integrated over tagFlav)

In [10]:
bmix_gm1.plotOn(frame2, Slice=(mixState, "mixed"))
Out[10]:
<cppyy.gbl.RooPlot object at 0x954ec80>
[#1] INFO:Plotting -- RooAbsReal::plotOn(bmix) plot on dt represents a slice in (mixState)
[#1] INFO:Plotting -- RooAbsReal::plotOn(bmix) plot on dt integrates over variables (tagFlav)

Create frame, data (unmixed only)

In [11]:
frame3 = dt.frame(Title="Decay distribution of unmixed events")
data.plotOn(frame3, Cut="mixState==mixState::unmixed")
Out[11]:
<cppyy.gbl.RooPlot object at 0x978f080>
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 16213 events out of 20000 total events

Position slice in mixState at "unmixed" and plot slice of pdf in mixstate over data (integrated over tagFlav)

In [12]:
bmix_gm1.plotOn(frame3, Slice=(mixState, "unmixed"))

c = ROOT.TCanvas("rf310_sliceplot", "rf310_sliceplot", 1200, 400)
c.Divide(3)
c.cd(1)
ROOT.gPad.SetLeftMargin(0.15)
frame.GetYaxis().SetTitleOffset(1.4)
ROOT.gPad.SetLogy()
frame.Draw()
c.cd(2)
ROOT.gPad.SetLeftMargin(0.15)
frame2.GetYaxis().SetTitleOffset(1.4)
ROOT.gPad.SetLogy()
frame2.Draw()
c.cd(3)
ROOT.gPad.SetLeftMargin(0.15)
frame3.GetYaxis().SetTitleOffset(1.4)
ROOT.gPad.SetLogy()
frame3.Draw()

c.SaveAs("rf310_sliceplot.png")
[#1] INFO:Plotting -- RooAbsReal::plotOn(bmix) plot on dt represents a slice in (mixState)
[#1] INFO:Plotting -- RooAbsReal::plotOn(bmix) plot on dt integrates over variables (tagFlav)
Info in <TCanvas::Print>: png file rf310_sliceplot.png has been created

Draw all canvases

In [13]:
from ROOT import gROOT 
gROOT.GetListOfCanvases().Draw()