Rf 7 0 8_Bphysics

Special pdf's: special decay pdf for B physics with mixing and/or CP violation

Author: Wouter Verkerke
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Wednesday, January 19, 2022 at 10:36 AM.

In [1]:
%%cpp -d
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooCategory.h"
#include "RooBMixDecay.h"
#include "RooBCPEffDecay.h"
#include "RooBDecay.h"
#include "RooFormulaVar.h"
#include "RooTruthModel.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
In [2]:
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace RooFit;

B-Decay with mixing

Construct pdf

Observable

In [3]:
RooRealVar dt("dt", "dt", -10, 10);
dt.setBins(40);
RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

Parameters

In [4]:
RooRealVar dm("dm", "delta m(B0)", 0.472);
RooRealVar tau("tau", "tau (B0)", 1.547);
RooRealVar w("w", "flavour mistag rate", 0.1);
RooRealVar dw("dw", "delta mistag rate for B0/B0bar", 0.1);

RooCategory mixState("mixState", "B0/B0bar mixing state");
mixState.defineType("mixed", -1);
mixState.defineType("unmixed", 1);

RooCategory tagFlav("tagFlav", "Flavour of the tagged B0");
tagFlav.defineType("B0", 1);
tagFlav.defineType("B0bar", -1);

Use delta function resolution model

In [5]:
RooTruthModel truthModel("tm", "truth model", dt);

Construct bdecay with mixing

In [6]:
RooBMixDecay bmix("bmix", "decay", dt, mixState, tagFlav, tau, dm, w, dw, truthModel, RooBMixDecay::DoubleSided);

Plot pdf in various slices

Generate some data

In [7]:
RooDataSet *data = bmix.generate(RooArgSet(dt, mixState, tagFlav), 10000);

Plot b0 and b0bar tagged data separately For all plots below B0 and B0 tagged data will look somewhat differently if the flavor tagging mistag rate for B0 and B0 is different (i.e. dw!=0)

In [8]:
RooPlot *frame1 = dt.frame(Title("B decay distribution with mixing (B0/B0bar)"));

data->plotOn(frame1, Cut("tagFlav==tagFlav::B0"));
bmix.plotOn(frame1, Slice(tagFlav, "B0"));

