Difference between C++ and python outputs

Hi,

I wonder why I see a difference between the outputs of two pieces of code. The pieces seem to be identical, but one is in C++, another one is in python:

C++:

E = TGLVertex3(-55.*256/2/1000, -55.*256/2/1000, 0)
F = TGLVertex3(-55.*256/2/1000, +55.*256/2/1000, 0)
G = TGLVertex3(+55.*256/2/1000, +55.*256/2/1000, 0)
EFGH = TGLPlane(E, F, G)
trackAfterScattering = TGLLine3(TGLVertex3(2., 3., 0.2), TGLVector3(0., 0., -20.))
std::pair<bool, TGLVertex3> intersectionPointWithEFGH = Intersection(EFGH, trackAfterScattering, false);  
printf("Track after scattering intersects the EFGH plane at (%+.2f, %+.2f, %+.2f) mm\n", intersectionPointWithEFGH.second.X(), intersectionPointWithEFGH.second.Y(), intersectionPointWithEFGH.second.Z())

this one prints Track after scattering intersects the EFGH plane at (+2.00, +3.00, +0.00) mm

PyROOT:

import ROOT
from ROOT import *

E = TGLVertex3(-55.*256/2/1000, -55.*256/2/1000, 0)
F = TGLVertex3(-55.*256/2/1000, +55.*256/2/1000, 0)
G = TGLVertex3(+55.*256/2/1000, +55.*256/2/1000, 0)
EFGH = TGLPlane(E, F, G)
trackAfterScattering = TGLLine3(TGLVertex3(2., 3., 0.2), TGLVector3(0., 0., -20.))
intersectionPointWithEFGH = ROOT.std.pair(bool, TGLVertex3)(Intersection(EFGH, trackAfterScattering, False))    
print("Track after scattering intersects the EFGH plane at (%+.2f, %+.2f, %+.2f) mm" % (intersectionPointWithEFGH.second.X(), intersectionPointWithEFGH.second.Y(), intersectionPointWithEFGH.second.Z()))

this one prints Track after scattering intersects the EFGH plane at (+1.98, +2.97, +0.00) mm

The C++ output is correct, why does python’s one lack precision?


ROOT Version: 6.14.04
Platform: x86_64-slc6
Compiler: gcc62-opt


It seems that python incorrectly calls:

TGLLine3::TGLLine3(const TGLVertex3& start, const TGLVertex3& end)

instead of:

TGLLine3::TGLLine3(const TGLVertex3& start, const TGLVector3& vector)

Hi,

I think you are right, thanks for spotting! If I ask for a TGLLine3 in python like this

import ROOT
from ROOT import *
trackAfterScattering = TGLLine3(TGLVertex3(2., 3., 0.2), TGLVector3(0., 0., -20.))

and then print the attributes of the TGLVector3 this line is made of

print("Track vector: (%f, %f, %f)" % (trackAfterScattering.Vector().X(), trackAfterScattering.Vector().Y(), trackAfterScattering.Vector().Z()))

, it won’t return (0., 0., -20.) as in constructor above, it will return

Track vector: (-2.000000, -3.000000, -20.200000)

instead.

However, if I do the same in C++:

trackAfterScattering = TGLLine3(TGLVertex3(2., 3., 0.2), TGLVector3(0., 0., -20.));
printf("Track vector: (%f, %f, %f)\n", trackAfterScattering.Vector().X(), trackAfterScattering.Vector().Y(), trackAfterScattering.Vector().Z());

, it returns the values from the constructor:

Track vector: (0.000000, 0.000000, -20.000000)

This is now https://sft.its.cern.ch/jira/browse/ROOT-10102

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.