ROOT
Version v6.34
master
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
rf208_convolution.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_roofit
3
## \notebook
4
## 'ADDITION AND CONVOLUTION' RooFit tutorial macro #208
5
## One-dimensional numeric convolution
6
## (require ROOT to be compiled with --enable-fftw3)
7
##
8
## pdf = landau(t) (x) gauss(t)
9
##
10
## \macro_image
11
## \macro_code
12
## \macro_output
13
##
14
## \date February 2018
15
## \authors Clemens Lange, Wouter Verkerke (C version)
16
17
import
ROOT
18
19
# Set up component pdfs
20
# ---------------------------------------
21
22
# Construct observable
23
t =
ROOT.RooRealVar
(
"t"
,
"t"
, -10, 30)
24
25
# Construct landau(t,ml,sl)
26
ml =
ROOT.RooRealVar
(
"ml"
,
"mean landau"
, 5.0, -20, 20)
27
sl =
ROOT.RooRealVar
(
"sl"
,
"sigma landau"
, 1, 0.1, 10)
28
landau =
ROOT.RooLandau
(
"lx"
,
"lx"
, t, ml, sl)
29
30
# Construct gauss(t,mg,sg)
31
mg =
ROOT.RooRealVar
(
"mg"
,
"mg"
, 0)
32
sg =
ROOT.RooRealVar
(
"sg"
,
"sg"
, 2, 0.1, 10)
33
gauss =
ROOT.RooGaussian
(
"gauss"
,
"gauss"
, t, mg, sg)
34
35
# Construct convolution pdf
36
# ---------------------------------------
37
38
# Set #bins to be used for FFT sampling to 10000
39
t.setBins
(10000,
"cache"
)
40
41
# Construct landau (x) gauss
42
lxg =
ROOT.RooFFTConvPdf
(
"lxg"
,
"landau (X) gauss"
, t, landau, gauss)
43
44
# Sample, fit and plot convoluted pdf
45
# ----------------------------------------------------------------------
46
47
# Sample 1000 events in x from gxlx
48
data =
lxg.generate
({t}, 10000)
49
50
# Fit gxlx to data
51
lxg.fitTo
(data, PrintLevel=-1)
52
53
# Plot data, pdf, landau (X) gauss pdf
54
frame =
t.frame
(Title=
"landau (x) gauss convolution"
)
55
data.plotOn
(frame)
56
lxg.plotOn
(frame)
57
landau.plotOn
(frame, LineStyle=
"--"
)
58
59
# Draw frame on canvas
60
c =
ROOT.TCanvas
(
"rf208_convolution"
,
"rf208_convolution"
, 600, 600)
61
ROOT.gPad.SetLeftMargin
(0.15)
62
frame.GetYaxis
().SetTitleOffset(1.4)
63
frame.Draw
()
64
65
c.SaveAs
(
"rf208_convolution.png"
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
tutorials
roofit
rf208_convolution.py
ROOT tags/6-34-04 - Reference Guide Generated on Fri Mar 21 2025 04:40:18 (GVA Time) using Doxygen 1.10.0