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

Extracts of LArSoft geometry information from ROOT. More...

#include "GeometryBuilderStandard.h"

Inheritance diagram for geo::GeometryBuilderStandard:
geo::GeometryBuilder

Classes

struct  Config
 Configuration parameters. More...
 

Public Types

using AuxDetSensitive_t = GeoColl_t< AuxDetSensitiveGeo >
 
using OpDets_t = GeoColl_t< OpDetGeo >
 
using TPCs_t = GeoColl_t< TPCGeo >
 
using Path_t = GeoNodePath
 Identification of a single node in ROOT geometry. More...
 
template<typename GeoObj >
using GeoColl_t = std::vector< GeoObj >
 Type of direct collection of geometry objects. More...
 

Public Member Functions

 GeometryBuilderStandard (fhicl::Table< Config > const &config)
 
Auxiliary detector information

Name of the optical detector nodes.

AuxDetGeo makeAuxDet (Path_t &path) const
 Constructs a geo::AuxDetGeo from the current node of the path. More...
 
AuxDets_t doExtractAuxiliaryDetectors (Path_t &path) const override
 
Auxiliary detector sensitive volume information
AuxDetSensitive_t extractAuxDetSensitive (Path_t &path) const
 Looks for all auxiliary detectors under the specified path. More...
 
Cryostat information
CryostatGeo makeCryostat (Path_t &path) const
 Constructs a geo::CryostatGeo from the current node of the path. More...
 
Cryostats_t doExtractCryostats (Path_t &path) const override
 
Optical detector information
OpDets_t extractOpDets (Path_t &path) const
 Looks for all optical detectors under the specified path. More...
 
TPC information
TPCs_t extractTPCs (Path_t &path) const
 Looks for all TPCs under the specified path. More...
 
TPCGeo makeTPC (Path_t &path) const
 Constructs a geo::TPCGeo from the current node of the path. More...
 

Public Attributes

GeometryExtractor fExtractObjects
 
std::string fOpDetGeoName
 

Cryostat information

using Cryostats_t = GeoColl_t< CryostatGeo >
 Collection of cryostat information objects. More...
 
Cryostats_t extractCryostats (Path_t path) const
 Looks for all cryostats under the specified path. More...
 

Auxiliary detector information

using AuxDets_t = GeoColl_t< AuxDetGeo >
 Collection of auxiliary detector information objects. More...
 
AuxDets_t extractAuxiliaryDetectors (Path_t path) const
 Looks for all auxiliary detectors under the specified path. More...
 

Detailed Description

Extracts of LArSoft geometry information from ROOT.

The builder manages several components, each devoted to the extraction of a specific type of geometry object (e.g. cryostat, or wire plane within a TPC).

Further customization notes

This builder does not extend the interface of geo::GeometryBuilder, but it defines an interface that other builder classes can override to customize single elements of the build. As long as the interface is complied to, the different components are interchangeable.

If instead a different interface is needed for one component, the parent component needs to be customised too. For example, if the signature of doExtractPlanes() is changed, also doMakePlane() needs to be customized to correctly call the previous. In that case, take care of deleting the inherited interface to avoid confusion and errors.

Technical notes on customization

The internal structure of the builder follows the pattern already employed in the base class. The base class defines both the public interface and the implementation, but it separates the two leaving the former as non-virtual functions, and the latter as virtual functions accessible only by derived classes.

Definition at line 53 of file GeometryBuilderStandard.h.

Member Typedef Documentation

Collection of auxiliary detector information objects.

Definition at line 82 of file GeometryBuilder.h.

Collection of cryostat information objects.

Definition at line 62 of file GeometryBuilder.h.

template<typename GeoObj >
using geo::GeometryBuilder::GeoColl_t = std::vector<GeoObj>
inherited

Type of direct collection of geometry objects.

Definition at line 47 of file GeometryBuilder.h.

Identification of a single node in ROOT geometry.

Definition at line 43 of file GeometryBuilder.h.

Constructor & Destructor Documentation

geo::GeometryBuilderStandard::GeometryBuilderStandard ( fhicl::Table< Config > const &  config)
explicit

Definition at line 129 of file GeometryBuilderStandard.cxx.

130  : fExtractObjects(config().extractor()), fOpDetGeoName(config().opDetGeoName())
131 {}

Member Function Documentation

auto geo::GeometryBuilderStandard::doExtractAuxiliaryDetectors ( Path_t path) const
overridevirtual

Core implementation of extractCryostats().

The actual algorithm is specialization of doExtractGeometryObjects().

Implements geo::GeometryBuilder.

Definition at line 134 of file GeometryBuilderStandard.cxx.

References fExtractObjects, and makeAuxDet().

