Hi all,
I observed a strange effect in one of my macros. Consider the following
code (the important lines are marked with '!'):
[...]
TVector3 pos_Trk, mom_Trk;
for(Int_t i=0; i<10; i++) {
HCalQual* cal = (HCalQual*) Event->GetCalQualList()->AddrAt(i);
Double_t p_rad = cal->GetPosition().Perp();
for(Int_t j=0; j<Event->GetNTrk(); j++) {
HTrkQual* trk = (HTrlQual*) Event->GetTrkQualList()->AddrAt(j);
if (!trk->GetTrackPointR(p_rad, pos_Trk, mom_Trk)) {
! Double_t diff = (calQual1->GetPosition() - pos_Trk).Mag();
! TVector3 diffV = calQual1->GetPosition() - pos_Trk;
! Double_t diff_test = diffV.Mag();
! cout << diff << " =? " << diff_test << endl;
[...]
}
}
}
[...]
I repeated the code like it is, because the effect seems to depend on
the context. 'cal' and 'trk' are just container holding some results,
cal->GetPosition() returns a TVector3 by value and trk->GetTrackPointR(...)
puts its results in pos_Trk and mom_Trk (by reference). However,
nothing special so far.
The lines marked with '!' should give the same value for diff and
diff_test. That's not the case at all! Rather than evaluating
'diff' to '(calQual1->GetPosition() - pos_Trk).Mag();' this value
is always equal to 'calQual1->GetPosition().Mag()', i.e. the
value of pos_Trk seems to be (0,0,0). However, the next two lines
show that this is not the case, because diff_test gives the right
result.
I tried to reproduce this effect with a small stand-alone macro, but
I didn't succeed. The following code works perfectly:
{
gROOT->Reset();
for(Int_t i=0; i<10; i++) {
TVector3 v1(10.,10.,i);
TVector3 v2(20.,20.,i);
if (true) {
Double_t diff1 = (v1-v2).Mag();
TVector3 diffV = v1-v2;
Double_t diff2 = diffV.Mag();
cout << diff1 << ", " << diff2 << endl;
}
}
}
Best regards,
Volker
--
Dr. Volker Hejny Tel: 02461/616853 **
Institut f. Kernphysik Fax: 02461/613930 **
---------------------------------------------------------------- ** ** ---
Forschungszentrum Juelich GmbH, D-52425 Juelich **
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET