# Parameterized Volumes: How does Geant determine which volume a step point is in?

I am interested in exporting track structure information from Geant4 and then analyzing those tracks
using another software toolkit, rather than using the sensitive detector functionality of Geant4. Something I regularly find myself doing in Geant is placing thousands of objects (typically of the same shape, cubic or spherical) with arbitrary positions and then using the G4 copy number of the parameterized objects to index energy deposition information according to which parameterized volume the step point occurred within.

My question is: What algorithm does Geant4 use when it is determining which parametrized object a step point belongs to?

Evidently I could perform an exhaustive search of all of the replicated volumes in my geometry to check if an energy deposition event occurred within them, however this seems extraordinarily inefficient. I have some ideas for ways that I could optimize such a search, but I assume that folks much more knowledgeable than myself have established algorithms for such a task. If anyone could at all point me in the right direction, even with the just the title of some such “geometry searching algorithm”, I would appreciate that tremendously.

with thanks,

Joseph DeCunha

1 Like

Geant4 doesn’t do that kind of search of the geometry during tracking. Instead, when the geometry is “closed” (i.e. after your code has created all of the geometry objects) Geant4 “voxelizes” the geometry tree, dividing the world volume into a flat table of three dimensional chunks. Each voxel has a pointer to the unique “leaf node” placement volume and its copy number (technically, the pointer is to a `G4Touchable` which carries the unique path through the geometry tree from the World volume down to the leaf node).

During tracking, this “voxelized” geometry is used to very quickly get the volume occupied by the track, from which material properties, distance to boundaries, etc., are extracted.

Within the Geant4 code, the `G4Navigator` class provides the interface to the voxelized geometry, with functions to return a G4Touchable given a position, and other tools.

1 Like

Thank you Michael! this is a great response and much appreciated.