Hello World example for TH1.
Shows how to create, fill and write a histogram to a ROOT file.
import ROOT
with ROOT.TFile.Open("outfile.root", "RECREATE") as outFile:
histogram = ROOT.TH1D("histogram", "My first ROOT histogram", nbinsx = 30, xlow = 0.0, xup = 10.0)
values = [1, 2, 3, 3, 3, 4, 3, 2, 1, 0]
for val in values:
histogram.Fill(val)
outFile.WriteObject(histogram, histogram.GetName())
- Date
- November 2024
- Author
- Giacomo Parolini (CERN)
Definition in file hist000_TH1_first.py.