LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
geo::GeoNodePath Class Reference

Representation of a node and its ancestry. More...

#include "GeoNodePath.h"

Public Types

using Entry = GeoNodePathEntry
 
using Depth_t = std::size_t
 Type used to represent the depth of the path. More...
 

Public Member Functions

 GeoNodePath (TGeoNode const *topNode)
 Sets all the the specified nodes into the current path. More...
 
bool empty () const
 Returns whether there is a current node. More...
 
Depth_t depth () const
 Returns the depth of the path (elements including up to the current). More...
 
TGeoNode const * current () const
 Returns the current node. Undefined if the path is empty. More...
 
Entry current_entry () const
 Returns the current node. Undefined if the path is empty. More...
 
Entry parent_entry () const
 Returns the parent entry of the current entry, or null if there is no parent. More...
 
void append (TGeoNode const *node)
 Adds a node to the current path. More...
 
void pop ()
 Removes the current node from the path, moving the current one up. More...
 
template<typename Matrix = TGeoHMatrix>
Matrix currentTransformation () const
 Returns the total transformation to the current node, as a Matrix. More...
 
 operator std::string () const
 Prints the full path (as node names) into a string. More...
 

Private Attributes

std::vector< EntryfNodes
 Local path of pointers to ROOT geometry nodes. More...
 

Detailed Description

Representation of a node and its ancestry.

A GeoNodePath contains a sequence of nodes, from the root() node down to a current() one.

It behaves like a stack in that it inserts and removes elements at the "top", which is also what defines the current node.

Definition at line 34 of file GeoNodePath.h.

Member Typedef Documentation

using geo::GeoNodePath::Depth_t = std::size_t

Type used to represent the depth of the path.

Definition at line 41 of file GeoNodePath.h.

Definition at line 37 of file GeoNodePath.h.

Constructor & Destructor Documentation

geo::GeoNodePath::GeoNodePath ( TGeoNode const *  topNode)
explicit

Sets all the the specified nodes into the current path.

Definition at line 39 of file GeoNodePath.cxx.

39 : fNodes{entry_for(topNode)} {}
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84

Member Function Documentation

void geo::GeoNodePath::append ( TGeoNode const *  node)

Adds a node to the current path.

Definition at line 67 of file GeoNodePath.cxx.

References current_entry(), empty(), and fNodes.

Referenced by geo::ROOTGeometryNavigator::apply(), and geo::GeometryExtractor::operator()().

68  {
69  auto entry = empty() ? entry_for(node) : entry_for(current_entry(), node);
70  fNodes.push_back(std::move(entry));
71  }
bool empty() const
Returns whether there is a current node.
Definition: GeoNodePath.cxx:41
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84
Entry current_entry() const
Returns the current node. Undefined if the path is empty.
Definition: GeoNodePath.cxx:56
TGeoNode const * geo::GeoNodePath::current ( ) const

Returns the current node. Undefined if the path is empty.

Definition at line 51 of file GeoNodePath.cxx.

References current_entry(), and geo::GeoNodePathEntry::node.

Referenced by geo::ROOTGeometryNavigator::apply(), geo::GeometryBuilderStandard::makeAuxDet(), geo::GeometryBuilderStandard::makeCryostat(), geo::WireReadoutGeomBuilderStandard::makePlane(), geo::WireReadoutGeomBuilderStandard::makeWire(), and geo::GeometryExtractor::operator()().

52  {
53  return current_entry().node;
54  }
Entry current_entry() const
Returns the current node. Undefined if the path is empty.
Definition: GeoNodePath.cxx:56
auto geo::GeoNodePath::current_entry ( ) const

Returns the current node. Undefined if the path is empty.

Definition at line 56 of file GeoNodePath.cxx.

References fNodes.

Referenced by append(), current(), and geo::GeometryBuilderStandard::makeTPC().

57  {
58  return fNodes.back();
59  }
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84
template<typename Matrix >
Matrix geo::GeoNodePath::currentTransformation ( ) const

Returns the total transformation to the current node, as a Matrix.

Definition at line 94 of file GeoNodePath.h.

References fNodes.

Referenced by geo::GeometryBuilderStandard::makeAuxDet(), geo::GeometryBuilderStandard::makeCryostat(), geo::WireReadoutGeomBuilderStandard::makePlane(), geo::GeometryBuilderStandard::makeTPC(), and geo::WireReadoutGeomBuilderStandard::makeWire().

95 {
96  return transformationFromPath<Matrix>(fNodes.begin(), fNodes.end());
97 }
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84
GeoNodePath::Depth_t geo::GeoNodePath::depth ( ) const

Returns the depth of the path (elements including up to the current).

Definition at line 46 of file GeoNodePath.cxx.

References fNodes.

Referenced by geo::GeometryExtractor::operator()(), and parent_entry().

47  {
48  return fNodes.size();
49  }
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84
bool geo::GeoNodePath::empty ( ) const

Returns whether there is a current node.

Definition at line 41 of file GeoNodePath.cxx.

References fNodes.

Referenced by append().

42  {
43  return fNodes.empty();
44  }
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84
geo::GeoNodePath::operator std::string ( ) const

Prints the full path (as node names) into a string.

Definition at line 78 of file GeoNodePath.cxx.

References util::end(), and fNodes.

79  {
80  std::string s = "[";
81  auto it = fNodes.cbegin(), end = fNodes.cend();
82  if (it != end) {
83  s += it->node->GetName();
84  while (++it != fNodes.cend()) {
85  s += '/';
86  s += it->node->GetName();
87  }
88  } // if
89  return s + ']';
90  }
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
auto geo::GeoNodePath::parent_entry ( ) const

Returns the parent entry of the current entry, or null if there is no parent.

Definition at line 61 of file GeoNodePath.cxx.

References depth(), fNodes, and util::size().

Referenced by geo::WireReadoutGeomBuilderStandard::doExtractPlanes().

62  {
63  if (auto const size = depth(); size > 1ull) { return fNodes[size - 2ull]; }
64  return {};
65  }
Depth_t depth() const
Returns the depth of the path (elements including up to the current).
Definition: GeoNodePath.cxx:46
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void geo::GeoNodePath::pop ( )

Removes the current node from the path, moving the current one up.

Definition at line 73 of file GeoNodePath.cxx.

References fNodes.

Referenced by geo::ROOTGeometryNavigator::apply(), and geo::GeometryExtractor::operator()().

74  {
75  fNodes.pop_back();
76  }
std::vector< Entry > fNodes
Local path of pointers to ROOT geometry nodes.
Definition: GeoNodePath.h:84

Member Data Documentation

std::vector<Entry> geo::GeoNodePath::fNodes
private

Local path of pointers to ROOT geometry nodes.

Definition at line 84 of file GeoNodePath.h.

Referenced by append(), current_entry(), currentTransformation(), depth(), empty(), operator std::string(), parent_entry(), and pop().


The documentation for this class was generated from the following files: