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

Namespaces

namespace  fillrandom
 

Detailed Description

View in nbviewer Open in SWAN
FillRandom example

fillrandom: Real Time = 0.24 seconds Cpu Time = 0.24 seconds
from ROOT import TCanvas, TPad, TFormula, TF1, TPaveLabel, TH1F, TFile
from ROOT import gROOT, gBenchmark
c1 = TCanvas( 'c1', 'The FillRandom example', 200, 10, 700, 900 )
pad1 = TPad( 'pad1', 'The pad with the function', 0.05, 0.50, 0.95, 0.95, 21 )
pad2 = TPad( 'pad2', 'The pad with the histogram', 0.05, 0.05, 0.95, 0.45, 21 )
gBenchmark.Start( 'fillrandom' )
#
# A function (any dimension) or a formula may reference
# an already defined formula
#
form1 = TFormula( 'form1', 'abs(sin(x)/x)' )
sqroot = TF1( 'sqroot', 'x*gaus(0) + [3]*form1', 0, 10 )
sqroot.SetParameters( 10, 4, 1, 20 )
pad1.GetFrame().SetBorderMode( -1 )
lfunction = TPaveLabel( 5, 39, 9.8, 46, 'The sqroot function' )
#
# Create a one dimensional histogram (one float per bin)
# and fill it following the distribution in function sqroot.
#
pad2.GetFrame().SetBorderMode( -1 )
h1f = TH1F( 'h1f', 'Test random numbers', 200, 0, 10 )
h1f.FillRandom( 'sqroot', 10000 )
#
# Open a ROOT file and save the formula, function and histogram
#
myfile = TFile( 'py-fillrandom.root', 'RECREATE' )
gBenchmark.Show( 'fillrandom' )
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t SetFillColor
The Canvas class.
Definition TCanvas.h:23
1-Dim function class
Definition TF1.h:233
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
The Formula class.
Definition TFormula.h:89
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:621
The most important graphics class in the ROOT system.
Definition TPad.h:28
A Pave (see TPave) with a text centered in the Pave.
Definition TPaveLabel.h:20
c SetBorderSize(2)
Author
Wim Lavrijsen

Definition in file fillrandom.py.