Hello World example for TH1.
Shows how to create, fill and write a histogram to a ROOT file.
import numpy as np
import ROOT
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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
- Date
- July 2025
- Author
- Giacomo Parolini, Nursena Bitirgen
Definition in file hist000_TH1_first_uhi.py.