Eta() of TVector3 affects comparison of variables

From: Sebastian Naumann <snaumann_at_mail.desy.de>
Date: Tue, 27 Jun 2006 09:58:52 +0200 (CEST)


Hello everybody!

A colleague of mine and I stumbled across the following problem: When we calculated an expression with a call to the Eta() function of TVector3 (or TLorentzVector) *twice* and stored the result in two variables, they would not always be recognized as being the same.

An example to illustrate my point:

##########################

#include "Riostream.h"
#include <TSystem.h>
#include <TVector3.h>

void test(){

     Double_t a;
     Double_t b;
     TVector3 vec1;
     TVector3 vec2;
     vec2.SetXYZ(1.,1.,1.);
     vec1.SetXYZ(10.,1.,1.);
     a =  0.5 * (vec1.PseudoRapidity()-vec2.PseudoRapidity());
     b =  0.5 * (vec1.PseudoRapidity()-vec2.PseudoRapidity());
     if (a == b) {
 	cout << "identical:" << " a: " << a  << " b: " << b << endl;
     }
     else {
 	cout << "NOT identical:" << " a: " << a  << " b: " << b << endl;
     }

} // test()
#####################

To run use:

gSystem->Load("libPhysics.so")
.x test.C+

This will output: "NOT identical: a: -0.279569 b: -0.279569" It DOES however work, if I replace "vec1.SetXYZ(10.,1.,1.);" with "vec1.SetXYZ(9.,1.,1.);" OR insert a statement like "gSystem->Sleep(0);", or any kind of "cout" between "b = ..." and "if ...". Replacing Eta() with Phi() did not cause this behavior.

This shows up with root versions 3.10.02, 4.04 and 5.11 on linux.

If you could shed some light on this issue, we'll be able to sleep better again! ;-)

Sincerely yours,

Sebastian Naumann Received on Tue Jun 27 2006 - 09:58:59 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:59 MET