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