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
rs601_HLFactoryexample.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_roostats
3
## \notebook -js
4
## High Level Factory: creation of a simple model
5
##
6
## \macro_image
7
## \macro_output
8
## \macro_code
9
##
10
## \date July 2022
11
## \authors Artem Busorgin, Danilo Piparo (C++ version)
12
13
import
ROOT
14
15
# --- Build the datacard and dump to file---
16
card_name =
"HLFavtoryexample.rs"
17
with
open(card_name,
"w"
)
as
f:
18
f.write
(
"// The simplest card\n\n"
)
19
f.write
(
"gauss = Gaussian(mes[5.20,5.30],mean[5.28,5.2,5.3],width[0.0027,0.001,1]);\n"
)
20
f.write
(
"argus = ArgusBG(mes,5.291,argpar[-20,-100,-1]);\n"
)
21
f.write
(
"sum = SUM(nsig[200,0,10000]*gauss,nbkg[800,0,10000]*argus);\n\n"
)
22
23
hlf =
ROOT.RooStats.HLFactory
(
"HLFavtoryexample"
, card_name,
False
)
24
25
# --- Take elements out of the internal workspace ---
26
w =
hlf.GetWs
()
27
28
mes =
w.arg
(
"mes"
)
29
sumpdf = w[
"sum"
]
30
argus = w[
"argus"
]
31
32
# --- Generate a toyMC sample from composite PDF ---
33
data =
sumpdf.generate
(mes, 2000)
34
35
# --- Perform extended ML fit of composite PDF to toy data ---
36
sumpdf.fitTo
(data)
37
38
# --- Plot toy data and composite PDF overlaid ---
39
mesframe =
mes.frame
()
40
data.plotOn
(mesframe)
41
sumpdf.plotOn
(mesframe)
42
sumpdf.plotOn
(mesframe, Components=argus, LineStyle=
"--"
)
43
44
ROOT.gROOT.SetStyle
(
"Plain"
)
45
46
c =
ROOT.TCanvas
()
47
mesframe.Draw
()
48
49
c.SaveAs
(
"rs601_HLFactoryexample.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
roostats
rs601_HLFactoryexample.py
ROOT tags/6-34-04 - Reference Guide Generated on Fri Mar 21 2025 04:40:18 (GVA Time) using Doxygen 1.10.0