8 #ifndef LARCOREALG_GEOMETRY_ROOTGEOMETRYNAVIGATOR_H 9 #define LARCOREALG_GEOMETRY_ROOTGEOMETRYNAVIGATOR_H 16 #include "TGeoManager.h" 18 #include "TGeoVolume.h" 26 class ROOTGeometryNavigator;
82 template <
typename Op>
96 template <
typename Op>
97 bool apply(TGeoNode
const* node, Op&& op)
const;
108 template <
typename Op>
109 bool apply(Op&& op)
const;
116 template <
typename Op>
119 if (!op(path))
return false;
121 TGeoNode
const* node = path.
current();
122 TGeoVolume
const* pVolume = node->GetVolume();
124 int const nDaughters = pVolume->GetNdaughters();
125 for (
int iDaughter : util::counter<int>(nDaughters)) {
126 TGeoNode
const* pDaughter = pVolume->GetNode(iDaughter);
127 if (!pDaughter)
continue;
130 if (!
apply(path, std::forward<Op>(op)))
return false;
139 template <
typename Op>
143 return apply(path, std::forward<Op>(op));
147 template <
typename Op>
156 #endif // LARCOREALG_GEOMETRY_ROOTGEOMETRYNAVIGATOR_H TGeoNode const * current() const
Returns the current node. Undefined if the path is empty.
Executes an operation on all the nodes of the ROOT geometry.
bool apply(GeoNodePath &path, Op &&op) const
Applies the specified operation to all nodes under the path.
Class representing a path in ROOT geometry.
void pop()
Removes the current node from the path, moving the current one up.
Test of util::counter and support utilities.
TGeoNode const * fTopNode
void append(TGeoNode const *node)
Adds a node to the current path.
Representation of a node and its ancestry.
ROOTGeometryNavigator(TGeoManager const &manager)
Constructor: picks the manager.