135 {
136  std::vector<AuxDetGeo> result;
138  path, isAuxDetNode, [&result, this](Path_t& path) { result.push_back(makeAuxDet(path)); });
139  return result;
140 }
AuxDetGeo makeAuxDet(Path_t &path) const
Constructs a geo::AuxDetGeo from the current node of the path.
GeoNodePath Path_t
Identification of a single node in ROOT geometry.
auto geo::GeometryBuilderStandard::doExtractCryostats ( Path_t path) const
overridevirtual

Core implementation of extractCryostats().

The actual algorithm is specialization of doExtractGeometryObjects().

Implements geo::GeometryBuilder.

Definition at line 161 of file GeometryBuilderStandard.cxx.

References fExtractObjects, and makeCryostat().

162 {
163  std::vector<CryostatGeo> result;
165  path, isCryostatNode, [&result, this](Path_t& path) { result.push_back(makeCryostat(path)); });
166  return result;
167 }
CryostatGeo makeCryostat(Path_t &path) const
Constructs a geo::CryostatGeo from the current node of the path.
GeoNodePath Path_t
Identification of a single node in ROOT geometry.
auto geo::GeometryBuilderStandard::extractAuxDetSensitive ( Path_t path) const

Looks for all auxiliary detectors under the specified path.

Parameters
pathpath pointing to the starting node
Returns
a list of fully constructed auxiliary detectors

The auxiliary detectors contain all their inner elements. The current node itself of the path is also considered as auxiliary detector candidate, then it is descended into.

Note
Multithreading note: path is allowed to change during processing.

Definition at line 151 of file GeometryBuilderStandard.cxx.

References fExtractObjects.

Referenced by makeAuxDet().

152 {
153  std::vector<AuxDetSensitiveGeo> result;
154  fExtractObjects(path, isAuxDetSensitiveNode, [&result](Path_t const& path) {
155  result.push_back(makeAuxDetSensitive(path));
156  });
157  return result;
158 }
GeoNodePath Path_t
Identification of a single node in ROOT geometry.
AuxDets_t geo::GeometryBuilder::extractAuxiliaryDetectors ( Path_t  path) const
inlineinherited

Looks for all auxiliary detectors under the specified path.

Parameters
pathpath pointing to the starting node
Returns
a list of fully constructed auxiliary detectors

The auxiliary detectors contain all their inner elements. The current node itself of the path is also considered as auxiliary detector candidate, then it is descended into.

Definition at line 93 of file GeometryBuilder.h.

References geo::GeometryBuilder::doExtractAuxiliaryDetectors(), and geo::GeometryBuilder::doExtractCryostats().

Referenced by geo::AuxDetGeometryCore::LoadGeometryFile().

94  {
95  return doExtractAuxiliaryDetectors(path);
96  }
virtual AuxDets_t doExtractAuxiliaryDetectors(Path_t &path) const =0
Cryostats_t geo::GeometryBuilder::extractCryostats ( Path_t  path) const
inlineinherited

Looks for all cryostats under the specified path.

Parameters
pathpath pointing to the starting node
Returns
a list of fully constructed cryostats

The cryostats contain all their inner elements. The current node itself of the path is also considered as cryostat candidate, then it is descended into.

Definition at line 72 of file GeometryBuilder.h.

References geo::GeometryBuilder::doExtractCryostats().

72 { return doExtractCryostats(path); }
virtual Cryostats_t doExtractCryostats(Path_t &path) const =0
auto geo::GeometryBuilderStandard::extractOpDets ( Path_t path) const

Looks for all optical detectors under the specified path.

Parameters
pathpath pointing to the starting node
Returns
a list of fully constructed optical detector objects

Definition at line 179 of file GeometryBuilderStandard.cxx.

References fExtractObjects, and fOpDetGeoName.

Referenced by makeCryostat().

180 {
181  std::vector<OpDetGeo> result;
183  path,
184  [this](auto const& node) { return isOpDetNode(node, fOpDetGeoName); },
185  [&result](Path_t const& path) { result.push_back(makeOpDet(path)); });
186  return result;
187 }
GeoNodePath Path_t
Identification of a single node in ROOT geometry.
auto geo::GeometryBuilderStandard::extractTPCs ( Path_t path) const

Looks for all TPCs under the specified path.

Parameters
pathpath pointing to the starting node
Returns
a list of fully constructed TPC objects

Each TPC has its own wire planes already in.

Definition at line 190 of file GeometryBuilderStandard.cxx.

References fExtractObjects, and makeTPC().

Referenced by makeCryostat().

191 {
192  std::vector<TPCGeo> result;
194  path, isTPCNode, [&result, this](Path_t& path) { result.push_back(makeTPC(path)); });
195  return result;
196 }
GeoNodePath Path_t
Identification of a single node in ROOT geometry.
TPCGeo makeTPC(Path_t &path) const
Constructs a geo::TPCGeo from the current node of the path.
geo::AuxDetGeo geo::GeometryBuilderStandard::makeAuxDet ( Path_t path) const

Constructs a geo::AuxDetGeo from the current node of the path.