data->plotOn(frame1, Cut("tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
bmix.plotOn(frame1, Slice(tagFlav, "B0bar"), LineColor(kCyan));
input_line_64:4:1: error: reference to 'data' is ambiguous
data->plotOn(frame1, Cut("tagFlav==tagFlav::B0"));
^
input_line_63:2:14: note: candidate found by name lookup is '__cling_N525::data'
 RooDataSet *data = bmix.generate(RooArgSet(dt, mixState, tagFlav), 10000);
             ^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
    data(initializer_list<_Tp> __il) noexcept
    ^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
    data(_Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
    data(const _Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
    data(_Tp (&__array)[_Nm]) noexcept
    ^
input_line_64:7:1: error: reference to 'data' is ambiguous
data->plotOn(frame1, Cut("tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
^
input_line_63:2:14: note: candidate found by name lookup is '__cling_N525::data'
 RooDataSet *data = bmix.generate(RooArgSet(dt, mixState, tagFlav), 10000);
             ^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
    data(initializer_list<_Tp> __il) noexcept
    ^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
    data(_Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
    data(const _Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
    data(_Tp (&__array)[_Nm]) noexcept
    ^

Plot mixed slice for b0 and b0bar tagged data separately

In [9]:
RooPlot *frame2 = dt.frame(Title("B decay distribution of mixed events (B0/B0bar)"));

data->plotOn(frame2, Cut("mixState==mixState::mixed&&tagFlav==tagFlav::B0"));
bmix.plotOn(frame2, Slice({{&tagFlav, "B0"}, {&mixState, "mixed"}}));

data->plotOn(frame2, Cut("mixState==mixState::mixed&&tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
bmix.plotOn(frame2, Slice({{&tagFlav, "B0bar"}, {&mixState, "mixed"}}), LineColor(kCyan));
input_line_65:4:1: error: reference to 'data' is ambiguous
data->plotOn(frame2, Cut("mixState==mixState::mixed&&tagFlav==tagFlav::B0"));
^
input_line_63:2:14: note: candidate found by name lookup is '__cling_N525::data'
 RooDataSet *data = bmix.generate(RooArgSet(dt, mixState, tagFlav), 10000);
             ^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
    data(initializer_list<_Tp> __il) noexcept
    ^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
    data(_Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
    data(const _Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
    data(_Tp (&__array)[_Nm]) noexcept
    ^
input_line_65:7:1: error: reference to 'data' is ambiguous
data->plotOn(frame2, Cut("mixState==mixState::mixed&&tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
^
input_line_63:2:14: note: candidate found by name lookup is '__cling_N525::data'
 RooDataSet *data = bmix.generate(RooArgSet(dt, mixState, tagFlav), 10000);
             ^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
    data(initializer_list<_Tp> __il) noexcept
    ^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
    data(_Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
    data(const _Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
    data(_Tp (&__array)[_Nm]) noexcept
    ^

Plot unmixed slice for b0 and b0bar tagged data separately

In [10]:
RooPlot *frame3 = dt.frame(Title("B decay distribution of unmixed events (B0/B0bar)"));

data->plotOn(frame3, Cut("mixState==mixState::unmixed&&tagFlav==tagFlav::B0"));
bmix.plotOn(frame3, Slice({{&tagFlav, "B0"}, {&mixState, "unmixed"}}));

data->plotOn(frame3, Cut("mixState==mixState::unmixed&&tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
bmix.plotOn(frame3, Slice({{&tagFlav, "B0bar"}, {&mixState, "unmixed"}}), LineColor(kCyan));
input_line_66:4:1: error: reference to 'data' is ambiguous
data->plotOn(frame3, Cut("mixState==mixState::unmixed&&tagFlav==tagFlav::B0"));
^
input_line_63:2:14: note: candidate found by name lookup is '__cling_N525::data'
 RooDataSet *data = bmix.generate(RooArgSet(dt, mixState, tagFlav), 10000);
             ^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
    data(initializer_list<_Tp> __il) noexcept
    ^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
    data(_Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
    data(const _Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
    data(_Tp (&__array)[_Nm]) noexcept
    ^
input_line_66:5:21: error: no matching function for call to 'Slice'
bmix.plotOn(frame3, Slice({{&tagFlav, "B0"}, {&mixState, "unmixed"}}));
                    ^~~~~
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:82:11: note: candidate function not viable: cannot convert initializer list argument to 'const RooArgSet'
RooCmdArg Slice(const RooArgSet& sliceSet) ;
          ^
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:83:11: note: candidate function not viable: cannot convert initializer list argument to 'RooArgSet'
RooCmdArg Slice(RooArgSet && sliceSet) ;
          ^
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:85:11: note: candidate function not viable: cannot convert initializer list argument to 'const std::map<RooCategory *, std::string>' (aka 'const map<RooCategory *, basic_string<char> >')
RooCmdArg Slice(std::map<RooCategory*, std::string> const&) ;
          ^
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:84:11: note: candidate function not viable: requires 2 arguments, but 1 was provided
RooCmdArg Slice(RooCategory& cat, const char* label) ;
          ^
input_line_66:7:1: error: reference to 'data' is ambiguous
data->plotOn(frame3, Cut("mixState==mixState::unmixed&&tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
^
input_line_63:2:14: note: candidate found by name lookup is '__cling_N525::data'
 RooDataSet *data = bmix.generate(RooArgSet(dt, mixState, tagFlav), 10000);
             ^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
    data(initializer_list<_Tp> __il) noexcept
    ^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
    data(_Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
    data(const _Container& __cont) noexcept(noexcept(__cont.data()))
    ^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
    data(_Tp (&__array)[_Nm]) noexcept
    ^
input_line_66:8:21: error: no matching function for call to 'Slice'
bmix.plotOn(frame3, Slice({{&tagFlav, "B0bar"}, {&mixState, "unmixed"}}), LineColor(kCyan));
                    ^~~~~
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:82:11: note: candidate function not viable: cannot convert initializer list argument to 'const RooArgSet'
RooCmdArg Slice(const RooArgSet& sliceSet) ;
          ^
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:83:11: note: candidate function not viable: cannot convert initializer list argument to 'RooArgSet'
RooCmdArg Slice(RooArgSet && sliceSet) ;
          ^
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:85:11: note: candidate function not viable: cannot convert initializer list argument to 'const std::map<RooCategory *, std::string>' (aka 'const map<RooCategory *, basic_string<char> >')
RooCmdArg Slice(std::map<RooCategory*, std::string> const&) ;
          ^
/home/sftnight/build/workspace/root-makedoc-master/rootspi/rdoc/src/master.build/include/RooGlobalFunc.h:84:11: note: candidate function not viable: requires 2 arguments, but 1 was provided
RooCmdArg Slice(RooCategory& cat, const char* label) ;
          ^

B-Decay with CP violation

Construct pdf

Additional parameters needed for b decay with cpv

In [11]:
RooRealVar CPeigen("CPeigen", "CP eigen value", -1);
RooRealVar absLambda("absLambda", "|lambda|", 1, 0, 2);
RooRealVar argLambda("absLambda", "|lambda|", 0.7, -1, 1);
RooRealVar effR("effR", "B0/B0bar reco efficiency ratio", 1);

Construct bdecay with cp violation

In [12]:
RooBCPEffDecay bcp("bcp", "bcp", dt, tagFlav, tau, dm, w, CPeigen, absLambda, argLambda, effR, dw, truthModel,
                   RooBCPEffDecay::DoubleSided);
[#1] INFO:InputArguments -- The formula exp(-abs(@0)/@1)_dt_tau_dm claims to use the variables (dt,tau,dm) but only (dt,tau) seem to be in use.
  inputs:         exp(-abs(@0)/@1)

Plot scenario 1 - sin(2b) = 0.7, |l|=1

Generate some data

In [13]:
RooDataSet *data2 = bcp.generate(RooArgSet(dt, tagFlav), 10000);

Plot b0 and b0bar tagged data separately

In [14]:
RooPlot *frame4 = dt.frame(Title("B decay distribution with CPV(|l|=1,Im(l)=0.7) (B0/B0bar)"));

data2->plotOn(frame4, Cut("tagFlav==tagFlav::B0"));
bcp.plotOn(frame4, Slice(tagFlav, "B0"));

data2->plotOn(frame4, Cut("tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
bcp.plotOn(frame4, Slice(tagFlav, "B0bar"), LineColor(kCyan));
[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 4495 events out of 10000 total events
[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)
[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 5505 events out of 10000 total events
[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)

Plot scenario 2 - sin(2b) = 0.7, |l|=0.7

In [15]:
absLambda = 0.7;

Generate some data

In [16]:
RooDataSet *data3 = bcp.generate(RooArgSet(dt, tagFlav), 10000);

Plot b0 and b0bar tagged data separately (sin2b = 0.7 plus direct cpv |l|=0.5)

In [17]:
RooPlot *frame5 = dt.frame(Title("B decay distribution with CPV(|l|=0.7,Im(l)=0.7) (B0/B0bar)"));

data3->plotOn(frame5, Cut("tagFlav==tagFlav::B0"));
bcp.plotOn(frame5, Slice(tagFlav, "B0"));

data3->plotOn(frame5, Cut("tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
bcp.plotOn(frame5, Slice(tagFlav, "B0bar"), LineColor(kCyan));
[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 3617 events out of 10000 total events
[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)
[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 6383 events out of 10000 total events
[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)

Generic B decay with user coefficients

Construct pdf

Model parameters

In [18]:
RooRealVar DGbG("DGbG", "DGamma/GammaAvg", 0.5, -1, 1);
RooRealVar Adir("Adir", "-[1-abs(l)**2]/[1+abs(l)**2]", 0);
RooRealVar Amix("Amix", "2Im(l)/[1+abs(l)**2]", 0.7);
RooRealVar Adel("Adel", "2Re(l)/[1+abs(l)**2]", 0.7);

Derived input parameters for pdf

In [19]:
RooFormulaVar DG("DG", "Delta Gamma", "@1/@0", RooArgList(tau, DGbG));

Construct coefficient functions for sin,cos,sinh modulations of decay distribution

In [20]:
RooFormulaVar fsin("fsin", "fsin", "@0*@1*(1-2*@2)", RooArgList(Amix, tagFlav, w));
RooFormulaVar fcos("fcos", "fcos", "@0*@1*(1-2*@2)", RooArgList(Adir, tagFlav, w));
RooFormulaVar fsinh("fsinh", "fsinh", "@0", RooArgList(Adel));

Construct generic b decay pdf using above user coefficients

In [21]:
RooBDecay bcpg("bcpg", "bcpg", dt, tau, DG, RooConst(1), fsinh, fcos, fsin, dm, truthModel, RooBDecay::DoubleSided);

Plot - im(l)=0.7, re(l)=0.7 |l|=1, dg/g=0.5

Generate some data

In [22]:
RooDataSet *data4 = bcpg.generate(RooArgSet(dt, tagFlav), 10000);

Plot b0 and b0bar tagged data separately

In [23]:
RooPlot *frame6 = dt.frame(Title("B decay distribution with CPV(Im(l)=0.7,Re(l)=0.7,|l|=1,dG/G=0.5) (B0/B0bar)"));

data4->plotOn(frame6, Cut("tagFlav==tagFlav::B0"));
bcpg.plotOn(frame6, Slice(tagFlav, "B0"));

data4->plotOn(frame6, Cut("tagFlav==tagFlav::B0bar"), MarkerColor(kCyan));
bcpg.plotOn(frame6, Slice(tagFlav, "B0bar"), LineColor(kCyan));

TCanvas *c = new TCanvas("rf708_bphysics", "rf708_bphysics", 1200, 800);
c->Divide(3, 2);
c->cd(1);
gPad->SetLeftMargin(0.15);
frame1->GetYaxis()->SetTitleOffset(1.6);
frame1->Draw();
c->cd(2);
gPad->SetLeftMargin(0.15);
frame2->GetYaxis()->SetTitleOffset(1.6);
frame2->Draw();
c->cd(3);
gPad->SetLeftMargin(0.15);
frame3->GetYaxis()->SetTitleOffset(1.6);
frame3->Draw();
c->cd(4);
gPad->SetLeftMargin(0.15);
frame4->GetYaxis()->SetTitleOffset(1.6);
frame4->Draw();
c->cd(5);
gPad->SetLeftMargin(0.15);
frame5->GetYaxis()->SetTitleOffset(1.6);
frame5->Draw();
c->cd(6);
gPad->SetLeftMargin(0.15);
frame6->GetYaxis()->SetTitleOffset(1.6);
frame6->Draw();
[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 4991 events out of 10000 total events
[#1] INFO:Plotting -- RooAbsReal::plotOn(bcpg) plot on dt represents a slice in (tagFlav)
[#0] WARNING:Plotting -- Cannot apply a bin width correction and use Poisson errors. Not correcting for bin width.
[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 5009 events out of 10000 total events
[#1] INFO:Plotting -- RooAbsReal::plotOn(bcpg) plot on dt represents a slice in (tagFlav)
input_line_104:2:3: error: use of undeclared identifier 'frame1'
 (frame1->GetYaxis()->SetTitleOffset(1.6000000000000001))
  ^
Error in <HandleInterpreterException>: Error evaluating expression (frame1->GetYaxis()->SetTitleOffset(1.6000000000000001))
Execution of your code was aborted.

Draw all canvases

In [24]:
%jsroot on
gROOT->GetListOfCanvases()->Draw()