ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
fillrandom.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_hist
3
## \notebook
4
## Fill a 1-D histogram from a parametric function. Original tutorial by Rene Brun.
5
##
6
## \macro_image
7
## \macro_code
8
##
9
## \author Alberto Ferro
10
11
import
ROOT
12
13
c1 =
ROOT.TCanvas
(
"c1"
,
"The FillRandom example"
,200,10,700,900)
14
pad1 =
ROOT.TPad
(
"pad1"
,
"The pad with the function"
,0.05,0.50,0.95,0.95)
15
pad2 =
ROOT.TPad
(
"pad2"
,
"The pad with the histogram"
,0.05,0.05,0.95,0.45)
16
pad1.Draw
()
17
pad2.Draw
()
18
pad1.cd
()
19
ROOT.gBenchmark.Start
(
"fillrandom"
)
20
21
form1 =
ROOT.TFormula
(
"form1"
,
"abs(sin(x)/x)"
)
22
sqroot =
ROOT.TF1
(
"sqroot"
,
"x*gaus(0) + [3]*form1"
,0,10)
23
sqroot.SetParameters
(10,4,1,20)
24
pad1.SetGridx
()
25
pad1.SetGridy
()
26
pad1.GetFrame
().SetBorderMode(-1)
27
pad1.GetFrame
().
SetBorderSize
(5)
28
sqroot.SetLineColor
(4)
29
sqroot.SetLineWidth
(6)
30
sqroot.Draw
()
31
lfunction =
ROOT.TPaveLabel
(5,39,9.8,46,
"The sqroot function"
)
32
lfunction.Draw
()
33
c1.Update
()
34
35
pad2.cd
()
36
pad2.GetFrame
().SetBorderMode(-1)
37
pad2.GetFrame
().
SetBorderSize
(5)
38
h1f =
ROOT.TH1F
(
"h1f"
,
"Test random numbers"
,200,0,10)
39
h1f.SetFillColor
(45)
40
h1f.FillRandom
(
"sqroot"
,10000)
41
h1f.Draw
()
42
c1.Update
()
43
44
f =
ROOT.TFile
(
"fillrandom-py.root"
,
"RECREATE"
)
45
form1.Write
()
46
sqroot.Write
()
47
h1f.Write
()
48
ROOT.gBenchmark.Show
(
"fillrandom"
)
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
SetBorderSize
c SetBorderSize(2)
tutorials
hist
fillrandom.py
ROOT v6-32 - Reference Guide Generated on Mon Feb 17 2025 14:17:25 (GVA Time) using Doxygen 1.10.0