Distance to the next boundary

Hi, I have made a number of voxels entirely covering the world volume, and now I am trying to calculate distance of my ray from one boundary to another boundary.

Here’s my snippet
gGeoManager->SetCurrentPoint(X0,Y0,Z0-0.000000001);
gGeoManager->SetCurrentDirection((PX0/P0),(PY0/P0),(PZ0/P0));
TGeoNode *current= gGeoManager->GetCurrentNode();
gGeoManager->FindNode();
const char *path= gGeoManager->GetPath();
TGeoNode *distance= gGeoManager->FindNextBoundary(stepmax,path);
Float_t dist=gGeoManager->GetStep();

where I have set stepmax to 10000,and X0,Y0,Z0 are coordinates I am reading from a txt file. What could possibly have gone wrong??

Thanks,
Dhruv

I think @agheata can help you.

Hi Dhruv,
You’ve told us what you are doing, but not what it getting wrong. What may get wrong is that FindNode puts the point inside one of the volume that is daugter of the world volume, since it is very close to a boundary. Then FindNextBoundary may produce a zero step. Is this your problem?

Hi @agheata ,
I am guessing that’s probably it. Once I calculate my new point which is on the boundary, it returns the same index as before with zero distance. I had to add an infinitesimally small error to each point, so that it gets included inside a daughter volume instead of being on the boundary, and it returns correct results. Is there a better way out of it??

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