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 Tuesday, March 19, 2024 at 07:15 PM.
%%cpp -d
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooPolynomial.h"
#include "RooProdPdf.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit;
Define observable (x,y,z)
RooRealVar x("x", "x", 0, 10);
RooRealVar y("y", "y", 0, 10);
RooRealVar z("z", "z", 0, 10);
Define 3 dimensional pdf
RooRealVar z0("z0", "z0", -0.1, 1);
RooPolynomial px("px", "px", x, RooConst(0.0));
RooPolynomial py("py", "py", y, RooConst(0.0));
RooPolynomial pz("pz", "pz", z, z0);
RooProdPdf pxyz("pxyz", "pxyz", RooArgSet(px, py, pz));
R = Z[0 - 0.1*Y^2] * Y[0.1X - 0.9X] * X[0 - 10]
Construct range parametrized in "R" in y [ 0.1x, 0.9x ]
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 ]
RooFormulaVar zlo("zlo", "0.0*y", y);
RooFormulaVar zhi("zhi", "0.1*y*y", y);
z.setRange("R", zlo, zhi);
Create integral over normalized pdf model over x,y,z in "R" region
std::unique_ptr<RooAbsReal> intPdf{pxyz.createIntegral(RooArgSet(x, y, z), RooArgSet(x, y, z), "R")};
Plot value of integral as function of pdf parameter z0
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
%jsroot on
gROOT->GetListOfCanvases()->Draw()