17 from ROOT
import TCanvas, TFile, TProfile, TNtuple, TH1F, TH2F
18 from ROOT
import gROOT, gBenchmark, gRandom, gSystem
22 c1 = TCanvas(
'c1',
'Dynamic Filling Example', 200, 10, 700, 500 )
24 c1.GetFrame().SetFillColor( 21 )
25 c1.GetFrame().SetBorderSize( 6 )
26 c1.GetFrame().SetBorderMode( -1 )
33 hfile = gROOT.FindObject(
'py-hsimple.root' )
36 hfile = TFile(
'py-hsimple.root',
'RECREATE',
'Demo ROOT file with histograms' )
39 hpx = TH1F(
'hpx',
'This is the px distribution', 100, -4, 4 )
40 hpxpy = TH2F(
'hpxpy',
'py vs px', 40, -4, 4, 40, -4, 4 )
41 hprof = TProfile(
'hprof',
'Profile of pz versus px', 100, -4, 4, 0, 20 )
42 ntuple = TNtuple(
'ntuple',
'Demo ntuple',
'px:py:pz:random:i' )
45 hpx.SetFillColor( 48 )
47 gBenchmark.Start(
'hsimple' )
51 rannor, rndm = gRandom.Rannor, gRandom.Rndm
54 histos = [
'hpx',
'hpxpy',
'hprof',
'ntuple' ]
56 exec(
'%sFill = %s.Fill' % (name,name))
59 px_ref, py_ref = ctypes.c_double(), ctypes.c_double()
61 for i
in range( 25000 ):
63 rannor( px_ref, py_ref )
75 ntuple.Fill( px, py, pz, random, i )
78 if i
and i%kUPDATE == 0:
85 if gSystem.ProcessEvents():
90 exec(
'del %sFill' % name)
93 gBenchmark.Show(
'hsimple' )
98 hpx.SetFillColor( 48 )