I am having problem handling 8 bit unsigned integers read from a TTree.
The tree has one of the the leafs declared as type “b” - “ipart/b”. mytree.Show() shows data in this leaf while trying to do print of values in each event fails. Trying to convert these with int() raises a type error. This is the code snippet I use to read in the tree entries:
mytree = mcfile.Get(treename)
mytree.Show(5)
for event in mytree:
print event.ipart
import sys, os
from ROOT import TFile
def process_file(filname):
mcfile = TFile(filname)
mytree = mcfile.Get('h9001')
mytree.Print()
for event in mytree:
print event.ipart
if type(event.ipart).__name__=='str':
int(event.ipart)
if __name__=='__main__':
process_file('test.root')
print does not show anything and the error when I try to convert to an integer is
I have also attached a root file I am analyzing test.root (17.7 KB)