19from ROOT
import TH1F, TH2F, TCanvas, TFile, TNtuple, TProfile, gBenchmark, gSystem
22c1 =
TCanvas(
"c1",
"Dynamic Filling Example", 200, 10, 700, 500)
27frame.SetBorderMode(-1)
30hpx =
TH1F(
"hpx",
"This is the px distribution", 100, -4, 4)
31hpxpy =
TH2F(
"hpxpy",
"py vs px", 40, -4, 4, 40, -4, 4)
32hprof =
TProfile(
"hprof",
"Profile of pz versus px", 100, -4, 4, 0, 20)
33ntuple =
TNtuple(
"ntuple",
"Demo ntuple",
"px:py:pz:random:i")
38gBenchmark.Start(
"hsimple")
43 px, py = numpy.random.standard_normal(size=2)
45 pz = px * px + py * py
46 random = numpy.random.rand()
52 ntuple.Fill(px, py, pz, random, i)
55 if i > 0
and i % 1000 == 0:
61 if gSystem.ProcessEvents():
64gBenchmark.Show(
"hsimple")
69with TFile(
"py-hsimple.root",
"RECREATE",
"Demo ROOT file with histograms")
as hfile:
71 hfile.WriteObject(hpx)
72 hfile.WriteObject(hpxpy)
73 hfile.WriteObject(hprof)
77 ntuple.SetDirectory(hfile)
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
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.