Rf 3 1 3_Paramranges

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 Wednesday, January 19, 2022 at 10:19 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"
In [2]:
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace RooFit;

Create 3d pdf

Define observable (x,y,z)

In [3]:
RooRealVar x("x", "x", 0, 10);
RooRealVar y("y", "y", 0, 10);
RooRealVar z("z", "z", 0, 10);
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

Define 3 dimensional pdf

In [4]:
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 [5]:
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 [6]:
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 [7]:
RooAbsReal *intPdf = pxyz.createIntegral(RooArgSet(x, y, z), RooArgSet(x, y, z), "R");
[#1] INFO:NumericIntegration -- RooRealIntegral::init(pxyz_Int[z|R]_Norm[x,y,z]_Int[y|R]) using numeric integrator RooIntegrator1D to calculate Int(y)

Plot value of integral as function of pdf parameter z0

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

new TCanvas("rf313_paramranges", "rf313_paramranges", 600, 600);
gPad->SetLeftMargin(0.15);
frame->GetYaxis()->SetTitleOffset(1.6);
frame->Draw();

return;
[#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 [9]:
%jsroot on
gROOT->GetListOfCanvases()->Draw()