{ "cells": [ { "cell_type": "markdown", "id": "787f4570", "metadata": {}, "source": [ "# rf209_anaconv\n", "Addition and convolution: decay function pdfs with optional B physics effects (mixing and CP violation)\n", "\n", "that can be analytically convolved with e.g. Gaussian resolution functions\n", "\n", "```\n", " pdf1 = decay(t,tau) (x) delta(t)\n", " pdf2 = decay(t,tau) (x) gauss(t,m,s)\n", " pdf3 = decay(t,tau) (x) (f*gauss1(t,m1,s1) + (1-f)*gauss2(t,m1,s1))\n", "```\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:30 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "d7f6d869", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:10.009450Z", "iopub.status.busy": "2026-05-19T20:30:10.009329Z", "iopub.status.idle": "2026-05-19T20:30:10.022891Z", "shell.execute_reply": "2026-05-19T20:30:10.022306Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "#include \"RooRealVar.h\"\n", "#include \"RooDataSet.h\"\n", "#include \"RooGaussModel.h\"\n", "#include \"RooAddModel.h\"\n", "#include \"RooTruthModel.h\"\n", "#include \"RooDecay.h\"\n", "#include \"RooPlot.h\"\n", "#include \"TCanvas.h\"\n", "#include \"TAxis.h\"\n", "#include \"TH1.h\"\n", "using namespace RooFit;" ] }, { "cell_type": "markdown", "id": "0423b4cf", "metadata": {}, "source": [ "B-physics pdf with truth resolution\n", "---------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "c1008813", "metadata": {}, "source": [ "Variables of decay pdf" ] }, { "cell_type": "code", "execution_count": 2, "id": "9e402095", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:10.024230Z", "iopub.status.busy": "2026-05-19T20:30:10.024117Z", "iopub.status.idle": "2026-05-19T20:30:10.342639Z", "shell.execute_reply": "2026-05-19T20:30:10.341912Z" } }, "outputs": [], "source": [ "RooRealVar dt(\"dt\", \"dt\", -10, 10);\n", "RooRealVar tau(\"tau\", \"tau\", 1.548);" ] }, { "cell_type": "markdown", "id": "83ad3c4b", "metadata": {}, "source": [ "Build a truth resolution model (delta function)" ] }, { "cell_type": "code", "execution_count": 3, "id": "5a365678", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:10.345427Z", "iopub.status.busy": "2026-05-19T20:30:10.345298Z", "iopub.status.idle": "2026-05-19T20:30:10.553334Z", "shell.execute_reply": "2026-05-19T20:30:10.552764Z" } }, "outputs": [], "source": [ "RooTruthModel tm1(\"tm\", \"truth model\", dt);" ] }, { "cell_type": "markdown", "id": "b6edc086", "metadata": {}, "source": [ "Construct decay(t) (x) delta(t)" ] }, { "cell_type": "code", "execution_count": 4, "id": "ce3b1cbf", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:10.555411Z", "iopub.status.busy": "2026-05-19T20:30:10.555298Z", "iopub.status.idle": "2026-05-19T20:30:10.762898Z", "shell.execute_reply": "2026-05-19T20:30:10.762313Z" } }, "outputs": [], "source": [ "RooDecay decay_tm(\"decay_tm\", \"decay\", dt, tau, tm1, RooDecay::DoubleSided);" ] }, { "cell_type": "markdown", "id": "f8179817", "metadata": {}, "source": [ "Plot pdf (dashed)" ] }, { "cell_type": "code", "execution_count": 5, "id": "bcc6ea0c", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:10.765055Z", "iopub.status.busy": "2026-05-19T20:30:10.764922Z", "iopub.status.idle": "2026-05-19T20:30:10.972285Z", "shell.execute_reply": "2026-05-19T20:30:10.971728Z" } }, "outputs": [], "source": [ "RooPlot *frame = dt.frame(Title(\"Bdecay (x) resolution\"));\n", "decay_tm.plotOn(frame, LineStyle(kDashed));" ] }, { "cell_type": "markdown", "id": "47fa35dd", "metadata": {}, "source": [ "B-physics pdf with Gaussian resolution\n", "----------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "1e461772", "metadata": {}, "source": [ "Build a gaussian resolution model" ] }, { "cell_type": "code", "execution_count": 6, "id": "7902ed71", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:10.974417Z", "iopub.status.busy": "2026-05-19T20:30:10.974299Z", "iopub.status.idle": "2026-05-19T20:30:11.181623Z", "shell.execute_reply": "2026-05-19T20:30:11.181191Z" } }, "outputs": [], "source": [ "RooRealVar bias1(\"bias1\", \"bias1\", 0);\n", "RooRealVar sigma1(\"sigma1\", \"sigma1\", 1);\n", "RooGaussModel gm1(\"gm1\", \"gauss model 1\", dt, bias1, sigma1);" ] }, { "cell_type": "markdown", "id": "1c34530f", "metadata": {}, "source": [ "Construct decay(t) (x) gauss1(t)" ] }, { "cell_type": "code", "execution_count": 7, "id": "2a4f4e77", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:11.183870Z", "iopub.status.busy": "2026-05-19T20:30:11.183747Z", "iopub.status.idle": "2026-05-19T20:30:11.391561Z", "shell.execute_reply": "2026-05-19T20:30:11.390760Z" } }, "outputs": [], "source": [ "RooDecay decay_gm1(\"decay_gm1\", \"decay\", dt, tau, gm1, RooDecay::DoubleSided);" ] }, { "cell_type": "markdown", "id": "7f6a5e99", "metadata": {}, "source": [ "Plot pdf" ] }, { "cell_type": "code", "execution_count": 8, "id": "8c70965c", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:11.393152Z", "iopub.status.busy": "2026-05-19T20:30:11.393017Z", "iopub.status.idle": "2026-05-19T20:30:11.600719Z", "shell.execute_reply": "2026-05-19T20:30:11.600093Z" } }, "outputs": [], "source": [ "decay_gm1.plotOn(frame);" ] }, { "cell_type": "markdown", "id": "2ba7716f", "metadata": {}, "source": [ "B-physics pdf with double Gaussian resolution\n", "------------------------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "c3322323", "metadata": {}, "source": [ "Build another gaussian resolution model" ] }, { "cell_type": "code", "execution_count": 9, "id": "4db7a90f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:11.602753Z", "iopub.status.busy": "2026-05-19T20:30:11.602630Z", "iopub.status.idle": "2026-05-19T20:30:11.810254Z", "shell.execute_reply": "2026-05-19T20:30:11.809622Z" } }, "outputs": [], "source": [ "RooRealVar bias2(\"bias2\", \"bias2\", 0);\n", "RooRealVar sigma2(\"sigma2\", \"sigma2\", 5);\n", "RooGaussModel gm2(\"gm2\", \"gauss model 2\", dt, bias2, sigma2);" ] }, { "cell_type": "markdown", "id": "1da0f969", "metadata": {}, "source": [ "Build a composite resolution model f*gm1+(1-f)*gm2" ] }, { "cell_type": "code", "execution_count": 10, "id": "2712a56e", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:11.812152Z", "iopub.status.busy": "2026-05-19T20:30:11.812034Z", "iopub.status.idle": "2026-05-19T20:30:12.019216Z", "shell.execute_reply": "2026-05-19T20:30:12.018857Z" } }, "outputs": [], "source": [ "RooRealVar gm1frac(\"gm1frac\", \"fraction of gm1\", 0.5);\n", "RooAddModel gmsum(\"gmsum\", \"sum of gm1 and gm2\", RooArgList(gm1, gm2), gm1frac);" ] }, { "cell_type": "markdown", "id": "b6a144ae", "metadata": {}, "source": [ "Construct decay(t) (x) (f*gm1 + (1-f)*gm2)" ] }, { "cell_type": "code", "execution_count": 11, "id": "342f7603", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:12.022997Z", "iopub.status.busy": "2026-05-19T20:30:12.022878Z", "iopub.status.idle": "2026-05-19T20:30:12.230810Z", "shell.execute_reply": "2026-05-19T20:30:12.229977Z" } }, "outputs": [], "source": [ "RooDecay decay_gmsum(\"decay_gmsum\", \"decay\", dt, tau, gmsum, RooDecay::DoubleSided);" ] }, { "cell_type": "markdown", "id": "693f7928", "metadata": {}, "source": [ "Plot pdf (red)" ] }, { "cell_type": "code", "execution_count": 12, "id": "891c19a5", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:12.232433Z", "iopub.status.busy": "2026-05-19T20:30:12.232315Z", "iopub.status.idle": "2026-05-19T20:30:12.439828Z", "shell.execute_reply": "2026-05-19T20:30:12.439268Z" } }, "outputs": [], "source": [ "decay_gmsum.plotOn(frame, LineColor(kRed));" ] }, { "cell_type": "markdown", "id": "1288ff51", "metadata": {}, "source": [ "Draw all frames on canvas" ] }, { "cell_type": "code", "execution_count": 13, "id": "40feed8a", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:12.441931Z", "iopub.status.busy": "2026-05-19T20:30:12.441812Z", "iopub.status.idle": "2026-05-19T20:30:12.649287Z", "shell.execute_reply": "2026-05-19T20:30:12.648743Z" } }, "outputs": [], "source": [ "new TCanvas(\"rf209_anaconv\", \"rf209_anaconv\", 600, 600);\n", "gPad->SetLeftMargin(0.15);\n", "frame->GetYaxis()->SetTitleOffset(1.6);\n", "frame->Draw();" ] }, { "cell_type": "markdown", "id": "4a678b35", "metadata": {}, "source": [ "Draw all canvases " ] }, { "cell_type": "code", "execution_count": 14, "id": "39e1fde9", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:30:12.651558Z", "iopub.status.busy": "2026-05-19T20:30:12.651436Z", "iopub.status.idle": "2026-05-19T20:30:12.879698Z", "shell.execute_reply": "2026-05-19T20:30:12.879161Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "