It seems I can’t use TTreeReader from Python, because I can’t get the value of a TTreeReaderValue (it uses the operator ‘*’ in C++, and I don’t know how translate that to Python; I couldn’t find the answer).
ROOT.TTreeReaderValue['double']
age = ROOT.TTreeReaderValue('double')(reader, "Age")
staff_list = []
for entry in itertools.islice(tree, 10):
# this adds just objects, need numbers
staff_list.append(age)
I also found a suggestion by @etejedor in 2019:
…it also reads the whole branch. If you wanted to benefit from the optimization, you would need to do (from Python)
SetBranchAddress
+GetEntry
. Alternatively, you could also useRDataFrame
to efficiently read tree data from Python.