Hello World example for TH1.
Shows how to create, fill and write a histogram to a ROOT file.
import numpy as np
import ROOT
with ROOT.TFile.Open("outfile_uhi.root", "RECREATE") as outFile:
histogram = ROOT.TH1D("histogram", "My first ROOT histogram", nbinsx=30, xlow=0.0, xup=10.0)
values = np.array([1, 2, 3, 3, 3, 4, 3, 2, 1, 0])
counts, edges = np.histogram(values, bins=30, range=(0.0, 10.0))
histogram[...] = counts
outFile.WriteObject(histogram, histogram.GetName())
- Date
- July 2025
- Author
- Giacomo Parolini, Nursena Bitirgen
Definition in file hist000_TH1_first_uhi.py.