Multidimensional models: working with parametrized ranges to define non-rectangular regions for fitting and integration

Author: Wouter Verkerke
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]:
%%cpp -d
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooPolynomial.h"
#include "RooProdPdf.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit;

Create 3D pdf

Define observable (x,y,z)

In [2]:
RooRealVar x("x", "x", 0, 10);
RooRealVar y("y", "y", 0, 10);
RooRealVar z("z", "z", 0, 10);

Define 3 dimensional pdf

In [3]:
RooRealVar z0("z0", "z0", -0.1, 1);
RooPolynomial px("px", "px", x, RooConst(0));
RooPolynomial py("py", "py", y, RooConst(0));
RooPolynomial pz("pz", "pz", z, z0);
RooProdPdf pxyz("pxyz", "pxyz", RooArgSet(px, py, pz));

Defined non-rectangular region R in (x,y,z)

R = Z[0 - 0.1Y^2] Y[0.1X - 0.9X] * X[0 - 10]

Construct range parametrized in "R" in y [ 0.1x, 0.9x ]

In [4]:
RooFormulaVar ylo("ylo", "0.1*x", x);
RooFormulaVar yhi("yhi", "0.9*x", x);
y.setRange("R", ylo, yhi);

Construct parametrized ranged "R" in z [ 0, 0.1*y^2 ]

In [5]:
RooFormulaVar zlo("zlo", "0.0*y", y);
RooFormulaVar zhi("zhi", "0.1*y*y", y);
z.setRange("R", zlo, zhi);

Calculate integral of normalized pdf in R

Create integral over normalized pdf model over x,y,z in "R" region

In [6]:
RooAbsReal *intPdf = pxyz.createIntegral(RooArgSet(x, y, z), RooArgSet(x, y, z), "R");

Plot value of integral as function of pdf parameter z0

In [7]:
RooPlot *frame = z0.frame(Title("Integral of pxyz over x,y,z in region R"));

new TCanvas("rf313_paramranges", "rf313_paramranges", 600, 600);

[#1] INFO:NumericIntegration -- RooRealIntegral::init(pxyz_Int[z|R]_Norm[x,y,z]_Int[y|R]_Int[x|R]) using numeric integrator RooIntegrator1D to calculate Int(x)
[#1] INFO:NumericIntegration -- RooRealIntegral::init(pxyz_Int[z|R]_Norm[x,y,z]_Int[y|R]) using numeric integrator RooIntegrator1D to calculate Int(y)

Draw all canvases

In [8]:
%jsroot on