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.
import numpy
from ROOT import TH1F, TH2F, TCanvas, TFile, TNtuple, TProfile, gBenchmark, gSystem
c1 =
TCanvas(
"c1",
"Dynamic Filling Example", 200, 10, 700, 500)
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")
pz = px * px + py * py
if i > 0 and i % 1000 == 0:
break
with TFile(
"py-hsimple.root",
"RECREATE",
"Demo ROOT file with histograms")
as hfile:
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.