A TTree in Uproot behaves like a Mapping, where keys are TBranch names and values are TBranch objects. Since branches can be nested, both TTree and TBranch inherit from HasBranches.
To inspect the structure of a TTree without reading data:
- Use
.keys() to see available branch names. - Use
.values() to see the TBranch objects. - Use
.typenames() to see the data types of each branch. - Use
.show() for a human-readable summary of names, types, and how the data is interpreted (e.g., how it maps to arrays).
>>> events = uproot.open("https://scikit-hep.org/uproot3/examples/Zmumu.root:events")
>>> events.keys()
['Type', 'Run', 'Event', 'E1', 'px1', 'py1', 'pz1', 'pt1', 'eta1', 'phi1', 'Q1', 'E2', 'px2', 'py2', 'pz2', 'pt2', 'eta2', 'phi2', 'Q2', 'M']
>>> events.typenames()
{'Type': 'char*', 'Run': 'int32_t', 'Event': 'int32_t', 'E1': 'double', ...}
>>> events.show()
name | typename | interpretation
---------------------+--------------------------+-------------------------------
Type | char* | AsStrings()
Run | int32_t | AsDtype('>i4')
...