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
ROOT Reference Documentation
Tutorials
►
Functional Parts
►
Namespaces
►
All Classes
▼
Files
▼
File List
►
bindings
►
core
►
documentation
►
geom
►
graf2d
►
graf3d
►
gui
►
hist
►
html
►
io
►
main
►
math
►
montecarlo
►
net
►
proof
►
roofit
►
sql
►
tmva
►
tree
▼
tutorials
►
cocoa
►
cont
►
dataframe
►
eve
►
eve7
►
fft
►
fit
►
fitsio
►
foam
►
geom
►
gl
►
graphics
►
graphs
►
gui
►
hist
►
histfactory
►
http
►
image
►
io
►
legacy
►
math
►
matrix
►
mc
►
multicore
►
net
►
physics
►
proof
►
pyroot
►
pythia
►
quadp
►
r
►
rcanvas
▼
roofit
rf101_basics.C
rf101_basics.py
rf102_dataimport.C
rf102_dataimport.py
rf103_interprfuncs.C
rf103_interprfuncs.py
rf104_classfactory.C
rf104_classfactory.py
rf105_funcbinding.C
rf105_funcbinding.py
rf106_plotdecoration.C
rf106_plotdecoration.py
rf107_plotstyles.C
rf107_plotstyles.py
rf108_plotbinning.C
rf108_plotbinning.py
rf109_chi2residpull.C
rf109_chi2residpull.py
rf110_normintegration.C
rf110_normintegration.py
rf111_derivatives.C
rf111_derivatives.py
rf201_composite.C
rf201_composite.py
rf202_extendedmlfit.C
rf202_extendedmlfit.py
rf203_ranges.C
rf203_ranges.py
rf204a_extendedLikelihood.C
rf204a_extendedLikelihood.py
rf204b_extendedLikelihood_rangedFit.C
rf204b_extendedLikelihood_rangedFit.py
rf205_compplot.C
rf205_compplot.py
rf206_treevistools.C
rf206_treevistools.py
rf207_comptools.C
rf207_comptools.py
rf208_convolution.C
rf208_convolution.py
rf209_anaconv.C
rf209_anaconv.py
rf210_angularconv.C
rf210_angularconv.py
rf211_paramconv.C
rf211_paramconv.py
rf212_plottingInRanges_blinding.C
rf212_plottingInRanges_blinding.py
rf301_composition.C
rf301_composition.py
rf302_utilfuncs.C
rf302_utilfuncs.py
rf303_conditional.C
rf303_conditional.py
rf304_uncorrprod.C
rf304_uncorrprod.py
rf305_condcorrprod.C
rf305_condcorrprod.py
rf306_condpereventerrors.C
rf306_condpereventerrors.py
rf307_fullpereventerrors.C
rf307_fullpereventerrors.py
rf308_normintegration2d.C
rf308_normintegration2d.py
rf309_ndimplot.C
rf309_ndimplot.py
rf310_sliceplot.C
rf310_sliceplot.py
rf311_rangeplot.C
rf311_rangeplot.py
rf312_multirangefit.C
rf312_multirangefit.py
rf313_paramranges.C
rf313_paramranges.py
rf314_paramfitrange.C
rf314_paramfitrange.py
rf315_projectpdf.C
rf315_projectpdf.py
rf316_llratioplot.C
rf316_llratioplot.py
rf401_importttreethx.C
rf401_importttreethx.py
rf402_datahandling.C
rf402_datahandling.py
rf403_weightedevts.C
rf403_weightedevts.py
rf404_categories.C
rf404_categories.py
rf405_realtocatfuncs.C
rf405_realtocatfuncs.py
rf406_cattocatfuncs.C
rf406_cattocatfuncs.py
rf407_latextables.C
rf407_latextables.py
rf408_RDataFrameToRooFit.C
rf408_RDataFrameToRooFit.py
rf409_NumPyPandasToRooFit.py
rf501_simultaneouspdf.C
rf501_simultaneouspdf.py
rf502_wspacewrite.C
rf502_wspacewrite.py
rf503_wspaceread.C
rf503_wspaceread.py
rf504_simwstool.C
rf504_simwstool.py
rf505_asciicfg.C
rf505_asciicfg.py
rf506_msgservice.C
rf506_msgservice.py
rf508_listsetmanip.C
rf508_listsetmanip.py
rf509_wsinteractive.C
rf509_wsinteractive.py
rf510_wsnamedsets.C
rf510_wsnamedsets.py
rf511_wsfactory_basic.C
rf511_wsfactory_basic.py
rf512_wsfactory_oper.C
rf512_wsfactory_oper.py
rf513_wsfactory_tools.C
rf513_wsfactory_tools.py
rf514_RooCustomizer.C
rf514_RooCustomizer.py
rf515_hfJSON.py
rf601_intminuit.C
rf601_intminuit.py
rf602_chi2fit.C
rf602_chi2fit.py
rf603_multicpu.C
rf603_multicpu.py
rf604_constraints.C
rf604_constraints.py
rf605_profilell.C
rf605_profilell.py
rf606_nllerrorhandling.C
rf606_nllerrorhandling.py
rf607_fitresult.C
rf607_fitresult.py
rf608_fitresultaspdf.C
rf608_fitresultaspdf.py
rf609_xychi2fit.C
rf609_xychi2fit.py
rf610_visualerror.C
rf610_visualerror.py
rf611_weightedfits.C
rf612_recoverFromInvalidParameters.C
rf612_recoverFromInvalidParameters.py
rf613_global_observables.C
rf613_global_observables.py
rf614_binned_fit_problems.C
rf614_binned_fit_problems.py
rf615_simulation_based_inference.py
rf616_morphing.C
rf616_morphing.py
rf617_simulation_based_inference_multidimensional.py
rf618_mixture_models.py
rf701_efficiencyfit.C
rf701_efficiencyfit.py
rf702_efficiencyfit_2D.C
rf702_efficiencyfit_2D.py
rf703_effpdfprod.C
rf703_effpdfprod.py
rf704_amplitudefit.C
rf704_amplitudefit.py
rf705_linearmorph.C
rf705_linearmorph.py
rf706_histpdf.C
rf706_histpdf.py
rf707_kernelestimation.C
rf707_kernelestimation.py
rf708_bphysics.C
rf708_bphysics.py
rf709_BarlowBeeston.C
rf709_BarlowBeeston.py
rf710_roopoly.C
rf710_roopoly.py
rf711_lagrangianmorph.C
rf711_lagrangianmorph.py
rf712_lagrangianmorphfit.C
rf712_lagrangianmorphfit.py
rf801_mcstudy.C
rf801_mcstudy.py
rf802_mcstudy_addons.C
rf802_mcstudy_addons.py
rf803_mcstudy_addons2.C
rf803_mcstudy_addons2.py
rf804_mcstudy_constr.C
rf804_mcstudy_constr.py
rf901_numintconfig.C
rf901_numintconfig.py
rf902_numgenconfig.C
rf902_numgenconfig.py
rf903_numintcache.C
rf903_numintcache.py
►
roostats
►
spectrum
►
splot
►
sql
►
tmva
►
tree
►
unfold
►
unuran
►
v7
►
vecops
►
webcanv
►
webgui
►
xml
►
.enableImplicitMTWrapper.py
.rootlogon.py
demos.C
demoshelp.C
hsimple.C
rootlogoff.C
rootlogon.C
►
v6-34-00-patches
►
File Members
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
rf804_mcstudy_constr.py
Go to the documentation of this file.
1
## \ingroup tutorial_roofit
2
## \notebook
3
##
4
## 'VALIDATION AND MC STUDIES' RooFit tutorial macro #804
5
##
6
## Using RooMCStudy on models with constraints
7
##
8
## \macro_image
9
## \macro_code
10
## \macro_output
11
##
12
## \date February 2018
13
## \author Clemens Lange
14
15
16
import
ROOT
17
18
19
# Create model with parameter constraint
20
# ---------------------------------------------------------------------------
21
22
# Observable
23
x =
ROOT.RooRealVar
(
"x"
,
"x"
, -10, 10)
24
25
# Signal component
26
m =
ROOT.RooRealVar
(
"m"
,
"m"
, 0, -10, 10)
27
s =
ROOT.RooRealVar
(
"s"
,
"s"
, 2, 0.1, 10)
28
g =
ROOT.RooGaussian
(
"g"
,
"g"
, x, m, s)
29
30
# Background component
31
p =
ROOT.RooPolynomial
(
"p"
,
"p"
, x)
32
33
# Composite model
34
f =
ROOT.RooRealVar
(
"f"
,
"f"
, 0.4, 0.0, 1.0)
35
sum =
ROOT.RooAddPdf
(
"sum"
,
"sum"
, [g, p], [f])
36
37
# Construct constraint on parameter f
38
fconstraint =
ROOT.RooGaussian
(
"fconstraint"
,
"fconstraint"
, f, 0.7, 0.1)
39
40
# Multiply constraint with p.d.f
41
sumc =
ROOT.RooProdPdf
(
"sumc"
,
"sum with constraint"
, [sum, fconstraint])
42
43
# Setup toy study with model
44
# ---------------------------------------------------
45
46
# Perform toy study with internal constraint on f
47
mcs =
ROOT.RooMCStudy
(sumc, {x}, Constrain={f}, Silence=
True
, Binned=
True
, FitOptions={
"PrintLevel"
: -1})
48
49
# Run 500 toys of 2000 events.
50
# Before each toy is generated, value for the f is sampled from the constraint pdf and
51
# that value is used for the generation of that toy.
52
mcs.generateAndFit
(500, 2000)
53
54
# Make plot of distribution of generated value of f parameter
55
h_f_gen =
mcs.fitParDataSet
().createHistogram(
"f_gen"
, AutoBinning=40)
56
57
# Make plot of distribution of fitted value of f parameter
58
frame1 =
mcs.plotParam
(f, Bins=40)
59
frame1.SetTitle
(
"Distribution of fitted f values"
)
60
61
# Make plot of pull distribution on f
62
frame2 =
mcs.plotPull
(f, Bins=40, FitGauss=
True
)
63
frame1.SetTitle
(
"Distribution of f pull values"
)
64
65
c =
ROOT.TCanvas
(
"rf804_mcstudy_constr"
,
"rf804_mcstudy_constr"
, 1200, 400)
66
c.Divide
(3)
67
c.cd
(1)
68
ROOT.gPad.SetLeftMargin
(0.15)
69
h_f_gen.GetYaxis
().SetTitleOffset(1.4)
70
h_f_gen.Draw
()
71
c.cd
(2)
72
ROOT.gPad.SetLeftMargin
(0.15)
73
frame1.GetYaxis
().SetTitleOffset(1.4)
74
frame1.Draw
()
75
c.cd
(3)
76
ROOT.gPad.SetLeftMargin
(0.15)
77
frame2.GetYaxis
().SetTitleOffset(1.4)
78
frame2.Draw
()
79
80
c.SaveAs
(
"rf804_mcstudy_constr.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
rf804_mcstudy_constr.py
ROOT v6-34 - Reference Guide Generated on Sat Apr 12 2025 16:37:50 (GVA Time) using Doxygen 1.10.0