Logo ROOT  
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
11import ROOT
12
13c1 = ROOT.TCanvas("c1","The FillRandom example",200,10,700,900)
14pad1 = ROOT.TPad("pad1","The pad with the function",0.05,0.50,0.95,0.95)
15pad2 = ROOT.TPad("pad2","The pad with the histogram",0.05,0.05,0.95,0.45)
18pad1.cd()
19ROOT.gBenchmark.Start("fillrandom")
20
21form1 = ROOT.TFormula("form1","abs(sin(x)/x)")
22sqroot = ROOT.TF1("sqroot","x*gaus(0) + [3]*form1",0,10)
23sqroot.SetParameters(10,4,1,20)
26pad1.GetFrame().SetBorderMode(-1)
31lfunction = ROOT.TPaveLabel(5,39,9.8,46,"The sqroot function")
34
35pad2.cd()
36pad2.GetFrame().SetBorderMode(-1)
38h1f = ROOT.TH1F("h1f","Test random numbers",200,0,10)
40h1f.FillRandom("sqroot",10000)
43
44f = ROOT.TFile("fillrandom-py.root","RECREATE")
48ROOT.gBenchmark.Show("fillrandom")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
c SetBorderSize(2)