{
"cells": [
{
"cell_type": "markdown",
"id": "79d9f6e4",
"metadata": {},
"source": [
"# rf708_bphysics\n",
"Special pdf's: special decay pdf for B physics with mixing and/or CP violation\n",
"\n",
"\n",
"\n",
"\n",
"**Author:** Wouter Verkerke \n",
"This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:34 PM."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6ad86782",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:51.102489Z",
"iopub.status.busy": "2026-05-19T20:34:51.102364Z",
"iopub.status.idle": "2026-05-19T20:34:51.118223Z",
"shell.execute_reply": "2026-05-19T20:34:51.117719Z"
}
},
"outputs": [],
"source": [
"%%cpp -d\n",
"#include \"RooRealVar.h\"\n",
"#include \"RooDataSet.h\"\n",
"#include \"RooGaussian.h\"\n",
"#include \"RooConstVar.h\"\n",
"#include \"RooCategory.h\"\n",
"#include \"RooBMixDecay.h\"\n",
"#include \"RooBCPEffDecay.h\"\n",
"#include \"RooBDecay.h\"\n",
"#include \"RooFormulaVar.h\"\n",
"#include \"RooTruthModel.h\"\n",
"#include \"TCanvas.h\"\n",
"#include \"TAxis.h\"\n",
"#include \"RooPlot.h\"\n",
"using namespace RooFit;"
]
},
{
"cell_type": "markdown",
"id": "71caae09",
"metadata": {},
"source": [
"-------------------------------------\n",
"B-Decay with mixing\n",
"====================================="
]
},
{
"cell_type": "markdown",
"id": "8c560740",
"metadata": {},
"source": [
"Construct pdf\n",
"-------------------------"
]
},
{
"cell_type": "markdown",
"id": "acd27fd0",
"metadata": {},
"source": [
"Observable"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "9154aca6",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:51.119818Z",
"iopub.status.busy": "2026-05-19T20:34:51.119702Z",
"iopub.status.idle": "2026-05-19T20:34:51.442260Z",
"shell.execute_reply": "2026-05-19T20:34:51.441493Z"
}
},
"outputs": [],
"source": [
"RooRealVar dt(\"dt\", \"dt\", -10, 10);\n",
"dt.setBins(40);"
]
},
{
"cell_type": "markdown",
"id": "bb92a534",
"metadata": {},
"source": [
"Parameters"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "71709110",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:51.444147Z",
"iopub.status.busy": "2026-05-19T20:34:51.444013Z",
"iopub.status.idle": "2026-05-19T20:34:51.650235Z",
"shell.execute_reply": "2026-05-19T20:34:51.649459Z"
}
},
"outputs": [],
"source": [
"RooRealVar dm(\"dm\", \"delta m(B0)\", 0.472);\n",
"RooRealVar tau(\"tau\", \"tau (B0)\", 1.547);\n",
"RooRealVar w(\"w\", \"flavour mistag rate\", 0.1);\n",
"RooRealVar dw(\"dw\", \"delta mistag rate for B0/B0bar\", 0.1);\n",
"\n",
"RooCategory mixState(\"mixState\", \"B0/B0bar mixing state\");\n",
"mixState.defineType(\"mixed\", -1);\n",
"mixState.defineType(\"unmixed\", 1);\n",
"\n",
"RooCategory tagFlav(\"tagFlav\", \"Flavour of the tagged B0\");\n",
"tagFlav.defineType(\"B0\", 1);\n",
"tagFlav.defineType(\"B0bar\", -1);"
]
},
{
"cell_type": "markdown",
"id": "e32504ae",
"metadata": {},
"source": [
"Use delta function resolution model"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "29866b54",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:51.652002Z",
"iopub.status.busy": "2026-05-19T20:34:51.651882Z",
"iopub.status.idle": "2026-05-19T20:34:51.860893Z",
"shell.execute_reply": "2026-05-19T20:34:51.860407Z"
}
},
"outputs": [],
"source": [
"RooTruthModel truthModel(\"tm\", \"truth model\", dt);"
]
},
{
"cell_type": "markdown",
"id": "0947079b",
"metadata": {},
"source": [
"Construct Bdecay with mixing"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "dcd4eab7",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:51.863039Z",
"iopub.status.busy": "2026-05-19T20:34:51.862920Z",
"iopub.status.idle": "2026-05-19T20:34:52.071804Z",
"shell.execute_reply": "2026-05-19T20:34:52.071258Z"
}
},
"outputs": [],
"source": [
"RooBMixDecay bmix(\"bmix\", \"decay\", dt, mixState, tagFlav, tau, dm, w, dw, truthModel, RooBMixDecay::DoubleSided);"
]
},
{
"cell_type": "markdown",
"id": "c68bc146",
"metadata": {},
"source": [
"Plot pdf in various slices\n",
"---------------------------------------------------"
]
},
{
"cell_type": "markdown",
"id": "435c4dc8",
"metadata": {},
"source": [
"Generate some data"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c300db68",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:52.073506Z",
"iopub.status.busy": "2026-05-19T20:34:52.073381Z",
"iopub.status.idle": "2026-05-19T20:34:52.282614Z",
"shell.execute_reply": "2026-05-19T20:34:52.282147Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_65:2:2: warning: 'data' shadows a declaration with the same name in the 'std' namespace; use '::data' to reference this declaration\n",
" std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};\n",
" ^\n"
]
}
],
"source": [
"std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};"
]
},
{
"cell_type": "markdown",
"id": "5bab2ae9",
"metadata": {},
"source": [
"Plot B0 and B0bar tagged data separately\n",
"For all plots below B0 and B0 tagged data will look somewhat differently\n",
"if the flavor tagging mistag rate for B0 and B0 is different (i.e. dw!=0)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "0b62c672",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:52.284082Z",
"iopub.status.busy": "2026-05-19T20:34:52.283964Z",
"iopub.status.idle": "2026-05-19T20:34:52.494471Z",
"shell.execute_reply": "2026-05-19T20:34:52.494035Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_66:4:1: error: reference to 'data' is ambiguous\n",
"data->plotOn(frame1, Cut(\"tagFlav==tagFlav::B0\"));\n",
"^\n",
"input_line_65:2:30: note: candidate found by name lookup is 'data'\n",
" std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n",
"input_line_66:7:1: error: reference to 'data' is ambiguous\n",
"data->plotOn(frame1, Cut(\"tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"^\n",
"input_line_65:2:30: note: candidate found by name lookup is 'data'\n",
" std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n"
]
}
],
"source": [
"RooPlot *frame1 = dt.frame(Title(\"B decay distribution with mixing (B0/B0bar)\"));\n",
"\n",
"data->plotOn(frame1, Cut(\"tagFlav==tagFlav::B0\"));\n",
"bmix.plotOn(frame1, Slice(tagFlav, \"B0\"));\n",
"\n",
"data->plotOn(frame1, Cut(\"tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"bmix.plotOn(frame1, Slice(tagFlav, \"B0bar\"), LineColor(kCyan));"
]
},
{
"cell_type": "markdown",
"id": "e19fed54",
"metadata": {},
"source": [
"Plot mixed slice for B0 and B0bar tagged data separately"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "d01e1d22",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:52.495958Z",
"iopub.status.busy": "2026-05-19T20:34:52.495840Z",
"iopub.status.idle": "2026-05-19T20:34:52.706284Z",
"shell.execute_reply": "2026-05-19T20:34:52.705856Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_67:4:1: error: reference to 'data' is ambiguous\n",
"data->plotOn(frame2, Cut(\"mixState==mixState::mixed&&tagFlav==tagFlav::B0\"));\n",
"^\n",
"input_line_65:2:30: note: candidate found by name lookup is 'data'\n",
" std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n",
"input_line_67:7:1: error: reference to 'data' is ambiguous\n",
"data->plotOn(frame2, Cut(\"mixState==mixState::mixed&&tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"^\n",
"input_line_65:2:30: note: candidate found by name lookup is 'data'\n",
" std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n"
]
}
],
"source": [
"RooPlot *frame2 = dt.frame(Title(\"B decay distribution of mixed events (B0/B0bar)\"));\n",
"\n",
"data->plotOn(frame2, Cut(\"mixState==mixState::mixed&&tagFlav==tagFlav::B0\"));\n",
"bmix.plotOn(frame2, Slice({{&tagFlav, \"B0\"}, {&mixState, \"mixed\"}}));\n",
"\n",
"data->plotOn(frame2, Cut(\"mixState==mixState::mixed&&tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"bmix.plotOn(frame2, Slice({{&tagFlav, \"B0bar\"}, {&mixState, \"mixed\"}}), LineColor(kCyan));"
]
},