Given a point and a TGeometry, return the Node or volume that contains the point?

I have a TGeometry that was created by reading a GDML file. I also have a 3D point located somewhere within that geometry. I would like to determine the lowest level TGeoVolume that contains that point. I looked at the TGeometry class documentation and did not see any member function that looked like it would do the job.

I see how to do the simplest version: just traverse the node tree, get the TGeoVolume and the TGeoShape. Then use

Bool_t TGeoShape::Contains(const Double_t *point) const = 0;

Our geometry is small enough that even the naive algorithm is likely to be fast enough. However I am a little concerned about dealing with the case that the point is close to a surface so that the answer is potentially ambiguous within numerical precision. The main reason I am asking this question is to learn if anyone has solved this problem in a portable way.

Does anyone have code that Mu2e can use, with appropriate credit?

We are using root v6_22_06

Thanks,

Rob


Please read tips for efficient and successful posting and posting code

_ROOT Version: v6_22_06
_Platform: SL7
_Compiler: g++ 9.3.0


I guess @agheata can help you.

Hi Rob, it is in the navigation and tracking chapter of the geometry user guide. You can call: gGeoManager->FindNode(x,y,z) to get the deepest TGeoNode, this is generally much faster than just traversing the geometry. To inspect the path to this node: gGeoManager->GetPath()

Thanks,

I will have a look at it.

Rob

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