FillRandom example
fillrandom: Real Time = 0.54 seconds Cpu Time = 0.25 seconds
2 from ROOT
import TCanvas, TPad, TFormula, TF1, TPaveLabel, TH1F, TFile
3 from ROOT
import gROOT, gBenchmark
7 c1 =
TCanvas(
'c1',
'The FillRandom example', 200, 10, 700, 900 )
10 pad1 =
TPad(
'pad1',
'The pad with the function', 0.05, 0.50, 0.95, 0.95, 21 )
11 pad2 =
TPad(
'pad2',
'The pad with the histogram', 0.05, 0.05, 0.95, 0.45, 21 )
16 gBenchmark.Start(
'fillrandom' )
21 form1 =
TFormula(
'form1',
'abs(sin(x)/x)' )
22 sqroot =
TF1(
'sqroot',
'x*gaus(0) + [3]*form1', 0, 10 )
23 sqroot.SetParameters( 10, 4, 1, 20 )
27 pad1.GetFrame().SetBorderMode( -1 )
29 sqroot.SetLineColor( 4 )
30 sqroot.SetLineWidth( 6 )
32 lfunction =
TPaveLabel( 5, 39, 9.8, 46,
'The sqroot function' )
33 lfunction.SetFillColor( 41 )
43 pad2.GetFrame().SetBorderMode( -1 )
45 h1f =
TH1F(
'h1f',
'Test random numbers', 200, 0, 10 )
46 h1f.SetFillColor( 45 )
47 h1f.FillRandom(
'sqroot', 10000 )
53 myfile =
TFile(
'py-fillrandom.root',
'RECREATE' )
58 gBenchmark.Show(
'fillrandom' )
- Author
- Wim Lavrijsen
Definition in file fillrandom.py.