
{
"cell_type": "markdown",
"id": "8d3e667b",
"metadata": {},
"source": [
"Plot unmixed slice for B0 and B0bar tagged data separately"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "3868f5db",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:52.707769Z",
"iopub.status.busy": "2026-05-19T20:34:52.707640Z",
"iopub.status.idle": "2026-05-19T20:34:52.918774Z",
"shell.execute_reply": "2026-05-19T20:34:52.918302Z"
}
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_68:4:1: error: reference to 'data' is ambiguous\n",
"data->plotOn(frame3, Cut(\"mixState==mixState::unmixed&&tagFlav==tagFlav::B0\"));\n",
"^\n",
"input_line_65:2:30: note: candidate found by name lookup is 'data'\n",
" std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n",
"In module 'std' imported from input_line_1:1:\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/initializer_list:45:11: error: 'initializer_list' (aka 'initializer_list > >') layout not recognized. Must be a non-polymorphic class type with no bases and two fields: a 'const E *' and either another 'const E *' or a 'std::size_t'\n",
" class initializer_list\n",
" ^\n",
"input_line_68:7:1: error: reference to 'data' is ambiguous\n",
"data->plotOn(frame3, Cut(\"mixState==mixState::unmixed&&tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"^\n",
"input_line_65:2:30: note: candidate found by name lookup is 'data'\n",
" std::unique_ptr data{bmix.generate({dt, mixState, tagFlav}, 10000)};\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:344:5: note: candidate found by name lookup is 'std::data'\n",
" data(initializer_list<_Tp> __il) noexcept\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:312:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:323:5: note: candidate found by name lookup is 'std::data'\n",
" data(const _Container& __cont) noexcept(noexcept(__cont.data()))\n",
" ^\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/bits/range_access.h:334:5: note: candidate found by name lookup is 'std::data'\n",
" data(_Tp (&__array)[_Nm]) noexcept\n",
" ^\n",
"In module 'std' imported from input_line_1:1:\n",
"/usr/lib/gcc/x86_64-redhat-linux/14/../../../../include/c++/14/initializer_list:45:11: error: 'initializer_list' (aka 'initializer_list > >') layout not recognized. Must be a non-polymorphic class type with no bases and two fields: a 'const E *' and either another 'const E *' or a 'std::size_t'\n",
" class initializer_list\n",
" ^\n"
]
}
],
"source": [
"RooPlot *frame3 = dt.frame(Title(\"B decay distribution of unmixed events (B0/B0bar)\"));\n",
"\n",
"data->plotOn(frame3, Cut(\"mixState==mixState::unmixed&&tagFlav==tagFlav::B0\"));\n",
"bmix.plotOn(frame3, Slice({{&tagFlav, \"B0\"}, {&mixState, \"unmixed\"}}));\n",
"\n",
"data->plotOn(frame3, Cut(\"mixState==mixState::unmixed&&tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"bmix.plotOn(frame3, Slice({{&tagFlav, \"B0bar\"}, {&mixState, \"unmixed\"}}), LineColor(kCyan));"
]
},
{
"cell_type": "markdown",
"id": "8f824d02",
"metadata": {},
"source": [
"-------------------------------------------------\n",
"B-Decay with CP violation\n",
"================================================="
]
},
{
"cell_type": "markdown",
"id": "5b0edb1f",
"metadata": {},
"source": [
"Construct pdf\n",
"-------------------------"
]
},
{
"cell_type": "markdown",
"id": "d2f180db",
"metadata": {},
"source": [
"Additional parameters needed for B decay with CPV"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "3bd14523",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:52.920288Z",
"iopub.status.busy": "2026-05-19T20:34:52.920170Z",
"iopub.status.idle": "2026-05-19T20:34:53.137028Z",
"shell.execute_reply": "2026-05-19T20:34:53.136458Z"
}
},
"outputs": [],
"source": [
"RooRealVar CPeigen(\"CPeigen\", \"CP eigen value\", -1);\n",
"RooRealVar absLambda(\"absLambda\", \"|lambda|\", 1, 0, 2);\n",
"RooRealVar argLambda(\"absLambda\", \"|lambda|\", 0.7, -1, 1);\n",
"RooRealVar effR(\"effR\", \"B0/B0bar reco efficiency ratio\", 1);"
]
},