GeometryBuilderStandard.cxx
Go to the documentation of this file.
1 /**
2  * @file larcorealg/Geometry/GeometryBuilderStandard.cxx
3  * @brief Standard implementation of geometry extractor (implementation file).
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date January 29, 2019
6  * @see `larcorealg/Geometry/GeometryBuilderStandard.h`
7  */
8 
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 
22 namespace {
23 
24  //------------------------------------------------------------------------------
25  template <typename Dest, typename Src>
26  Dest& extendCollection(Dest& dest, Src&& src) {
27  std::move(src.begin(), src.end(), std::back_inserter(dest));
28  return dest;
29  } // extend()
30 
31 
32  //------------------------------------------------------------------------------
33 
34 } // local namespace
35 
36 
37 
38 //------------------------------------------------------------------------------
40  : fMaxDepth(config.maxDepth())
41  , fOpDetGeoName(config.opDetGeoName())
42  {}
43 
44 
45 //------------------------------------------------------------------------------
48 
53  >
54  (path);
55 
56 } // geo::GeometryBuilderStandard::doExtractAuxiliaryDetectors()
57 
58 
59 //------------------------------------------------------------------------------
61 
62  return geo::AuxDetGeo(
65  );
66 
67 } // geo::GeometryBuilderStandard::doMakeAuxDet()
68 
69 
70 //------------------------------------------------------------------------------
77  >
78  (path);
79 } // geo::GeometryBuilderStandard::doExtractAuxDetSensitive()
80 
81 
82 //------------------------------------------------------------------------------
84  (Path_t& path)
85 {
88 } // geo::GeometryBuilderStandard::doMakeAuxDetSensitive()
89 
90 
91 //------------------------------------------------------------------------------
94 
99  >
100  (path);
101 
102 } // geo::GeometryBuilderStandard::doExtractCryostats()
103 
104 
105 //------------------------------------------------------------------------------
107 
108  return geo::CryostatGeo(
110  extractTPCs(path),
111  extractOpDets(path)
112  );
113 
114 } // geo::GeometryBuilderStandard::doMakeCryostat()
115 
116 
117 //------------------------------------------------------------------------------
124  >
125  (path);
126 } // geo::GeometryBuilderStandard::doExtractOpDets()
127 
128 
129 //------------------------------------------------------------------------------
131  return geo::OpDetGeo
133 } // geo::GeometryBuilderStandard::doMakeOpDet()
134 
135 
136 //------------------------------------------------------------------------------
138  (Path_t& path)
139 {
141  geo::TPCGeo,
144  >
145  (path);
146 
147 } // geo::GeometryBuilderStandard::doExtractTPCs()
148 
149 
150 //------------------------------------------------------------------------------
152  return geo::TPCGeo(
154  extractPlanes(path)
155  );
156 } // geo::GeometryBuilderStandard::doMakeTPC()
157 
158 
159 //------------------------------------------------------------------------------
162 {
167  >
168  (path);
169 
170 } // geo::GeometryBuilderStandard::doExtractPlanes()
171 
172 
173 //------------------------------------------------------------------------------
175  return geo::PlaneGeo(
177  extractWires(path)
178  );
179 } // geo::GeometryBuilderStandard::doMakePlane()
180 
181 
182 //------------------------------------------------------------------------------
185 {
187  geo::WireGeo,
190  >
191  (path);
192 
193 } // geo::GeometryBuilderStandard::doExtractWires()
194 
195 
196 //------------------------------------------------------------------------------
198 
199  return geo::WireGeo
201 
202 } // geo::GeometryBuilderStandard::doMakeWire()
203 
204 
205 //------------------------------------------------------------------------------
206 bool geo::GeometryBuilderStandard::isAuxDetNode(TGeoNode const& node) const {
207  using namespace std::literals;
208  return starts_with(node.GetName(), "volAuxDet"sv);
209 } // geo::GeometryBuilderStandard::isAuxDetNode()
210 
211 
212 //------------------------------------------------------------------------------
214  (TGeoNode const& node) const
215 {
216  return std::string_view(node.GetName()).find("Sensitive")
217  != std::string_view::npos;
218 } // geo::GeometryBuilderStandard::isAuxDetSensitiveNode()
219 
220 
221 //------------------------------------------------------------------------------
222 bool geo::GeometryBuilderStandard::isCryostatNode(TGeoNode const& node) const {
223  using namespace std::literals;
224  return starts_with(node.GetName(), "volCryostat"sv);
225 } // geo::GeometryBuilderStandard::isCryostatNode()
226 
227 
228 //------------------------------------------------------------------------------
229 bool geo::GeometryBuilderStandard::isOpDetNode(TGeoNode const& node) const {
230  return starts_with(node.GetName(), fOpDetGeoName);
231 } // geo::GeometryBuilderStandard::isOpDetNode()
232 
233 
234 
235 //------------------------------------------------------------------------------
236 bool geo::GeometryBuilderStandard::isTPCNode(TGeoNode const& node) const {
237  using namespace std::literals;
238  return starts_with(node.GetName(), "volTPC"sv);
239 } // geo::GeometryBuilderStandard::isTPCNode()
240 
241 
242 //------------------------------------------------------------------------------
243 bool geo::GeometryBuilderStandard::isPlaneNode(TGeoNode const& node) const {
244  using namespace std::literals;
245  return starts_with(node.GetName(), "volTPCPlane"sv);
246 } // geo::GeometryBuilderStandard::isPlaneNode()
247 
248 
249 //------------------------------------------------------------------------------
250 bool geo::GeometryBuilderStandard::isWireNode(TGeoNode const& node) const {
251  using namespace std::literals;
252  return starts_with(node.GetName(), "volTPCWire"sv);
253 } // geo::GeometryBuilderStandard::isWireNode()
254 
255 
256 //------------------------------------------------------------------------------
257 template <
258  typename ObjGeo,
259  bool (geo::GeometryBuilderStandard::*IsObj)(TGeoNode const&) const,
261  >
264  Path_t& path
265 ) {
266 
268 
269  //
270  // if this is a wire, we are set
271  //
272  if ((this->*IsObj)(path.current())) {
273  objs.push_back((this->*MakeObj)(path));
274  return objs;
275  }
276 
277  //
278  // descend into the next layer down, concatenate the results and return them
279  //
280  if (path.depth() >= fMaxDepth) return objs; // yep, this is empty
281 
282  TGeoVolume const& volume = *(path.current().GetVolume());
283  int const n = volume.GetNdaughters();
284  for (int i = 0; i < n; ++i) {
285  path.append(*(volume.GetNode(i)));
286  extendCollection(objs, doExtractGeometryObjects<ObjGeo, IsObj, MakeObj>(path));
287  path.pop();
288  } // for
289 
290  return objs;
291 
292 } // geo::GeometryBuilderStandard::doExtractGeometryObjects()
293 
294 
295 //------------------------------------------------------------------------------
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
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
Geometry information for a single TPC.
Definition: TPCGeo.h:38
bool isCryostatNode(TGeoNode const &node) const
Returns whether the specified node is recognised as a cryostat.
static const std::string volume[nvol]
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:85
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
GeoColl_t< ObjGeo > doExtractGeometryObjects(Path_t &path)
Boilerplate implementation of doExtractXxxx() methods.
virtual AuxDets_t doExtractAuxiliaryDetectors(Path_t &path) override
bool isTPCNode(TGeoNode const &node) const
Returns whether the specified node is recognised as a TPC.
GeoColl_t< geo::WireGeo > Wires_t
static Config * config
Definition: config.cpp:1054
std::void_t< T > n
void pop()
Removes the current node from the path, moving the current one up.
Definition: GeoNodePath.h:88
bool isOpDetNode(TGeoNode const &node) const
Returns whether the specified node is recognised as a optical detector.
def move(depos, offset)
Definition: depos.py:107
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:82
virtual TPCs_t doExtractTPCs(Path_t &path)
GeoColl_t< geo::CryostatGeo > Cryostats_t
Collection of cryostat information objects.
bool isWireNode(TGeoNode const &node) const
Returns whether the specified node is recognised as a wire.
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:114
virtual geo::OpDetGeo doMakeOpDet(Path_t &path)
Core implementation of makeOpDet().
GeoColl_t< geo::PlaneGeo > Planes_t
GeoColl_t< geo::OpDetGeo > OpDets_t
Standard implementation of geometry extractor.
Wires_t extractWires(Path_t &path)
Looks for all wires under the specified path.
bool isPlaneNode(TGeoNode const &node) const
Returns whether the specified node is recognised as a wire plane.
bool isAuxDetSensitiveNode(TGeoNode const &node) const
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:38
Node_t const & current() const
Returns the current node. Undefined if the path is empty.
Definition: GeoNodePath.h:78
geo::PlaneGeo makePlane(Path_t &path)
Constructs a geo::PlaneGeo from the current node of the path.
virtual Planes_t doExtractPlanes(Path_t &path)
int bool
Definition: qglobal.h:345
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:75
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().
static bool starts_with(std::string_view const &s, std::string_view const &key)
bool isAuxDetNode(TGeoNode const &node) const
geo::WireGeo makeWire(Path_t &path)
Constructs a geo::WireGeo from the current node of the path.
geo::AuxDetSensitiveGeo makeAuxDetSensitive(Path_t &path)