LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeometryBuilderStandard.cxx
Go to the documentation of this file.
1 
9 // LArSoft libraries
11 
12 // support libraries
13 // #include "cetlib_except/exception.h"
14 
15 // ROOT libraries
16 
17 // C++ standard library
18 #include <algorithm> // std::move()
19 #include <string_view>
20 
21 using namespace std::literals;
22 
23 namespace {
24  template <typename Dest, typename Src>
25  void extendCollection(Dest& dest, Src&& src)
26  {
27  std::move(src.begin(), src.end(), std::back_inserter(dest));
28  }
29 
32  bool starts_with(std::string_view const s, std::string_view const key)
33  {
34  return s.compare(0, key.size(), key) == 0;
35  }
36 
37  bool isAuxDetNode(TGeoNode const& node)
38  {
39  return starts_with(node.GetName(), "volAuxDet"sv);
40  }
41  bool isAuxDetSensitiveNode(TGeoNode const& node)
42  {
43  return std::string_view(node.GetName()).find("Sensitive") != std::string_view::npos;
44  }
45  bool isCryostatNode(TGeoNode const& node)
46  {
47  return starts_with(node.GetName(), "volCryostat"sv);
48  }
49 
50  bool isOpDetNode(TGeoNode const& node, std::string_view const opDetGeoName)
51  {
52  return starts_with(node.GetName(), opDetGeoName);
53  }
54  bool isTPCNode(TGeoNode const& node)
55  {
56  return starts_with(node.GetName(), "volTPC"sv);
57  }
58  bool isPlaneNode(TGeoNode const& node)
59  {
60  return starts_with(node.GetName(), "volTPCPlane"sv);
61  }
62  bool isWireNode(TGeoNode const& node)
63  {
64  return starts_with(node.GetName(), "volTPCWire"sv);
65  }
66 }
67 
68 //------------------------------------------------------------------------------
70  : fMaxDepth(config.maxDepth()), fOpDetGeoName(config.opDetGeoName())
71 {}
72 
73 //------------------------------------------------------------------------------
75  Path_t& path)
76 {
77 
79 }
80 
81 //------------------------------------------------------------------------------
83 {
84 
85  return AuxDetGeo(path.current(),
88 }
89 
90 //------------------------------------------------------------------------------
93 {
95  path, isAuxDetSensitiveNode, &GeometryBuilderStandard::makeAuxDetSensitive);
96 }
97 
98 //------------------------------------------------------------------------------
100 {
102 }
103 
104 //------------------------------------------------------------------------------
106  Path_t& path)
107 {
109 }
110 
111 //------------------------------------------------------------------------------
113 {
114  return CryostatGeo{path.current(),
116  extractTPCs(path),
117  extractOpDets(path)};
118 }
119 
120 //------------------------------------------------------------------------------
122 {
124  path,
125  [this](auto const& node) { return isOpDetNode(node, fOpDetGeoName); },
127 }
128 
129 //------------------------------------------------------------------------------
131 {
133 }
134 
135 //------------------------------------------------------------------------------
137 {
139 }
140 
141 //------------------------------------------------------------------------------
143 {
144  return TPCGeo{
146 }
147 
148 //------------------------------------------------------------------------------
150 {
152 }
153 
154 //------------------------------------------------------------------------------
156 {
157  return PlaneGeo{
159 }
160 
161 //------------------------------------------------------------------------------
163 {
165 }
166 
167 //------------------------------------------------------------------------------
169 {
171 }
172 
173 //------------------------------------------------------------------------------
174 template <typename ObjGeo>
176  Path_t& path,
177  std::function<bool(TGeoNode const&)> const IsObj,
178  ObjGeo (GeometryBuilderStandard::*MakeObj)(Path_t&))
179 {
180  GeoColl_t<ObjGeo> objs;
181 
182  //
183  // if this is a wire, we are set
184  //
185  if (IsObj(path.current())) {
186  objs.push_back((this->*MakeObj)(path));
187  return objs;
188  }
189 
190  //
191  // descend into the next layer down, concatenate the results and return them
192  //
193  if (path.depth() >= fMaxDepth) return objs; // yep, this is empty
194 
195  TGeoVolume const* volume = path.current().GetVolume();
196  int const n = volume->GetNdaughters();
197  for (int i = 0; i < n; ++i) {
198  path.append(*volume->GetNode(i));
199  extendCollection(objs, doExtractGeometryObjects(path, IsObj, MakeObj));
200  path.pop();
201  } // for
202 
203  return objs;
204 }
205 
206 //------------------------------------------------------------------------------
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:114
virtual OpDets_t doExtractOpDets(Path_t &path)
TPCs_t extractTPCs(Path_t &path)
Looks for all TPCs under the specified path.
Planes_t extractPlanes(Path_t &path)
Looks for all wire planes under the specified path.
virtual geo::PlaneGeo doMakePlane(Path_t &path)
Core implementation of makePlanes().
virtual geo::AuxDetSensitiveGeo doMakeAuxDetSensitive(Path_t &path)
Core implementation of makeAuxDetSensitive().
virtual geo::TPCGeo doMakeTPC(Path_t &path)
Core implementation of makeTPC().
geo::TPCGeo makeTPC(Path_t &path)
Constructs a geo::TPCGeo from the current node of the path.
GeometryBuilderStandard(Config const &config)
GeoColl_t< geo::AuxDetSensitiveGeo > AuxDetSensitive_t
Looks for all auxiliary detectors under the specified path.
Geometry information for a single TPC.
Definition: TPCGeo.h:36
GeoColl_t< ObjGeo > doExtractGeometryObjects(Path_t &path, std::function< bool(TGeoNode const &)> IsObj, ObjGeo(geo::GeometryBuilderStandard::*MakeObj)(Path_t &))
Boilerplate implementation of doExtractXxxx() methods.
GeoColl_t< geo::TPCGeo > TPCs_t
Looks for all TPCs under the specified path.
virtual geo::CryostatGeo doMakeCryostat(Path_t &path)
Core implementation of extractAuxDetSensitive().
virtual AuxDetSensitive_t doExtractAuxDetSensitive(Path_t &path)
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
void append(Node_t const &node)
Adds a node to the current path.
Definition: GeoNodePath.h:80
virtual geo::AuxDetGeo doMakeAuxDet(Path_t &path)
Core implementation of extractAuxiliaryDetectors().
GeoColl_t< geo::AuxDetGeo > AuxDets_t
Collection of auxiliary detector information objects.
OpDets_t extractOpDets(Path_t &path)
Looks for all optical detectors under the specified path.
virtual Cryostats_t doExtractCryostats(Path_t &path) override
virtual AuxDets_t doExtractAuxiliaryDetectors(Path_t &path) override
GeoColl_t< geo::WireGeo > Wires_t
Looks for all wires under the specified path.
void pop()
Removes the current node from the path, moving the current one up.
Definition: GeoNodePath.h:83
std::string fOpDetGeoName
Name of the optical detector nodes.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:78
virtual TPCs_t doExtractTPCs(Path_t &path)
GeoColl_t< geo::CryostatGeo > Cryostats_t
Collection of cryostat information objects.
Path_t::Depth_t fMaxDepth
Maximum level to descend into in the path.
Matrix currentTransformation() const
Returns the total transformation to the current node, as a Matrix.
Definition: GeoNodePath.h:104
virtual geo::OpDetGeo doMakeOpDet(Path_t &path)
Core implementation of makeOpDet().
GeoColl_t< geo::PlaneGeo > Planes_t
Looks for all wire planes under the specified path.
GeoColl_t< geo::OpDetGeo > OpDets_t
Looks for all optical detectors under the specified path.
Standard implementation of geometry extractor.
Wires_t extractWires(Path_t &path)
Looks for all wires under the specified path.
AuxDetSensitive_t extractAuxDetSensitive(Path_t &path)
Looks for all auxiliary detectors under the specified path.
virtual Wires_t doExtractWires(Path_t &path)
geo::OpDetGeo makeOpDet(Path_t &path)
Constructs a geo::OpDetGeo from the current node of the path.
Representation of a node and its ancestry.
Definition: GeoNodePath.h:37
Char_t n[5]
Node_t const & current() const
Returns the current node. Undefined if the path is empty.
Definition: GeoNodePath.h:74
geo::PlaneGeo makePlane(Path_t &path)
Constructs a geo::PlaneGeo from the current node of the path.
virtual Planes_t doExtractPlanes(Path_t &path)
Extracts of LArSoft geometry information from ROOT.
Depth_t depth() const
Returns the depth of the path (elements including up to the current).
Definition: GeoNodePath.h:71
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
std::vector< GeoObj > GeoColl_t
Type of direct collection of geometry objects.
geo::CryostatGeo makeCryostat(Path_t &path)
Constructs a geo::CryostatGeo from the current node of the path.
virtual geo::WireGeo doMakeWire(Path_t &path)
Core implementation of makeWire().
geo::WireGeo makeWire(Path_t &path)
Constructs a geo::WireGeo from the current node of the path.
geo::AuxDetSensitiveGeo makeAuxDetSensitive(Path_t &path)