I am having trouble to read info from the branches of a TTree using the following code:
z = array('d',[0.])
pt = array('d',[0.])
for j in range(tree.GetEntries()):
and I got in the prints very small numbers like 5.721481036e-315 I don't understand because this method used to work for me...
Thanks in advance for your time!
yeah they were float numbers instead of doubles… dumb error, thanks!
Also, there is another branch I want to store:
proton_HASVELO : proton_HASVELO/O
they are doubles, can I use for example:
ar = array(‘i’,) to store them?
sorry they are “booleans”, I meant
"/O" means ROOT “
Bool_t” which is then probably an ordinary C++ “
I think “
numpy.array” supports “
Perfect, works for me. Thanks!
Hi @mendoza ,
please note that while reading TTree data from a Python for loop works fine in general, it is also much slower than alternative interfaces (namely RDataFrame) so make sure you don’t use raw Python loops for large-scale, full-blown analysis.