LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
GeoNodePath.h
Go to the documentation of this file.
1 
8 #ifndef LARCOREALG_GEOMETRY_GEONODEPATH_H
9 #define LARCOREALG_GEOMETRY_GEONODEPATH_H
10 
11 // LArSoft libraries
13 
14 // ROOT libraries
15 #include "TGeoNode.h"
16 
17 // C++ standard library
18 #include <cstddef> // std::size_t
19 #include <string>
20 #include <vector>
21 
22 namespace geo {
23 
34  class GeoNodePath {
35  public:
36  // FIXME: a better factorization is desirable
38 
39  // --- BEGIN Data types ----------------------------------------------------
41  using Depth_t = std::size_t;
42 
43  // --- END Data types ------------------------------------------------------
44 
45  // --- BEGIN Constructors and destructor -----------------------------------
47  explicit GeoNodePath(TGeoNode const* topNode);
48  // --- END Constructors and destructor -------------------------------------
49 
50  // --- BEGIN Query and access ----------------------------------------------
52  bool empty() const;
53 
55  Depth_t depth() const;
56 
58  TGeoNode const* current() const;
59 
61  Entry current_entry() const;
62 
64  Entry parent_entry() const;
65 
66  // --- END Query and access ------------------------------------------------
67 
68  // --- BEGIN Content management --------------------------------------------
70  void append(TGeoNode const* node);
71 
73  void pop();
74  // --- END Content management ----------------------------------------------
75 
77  template <typename Matrix = TGeoHMatrix>
78  Matrix currentTransformation() const;
79 
81  operator std::string() const;
82 
83  private:
84  std::vector<Entry> fNodes;
85 
86  }; // class GeoNodePath
87 
88 } // namespace geo
89 
90 //------------------------------------------------------------------------------
91 //--- template implementation
92 //------------------------------------------------------------------------------
93 template <typename Matrix /* = TGeoHMatrix */>
95 {
96  return transformationFromPath<Matrix>(fNodes.begin(), fNodes.end());
97 }
98 
99 //------------------------------------------------------------------------------
100 
101 #endif // LARCOREALG_GEOMETRY_GEONODEPATH_H
Depth_t depth() const
Returns the depth of the path (elements including up to the current).
Definition: GeoNodePath.cxx:46
GeoNodePath(TGeoNode const *topNode)
Sets all the the specified nodes into the current path.
Definition: GeoNodePath.cxx:39
TGeoNode const * current() const
Returns the current node. Undefined if the path is empty.
Definition: GeoNodePath.cxx:51
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 parent_entry() const
Returns the parent entry of the current entry, or null if there is no parent.
Definition: GeoNodePath.cxx:61
Class containing local-to-world transformations.
void pop()
Removes the current node from the path, moving the current one up.
Definition: GeoNodePath.cxx:73
Entry current_entry() const
Returns the current node. Undefined if the path is empty.
Definition: GeoNodePath.cxx:56
Matrix currentTransformation() const
Returns the total transformation to the current node, as a Matrix.
Definition: GeoNodePath.h:94
std::size_t Depth_t
Type used to represent the depth of the path.
Definition: GeoNodePath.h:41
void append(TGeoNode const *node)
Adds a node to the current path.
Definition: GeoNodePath.cxx:67
Representation of a node and its ancestry.
Definition: GeoNodePath.h:34
ROOT libraries.