FindNextBoundary - Step IsOnBoundary question

It’s seems if I make the following line of execution:
FindNextBoundary(some value < actual distance to boundary);

then IsOnBoundary() returns true while the current position is not actually close to boundary.
Why so?

Hi Kiril,

The prototype of Step() method is:
Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)

That means that when you call Step() without arguments the modeller will make the assumption that the step you want to make is limited geometrically, without performing any check.

First you should know that the Step method was only designed to make sure that a boundary is really crossed after propagating the current point with a distance equal to the one to the next boundary. It is not used at all when Tgeo is used by a transport MC (as G3).

To transport safely a particle you should do:

Double_t *point = gGeoManager->GetCurrentPoint(); Double_t *dir = gGeoManager->GetCurrentDirection(); // (...) // Ask for the distance to next boundary, within a proposed distance gGeoManager->FindNextBoundary(proposedStep); Double_t snext = gGeoManager->GetStep(); // this is the distance to next boundary // If the boundary is closer than the proposed step, the modeller returns this distance if (snext<proposedStep) { // use the Step method to extrapolate and cross the boundary gGeoManager->Step(); // IsOnBoundary will be set, but TGeo makes an extra tiny step to make sure the location really changes } else { // the proposed step is safe - the modeler returns snext=proposedStep // you can safely propagate the point since no boundary is crossed for (Int_t i=0; i<3; i++) point[i] += proposedStep*dir[i]; // isOnBoundary=false }
Hope it helps,