13 from ROOT
import TCanvas, TFile, TProfile, TNtuple, TH1F, TH2F
14 from ROOT
import gROOT, gBenchmark, gRandom, gSystem, Double
19 c1 = TCanvas(
'c1',
'Dynamic Filling Example', 200, 10, 700, 500 )
23 c1.GetFrame().SetBorderMode( -1 )
30 hfile = gROOT.FindObject(
'py-hsimple.root' )
33 hfile = TFile(
'py-hsimple.root',
'RECREATE',
'Demo ROOT file with histograms' )
36 hpx = TH1F(
'hpx',
'This is the px distribution', 100, -4, 4 )
37 hpxpy = TH2F(
'hpxpy',
'py vs px', 40, -4, 4, 40, -4, 4 )
38 hprof = TProfile(
'hprof',
'Profile of pz versus px', 100, -4, 4, 0, 20 )
39 ntuple = TNtuple(
'ntuple',
'Demo ntuple',
'px:py:pz:random:i' )
42 hpx.SetFillColor( 48 )
44 gBenchmark.Start(
'hsimple' )
48 rannor, rndm = gRandom.Rannor, gRandom.Rndm
51 histos = [
'hpx',
'hpxpy',
'hprof',
'ntuple' ]
53 exec
'%sFill = %s.Fill' % (name,name)
58 for i
in xrange( 25000 ):
68 ntupleFill( px, py, pz, random, i )
71 if i
and i%kUPDATE == 0:
78 if gSystem.ProcessEvents():
83 exec
'del %sFill' % name
86 gBenchmark.Show(
'hsimple' )
91 hpx.SetFillColor( 48 )