Rf 2 0 8_Convolution¶

'ADDITION AND CONVOLUTION' RooFit tutorial macro #208 One-dimensional numeric convolution (require ROOT to be compiled with --enable-fftw3)

pdf = landau(t) (x) gauss(t)

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

In [ ]:
import ROOT

Set up component pdfs¶

Construct observable

In [ ]:
t = ROOT.RooRealVar("t", "t", -10, 30)

Construct landau(t,ml,sl)

In [ ]:
ml = ROOT.RooRealVar("ml", "mean landau", 5.0, -20, 20)
sl = ROOT.RooRealVar("sl", "sigma landau", 1, 0.1, 10)
landau = ROOT.RooLandau("lx", "lx", t, ml, sl)

Construct gauss(t,mg,sg)

In [ ]:
mg = ROOT.RooRealVar("mg", "mg", 0)
sg = ROOT.RooRealVar("sg", "sg", 2, 0.1, 10)
gauss = ROOT.RooGaussian("gauss", "gauss", t, mg, sg)

Construct convolution pdf¶

Set #bins to be used for FFT sampling to 10000

In [ ]:
t.setBins(10000, "cache")

Construct landau (x) gauss

In [ ]:
lxg = ROOT.RooFFTConvPdf("lxg", "landau (X) gauss", t, landau, gauss)

Sample, fit and plot convoluted pdf¶

Sample 1000 events in x from gxlx

In [ ]:
data = lxg.generate({t}, 10000)

Fit gxlx to data

In [ ]:
lxg.fitTo(data)

Plot data, pdf, landau (X) gauss pdf

In [ ]:
frame = t.frame(Title="landau (x) gauss convolution")
data.plotOn(frame)
lxg.plotOn(frame)
landau.plotOn(frame, LineStyle="--")

Draw frame on canvas

In [ ]:
c = ROOT.TCanvas("rf208_convolution", "rf208_convolution", 600, 600)