Rf 3 1 0_Sliceplot

Multidimensional models: projecting pdf and data slices in discrete observables

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:18 AM.

In [1]:
%%cpp -d
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussModel.h"
#include "RooDecay.h"
#include "RooBMixDecay.h"
#include "RooCategory.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;

Create b decay pdf with mixing

Decay time observables

In [3]:
RooRealVar dt("dt", "dt", -20, 20);
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

Discrete observables mixstate (b0tag==b0reco?) and tagflav (b0tag==b0(bar)?)

In [4]:
RooCategory mixState("mixState", "B0/B0bar mixing state");
RooCategory tagFlav("tagFlav", "Flavour of the tagged B0");

Define state labels of discrete observables

In [5]:
mixState.defineType("mixed", -1);
mixState.defineType("unmixed", 1);
tagFlav.defineType("B0", 1);
tagFlav.defineType("B0bar", -1);

Model parameters

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

Build a gaussian resolution model

In [7]:
RooRealVar bias1("bias1", "bias1", 0);
RooRealVar sigma1("sigma1", "sigma1", 0.01);
RooGaussModel gm1("gm1", "gauss model 1", dt, bias1, sigma1);

Construct a decay pdf, smeared with single gaussian resolution model

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

Generate bmixing data with above set of event errors

In [9]:
RooDataSet *data = bmix_gm1.generate(RooArgSet(dt, tagFlav, mixState), 20000);

Plot full decay distribution

Create frame, plot data and pdf projection (integrated over tagflav and mixstate)

In [10]:
RooPlot *frame = dt.frame(Title("Inclusive decay distribution"));
data->plotOn(frame);
bmix_gm1.plotOn(frame);
input_line_66:3:1: error: reference to 'data' is ambiguous
data->plotOn(frame);
^
input_line_65:2:14: note: candidate found by name lookup is '__cling_N527::data'
 RooDataSet *data = bmix_gm1.generate(RooArgSet(dt, tagFlav, mixState), 20000);
             ^
/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 decay distr. for mixed and unmixed slice of mixstate

Create frame, plot data (mixed only)

In [11]:
RooPlot *frame2 = dt.frame(Title("Decay distribution of mixed events"));
data->plotOn(frame2, Cut("mixState==mixState::mixed"));
input_line_67:3:1: error: reference to 'data' is ambiguous
data->plotOn(frame2, Cut("mixState==mixState::mixed"));
^
input_line_65:2:14: note: candidate found by name lookup is '__cling_N527::data'
 RooDataSet *data = bmix_gm1.generate(RooArgSet(dt, tagFlav, mixState), 20000);
             ^
/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
    ^

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

In [12]:
bmix_gm1.plotOn(frame2, Slice(mixState, "mixed"));
input_line_68:2:26: error: cannot initialize an array element of type 'void *' with an rvalue of type 'RooCmdArg (*)(RooCategory &, const char *)'
 bmix_gm1.plotOn(frame2, Slice(mixState, "mixed"));
                         ^~~~~

Create frame, plot data (unmixed only)

In [13]:
RooPlot *frame3 = dt.frame(Title("Decay distribution of unmixed events"));
data->plotOn(frame3, Cut("mixState==mixState::unmixed"));
input_line_69:3:1: error: reference to 'data' is ambiguous
data->plotOn(frame3, Cut("mixState==mixState::unmixed"));
^
input_line_65:2:14: note: candidate found by name lookup is '__cling_N527::data'
 RooDataSet *data = bmix_gm1.generate(RooArgSet(dt, tagFlav, mixState), 20000);
             ^
/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
    ^

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

In [14]:
bmix_gm1.plotOn(frame3, Slice(mixState, "unmixed"));

TCanvas *c = new TCanvas("rf310_sliceplot", "rf310_sliceplot", 1200, 400);
c->Divide(3);
c->cd(1);
gPad->SetLeftMargin(0.15);
frame->GetYaxis()->SetTitleOffset(1.4);
gPad->SetLogy();
frame->Draw();
c->cd(2);
gPad->SetLeftMargin(0.15);
frame2->GetYaxis()->SetTitleOffset(1.4);
gPad->SetLogy();
frame2->Draw();
c->cd(3);
gPad->SetLeftMargin(0.15);
frame3->GetYaxis()->SetTitleOffset(1.4);
gPad->SetLogy();
frame3->Draw();
input_line_70:2:26: error: cannot initialize an array element of type 'void *' with an rvalue of type 'RooCmdArg (*)(RooCategory &, const char *)'
 bmix_gm1.plotOn(frame3, Slice(mixState, "unmixed"));
                         ^~~~~

Draw all canvases

In [15]:
gROOT->GetListOfCanvases()->Draw()