Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
fillrandom.py File Reference

Detailed Description

View in nbviewer Open in SWAN
Fill a 1-D histogram from a parametric function.

Original tutorial by Rene Brun.

import ROOT
c1 = ROOT.TCanvas("c1","The FillRandom example",200,10,700,900)
pad1 = ROOT.TPad("pad1","The pad with the function",0.05,0.50,0.95,0.95)
pad2 = ROOT.TPad("pad2","The pad with the histogram",0.05,0.05,0.95,0.45)
ROOT.gBenchmark.Start("fillrandom")
form1 = ROOT.TFormula("form1","abs(sin(x)/x)")
sqroot = ROOT.TF1("sqroot","x*gaus(0) + [3]*form1",0,10)
pad1.GetFrame().SetBorderMode(-1)
lfunction = ROOT.TPaveLabel(5,39,9.8,46,"The sqroot function")
pad2.GetFrame().SetBorderMode(-1)
h1f = ROOT.TH1F("h1f","Test random numbers",200,0,10)
h1f.FillRandom("sqroot",10000)
f = ROOT.TFile("fillrandom-py.root","RECREATE")
ROOT.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)
Author
Alberto Ferro

Definition in file fillrandom.py.