This program creates :
- a one dimensional histogram
- a two dimensional histogram
- a profile histogram
- a memory-resident ntuple
These objects are filled with some random numbers and saved on a file.
from ROOT import TCanvas, TFile, TProfile, TNtuple, TH1F, TH2F
from ROOT import gROOT, gBenchmark, gRandom, gSystem
import ctypes
c1 =
TCanvas(
'c1',
'Dynamic Filling Example', 200, 10, 700, 500 )
if hfile:
hfile =
TFile(
'py-hsimple.root',
'RECREATE',
'Demo ROOT file with histograms' )
hpx =
TH1F(
'hpx',
'This is the px distribution', 100, -4, 4 )
hpxpy =
TH2F(
'hpxpy',
'py vs px', 40, -4, 4, 40, -4, 4 )
hprof =
TProfile(
'hprof',
'Profile of pz versus px', 100, -4, 4, 0, 20 )
ntuple =
TNtuple(
'ntuple',
'Demo ntuple',
'px:py:pz:random:i' )
histos = [ 'hpx', 'hpxpy', 'hprof', 'ntuple' ]
for name in histos:
exec('%sFill = %s.Fill' % (name,name))
kUPDATE = 1000
pz = px*px + py*py
if i and i%kUPDATE == 0:
if i == kUPDATE:
break
for name in histos:
exec('del %sFill' % name)
del histos
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t SetFillColor
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
1-D histogram with a float per channel (see TH1 documentation)
2-D histogram with a float per channel (see TH1 documentation)
A simple TTree restricted to a list of float variables only.
- Author
- Wim Lavrijsen, Enric Tejedor
Definition in file hsimple.py.