ATLAS Offline Software
Loading...
Searching...
No Matches
read_hist_ntuple.py
Go to the documentation of this file.
1#! /usr/bin/env python
2# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
4from ROOT import TFile
5print(":" * 80)
6print("::: ntuple...")
7f1 = TFile.Open("ntuple.root","READ")
8t = f1.Get("trees/tree1")
9print(":: entries:", t.GetEntries())
10print(":: branches:", [b.GetName() for b in t.GetListOfBranches()])
11for i in range(t.GetEntries()):
12 if t.GetEntry(i) <= 0:
13 print("** error reading entry [%i]" % (i,))
14 break
15 print(":: entry [%i]..." % (i,))
16 print(":: run:", t.run)
17 print(":: size:", t.size)
18 print(":: rundata:", list(t.rundata))
19print(":: done.")
20
21print(":" * 80)
22print("::: histogram...")
23f2 = TFile.Open("hist.root", "READ")
24h1 = f2.Get("simple1D/h1")
25print(":: entries:", h1.GetEntries())
26h1.Draw()
27print(":: done.")
28
29print("::: bye.")
void print(char *figname, TCanvas *c1)