ROOT
Version master
master
v6.34
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
v6.04
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
rf902_numgenconfig.py
2
## \ingroup tutorial_roofit_main
3
## \notebook -nodraw
4
## Numeric algorithm tuning: configuration and customization of how MC sampling algorithms
5
## on specific pdfs are executed
6
##
7
## \macro_code
8
## \macro_output
9
##
10
## \date February 2018
11
## \authors Clemens Lange, Wouter Verkerke (C++ version)
12
13
import
ROOT
14
15
16
# Adjust global MC sampling strategy
17
# ------------------------------------------------------------------
18
19
# Example pdf for use below
20
x =
ROOT.RooRealVar
(
"x"
,
"x"
, 0, 10)
21
model =
ROOT.RooChebychev
(
"model"
,
"model"
, x, [0.0, 0.5, -0.1])
22
23
# Change global strategy for 1D sampling problems without conditional observable
24
# (1st kFALSE) and without discrete observable (2nd kFALSE) from ROOT.RooFoamGenerator,
25
# ( an interface to the ROOT.TFoam MC generator with adaptive subdivisioning strategy ) to ROOT.RooAcceptReject,
26
# a plain accept/reject sampling algorithm [ ROOT.RooFit default before
27
# ROOT 5.23/04 ]
28
ROOT.RooAbsPdf.defaultGeneratorConfig
().method1D(
False
,
False
).setLabel(
"RooAcceptReject"
)
29
30
# Generate 10Kevt using ROOT.RooAcceptReject
31
data_ar =
model.generate
({x}, 10000, Verbose=
True
)
32
data_ar.Print
()
33
34
# Adjusting default config for a specific pdf
35
# -------------------------------------------------------------------------------------
36
37
# Another possibility: associate custom MC sampling configuration as default for object 'model'
38
# The kTRUE argument will install a clone of the default configuration as specialized configuration
39
# for self model if none existed so far
40
model.specialGeneratorConfig
(
True
).method1D(
False
,
False
).setLabel(
"RooFoamGenerator"
)
41
42
# Adjusting parameters of a specific technique
43
# ---------------------------------------------------------------------------------------
44
45
# Adjust maximum number of steps of ROOT.RooIntegrator1D in the global
46
# default configuration
47
ROOT.RooAbsPdf.defaultGeneratorConfig
().getConfigSection(
"RooAcceptReject"
).setRealValue(
"nTrial1D"
, 2000)
48
49
# Example of how to change the parameters of a numeric integrator
50
# (Each config section is a ROOT.RooArgSet with ROOT.RooRealVars holding real-valued parameters
51
# and ROOT.RooCategories holding parameters with a finite set of options)
52
model.specialGeneratorConfig
().getConfigSection(
"RooFoamGenerator"
).setRealValue(
"chatLevel"
, 1)
53
54
# Generate 10Kevt using ROOT.RooFoamGenerator (FOAM verbosity increased
55
# with above chatLevel adjustment for illustration purposes)
56
data_foam =
model.generate
({x}, 10000, Verbose=
True
)
57
data_foam.Print
()
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
roofit
rf902_numgenconfig.py
ROOT master - Reference Guide Generated on Thu Feb 20 2025 04:19:54 (GVA Time) using Doxygen 1.10.0