I’ve run into another problem which seems to be related to the same source, even though it’s in a completely different program - not just different code mind you, this time it’s a full-blown, compiled+linked ROOT library loaded into a macro by gSystem->Load().
The code fragment in question looks like this:
[code] Float_t posx = 0., posy = 0., posz;
for (Int_t a = 1; a <= nPlanes; ++a) {
posz = -492.17 - (224.8 / (nPlanes - 1)) * (a - 1);
const Int_t trkRes = TS->TrackTo(posz);
if ((trkRes == 0) || (trkRes == 2)) {
posx = TS->GetX();
posy = TS->GetY();
if ((TMath::Abs(posx) < 85.) && (TMath::Abs(posy) < 40.) && (TMath::Abs(posx) > 12.))
track2->SetPlaneValues(0, a, posx, posy, posz);
}
}
[/code]
where nPlanes is passed from the outside and TS in an instance of T49Trkstep as used in the first problem case.
In the code above, SetPlaneValues never gets called because regardless of what GetX() actually returns posx in the if statement always equals 0, thus making the condition false. However, if I add either
cout << posx;
or
cout << TS->GetX();
before the if statement, not only do correct values get displayed on the screen but also the code starts to work as it should. To make it even more interesting, I needn’t use cout or cerr to “fix” the problem - when I created an output file stream pointing to /dev/null and used it instead, it “unblocked” posx too.