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

Author: Clemens Lange, Wouter Verkerke (C++ version)
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Wednesday, November 30, 2022 at 11:22 AM.

In [1]:
import ROOT
Welcome to JupyROOT 6.27/01

Create 3D pdf

Define observable (x,y,z)

In [2]:
x = ROOT.RooRealVar("x", "x", 0, 10)
y = ROOT.RooRealVar("y", "y", 0, 10)
z = ROOT.RooRealVar("z", "z", 0, 10)

Define 3 dimensional pdf

In [3]:
z0 = ROOT.RooRealVar("z0", "z0", -0.1, 1)
px = ROOT.RooPolynomial("px", "px", x, [0.0])
py = ROOT.RooPolynomial("py", "py", y, [0.0])
pz = ROOT.RooPolynomial("pz", "pz", z, [z0])
pxyz = ROOT.RooProdPdf("pxyz", "pxyz", [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 parameterized in "R" in y [ 0.1x, 0.9x ]

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

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

In [5]:
zlo = ROOT.RooFormulaVar("zlo", "0.0*y", [y])
zhi = ROOT.RooFormulaVar("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, in "R" region

In [6]:
intPdf = pxyz.createIntegral({x, y, z}, {x, y, z}, "R")

Plot value of integral as function of pdf parameter z0

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

c = ROOT.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)
Info in <TCanvas::Print>: png file rf313_paramranges.png has been created

Draw all canvases

In [8]:
from ROOT import gROOT