
{
"cell_type": "markdown",
"id": "b4fc485f",
"metadata": {},
"source": [
"Construct Bdecay with CP violation"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "b8ed3476",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:53.138860Z",
"iopub.status.busy": "2026-05-19T20:34:53.138741Z",
"iopub.status.idle": "2026-05-19T20:34:53.347882Z",
"shell.execute_reply": "2026-05-19T20:34:53.347297Z"
}
},
"outputs": [],
"source": [
"RooBCPEffDecay bcp(\"bcp\", \"bcp\", dt, tagFlav, tau, dm, w, CPeigen, absLambda, argLambda, effR, dw, truthModel,\n",
" RooBCPEffDecay::DoubleSided);"
]
},
{
"cell_type": "markdown",
"id": "688a1ed5",
"metadata": {},
"source": [
"Plot scenario 1 - sin(2b) = 0.7, |l|=1\n",
"---------------------------------------------------------------------------"
]
},
{
"cell_type": "markdown",
"id": "9654838e",
"metadata": {},
"source": [
"Generate some data"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "18b1d054",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:53.349658Z",
"iopub.status.busy": "2026-05-19T20:34:53.349518Z",
"iopub.status.idle": "2026-05-19T20:34:53.558413Z",
"shell.execute_reply": "2026-05-19T20:34:53.557896Z"
}
},
"outputs": [],
"source": [
"std::unique_ptr data2{bcp.generate({dt, tagFlav}, 10000)};"
]
},
{
"cell_type": "markdown",
"id": "c5fbc63e",
"metadata": {},
"source": [
"Plot B0 and B0bar tagged data separately"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "e5f9ba1a",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:53.560214Z",
"iopub.status.busy": "2026-05-19T20:34:53.560097Z",
"iopub.status.idle": "2026-05-19T20:34:53.769328Z",
"shell.execute_reply": "2026-05-19T20:34:53.768756Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 4495 events out of 10000 total events\n",
"[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)\n",
"[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 5505 events out of 10000 total events\n",
"[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)\n"
]
}
],
"source": [
"RooPlot *frame4 = dt.frame(Title(\"B decay distribution with CPV(|l|=1,Im(l)=0.7) (B0/B0bar)\"));\n",
"\n",
"data2->plotOn(frame4, Cut(\"tagFlav==tagFlav::B0\"));\n",
"bcp.plotOn(frame4, Slice(tagFlav, \"B0\"));\n",
"\n",
"data2->plotOn(frame4, Cut(\"tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"bcp.plotOn(frame4, Slice(tagFlav, \"B0bar\"), LineColor(kCyan));"
]
},
{
"cell_type": "markdown",
"id": "d16bd42b",
"metadata": {},
"source": [
"Plot scenario 2 - sin(2b) = 0.7, |l|=0.7\n",
"-------------------------------------------------------------------------------"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "71c1f026",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:53.771171Z",
"iopub.status.busy": "2026-05-19T20:34:53.771053Z",
"iopub.status.idle": "2026-05-19T20:34:53.979860Z",
"shell.execute_reply": "2026-05-19T20:34:53.979171Z"
}
},
"outputs": [],
"source": [
"absLambda = 0.7;"
]
},
{
"cell_type": "markdown",
"id": "c1039240",
"metadata": {},
"source": [
"Generate some data"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "dd2e6997",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:53.981916Z",
"iopub.status.busy": "2026-05-19T20:34:53.981799Z",
"iopub.status.idle": "2026-05-19T20:34:54.190595Z",
"shell.execute_reply": "2026-05-19T20:34:54.189991Z"
}
},
"outputs": [],
"source": [
"std::unique_ptr data3{bcp.generate({dt, tagFlav}, 10000)};"
]
},
{
"cell_type": "markdown",
"id": "ab2ff074",
"metadata": {},
"source": [
"Plot B0 and B0bar tagged data separately (sin2b = 0.7 plus direct CPV |l|=0.5)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "2f182a04",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:54.192647Z",
"iopub.status.busy": "2026-05-19T20:34:54.192516Z",
"iopub.status.idle": "2026-05-19T20:34:54.401672Z",
"shell.execute_reply": "2026-05-19T20:34:54.401105Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 3617 events out of 10000 total events\n",
"[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)\n",
"[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 6383 events out of 10000 total events\n",
"[#1] INFO:Plotting -- RooAbsReal::plotOn(bcp) plot on dt represents a slice in (tagFlav)\n"
]
}
],
"source": [
"RooPlot *frame5 = dt.frame(Title(\"B decay distribution with CPV(|l|=0.7,Im(l)=0.7) (B0/B0bar)\"));\n",
"\n",
"data3->plotOn(frame5, Cut(\"tagFlav==tagFlav::B0\"));\n",
"bcp.plotOn(frame5, Slice(tagFlav, \"B0\"));\n",
"\n",
"data3->plotOn(frame5, Cut(\"tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"bcp.plotOn(frame5, Slice(tagFlav, \"B0bar\"), LineColor(kCyan));"
]
},
{
"cell_type": "markdown",
"id": "99961e70",
"metadata": {},
"source": [
"---------------------------------------------------------------------------\n",
"Generic B decay with user coefficients\n",
"==========================================================================="
]
},
{
"cell_type": "markdown",
"id": "e67af61b",
"metadata": {},
"source": [
"Construct pdf\n",
"-------------------------"
]
},
{
"cell_type": "markdown",
"id": "7d3acc73",
"metadata": {},
"source": [
"Model parameters"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "95339e66",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:54.403426Z",
"iopub.status.busy": "2026-05-19T20:34:54.403313Z",
"iopub.status.idle": "2026-05-19T20:34:54.612029Z",
"shell.execute_reply": "2026-05-19T20:34:54.611438Z"
}
},
"outputs": [],
"source": [
"RooRealVar DGbG(\"DGbG\", \"DGamma/GammaAvg\", 0.5, -1, 1);\n",
"RooRealVar Adir(\"Adir\", \"-[1-abs(l)**2]/[1+abs(l)**2]\", 0);\n",
"RooRealVar Amix(\"Amix\", \"2Im(l)/[1+abs(l)**2]\", 0.7);\n",
"RooRealVar Adel(\"Adel\", \"2Re(l)/[1+abs(l)**2]\", 0.7);"
]
},
{
"cell_type": "markdown",
"id": "725081e5",
"metadata": {},
"source": [
"Derived input parameters for pdf"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "58cadac0",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:54.614034Z",
"iopub.status.busy": "2026-05-19T20:34:54.613921Z",
"iopub.status.idle": "2026-05-19T20:34:54.822667Z",
"shell.execute_reply": "2026-05-19T20:34:54.822053Z"
}
},
"outputs": [],
"source": [
"RooFormulaVar DG(\"DG\", \"Delta Gamma\", \"@1/@0\", RooArgList(tau, DGbG));"
]
},
{
"cell_type": "markdown",
"id": "20444024",
"metadata": {},
"source": [
"Construct coefficient functions for sin,cos,sinh modulations of decay distribution"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "83954752",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:54.824757Z",
"iopub.status.busy": "2026-05-19T20:34:54.824626Z",
"iopub.status.idle": "2026-05-19T20:34:55.035328Z",
"shell.execute_reply": "2026-05-19T20:34:55.034702Z"
}
},
"outputs": [],
"source": [
"RooFormulaVar fsin(\"fsin\", \"fsin\", \"@0*@1*(1-2*@2)\", RooArgList(Amix, tagFlav, w));\n",
"RooFormulaVar fcos(\"fcos\", \"fcos\", \"@0*@1*(1-2*@2)\", RooArgList(Adir, tagFlav, w));\n",
"RooFormulaVar fsinh(\"fsinh\", \"fsinh\", \"@0\", RooArgList(Adel));"
]
},
{
"cell_type": "markdown",
"id": "8f62661d",
"metadata": {},
"source": [
"Construct generic B decay pdf using above user coefficients"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "ee5b9907",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:55.037552Z",
"iopub.status.busy": "2026-05-19T20:34:55.037432Z",
"iopub.status.idle": "2026-05-19T20:34:55.246229Z",
"shell.execute_reply": "2026-05-19T20:34:55.245618Z"
}
},
"outputs": [],
"source": [
"RooBDecay bcpg(\"bcpg\", \"bcpg\", dt, tau, DG, RooConst(1), fsinh, fcos, fsin, dm, truthModel, RooBDecay::DoubleSided);"
]
},
{
"cell_type": "markdown",
"id": "f3bbc66a",
"metadata": {},
"source": [
"Plot - Im(l)=0.7, Re(l)=0.7 |l|=1, dG/G=0.5\n",
"-------------------------------------------------------------------------------------"
]
},