Dear ROOT and Python experts,
Using python 2.4.3 and ROOT 5.18/00 I believe there’s a problem with the python TVector iterator.
Python 2.4.3 (#1, May 2 2006, 18:45:25)
[GCC 3.4.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TVector
>>> v =TVector(3)
>>> v.GetNrows()
3
>>> v.Print()
Vector (3) is as follows
| 1 |
------------------
0 |0
1 |0
2 |0
>>> for i in v:
... print i
...
0.0
0.0
0.0
Error in <TVectorT<float>::operator()>: Request index(3) outside vector range of 0 - 3
0.0
Error in <TVectorT<float>::operator()>: Request index(4) outside vector range of 0 - 3
and this goes on indefinitely. So for some reason the iterator on the Python side does not know how large the vector is, even though GetNrows() produces the correct result.
Is this fixable, or can the whole TVector class be declared uniterable to prevent me from making this mistake again?
By the way: just curious, but TVector is a templated class, and I saw PyROOT gets the float version
>>> type(v)
<class 'ROOT.TVectorT<float>'>
In which piece of PyROOT should I look to find the details about how these templates are dealt with. (I was a bit too lazy to grep for this myself right now…)
Cheers,
Jeroen