Rf 3 1 1_Rangeplot¶

Multidimensional models: projecting pdf and data ranges in continuous observables

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 :
%%cpp -d
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooProdPdf.h"
#include "RooPolynomial.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
In :
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace RooFit;

Create 3d pdf and data¶

Create observables

In :
RooRealVar x("x", "x", -5, 5);
RooRealVar y("y", "y", -5, 5);
RooRealVar z("z", "z", -5, 5);
RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University

Create signal pdf gauss(x)gauss(y)gauss(z)

In :
RooGaussian gx("gx", "gx", x, RooConst(0), RooConst(1));
RooGaussian gy("gy", "gy", y, RooConst(0), RooConst(1));
RooGaussian gz("gz", "gz", z, RooConst(0), RooConst(1));
RooProdPdf sig("sig", "sig", RooArgSet(gx, gy, gz));

Create background pdf poly(x)poly(y)poly(z)

In :
RooPolynomial px("px", "px", x, RooArgSet(-0.1, 0.004));
RooPolynomial py("py", "py", y, RooArgSet(0.1, -0.004));
RooPolynomial pz("pz", "pz", z);
RooProdPdf bkg("bkg", "bkg", RooArgSet(px, py, pz));

Create composite pdf sig+bkg

In :
RooRealVar fsig("fsig", "signal fraction", 0.1, 0., 1.);
RooAddPdf model("model", "model", RooArgList(sig, bkg), fsig);

RooDataSet *data = model.generate(RooArgSet(x, y, z), 20000);

Project pdf and data on x¶

Make plain projection of data and pdf on x observable

In :
RooPlot *frame = x.frame(Title("Projection of 3D data and pdf on X"), Bins(40));
data->plotOn(frame);
model.plotOn(frame);
input_line_57:3:1: error: reference to 'data' is ambiguous
data->plotOn(frame);
^
input_line_56:5:13: note: candidate found by name lookup is '__cling_N524::data'
RooDataSet *data = model.generate(RooArgSet(x, y, z), 20000);
^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
data(initializer_list<_Tp> __il) noexcept
^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
data(_Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
data(const _Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
data(_Tp (&__array)[_Nm]) noexcept
^

Project pdf and data on x in signal range¶

Define signal region in y and z observables

In :
y.setRange("sigRegion", -1, 1);
z.setRange("sigRegion", -1, 1);
[#1] INFO:Eval -- RooRealVar::setRange(y) new range named 'sigRegion' created with bounds [-1,1]
[#1] INFO:Eval -- RooRealVar::setRange(z) new range named 'sigRegion' created with bounds [-1,1]

Make plot frame

In :
RooPlot *frame2 = x.frame(Title("Same projection on X in signal range of (Y,Z)"), Bins(40));

Plot subset of data in which all observables are inside "sigregion" For observables that do not have an explicit "sigRegion" range defined (e.g. observable) an implicit definition is used that is identical to the full range (i.e. [-5,5] for x)

In :
data->plotOn(frame2, CutRange("sigRegion"));
input_line_60:2:2: error: reference to 'data' is ambiguous
data->plotOn(frame2, CutRange("sigRegion"));
^
input_line_56:5:13: note: candidate found by name lookup is '__cling_N524::data'
RooDataSet *data = model.generate(RooArgSet(x, y, z), 20000);
^
/usr/include/c++/9/bits/range_access.h:318:5: note: candidate found by name lookup is 'std::data'
data(initializer_list<_Tp> __il) noexcept
^
/usr/include/c++/9/bits/range_access.h:289:5: note: candidate found by name lookup is 'std::data'
data(_Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/9/bits/range_access.h:299:5: note: candidate found by name lookup is 'std::data'
data(const _Container& __cont) noexcept(noexcept(__cont.data()))
^
/usr/include/c++/9/bits/range_access.h:309:5: note: candidate found by name lookup is 'std::data'
data(_Tp (&__array)[_Nm]) noexcept
^

Project model on x, integrating projected observables (y,z) only in "sigregion"

In :
model.plotOn(frame2, ProjectionRange("sigRegion"));

TCanvas *c = new TCanvas("rf311_rangeplot", "rf310_rangeplot", 800, 400);
c->Divide(2);
c->cd(1);
frame->GetYaxis()->SetTitleOffset(1.4);
frame->Draw();
c->cd(2);