
{
"cell_type": "markdown",
"id": "84ac0742",
"metadata": {},
"source": [
"Generate some data"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "1abb9fc0",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:55.248325Z",
"iopub.status.busy": "2026-05-19T20:34:55.248209Z",
"iopub.status.idle": "2026-05-19T20:34:55.456995Z",
"shell.execute_reply": "2026-05-19T20:34:55.456363Z"
}
},
"outputs": [],
"source": [
"std::unique_ptr data4{bcpg.generate({dt, tagFlav}, 10000)};"
]
},
{
"cell_type": "markdown",
"id": "8abc058a",
"metadata": {},
"source": [
"Plot B0 and B0bar tagged data separately"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "01b02d71",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:55.459065Z",
"iopub.status.busy": "2026-05-19T20:34:55.458949Z",
"iopub.status.idle": "2026-05-19T20:34:55.668208Z",
"shell.execute_reply": "2026-05-19T20:34:55.667919Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 4991 events out of 10000 total events\n",
"[#1] INFO:Plotting -- RooAbsReal::plotOn(bcpg) plot on dt represents a slice in (tagFlav)\n",
"[#1] INFO:Plotting -- RooTreeData::plotOn: plotting 5009 events out of 10000 total events\n",
"[#1] INFO:Plotting -- RooAbsReal::plotOn(bcpg) plot on dt represents a slice in (tagFlav)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"input_line_130:2:3: error: use of undeclared identifier 'frame1'\n",
" (frame1->GetYaxis()->SetTitleOffset(1.6000000000000001))\n",
" ^\n",
"Error in : Error evaluating expression (frame1->GetYaxis()->SetTitleOffset(1.6000000000000001))\n",
"Execution of your code was aborted.\n"
]
}
],
"source": [
"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)\"));\n",
"\n",
"data4->plotOn(frame6, Cut(\"tagFlav==tagFlav::B0\"));\n",
"bcpg.plotOn(frame6, Slice(tagFlav, \"B0\"));\n",
"\n",
"data4->plotOn(frame6, Cut(\"tagFlav==tagFlav::B0bar\"), MarkerColor(kCyan));\n",
"bcpg.plotOn(frame6, Slice(tagFlav, \"B0bar\"), LineColor(kCyan));\n",
"\n",
"TCanvas *c = new TCanvas(\"rf708_bphysics\", \"rf708_bphysics\", 1200, 800);\n",
"c->Divide(3, 2);\n",
"c->cd(1);\n",
"gPad->SetLeftMargin(0.15);\n",
"frame1->GetYaxis()->SetTitleOffset(1.6);\n",
"frame1->Draw();\n",
"c->cd(2);\n",
"gPad->SetLeftMargin(0.15);\n",
"frame2->GetYaxis()->SetTitleOffset(1.6);\n",
"frame2->Draw();\n",
"c->cd(3);\n",
"gPad->SetLeftMargin(0.15);\n",
"frame3->GetYaxis()->SetTitleOffset(1.6);\n",
"frame3->Draw();\n",
"c->cd(4);\n",
"gPad->SetLeftMargin(0.15);\n",
"frame4->GetYaxis()->SetTitleOffset(1.6);\n",
"frame4->Draw();\n",
"c->cd(5);\n",
"gPad->SetLeftMargin(0.15);\n",
"frame5->GetYaxis()->SetTitleOffset(1.6);\n",
"frame5->Draw();\n",
"c->cd(6);\n",
"gPad->SetLeftMargin(0.15);\n",
"frame6->GetYaxis()->SetTitleOffset(1.6);\n",
"frame6->Draw();"
]
},
{
"cell_type": "markdown",
"id": "4f07f925",
"metadata": {},
"source": [
"Draw all canvases "
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "d73ebdc5",
"metadata": {
"collapsed": false,
"execution": {
"iopub.execute_input": "2026-05-19T20:34:55.670121Z",
"iopub.status.busy": "2026-05-19T20:34:55.670010Z",
"iopub.status.idle": "2026-05-19T20:34:55.902883Z",
"shell.execute_reply": "2026-05-19T20:34:55.902367Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"
\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%jsroot on\n",
"gROOT->GetListOfCanvases()->Draw()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "ROOT C++",
"language": "c++",
"name": "root"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".C",
"mimetype": " text/x-c++src",
"name": "c++"
}
},
"nbformat": 4,
"nbformat_minor": 5
}