|
Celeritas 0.7+cf8d83d
|
Incrementally compute the unique ID of a path in the volume hierarchy. More...
#include <VolumePathAccumulator.hh>
Public Types | |
Type aliases | |
| using | ParamsRef = NativeCRef< VolumeParamsData > |
Public Member Functions | |
| VolumePathAccumulator (ParamsRef const ¶ms) | |
| Construct from volume hierarchy data. | |
| VolumeUniqueInstanceId | operator() (VolumeUniqueInstanceId uid, VolumeInstanceId vi) const |
| Accumulate the contribution of one path step and return the updated ID. | |
Incrementally compute the unique ID of a path in the volume hierarchy.
Each VolumeUniqueInstanceId uniquely identifies a root-to-node path (i.e., a Geant4 "touchable") in the volume DAG. This class computes the ID on the fly without allocating a path buffer: call operator() once for each VolumeInstanceId encountered while descending from the world volume, passing the current accumulated ID and receiving the updated one.
For a volume instance vi at position k in its parent volume's children list, the offset is the sum of num_desc(volume(vj)) for all preceding siblings vj (positions 0..k-1), where num_desc(V) counts the total number of unique paths ending at any node in V's subtree (including V itself). For a path \([vi_0, vi_1, \ldots, vi_k]\) the unique instance ID is
\[ \text{uid} = \sum_{i=0}^{k} \bigl(\text{offset}[vi_i] + 1\bigr). \]
The empty path (the world volume itself, with no enclosing instance) maps to ID 0 (see world_unique_instance ).
The mapping relies on unique_instance_offsets precomputed in VolumeParamsData.
|
inline |
Accumulate the contribution of one path step and return the updated ID.
The result after \(k\) calls equals the VolumeUniqueInstanceId of the node reached via the first \(k\) instances in the path.