XYZVector operator +

Hi pyrooters,

I’ve seen a post on a similar topic but it’s quite old, so I dare asking.

Consider the python interactive session below. Using ROOT 5.27/06b, python 2.6.4.
What makes TVector3 different from XYZVector as far as operator + is concerned ?
Oddly enough, operator += works for XYZVector.

CMS is using XYZVector,XYZPoint extensively, it would be great to be able to use
their operators.

thanks

Stefano

v1= ROOT.TVector3(0,0,0)
v2= ROOT.TVector3(1,1,1)
v3= v1+v2
print v3.x()
1.0

v1= ROOT.Math.XYZVector(0,0,0)
v2= ROOT.Math.XYZVector(1,1,1)
v3 = v1+v2
Traceback (most recent call last):
File “”, line 1, in
TypeError: unsupported operand type(s) for +: ‘ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D,ROOT::Math::DefaultCoordinateSystem’ and ‘ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D,ROOT::Math::DefaultCoordinateSystem’

Hi,

difference between += and operator+ is that the former is part of the class (and thus equivalent with the way that python implements it and readily available), the latter is a global overload and needs an explicit lookup through a trampoline, since it could exist anywhere independent of the class. That is implemented, but apparently the global operator+ still can’t be found; I’m guessing that is because of the namespace. I’ll have a look later.

Cheers,
Wim