Definition at line 143 of file GeometryBuilderStandard.cxx.

References geo::GeoNodePath::current(), geo::GeoNodePath::currentTransformation(), and extractAuxDetSensitive().

Referenced by doExtractAuxiliaryDetectors().

144 {
145  return {path.current(),
146  path.currentTransformation<TransformationMatrix>(),
147  extractAuxDetSensitive(path)};
148 }
AuxDetSensitive_t extractAuxDetSensitive(Path_t &path) const
Looks for all auxiliary detectors under the specified path.
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
geo::CryostatGeo geo::GeometryBuilderStandard::makeCryostat ( Path_t path) const

Constructs a geo::CryostatGeo from the current node of the path.

Definition at line 170 of file GeometryBuilderStandard.cxx.

References geo::GeoNodePath::current(), geo::GeoNodePath::currentTransformation(), extractOpDets(), and extractTPCs().

Referenced by doExtractCryostats().

171 {
172  return {path.current(),
173  path.currentTransformation<TransformationMatrix>(),
174  extractTPCs(path),
175  extractOpDets(path)};
176 }
TPCs_t extractTPCs(Path_t &path) const
Looks for all TPCs under the specified path.
OpDets_t extractOpDets(Path_t &path) const
Looks for all optical detectors under the specified path.
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
geo::TPCGeo geo::GeometryBuilderStandard::makeTPC ( Path_t path) const

Constructs a geo::TPCGeo from the current node of the path.

Definition at line 199 of file GeometryBuilderStandard.cxx.

References geo::GeoNodePath::current_entry(), geo::GeoNodePath::currentTransformation(), geo::vect::dot(), fExtractObjects, geo::PlaneGeo::GetBoxCenter(), recob::tracking::makePlane(), geo::makeTransformationMatrix(), geo::TPCGeo::NodeForActiveVolume(), geo::vect::normalize(), and geo::vect::toPoint().

Referenced by extractTPCs().

200 {
201  auto const [tpc, hash_value] = path.current_entry();
202  auto tpc_matrix = path.currentTransformation<TransformationMatrix>();
203 
204  std::vector<PlaneGeo> planes;
206  path, isPlaneNode, [&planes](Path_t& path) { planes.push_back(makePlane(path)); });
207 
208  // we don't keep the active volume information... just store its center:
209  auto const* active_volume_node = TPCGeo::NodeForActiveVolume(tpc);
210  assert(active_volume_node);
211 
212  auto const daughter_matrix =
213  tpc_matrix * makeTransformationMatrix(*active_volume_node->GetMatrix());
214  auto const active_volume_center =
215  vect::toPoint(daughter_matrix(ROOT::Math::Transform3D::Point{}));
216 
217  auto const driftAxisWithSign = DriftAxisWithSign(active_volume_center, planes);
218  auto const driftAxis = vect::normalize(planes[0].GetBoxCenter() - active_volume_center);
219  double distance_to_last_plane{std::numeric_limits<double>::min()};
220  geo::PlaneGeo const* last_plane = nullptr;
221  for (auto const& plane : planes) {
222  double const distance = vect::dot(plane.GetBoxCenter() - active_volume_center, driftAxis);
223  if (distance > distance_to_last_plane) {
224  distance_to_last_plane = distance;
225  last_plane = &plane;
226  }
227  }
228 
229  auto const* active_volume_box =
230  static_cast<TGeoBBox const*>(active_volume_node->GetVolume()->GetShape());
231  auto const drift_distance = driftDistance(
232  active_volume_center, driftAxisWithSign, active_volume_box, last_plane->GetBoxCenter());
233 
234  return {tpc, hash_value, std::move(tpc_matrix), driftAxisWithSign, drift_distance};
235 }
Point_t GetBoxCenter() const
Returns the centre of the box representing the plane.
Definition: PlaneGeo.h:380
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:67
Plane makePlane(recob::tracking::Point_t const &pos, recob::tracking::Vector_t const &dir)
helper function to construct a recob::tracking::Plane from a Point_t and a Vector_t; the point is on ...
decltype(auto) makeTransformationMatrix(Trans &&trans)
Converts a transformation matrix into a geo::TransformationMatrix.
Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
static TGeoNode const * NodeForActiveVolume(TGeoNode const *tpc)
Definition: TPCGeo.cxx:213
constexpr auto dot(Vector const &a, OtherVector const &b)
Return cross product of two vectors.
GeoNodePath Path_t
Identification of a single node in ROOT geometry.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42
Vector normalize(Vector const &v)
Returns a vector parallel to v and with norm 1.
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.

Member Data Documentation

GeometryExtractor geo::GeometryBuilderStandard::fExtractObjects
std::string geo::GeometryBuilderStandard::fOpDetGeoName

Definition at line 77 of file GeometryBuilderStandard.h.

Referenced by extractOpDets().


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