Rf 3 0 5_Condcorrprod¶

Multidimensional models: multi-dimensional pdfs with conditional pdfs in product

pdf = gauss(x,f(y),sx | y ) * gauss(y,ms,sx) with f(y) = a0 + a1*y

Author: Wouter Verkerke
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Monday, January 17, 2022 at 09:58 AM.

In :
%%cpp -d
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "RooConstVar.h"
#include "RooPolyVar.h"
#include "RooProdPdf.h"
#include "RooPlot.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "TH1.h"
In :
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace RooFit;

Create conditional pdf gx(x|y)¶

Create observables

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

Create function f(y) = a0 + a1*y

In :
RooRealVar a0("a0", "a0", -0.5, -5, 5);
RooRealVar a1("a1", "a1", -0.5, -1, 1);
RooPolyVar fy("fy", "fy", y, RooArgSet(a0, a1));

Create gaussx(x,f(y),sx)

In :
RooRealVar sigmax("sigma", "width of gaussian", 0.5);
RooGaussian gaussx("gaussx", "Gaussian in x with shifting mean in y", x, fy, sigmax);
[#0] WARNING:InputArguments -- The parameter 'sigma' with range [-1e+30, 1e+30] of the RooGaussian 'gaussx' exceeds the safe range of (0, inf). Advise to limit its range.

Create pdf gy(y)¶

Create gaussy(y,0,5)

In :
RooGaussian gaussy("gaussy", "Gaussian in y", y, RooConst(0), RooConst(3));

Create product gx(x|y)*gy(y)¶

Create gaussx(x,sx|y) * gaussy(y)

In :
RooProdPdf model("model", "gaussx(x|y)*gaussy(y)", gaussy, Conditional(gaussx, x));

Sample, fit and plot product pdf¶

Generate 1000 events in x and y from model

In :
RooDataSet *data = model.generate(RooArgSet(x, y), 10000);

Plot x distribution of data and projection of model on x = int(dy) model(x,y)

In :
RooPlot *xframe = x.frame();
data->plotOn(xframe);
model.plotOn(xframe);
input_line_59:3:1: error: reference to 'data' is ambiguous
data->plotOn(xframe);
^
input_line_58:2:14: note: candidate found by name lookup is '__cling_N526::data'
RooDataSet *data = model.generate(RooArgSet(x, y), 10000);
^
/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
^

Plot x distribution of data and projection of model on y = int(dx) model(x,y)

In :
RooPlot *yframe = y.frame();
data->plotOn(yframe);
model.plotOn(yframe);
input_line_60:3:1: error: reference to 'data' is ambiguous
data->plotOn(yframe);
^
input_line_58:2:14: note: candidate found by name lookup is '__cling_N526::data'
RooDataSet *data = model.generate(RooArgSet(x, y), 10000);
^
/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
^

Make two-dimensional plot in x vs y

In :
TH1 *hh_model = model.createHistogram("hh_model", x, Binning(50), YVar(y, Binning(50)));
hh_model->SetLineColor(kBlue);

Make canvas and draw rooplots

In :
TCanvas *c = new TCanvas("rf305_condcorrprod", "rf05_condcorrprod", 1200, 400);
c->Divide(3);
c->cd(1);
xframe->GetYaxis()->SetTitleOffset(1.6);
xframe->Draw();
c->cd(2);
yframe->GetYaxis()->SetTitleOffset(1.6);
yframe->Draw();
c->cd(3); 