LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
geo::GeometryCore Class Reference

Description of the physical geometry of one entire detector. More...

#include "GeometryCore.h"

Inheritance diagram for geo::GeometryCore:
geo::Iterable< details::GeometryIterationPolicy, details::ToGeometryElement > geo::Geometry

Public Types

using CryostatList_t = std::vector< CryostatGeo >
 

Public Member Functions

 GeometryCore (fhicl::ParameterSet const &pset, std::unique_ptr< GeometryBuilder > builder, std::unique_ptr< GeoObjectSorter > sorter)
 Initialize geometry from a given configuration. More...
 
 GeometryCore (GeometryCore const &)=delete
 
 GeometryCore (GeometryCore &&)=delete
 
GeometryCoreoperator= (GeometryCore const &)=delete
 
GeometryCoreoperator= (GeometryCore &&)=delete
 
double DefaultWiggle () const
 Returns the tolerance used in looking for positions. More...
 
std::string const & GDMLFile () const
 Returns the full directory path to the GDML file source. More...
 
std::vector< TGeoNode const * > FindAllVolumes (std::set< std::string > const &vol_names) const
 Returns all the nodes with volumes with any of the specified names. More...
 
std::vector< std::vector< TGeoNode const * > > FindAllVolumePaths (std::set< std::string > const &vol_names) const
 Returns paths of all nodes with volumes with the specified names. More...
 
TGeoMaterial const * Material (Point_t const &point) const
 Returns the material at the specified position. More...
 
template<typename Stream >
void Print (Stream &&out, std::string indent=" ") const
 Prints geometry information with maximum verbosity. More...
 
std::string Info (std::string indent=" ") const
 Returns a string with complete geometry information. More...
 
CryostatGeo const * PositionToCryostatPtr (Point_t const &point) const
 Returns the cryostat at specified location. More...
 
CryostatID PositionToCryostatID (Point_t const &point) const
 Returns the ID of the cryostat at specified location. More...
 
bool HasTPC (TPCID const &tpcid) const
 Returns whether we have the specified TPC. More...
 
bool HasElement (TPCID const &tpcid) const
 Returns whether we have the specified TPC. More...
 
TPCGeo const * PositionToTPCptr (Point_t const &point) const
 Returns the TPC at specified location. More...
 
TPCID PositionToTPCID (Point_t const &point) const
 Returns the ID of the TPC at specified location. More...
 
std::string OpDetGeoName (CryostatID const &cid=details::cryostat_zero) const
 Returns gdml string which gives sensitive opdet name. More...
 
CryostatList_t const & Cryostats () const noexcept
 
Detector information
std::string const & DetectorName () const
 Returns a string with the name of the detector, as configured. More...
 
TGeoVolume const * WorldVolume () const
 Returns a pointer to the world volume. More...
 
void WorldBox (double *xlo, double *xhi, double *ylo, double *yhi, double *zlo, double *zhi) const
 Fills the arguments with the boundaries of the world. More...
 
BoxBoundedGeo WorldBox () const
 
Length_t SurfaceY () const
 The position of the detector respect to earth surface. More...
 
TGeoManager * ROOTGeoManager () const
 Access to the ROOT geometry description manager. More...
 
std::string const & GetWorldVolumeName () const
 Return the name of the world volume (needed by Geant4 simulation) More...
 
BoxBoundedGeo DetectorEnclosureBox (std::string const &name="volDetEnclosure") const
 
std::string VolumeName (Point_t const &point) const
 Returns the name of the deepest volume containing specified point. More...
 
std::string MaterialName (Point_t const &point) const
 Name of the deepest material containing the point xyz. More...
 
double TotalMass () const
 Returns the total mass [kg] of the specified volume (default: world). More...
 
double TotalMass (std::string vol) const
 Returns the total mass [kg] of the specified volume (default: world). More...
 
double MassBetweenPoints (Point_t const &p1, Point_t const &p2) const
 Returns the column density between two points. More...
 
Cryostat access and information
unsigned int Ncryostats () const
 Returns the number of cryostats in the detector. More...
 
unsigned int NElements () const
 Returns the number of cryostats in the detector. More...
 
unsigned int NSiblingElements (CryostatID const &) const
 Returns the number of cryostats in the detector. More...
 
bool HasCryostat (CryostatID const &cryoid) const
 Returns whether we have the specified cryostat. More...
 
bool HasElement (CryostatID const &cryoid) const
 Returns whether we have the specified cryostat. More...
 
CryostatGeo const & Cryostat (CryostatID const &cryoid=details::cryostat_zero) const
 Returns the specified cryostat. More...
 
CryostatGeo const & GetElement (CryostatID const &cryoid) const
 Returns the specified cryostat. More...
 
CryostatGeo const * CryostatPtr (CryostatID const &cryoid) const
 Returns the specified cryostat. More...
 
CryostatGeo const * GetElementPtr (CryostatID const &cryoid) const
 Returns the specified cryostat. More...
 
CryostatGeo const & PositionToCryostat (Point_t const &point) const
 Returns the cryostat at specified location. More...
 
TPC access and information
unsigned int MaxTPCs () const
 Returns the largest number of TPCs a cryostat in the detector has. More...
 
unsigned int TotalNTPC () const
 Returns the total number of TPCs in the detector. More...
 
unsigned int NTPC (CryostatID const &cryoid=details::cryostat_zero) const
 Returns the total number of TPCs in the specified cryostat. More...
 
unsigned int NElements (CryostatID const &cryoid) const
 Returns the largest number of TPCs a cryostat in the detector has. More...
 
unsigned int NSiblingElements (TPCID const &tpcid) const
 Returns the largest number of TPCs a cryostat in the detector has. More...
 
TPCGeo const & TPC (TPCID const &tpcid=details::tpc_zero) const
 Returns the specified TPC. More...
 
TPCGeo const & GetElement (TPCID const &tpcid) const
 Returns the specified TPC. More...
 
TPCGeo const * TPCPtr (TPCID const &tpcid) const
 Returns the specified TPC. More...
 
TPCGeo const * GetElementPtr (TPCID const &tpcid) const
 Returns the specified TPC. More...
 
TPCID FindTPCAtPosition (Point_t const &point) const
 Returns the ID of the TPC at specified location. More...
 
TPCGeo const & PositionToTPC (Point_t const &point) const
 Returns the TPC at specified location. More...
 
Optical detector geometry access and information

See also
optical detector channel information

There are a number of ways to identify an optical detector or channel:

  • geometric:
    • cryostat (e.g. geo::CryostatID) and relative optical detector number within it
    • unique optical detector number
  • readout:
    • optical detector channel
    • "hardware" channel

And they all should be better documented!

unsigned int NOpDets () const
 Number of OpDets in the whole detector. More...
 
OpDetGeo const & OpDetGeoFromOpDet (unsigned int OpDet) const
 Returns the geo::OpDetGeo object for the given detector number. More...
 
unsigned int GetClosestOpDet (Point_t const &point) const
 Find the nearest OpChannel to some point. More...
 
Optical readout channels
unsigned int OpDetFromCryo (unsigned int o, unsigned int c) const
 Get unique opdet number from cryo and internal count. More...
 

Private Types

using Iteration = Iterable< details::GeometryIterationPolicy, details::ToGeometryElement >
 
using range_type = details::RangeType< iterator_type< T >, id_sentinel_for< T >>
 

Private Member Functions

void LoadGeometryFile ()
 
void SortGeometry ()
 
std::vector< GeoNodePathEntryFindDetectorEnclosure (std::string const &name="volDetEnclosure") const
 
bool FindFirstVolume (std::string const &name, std::vector< GeoNodePathEntry > &path) const
 
void BuildGeometry ()
 Parses ROOT geometry nodes and builds LArSoft geometry representation. More...
 
iterator_type< T > begin () const
 
iterator_type< T > begin (BaseID const &id) const
 
id_sentinel_for< T > end () const
 
id_sentinel_for< T > end (BaseID const &id) const
 
range_type< T > Iterate () const
 
range_type< T > Iterate (ID const &id) const
 

Private Attributes

CryostatList_t fCryostats {}
 
std::unique_ptr< GeometryBuilderfBuilder
 
std::unique_ptr< GeoObjectSorterfSorter
 
TGeoManager * fManager {nullptr}
 
std::string fGDMLfile
 path to geometry file used for Geant4 simulation More...
 
std::string fDetectorName
 Name of the detector. More...
 
double fSurfaceY
 The point where air meets earth for this detector. More...
 
double fPositionWiggle
 accounting for rounding errors when testing positions More...
 

Detailed Description

Description of the physical geometry of one entire detector.


Note
All lengths are specified in centimeters

GeometryCore construction

The constructor of GeometryCore performs two steps:

  1. It initializes a GeometryCore object (the "service provider") with the configuration parameters, a user-provided geometry builder, and a user-provided geometry sorter.
  2. It loads the geometry with GeometryCore::LoadGeometryFile(), which: a. imports the GDML file into ROOT's TGeo* system b. builds all LArSoft geometry constructs using ROOT's geometry system according to the user-provided builder c. sorts all LArSoft geometry constructs according to the provided sorter.

Configuration parameters

  • GDML (string; mandatory): string identifying GDML file that represents the detector goemetry.
  • RelativePath (string; default: (empty)): string identifying path of GDML file relative to any paths on the FW_SEARCH_PATH environment variable.
  • Name (string; default: stem of GDML file): string identifying the detector; it can be different from the base name of the file used to initialize the geometry; standard names are recommended by each experiment.
  • SurfaceY (real; mandatory): depth of the detector, in centimeters; see SurfaceY() for details
  • PositionEpsilon (real; default: 0.01%) set the default tolerance (see DefaultWiggle())

Definition at line 91 of file GeometryCore.h.

Member Typedef Documentation

Definition at line 95 of file GeometryCore.h.

Constructor & Destructor Documentation

geo::GeometryCore::GeometryCore ( fhicl::ParameterSet const &  pset,
std::unique_ptr< GeometryBuilder builder,
std::unique_ptr< GeoObjectSorter sorter 
)

Initialize geometry from a given configuration.

Parameters
psetconfiguration parameters
builderbuilder for LArSoft's geometry constructs
sortersorter for LArSoft's geometry constructs, applied after building is complete

Definition at line 50 of file GeometryCore.cxx.

References fBuilder, fDetectorName, fGDMLfile, fPositionWiggle, fSorter, fSurfaceY, LoadGeometryFile(), geo::details::maybe_default_detector_name(), and lar::searchPathPlusRelative().

53  : Iteration{details::GeometryIterationPolicy{this}, details::ToGeometryElement{this}}
54  , fBuilder{std::move(builder)}
55  , fSorter{std::move(sorter)}
56  , fGDMLfile{lar::searchPathPlusRelative(pset.get<std::string>("RelativePath", ""),
57  pset.get<std::string>("GDML"))}
59  , fSurfaceY(pset.get<double>("SurfaceY"))
60  , fPositionWiggle(pset.get<double>("PositionEpsilon", 1.e-4))
61  {
62  std::transform(fDetectorName.begin(), fDetectorName.end(), fDetectorName.begin(), [](auto c) {
63  return std::tolower(c);
64  });
65 
67  }
double fSurfaceY
The point where air meets earth for this detector.
Definition: GeometryCore.h:613
std::string searchPathPlusRelative(std::string relativePath, std::string fileName)
std::unique_ptr< GeoObjectSorter > fSorter
Definition: GeometryCore.h:608
double fPositionWiggle
accounting for rounding errors when testing positions
Definition: GeometryCore.h:614
std::string fGDMLfile
path to geometry file used for Geant4 simulation
Definition: GeometryCore.h:611
std::string maybe_default_detector_name(fhicl::ParameterSet const &pset, std::string const &filename)
std::unique_ptr< GeometryBuilder > fBuilder
Definition: GeometryCore.h:607
std::string fDetectorName
Name of the detector.
Definition: GeometryCore.h:612
Iterable< details::GeometryIterationPolicy, details::ToGeometryElement > Iteration
Definition: GeometryCore.h:92
geo::GeometryCore::GeometryCore ( GeometryCore const &  )
delete
geo::GeometryCore::GeometryCore ( GeometryCore &&  )
delete

Member Function Documentation

Definition at line 72 of file Iterable.h.

Referenced by GetElementPtr().

73  {
74  using namespace details;
75  using ID = typename IDIteratorValueType<T>::type;
76  auto const iterator = iterator_for(ID::first(), fPolicy);
77  if constexpr (std::is_base_of<CryostatID, T>{}) { return iterator; }
78  else {
79  static_assert(!std::is_same_v<Transform, void_tag>);
80  return fTransform.template transform<T>(iterator);
81  }
82  }
intermediate_table::iterator iterator
auto iterator_for(LocalID const &id, SiblingPolicy const &siblingPolicy)
Definition: id_iterators.h:236
std::conditional_t< std::is_same_v< details::ToGeometryElement, void >, void_tag, details::ToGeometryElement > fTransform
Definition: Iterable.h:134
iterator_type<T> geo::Iterable< details::GeometryIterationPolicy , details::ToGeometryElement >::begin ( BaseID const &  id) const
inlineinherited

Definition at line 85 of file Iterable.h.

86  {
87  using namespace details;
88  using ID = typename IDIteratorValueType<T>::type;
89  static_assert(is_base_of_strict<BaseID, ID>);
90  auto const iterator = iterator_for(ID::first(id), fPolicy);
91  if constexpr (std::is_base_of<CryostatID, T>{}) { return iterator; }
92  else {
93  static_assert(!std::is_same_v<Transform, void_tag>);
94  return fTransform.template transform<T>(iterator);
95  }
96  }
intermediate_table::iterator iterator
auto iterator_for(LocalID const &id, SiblingPolicy const &siblingPolicy)
Definition: id_iterators.h:236
std::conditional_t< std::is_same_v< details::ToGeometryElement, void >, void_tag, details::ToGeometryElement > fTransform
Definition: Iterable.h:134
void geo::GeometryCore::BuildGeometry ( )
private

Parses ROOT geometry nodes and builds LArSoft geometry representation.

Definition at line 527 of file GeometryCore.cxx.

References fBuilder, and fCryostats.

Referenced by LoadGeometryFile().

528  {
529  GeoNodePath path{gGeoManager->GetTopNode()};
530  fCryostats = fBuilder->extractCryostats(path);
531  }
CryostatList_t fCryostats
Definition: GeometryCore.h:605
std::unique_ptr< GeometryBuilder > fBuilder
Definition: GeometryCore.h:607
CryostatGeo const & geo::GeometryCore::Cryostat ( CryostatID const &  cryoid = details::cryostat_zero) const

Returns the specified cryostat.

Parameters
cryoidcryostat ID
Returns
a constant reference to the specified cryostat
Exceptions
cet::exception(GeometryCore category) if cryostat not present

The GetElement() method is overloaded and its return depends on the type of ID.

Todo:
Make the cryostat number mandatory (as CryostatID)

Definition at line 150 of file GeometryCore.cxx.

References geo::CryostatID::Cryostat, and CryostatPtr().

Referenced by phot::PDFastSimANN::beginJob(), opdet::SimPhotonCounter::beginJob(), larg4::LArG4::beginJob(), evgen::PhotonGen::beginRun(), larg4::LArVoxelReadoutGeometry::Construct(), detinfo::DetectorPropertiesStandard::DataFor(), cosmic::BeamFlashTrackMatchTaggerAlg::FillFlashProperties(), opdet::FlashHypothesisAnaAlg::FillOpDetPositions(), simfilter::FilterNoDirtNeutrinos::filter(), GetElement(), HasElement(), trkf::SpacePointAlg::makeSpacePoints(), OpDetFromCryo(), OpDetGeoFromOpDet(), evgen::PhotonGen::PhotonGen(), larg4::LArG4::produce(), phot::PhotonVisibilityService::reconfigure(), and TPC().

151  {
152  if (auto pCryo = CryostatPtr(cryoid)) { return *pCryo; }
153  throw cet::exception("GeometryCore") << "Cryostat #" << cryoid.Cryostat << " does not exist\n";
154  }
CryostatGeo const * CryostatPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:345
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
CryostatGeo const* geo::GeometryCore::CryostatPtr ( CryostatID const &  cryoid) const
inline

Returns the specified cryostat.

Parameters
cryoidcryostat ID
Returns
a constant pointer to the specified cryostat, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 345 of file GeometryCore.h.

References geo::CryostatID::Cryostat, fCryostats, and HasCryostat().

Referenced by Cryostat(), GetElementPtr(), HasTPC(), and TPCPtr().

346  {
347  return HasCryostat(cryoid) ? &fCryostats[cryoid.Cryostat] : nullptr;
348  }
CryostatList_t fCryostats
Definition: GeometryCore.h:605
bool HasCryostat(CryostatID const &cryoid) const
Returns whether we have the specified cryostat.
Definition: GeometryCore.h:318
CryostatList_t const& geo::GeometryCore::Cryostats ( ) const
inlinenoexcept

Definition at line 599 of file GeometryCore.h.

References fCryostats, LoadGeometryFile(), and SortGeometry().

599 { return fCryostats; }
CryostatList_t fCryostats
Definition: GeometryCore.h:605
double geo::GeometryCore::DefaultWiggle ( ) const
inline

Returns the tolerance used in looking for positions.

Returns
the tolerance value

This parameter is used as tolerance ("wiggle") for methods that require it (e.g. geo::CryostatGeo::FindTPCAtPosition()). Typically, it's a additional fraction of tolerance: 0 means no tolerance, 0.1 means 10% tolerance.

Todo:
Confirm the definition of wiggle: this one is taken from other doc

Definition at line 121 of file GeometryCore.h.

References fPositionWiggle.

121 { return fPositionWiggle; }
double fPositionWiggle
accounting for rounding errors when testing positions
Definition: GeometryCore.h:614
BoxBoundedGeo geo::GeometryCore::DetectorEnclosureBox ( std::string const &  name = "volDetEnclosure") const

Returns the absolute coordinates of the detector enclosure volume [cm].

Parameters
namename of the volume to be sought (default: volDetEnclosure)
Exceptions
cet::exceptionif the specified volume is not found

Definition at line 221 of file GeometryCore.cxx.

References FindDetectorEnclosure(), and geo::LocalTransformation< StoredMatrix >::LocalToWorld().

Referenced by geo::WireReadoutDumper::dumpDetectorInfo(), Print(), and SurfaceY().

223  {
224  auto const& path = FindDetectorEnclosure(name);
225  if (path.empty()) {
226  throw cet::exception("GeometryCore")
227  << "DetectorEnclosureBox(): can't find enclosure volume '" << name << "'\n";
228  }
229 
230  TGeoVolume const* pEncl = path.back().node->GetVolume();
231  auto const* pBox = dynamic_cast<TGeoBBox const*>(pEncl->GetShape());
232 
233  // check that this is indeed a box
234  if (!pBox) {
235  // at initialisation time we don't know yet our real ID
236  throw cet::exception("GeometryCore")
237  << "Detector enclosure '" << name << "' is not a box! (it is a "
238  << pEncl->GetShape()->IsA()->GetName() << ")\n";
239  }
240 
241  LocalTransformation<TGeoHMatrix> trans(path, path.size() - 1);
242  // get the half width, height, etc of the cryostat
243  double const halfwidth = pBox->GetDX();
244  double const halfheight = pBox->GetDY();
245  double const halflength = pBox->GetDZ();
246 
247  return {trans.LocalToWorld(Point_t{-halfwidth, -halfheight, -halflength}),
248  trans.LocalToWorld(Point_t{+halfwidth, +halfheight, +halflength})};
249  }
std::vector< GeoNodePathEntry > FindDetectorEnclosure(std::string const &name="volDetEnclosure") const
recob::tracking::Point_t Point_t
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Definition at line 99 of file Iterable.h.

Referenced by GetElementPtr().

100  {
101  using namespace details;
102  using ID = typename IDIteratorValueType<T>::type;
103  static_assert(std::is_base_of<CryostatID, ID>{});
104  return {fPolicy.template GetEndID<ID>()};
105  }
id_sentinel_for<T> geo::Iterable< details::GeometryIterationPolicy , details::ToGeometryElement >::end ( BaseID const &  id) const
inlineinherited

Definition at line 108 of file Iterable.h.

109  {
110  using namespace details;
111  using ID = typename IDIteratorValueType<T>::type;
112  static_assert(std::is_base_of<CryostatID, ID>{});
113  static_assert(is_base_of_strict<BaseID, ID>);
114  return {fPolicy.template GetEndID<ID>(id)};
115  }
std::vector< std::vector< TGeoNode const * > > geo::GeometryCore::FindAllVolumePaths ( std::set< std::string > const &  vol_names) const

Returns paths of all nodes with volumes with the specified names.

Parameters
vol_nameslist of names of volumes
Returns
list paths of the found nodes

All the nodes in the geometry are checked, and the path of all the ones that contain a volume with a name among the ones specified in vol_names is saved in the collection and returned.

A node path is a ordered list of all nodes leading to the final one, starting from thetop level (root) down. The node at the back() of the path is the one with name in vol_names. No empty paths are returned.

Definition at line 363 of file GeometryCore.cxx.

References geo::CollectPathsByName::paths, and ROOTGeoManager().

Referenced by SurfaceY().

365  {
366  CollectPathsByName path_collector(vol_names);
367 
368  ROOTGeoNodeForwardIterator iNode(ROOTGeoManager()->GetTopNode());
369 
370  while (*iNode) {
371  path_collector(iNode);
372  ++iNode;
373  }
374 
375  return path_collector.paths;
376  }
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
std::vector< TGeoNode const * > geo::GeometryCore::FindAllVolumes ( std::set< std::string > const &  vol_names) const

Returns all the nodes with volumes with any of the specified names.

Parameters
vol_nameslist of names of volumes
Returns
list of nodes found

All the nodes in the geometry are checked, and all the ones that contain a volume with a name among the ones specified in vol_names are saved in the collection and returned.

Definition at line 346 of file GeometryCore.cxx.

References geo::CollectNodesByName::nodes, and ROOTGeoManager().

Referenced by SurfaceY().

348  {
349  CollectNodesByName node_collector(vol_names);
350 
351  ROOTGeoNodeForwardIterator iNode{ROOTGeoManager()->GetTopNode()};
352  TGeoNode const* pCurrentNode;
353 
354  while ((pCurrentNode = *iNode)) {
355  node_collector(*pCurrentNode);
356  ++iNode;
357  }
358 
359  return node_collector.nodes;
360  }
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
std::vector< GeoNodePathEntry > geo::GeometryCore::FindDetectorEnclosure ( std::string const &  name = "volDetEnclosure") const
private

Definition at line 496 of file GeometryCore.cxx.

References FindFirstVolume(), and ROOTGeoManager().

Referenced by DetectorEnclosureBox().

498  {
499  std::vector<GeoNodePathEntry> path{{ROOTGeoManager()->GetTopNode()}};
500  if (!FindFirstVolume(name, path)) path.clear();
501  return path;
502  }
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
bool FindFirstVolume(std::string const &name, std::vector< GeoNodePathEntry > &path) const
bool geo::GeometryCore::FindFirstVolume ( std::string const &  name,
std::vector< GeoNodePathEntry > &  path 
) const
private

Definition at line 505 of file GeometryCore.cxx.

Referenced by FindDetectorEnclosure().

507  {
508  assert(!path.empty());
509 
510  auto const* pCurrent = path.back().node;
511 
512  // first check the current layer
513  if (strncmp(name.c_str(), pCurrent->GetName(), name.length()) == 0) return true;
514 
515  //explore the next layer down
516  auto const* pCurrentVolume = pCurrent->GetVolume();
517  unsigned int nd = pCurrentVolume->GetNdaughters();
518  for (unsigned int i = 0; i < nd; ++i) {
519  path.push_back({pCurrentVolume->GetNode(i)});
520  if (FindFirstVolume(name, path)) return true;
521  path.pop_back();
522  }
523  return false;
524  }
bool FindFirstVolume(std::string const &name, std::vector< GeoNodePathEntry > &path) const
TPCID geo::GeometryCore::FindTPCAtPosition ( Point_t const &  point) const

Returns the ID of the TPC at specified location.

Parameters
point3D point (world reference frame, centimeters)
Returns
the TPC ID, or an invalid one if no TPC is there

Definition at line 157 of file GeometryCore.cxx.

References fPositionWiggle, PositionToCryostatPtr(), and geo::CryostatGeo::PositionToTPCID().

Referenced by trkf::TrajectoryMCSFitter::breakTrajInSegments(), pma::ProjectionMatchingAlg::buildShowerSeg(), ShowerRecoTools::ShowerUnidirectiondEdx::CalculateElement(), ShowerRecoTools::ShowerTrajPointdEdx::CalculateElement(), ems::MultiEMShowers::convCluster(), evd::RecoBaseDrawer::DrawTrack2D(), hit::HitCheater::FindHitsOnChannel(), shower::EMShowerAlg::FindInitialTrackHits(), geo::WireReadoutGeom::FindTPCsetAtPosition(), GetElementPtr(), opdet::GetHitGeometryInfo(), nnet::TrainingDataAlg::getProjection(), lar_pandora::LArPandoraInput::GetTrueStartAndEndPoints(), hit::DisambigCheater::InitHitToWids(), trkf::TrajectoryMCSFitter::linearRegression(), evd::SimulationDrawer::MCTruthOrtho(), shower::EMShowerAlg::OrderShowerHits_(), calo::Calorimetry::produce(), shower::EMShowerAlg::Project3DPointOntoPlane_(), filt::LArG4ParticleFilter::StartInTPCCheck(), filt::LArG4ParticleFilter::StopInTPCCheck(), filt::LArG4ParticleFilter::TPCTrajLengthCheck(), DUNE::NeutrinoTrackingEff::truthLength(), and DUNE::MuonTrackingEff::truthLength().

158  {
159  // first find the cryostat
160  CryostatGeo const* cryo = PositionToCryostatPtr(point);
161  if (!cryo) return {};
162 
163  // then ask it about the TPC
164  return cryo->PositionToTPCID(point, 1. + fPositionWiggle);
165  }
CryostatGeo const * PositionToCryostatPtr(Point_t const &point) const
Returns the cryostat at specified location.
double fPositionWiggle
accounting for rounding errors when testing positions
Definition: GeometryCore.h:614
std::string const& geo::GeometryCore::GDMLFile ( ) const
inline

Returns the full directory path to the GDML file source.

Returns
the full directory path to the GDML file source

This is the full path of the source of the detector geometry handed to the detector simulation (GEANT).

Definition at line 130 of file GeometryCore.h.

References fGDMLfile.

Referenced by larg4::LArG4::beginJob(), geo::DumpGeometry::dumpGeometry(), and evgen::GENIEGen::GENIEGen().

130 { return fGDMLfile; }
std::string fGDMLfile
path to geometry file used for Geant4 simulation
Definition: GeometryCore.h:611
unsigned int geo::GeometryCore::GetClosestOpDet ( Point_t const &  point) const

Find the nearest OpChannel to some point.

Parameters
pointpoint to be queried, in world coordinates
Returns
the index of the nearest OpChannel to the point, or std::numeric_limits<unsigned int>::max() if invalid point
Deprecated:
This method does not tell in which cryostat the detector is; use geo::CryostatGeo::GetClosestOpDet() instead (find the cryostat with PositionToCryostatPtr()).

Definition at line 658 of file GeometryCore.cxx.

References geo::CryostatID::Cryostat, geo::CryostatGeo::GetClosestOpDet(), geo::CryostatGeo::ID(), OpDetFromCryo(), and PositionToCryostatPtr().

Referenced by GetElementPtr().

659  {
660  CryostatGeo const* cryo = PositionToCryostatPtr(point);
661  if (!cryo) return std::numeric_limits<unsigned int>::max();
662  int o = cryo->GetClosestOpDet(point);
663  return OpDetFromCryo(o, cryo->ID().Cryostat);
664  }
CryostatGeo const * PositionToCryostatPtr(Point_t const &point) const
Returns the cryostat at specified location.
unsigned int OpDetFromCryo(unsigned int o, unsigned int c) const
Get unique opdet number from cryo and internal count.
CryostatGeo const& geo::GeometryCore::GetElement ( CryostatID const &  cryoid) const
inline

Returns the specified cryostat.

Parameters
cryoidcryostat ID
Returns
a constant reference to the specified cryostat
Exceptions
cet::exception(GeometryCore category) if cryostat not present

The GetElement() method is overloaded and its return depends on the type of ID.

Todo:
Make the cryostat number mandatory (as CryostatID)

Definition at line 334 of file GeometryCore.h.

References Cryostat().

Referenced by evd::SimulationDrawer::MCTruthOrtho().

334 { return Cryostat(cryoid); }
CryostatGeo const & Cryostat(CryostatID const &cryoid=details::cryostat_zero) const
Returns the specified cryostat.
TPCGeo const& geo::GeometryCore::GetElement ( TPCID const &  tpcid) const
inline

Returns the specified TPC.

Parameters
tpcidID of the tpc
Returns
a constant reference to the specified TPC
Exceptions
cet::exception(GeometryCore category) if cryostat not present
cet::exception(TPCOutOfRange category) if no such TPC

The GetElement() method is overloaded and its return depends on the type of ID.

Definition at line 452 of file GeometryCore.h.

References TPC().

452 { return TPC(tpcid); }
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:448
CryostatGeo const* geo::GeometryCore::GetElementPtr ( CryostatID const &  cryoid) const
inline

Returns the specified cryostat.

Parameters
cryoidcryostat ID
Returns
a constant pointer to the specified cryostat, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 349 of file GeometryCore.h.

References geo::Iterable< details::GeometryIterationPolicy, details::ToGeometryElement >::begin(), CryostatPtr(), geo::Iterable< details::GeometryIterationPolicy, details::ToGeometryElement >::end(), geo::Iterable< details::GeometryIterationPolicy, details::ToGeometryElement >::Iterate(), MaxTPCs(), PositionToCryostat(), PositionToCryostatID(), PositionToCryostatPtr(), and TotalNTPC().

Referenced by geo::details::getElementPtr(), and NTPC().

349 { return CryostatPtr(cryoid); }
CryostatGeo const * CryostatPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:345
TPCGeo const* geo::GeometryCore::GetElementPtr ( TPCID const &  tpcid) const
inline

Returns the specified TPC.

Parameters
tpcidTPC ID
Returns
a constant pointer to the specified TPC, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 468 of file GeometryCore.h.

References geo::details::cryostat_zero, FindTPCAtPosition(), GetClosestOpDet(), NOpDets(), OpDetFromCryo(), OpDetGeoFromOpDet(), OpDetGeoName(), PositionToTPC(), PositionToTPCID(), PositionToTPCptr(), and TPCPtr().

468 { return TPCPtr(tpcid); }
TPCGeo const * TPCPtr(TPCID const &tpcid) const
Returns the specified TPC.
Definition: GeometryCore.h:463
std::string const & geo::GeometryCore::GetWorldVolumeName ( ) const

Return the name of the world volume (needed by Geant4 simulation)

Definition at line 212 of file GeometryCore.cxx.

Referenced by SurfaceY(), WorldBox(), and WorldVolume().

213  {
214  // For now, and possibly forever, this is a constant (given the definition of
215  // "nodeNames" above).
216  static std::string const worldVolumeName{"volWorld"};
217  return worldVolumeName;
218  }
bool geo::GeometryCore::HasCryostat ( CryostatID const &  cryoid) const
inline

Returns whether we have the specified cryostat.

The HasElement() method is overloaded and its meaning depends on the type of ID.

Definition at line 318 of file GeometryCore.h.

References geo::CryostatID::Cryostat, and Ncryostats().

Referenced by CryostatPtr(), and HasElement().

318 { return cryoid.Cryostat < Ncryostats(); }
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:303
bool geo::GeometryCore::HasElement ( CryostatID const &  cryoid) const
inline

Returns whether we have the specified cryostat.

The HasElement() method is overloaded and its meaning depends on the type of ID.

Definition at line 319 of file GeometryCore.h.

References Cryostat(), geo::details::cryostat_zero, and HasCryostat().

319 { return HasCryostat(cryoid); }
bool HasCryostat(CryostatID const &cryoid) const
Returns whether we have the specified cryostat.
Definition: GeometryCore.h:318
bool geo::GeometryCore::HasElement ( TPCID const &  tpcid) const
inline

Returns whether we have the specified TPC.

Definition at line 436 of file GeometryCore.h.

References HasTPC().

436 { return HasTPC(tpcid); }
bool HasTPC(TPCID const &tpcid) const
Returns whether we have the specified TPC.
Definition: GeometryCore.h:429
bool geo::GeometryCore::HasTPC ( TPCID const &  tpcid) const
inline

Returns whether we have the specified TPC.

Definition at line 429 of file GeometryCore.h.

References CryostatPtr(), and geo::CryostatGeo::HasTPC().

Referenced by pma::ProjectionMatchingAlg::buildShowerSeg(), ems::MultiEMShowers::convCluster(), HasElement(), and evd::TWQProjectionView::SelectTPC().

430  {
431  CryostatGeo const* pCryo = CryostatPtr(tpcid);
432  return pCryo ? pCryo->HasTPC(tpcid) : false;
433  }
CryostatGeo const * CryostatPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:345
std::string geo::GeometryCore::Info ( std::string  indent = "  ") const

Returns a string with complete geometry information.

See also
Print()

Definition at line 588 of file GeometryCore.cxx.

References Print().

Referenced by SurfaceY().

589  {
590  std::ostringstream sstr;
591  Print(sstr, indent);
592  return sstr.str();
593  }
void Print(Stream &&out, std::string indent=" ") const
Prints geometry information with maximum verbosity.
Definition: GeometryCore.h:633
std::string indent(std::size_t const i)

Definition at line 121 of file Iterable.h.

Referenced by GetElementPtr().

122  {
123  return ranges::make_subrange(begin<T>(), end<T>());
124  }
range_type<T> geo::Iterable< details::GeometryIterationPolicy , details::ToGeometryElement >::Iterate ( ID const &  id) const
inlineinherited

Definition at line 127 of file Iterable.h.

128  {
129  return ranges::make_subrange(begin<T>(id), end<T>(id));
130  }
void geo::GeometryCore::LoadGeometryFile ( )
private

Definition at line 70 of file GeometryCore.cxx.

References BuildGeometry(), fGDMLfile, fManager, and SortGeometry().

Referenced by Cryostats(), and GeometryCore().

71  {
72  if (fManager) {
73  throw cet::exception("GeometryCore") << "Reloading a geometry is not supported.\n";
74  }
75 
76  if (fGDMLfile.empty()) {
77  throw cet::exception("GeometryCore") << "No GDML Geometry file specified!\n";
78  }
79 
80  (void)gROOT; // <= Can be removed once ROOT 6.26/08 is adopted
81 
82  if (!gGeoManager) {
83  // [20210630, petrillo@slac.stanford.edu]
84  // ROOT 6.22.08 allows us to choose the representation of lengths in the geometry
85  // objects parsed from GDML. In LArSoft we want them to be centimeters (ROOT
86  // standard). This was tracked as Redmine issue #25990, and I leave this mark
87  // because I feel that we'll be back to it not too far in the future. Despite the
88  // documentation (ROOT 6.22/08), it seems the units are locked from the beginning,
89  // so we unlock without prejudice.
90  TGeoManager::LockDefaultUnits(false);
91  TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits);
92  TGeoManager::LockDefaultUnits(true);
93 
94  TGeoManager::Import(fGDMLfile.c_str());
95  gGeoManager->LockGeometry();
96  }
97 
98  BuildGeometry();
99 
100  fManager = gGeoManager;
101 
102  SortGeometry();
103 
104  mf::LogInfo("GeometryCore") << "New detector geometry loaded from\n\t" << fGDMLfile;
105  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
TGeoManager * fManager
Definition: GeometryCore.h:610
std::string fGDMLfile
path to geometry file used for Geant4 simulation
Definition: GeometryCore.h:611
void BuildGeometry()
Parses ROOT geometry nodes and builds LArSoft geometry representation.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
double geo::GeometryCore::MassBetweenPoints ( Point_t const &  p1,
Point_t const &  p2 
) const

Returns the column density between two points.

Parameters
p1the first point
p2the second point
Returns
the column density [kg / cm²]

The column density is defined as $ \int_{\vec{p}_{1}}^{\vec{p}_{2}} \rho(\vec{p}) d\vec{p} $ where $ \rho(\vec{p}) $ is the density at point $ \vec{p} $, which the integral leads from p1 to p2 in a straight line.

Both points are specified in world coordinates.

Definition at line 550 of file GeometryCore.cxx.

References dir, and geo::vect::makePointFromCoords().

Referenced by SurfaceY().

551  {
552  //The purpose of this method is to determine the column density between the two points
553  //given. Do that by starting at p1 and stepping until you get to the node of p2.
554  //calculate the distance between the point just inside that node and p2 to get the
555  //last bit of column density
556  double columnD = 0.;
557 
558  //first initialize a track - get the direction cosines
559  Vector_t const dir = (p2 - p1).Unit();
560 
561  double const dxyz[3] = {dir.X(), dir.Y(), dir.Z()};
562  double const cp1[3] = {p1.X(), p1.Y(), p1.Z()};
563  gGeoManager->InitTrack(cp1, dxyz);
564 
565  //might be helpful to have a point to a TGeoNode
566  TGeoNode* node = gGeoManager->GetCurrentNode();
567 
568  //check that the points are not in the same volume already. if they are in different
569  //volumes, keep stepping until you are in the same volume as the second point
570  while (!gGeoManager->IsSameLocation(p2.X(), p2.Y(), p2.Z())) {
571  gGeoManager->FindNextBoundary();
572  columnD += gGeoManager->GetStep() * node->GetMedium()->GetMaterial()->GetDensity();
573 
574  //the act of stepping puts you in the next node and returns that node
575  node = gGeoManager->Step();
576  } //end loop to get to volume of second point
577 
578  //now you are in the same volume as the last point, but not at that point. get the
579  //distance between the current point and the last one
580  Point_t const last = vect::makePointFromCoords(gGeoManager->GetCurrentPoint());
581  double const lastStep = (p2 - last).R();
582  columnD += lastStep * node->GetMedium()->GetMaterial()->GetDensity();
583 
584  return columnD;
585  }
GENVECTOR_CONSTEXPR Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
recob::tracking::Point_t Point_t
TDirectory * dir
Definition: macro.C:5
recob::tracking::Vector_t Vector_t
TGeoMaterial const * geo::GeometryCore::Material ( Point_t const &  point) const

Returns the material at the specified position.

Definition at line 467 of file GeometryCore.cxx.

Referenced by MaterialName(), and SurfaceY().

468  {
469  auto const pNode = gGeoManager->FindNode(point.X(), point.Y(), point.Z());
470  if (!pNode) return nullptr;
471  auto const pMedium = pNode->GetMedium();
472  return pMedium ? pMedium->GetMaterial() : nullptr;
473  }
std::string geo::GeometryCore::MaterialName ( Point_t const &  point) const

Name of the deepest material containing the point xyz.

Parameters
pointthe location to query, in world coordinates
Returns
material name at the specified position

Definition at line 476 of file GeometryCore.cxx.

References geo::BoxBoundedGeo::ContainsPosition(), Material(), geo::BoxBoundedGeo::Max(), geo::BoxBoundedGeo::Min(), and WorldBox().

Referenced by larg4::LArG4Ana::analyze(), and SurfaceY().

477  {
478  // check that the given point is in the World volume at least
479  BoxBoundedGeo worldBox = WorldBox();
480  if (!worldBox.ContainsPosition(point)) {
481  mf::LogWarning("GeometryCoreBadInputPoint")
482  << "point " << point << " is not inside the world volume " << worldBox.Min() << " -- "
483  << worldBox.Max() << "; returning unknown material name";
484  return {"unknownMaterial"};
485  }
486  auto const pMaterial = Material(point);
487  if (!pMaterial) {
488  mf::LogWarning("GeometryCoreBadInputPoint")
489  << "material for point " << point << " not found! returning unknown material name";
490  return {"unknownMaterial"};
491  }
492  return pMaterial->GetName();
493  }
TGeoMaterial const * Material(Point_t const &point) const
Returns the material at the specified position.
BoxBoundedGeo WorldBox() const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
unsigned int geo::GeometryCore::MaxTPCs ( ) const

Returns the largest number of TPCs a cryostat in the detector has.

Definition at line 379 of file GeometryCore.cxx.

References fCryostats.

Referenced by geo::details::GeometryIterationPolicy::EndTPCID(), GetElementPtr(), and evd::TWQProjectionView::SetUpTPCselection().

380  {
381  unsigned int maxTPCs = 0;
382  for (CryostatGeo const& cryo : fCryostats) {
383  unsigned int maxTPCsInCryo = cryo.NTPC();
384  if (maxTPCsInCryo > maxTPCs) maxTPCs = maxTPCsInCryo;
385  }
386  return maxTPCs;
387  }
CryostatList_t fCryostats
Definition: GeometryCore.h:605
unsigned int geo::GeometryCore::Ncryostats ( ) const
inline

Returns the number of cryostats in the detector.

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 303 of file GeometryCore.h.

References fCryostats.

Referenced by detsim::WienerFilterAna::beginJob(), detsim::SimDriftElectrons::beginJob(), detsim::DriftElectronstoPlane::beginJob(), lar_cluster3d::StandardHit3DBuilder::BuildHitPairMap(), lar_cluster3d::SnippetHit3DBuilder::BuildHitPairMap(), larg4::LArVoxelReadout::ClearSimChannels(), lar_cluster3d::StandardHit3DBuilder::CollectArtHits(), lar_cluster3d::SnippetHit3DBuilder::CollectArtHits(), larg4::LArVoxelReadoutGeometry::Construct(), detinfo::DetectorPropertiesStandard::DataFor(), hit::DisambigCheater::DisambigCheater(), geo::WireReadoutDumper::dumpDetectorInfo(), geo::details::GeometryIterationPolicy::EndCryostatID(), detsim::WienerFilterAna::endJob(), geo::details::ReadoutIterationPolicy::EndPlaneID(), geo::details::GeometryIterationPolicy::EndTPCID(), geo::details::ReadoutIterationPolicy::EndWireID(), larg4::ISTPC::extractActiveLArVolume(), larg4::OpFastScintillation::extractActiveVolumes(), HasCryostat(), lar_cluster3d::SpacePointHit3DBuilder::Hit3DBuilder(), trkf::SpacePointAlg::makeSpacePoints(), NElements(), NSiblingElements(), OpDetFromCryo(), OpDetGeoFromOpDet(), larg4::OpFastScintillation::OpFastScintillation(), phot::PDFastSimPAR::PDFastSimPAR(), Print(), larg4::LArG4::produce(), evd::TWQProjectionView::SelectTPC(), evd::TWQProjectionView::SetUpTPCselection(), and cheat::BackTracker::SpacePointHitsToWeightedXYZ().

303 { return fCryostats.size(); }
CryostatList_t fCryostats
Definition: GeometryCore.h:605
unsigned int geo::GeometryCore::NElements ( ) const
inline

Returns the number of cryostats in the detector.

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 304 of file GeometryCore.h.

References Ncryostats().

304 { return Ncryostats(); }
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:303
unsigned int geo::GeometryCore::NElements ( CryostatID const &  cryoid) const
inline

Returns the largest number of TPCs a cryostat in the detector has.

Definition at line 421 of file GeometryCore.h.

References NTPC().

421 { return NTPC(cryoid); }
unsigned int NTPC(CryostatID const &cryoid=details::cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:416
unsigned int geo::GeometryCore::NSiblingElements ( CryostatID const &  ) const
inline

Returns the number of cryostats in the detector.

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 305 of file GeometryCore.h.

References Ncryostats().

Referenced by geo::details::GeometryIterationPolicy::NSiblings().

305 { return Ncryostats(); }
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:303
unsigned int geo::GeometryCore::NSiblingElements ( TPCID const &  tpcid) const
inline

Returns the largest number of TPCs a cryostat in the detector has.

Definition at line 422 of file GeometryCore.h.

References NTPC().

422 { return NTPC(tpcid); }
unsigned int NTPC(CryostatID const &cryoid=details::cryostat_zero) const
Returns the total number of TPCs in the specified cryostat.
Definition: GeometryCore.h:416
unsigned int geo::GeometryCore::NTPC ( CryostatID const &  cryoid = details::cryostat_zero) const
inline

Returns the total number of TPCs in the specified cryostat.

Parameters
cryoidcryostat number
Returns
number of TPCs in specified cryostat, or 0 if no cryostat found

The NElements() and NSiblingElements() methods are overloaded and their return depends on the type of ID.

Todo:
Change return type to size_t

Definition at line 416 of file GeometryCore.h.

References GetElementPtr(), and geo::CryostatGeo::NElements().

Referenced by apa::APAGeometryAlg::APAGeometryAlg(), detsim::WienerFilterAna::beginJob(), detsim::SimDriftElectrons::beginJob(), detsim::DriftElectronstoPlane::beginJob(), lar_cluster3d::StandardHit3DBuilder::BuildHitPairMap(), lar_cluster3d::SnippetHit3DBuilder::BuildHitPairMap(), mvapid::MVAAlg::CalcSegmentdEdxDist(), larg4::LArVoxelReadout::ClearSimChannels(), lar_cluster3d::StandardHit3DBuilder::CollectArtHits(), lar_cluster3d::SnippetHit3DBuilder::CollectArtHits(), hit::DisambigCheater::DisambigCheater(), detsim::WienerFilterAna::endJob(), mvapid::MVAAlg::GetWireNormals(), lar_cluster3d::SpacePointHit3DBuilder::Hit3DBuilder(), NElements(), NSiblingElements(), phot::PDFastSimPAR::PDFastSimPAR(), nnet::PointIdTrainingData::PointIdTrainingData(), evgen::ActiveVolumeVertexSampler::reconfigure(), evgen::ActiveVolumeVertexSampler::sample_vertex_pos(), evd::TWQProjectionView::SelectTPC(), phot::SemiAnalyticalModel::SemiAnalyticalModel(), tca::TrajClusterAlg::SetSourceHits(), evd::TWQProjectionView::SetUpTPCselection(), cheat::BackTracker::SpacePointHitsToWeightedXYZ(), tca::StitchPFPs(), apa::DisambigAlg::TrivialDisambig(), and evd::TWQMultiTPCProjectionView::TWQMultiTPCProjectionView().

417  {
418  CryostatGeo const* pCryo = GetElementPtr(cryoid);
419  return pCryo ? pCryo->NElements() : 0;
420  }
CryostatGeo const * GetElementPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:349
unsigned int geo::GeometryCore::OpDetFromCryo ( unsigned int  o,
unsigned int  c 
) const

Get unique opdet number from cryo and internal count.

Todo:
add explanation of the different IDs

Definition at line 598 of file GeometryCore.cxx.

References Cryostat(), Ncryostats(), and geo::CryostatGeo::NOpDet().

Referenced by GetClosestOpDet(), and GetElementPtr().

599  {
600  static bool Loaded = false;
601  static std::vector<unsigned int> LowestID;
602  static unsigned int NCryo;
603 
604  CryostatID const cid{c};
605  // If not yet loaded static parameters, do it
606  if (Loaded == false) {
607 
608  Loaded = true;
609 
610  // Store the lowest ID for each cryostat
611  NCryo = Ncryostats();
612  LowestID.resize(NCryo + 1);
613  LowestID.at(0) = 0;
614  for (size_t cryo = 0; cryo != NCryo; ++cryo) {
615  LowestID.at(cryo + 1) = LowestID.at(cryo) + Cryostat(cid).NOpDet();
616  }
617  }
618 
619  if ((c < NCryo) && (o < Cryostat(cid).NOpDet())) { return LowestID.at(c) + o; }
620 
621  throw cet::exception("OpDetCryoToOpID Error")
622  << "Coordinates c=" << c << ", o=" << o << " out of range. Abort\n";
623  }
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:303
CryostatGeo const & Cryostat(CryostatID const &cryoid=details::cryostat_zero) const
Returns the specified cryostat.
unsigned int NOpDet() const
Number of optical detectors in this TPC.
Definition: CryostatGeo.h:317
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
OpDetGeo const & geo::GeometryCore::OpDetGeoFromOpDet ( unsigned int  OpDet) const

Returns the geo::OpDetGeo object for the given detector number.

Parameters
OpDetoptical detector unique number
See also
GeometryCoreOpDetGeometry "optical detector identification"

Definition at line 626 of file GeometryCore.cxx.

References Cryostat(), Ncryostats(), geo::CryostatGeo::NOpDet(), and geo::CryostatGeo::OpDet().

Referenced by opdet::SimPhotonCounter::beginJob(), phot::CreateHybridLibrary::CreateHybridLibrary(), phot::PhotonVisibilityService::DistanceToOpDetImpl(), larg4::OpDetLookup::FindClosestOpDet(), phot::PhotonLibraryHybrid::GetCount(), GetElementPtr(), phot::PropagationTimeModel::opDetCenters(), phot::PDFastSimPAR::opDetCenters(), geo::WireReadoutGeom::OpDetGeoFromOpChannel(), phot::PropagationTimeModel::opDetOrientations(), larg4::OpFastScintillation::OpFastScintillation(), phot::SemiAnalyticalModel::opticalDetectors(), and phot::PhotonVisibilityService::SolidAngleFactorImpl().

627  {
628  static bool Loaded = false;
629  static std::vector<unsigned int> LowestID;
630  static size_t NCryo;
631  // If not yet loaded static parameters, do it
632  if (Loaded == false) {
633 
634  Loaded = true;
635 
636  // Store the lowest ID for each cryostat
637  NCryo = Ncryostats();
638  LowestID.resize(NCryo + 1);
639  LowestID[0] = 0;
640  for (size_t cryo = 0; cryo != NCryo; ++cryo) {
641  LowestID[cryo + 1] = LowestID[cryo] + Cryostat(CryostatID(cryo)).NOpDet();
642  }
643  }
644 
645  for (size_t i = 0; i != NCryo; ++i) {
646  if ((OpDet >= LowestID[i]) && (OpDet < LowestID[i + 1])) {
647  int c = i;
648  int o = OpDet - LowestID[i];
649  return Cryostat(CryostatID(c)).OpDet(o);
650  }
651  }
652  // If we made it here, we didn't find the right combination. abort
653  throw cet::exception("OpID To OpDetCryo error") << "OpID out of range, " << OpDet << "\n";
654  }
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
OpDetGeo const & OpDet(unsigned int iopdet) const
Return the iopdet&#39;th optical detector in the cryostat.
Definition: CryostatGeo.cxx:83
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:303
CryostatGeo const & Cryostat(CryostatID const &cryoid=details::cryostat_zero) const
Returns the specified cryostat.
unsigned int NOpDet() const
Number of optical detectors in this TPC.
Definition: CryostatGeo.h:317
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::string geo::GeometryCore::OpDetGeoName ( CryostatID const &  cid = details::cryostat_zero) const

Returns gdml string which gives sensitive opdet name.

Parameters
cidID of the cryostat the detector is in

This name is defined in the geometry (GDML) description.

Todo:
Change to use CryostatID

Referenced by GetElementPtr().

GeometryCore& geo::GeometryCore::operator= ( GeometryCore const &  )
delete
GeometryCore& geo::GeometryCore::operator= ( GeometryCore &&  )
delete
CryostatGeo const & geo::GeometryCore::PositionToCryostat ( Point_t const &  point) const

Returns the cryostat at specified location.

Parameters
pointthe location [cm]
Returns
a constant reference to the geo::CryostatGeo containing point
Exceptions
cet::exception("Geometry" category) if no cryostat matches

The tolerance used here is the one returned by DefaultWiggle().

Definition at line 205 of file GeometryCore.cxx.

References PositionToCryostatPtr().

Referenced by GetElementPtr().

206  {
207  if (auto cstat = PositionToCryostatPtr(point)) { return *cstat; }
208  throw cet::exception("GeometryCore") << "Can't find any cryostat at position " << point << "\n";
209  }
CryostatGeo const * PositionToCryostatPtr(Point_t const &point) const
Returns the cryostat at specified location.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
CryostatID geo::GeometryCore::PositionToCryostatID ( Point_t const &  point) const

Returns the ID of the cryostat at specified location.

Parameters
pointthe location [cm]
Returns
ID of the cryostat including point (invalid if none)

The tolerance used here is the one returned by DefaultWiggle().

Definition at line 177 of file GeometryCore.cxx.

References geo::CryostatGeo::ID(), and PositionToCryostatPtr().

Referenced by pma::ProjectionMatchingAlg::buildShowerSeg(), ems::MultiEMShowers::convCluster(), larg4::LArVoxelReadoutGeometry::FindNestedVolume(), GetElementPtr(), sim::MCRecoEdep::MakeMCEdep(), evd::SimulationDrawer::MCTruthOrtho(), and detsim::SimDriftElectrons::produce().

178  {
179  CryostatGeo const* cryo = PositionToCryostatPtr(point);
180  return cryo ? cryo->ID() : CryostatID{};
181  }
CryostatGeo const * PositionToCryostatPtr(Point_t const &point) const
Returns the cryostat at specified location.
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
CryostatGeo const * geo::GeometryCore::PositionToCryostatPtr ( Point_t const &  point) const

Returns the cryostat at specified location.

Parameters
pointthe location [cm]
Returns
pointer to the geo::CryostatGeo including point, or nullptr

The tolerance used here is the one returned by DefaultWiggle().

Definition at line 168 of file GeometryCore.cxx.

References fPositionWiggle.

Referenced by FindTPCAtPosition(), GetClosestOpDet(), GetElementPtr(), PositionToCryostat(), PositionToCryostatID(), and PositionToTPCptr().

169  {
170  for (auto const& cryostat : Iterate<CryostatGeo>()) {
171  if (cryostat.ContainsPosition(point, 1.0 + fPositionWiggle)) return &cryostat;
172  }
173  return nullptr;
174  }
double fPositionWiggle
accounting for rounding errors when testing positions
Definition: GeometryCore.h:614
TPCGeo const & geo::GeometryCore::PositionToTPC ( Point_t const &  point) const

Returns the TPC at specified location.

Parameters
pointthe location [cm]
Returns
a constant reference to the geo::TPCGeo including point
Exceptions
cet::exception("Geometry" category) if no TPC matches

Definition at line 191 of file GeometryCore.cxx.

References PositionToTPCptr().

Referenced by GetElementPtr(), and opreco::OpticalRecoAna::update_MC_particle_time().

192  {
193  if (auto tpc = PositionToTPCptr(point)) { return *tpc; }
194  throw cet::exception("GeometryCore") << "Can't find any TPC at position " << point << "\n";
195  }
TPCGeo const * PositionToTPCptr(Point_t const &point) const
Returns the TPC at specified location.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
TPCID geo::GeometryCore::PositionToTPCID ( Point_t const &  point) const

Returns the ID of the TPC at specified location.

Parameters
pointthe location [cm]
Returns
ID of the TPC at specified location, invalid if none
See also
PositionToTPC()

Definition at line 198 of file GeometryCore.cxx.

References geo::TPCGeo::ID(), and PositionToTPCptr().

Referenced by larg4::ISCalcCorrelated::AngleToEFieldAtStep(), evdb_tool::DrawLArVoxel3D::Draw(), evdb_tool::DrawSimEnergyDeposit3D::drawAll(), evdb_tool::DrawSimEnergyDeposit3D::drawMCPartAssociated(), larg4::ISCalcCorrelated::EFieldAtStep(), larg4::LArVoxelReadoutGeometry::FindNestedVolume(), GetElementPtr(), lar_pandora::LArPandoraInput::GetTrueX0(), apa::APAGeometryAlg::LineSegChanIntersect(), sim::MCRecoEdep::MakeMCEdep(), evd::SimulationDrawer::MCTruth3D(), detsim::SimDriftElectrons::produce(), and cheat::BackTracker::SpacePointHitsToWeightedXYZ().

199  {
200  TPCGeo const* tpc = PositionToTPCptr(point);
201  return tpc ? tpc->ID() : TPCID{};
202  }
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
TPCGeo const * PositionToTPCptr(Point_t const &point) const
Returns the TPC at specified location.
TPCGeo const * geo::GeometryCore::PositionToTPCptr ( Point_t const &  point) const

Returns the TPC at specified location.

Parameters
pointthe location [cm]
Returns
the geo::TPCGeo including point, or nullptr if none

Definition at line 184 of file GeometryCore.cxx.

References fPositionWiggle, PositionToCryostatPtr(), and geo::CryostatGeo::PositionToTPCptr().

Referenced by GetElementPtr(), lar_pandora::PFParticleMonitoring::GetStartAndEndPoints(), PositionToTPC(), and PositionToTPCID().

185  {
186  CryostatGeo const* cryo = PositionToCryostatPtr(point);
187  return cryo ? cryo->PositionToTPCptr(point, 1. + fPositionWiggle) : nullptr;
188  }
CryostatGeo const * PositionToCryostatPtr(Point_t const &point) const
Returns the cryostat at specified location.
double fPositionWiggle
accounting for rounding errors when testing positions
Definition: GeometryCore.h:614
template<typename Stream >
void geo::GeometryCore::Print ( Stream &&  out,
std::string  indent = "  " 
) const

Prints geometry information with maximum verbosity.

Definition at line 633 of file GeometryCore.h.

References DetectorEnclosureBox(), DetectorName(), art::detail::indent(), geo::TPCGeo::MaxVerbosity, geo::OpDetGeo::MaxVerbosity, Ncryostats(), geo::OpDetGeo::PrintOpDetInfo(), and geo::TPCGeo::PrintTPCInfo().

Referenced by Info(), and SurfaceY().

634 {
635 
636  out << "Detector " << DetectorName() << " has " << Ncryostats() << " cryostats:";
637 
638  auto const& detEnclosureBox = DetectorEnclosureBox();
639  out << "\n"
640  << indent << "Detector enclosure: " << detEnclosureBox.Min() << " -- "
641  << detEnclosureBox.Max() << " cm => ( " << detEnclosureBox.SizeX() << " x "
642  << detEnclosureBox.SizeY() << " x " << detEnclosureBox.SizeZ() << " ) cm^3";
643 
644  for (auto const& cryostat : Iterate<CryostatGeo>()) {
645  out << "\n" << indent;
646  cryostat.PrintCryostatInfo(std::forward<Stream>(out), indent + " ", cryostat.MaxVerbosity);
647 
648  unsigned const int nTPCs = cryostat.NTPC();
649  for (unsigned int t = 0; t < nTPCs; ++t) {
650  TPCGeo const& tpc = cryostat.TPC(t);
651 
652  out << "\n" << indent << " ";
653  tpc.PrintTPCInfo(std::forward<Stream>(out), indent + " ", tpc.MaxVerbosity);
654  } // for TPC
655 
656  unsigned int nOpDets = cryostat.NOpDet();
657  for (unsigned int iOpDet = 0; iOpDet < nOpDets; ++iOpDet) {
658  OpDetGeo const& opDet = cryostat.OpDet(iOpDet);
659  out << "\n" << indent << " [OpDet #" << iOpDet << "] ";
660  opDet.PrintOpDetInfo(std::forward<Stream>(out), indent + " ", opDet.MaxVerbosity);
661  } // for
662  } // for cryostat
663 
664  out << '\n';
665 
666 } // geo::GeometryCore::Print()
BoxBoundedGeo DetectorEnclosureBox(std::string const &name="volDetEnclosure") const
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
Definition: GeometryCore.h:303
std::string indent(std::size_t const i)
std::string const & DetectorName() const
Returns a string with the name of the detector, as configured.
Definition: GeometryCore.h:140
TGeoManager * geo::GeometryCore::ROOTGeoManager ( ) const

Access to the ROOT geometry description manager.

Definition at line 126 of file GeometryCore.cxx.

References fManager.

Referenced by evgen::BaseRadioGen::BaseRadioGen(), evgen::LightSource::checkMaterials(), FindAllVolumePaths(), FindAllVolumes(), FindDetectorEnclosure(), evgen::GENIEGen::GENIEGen(), evgen::RadioGen::SampleOne(), and SurfaceY().

127  {
128  assert(fManager == gGeoManager);
129  return fManager;
130  }
TGeoManager * fManager
Definition: GeometryCore.h:610
void geo::GeometryCore::SortGeometry ( )
private

Definition at line 108 of file GeometryCore.cxx.

References fCryostats, and fSorter.

Referenced by Cryostats(), and LoadGeometryFile().

109  {
110  mf::LogInfo("GeometryCore") << "Sorting volumes...";
111 
112  if (not fSorter) { return; }
113 
114  fSorter->sort(fCryostats);
115 
116  // Renumber cryostats according to sorted order
118  for (CryostatGeo& cryo : fCryostats) {
119  cryo.SortSubVolumes(*fSorter);
120  cryo.UpdateAfterSorting(CryostatID{c});
121  ++c;
122  }
123  }
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
CryostatList_t fCryostats
Definition: GeometryCore.h:605
std::unique_ptr< GeoObjectSorter > fSorter
Definition: GeometryCore.h:608
unsigned int CryostatID_t
Type for the ID number.
Definition: geo_types.h:188
Length_t geo::GeometryCore::SurfaceY ( ) const
inline

The position of the detector respect to earth surface.

Returns
typical y position at surface in units of cm

This is the depth (y) of the surface (where earth meets air) for this detector site. The number is expressed in world coordinates and in centimeters, and it represents the y coordinate of earth surface. A negative value means that the origin of coordinates, typically matching the detector centre, is above surface.

Todo:
check that this is actually how it is used

Definition at line 186 of file GeometryCore.h.

References DetectorEnclosureBox(), FindAllVolumePaths(), FindAllVolumes(), fSurfaceY, GetWorldVolumeName(), art::detail::indent(), Info(), MassBetweenPoints(), Material(), MaterialName(), Print(), ROOTGeoManager(), TotalMass(), and VolumeName().

Referenced by evgen::CosmicsGen::produce().

186 { return fSurfaceY; }
double fSurfaceY
The point where air meets earth for this detector.
Definition: GeometryCore.h:613
double geo::GeometryCore::TotalMass ( ) const
inline

Returns the total mass [kg] of the specified volume (default: world).

Definition at line 255 of file GeometryCore.h.

Referenced by evgen::GENIEGen::GENIEGen(), and SurfaceY().

255 { return TotalMass(GetWorldVolumeName()); }
std::string const & GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
Definition: GeometryCore.h:255
double geo::GeometryCore::TotalMass ( std::string  vol) const

Returns the total mass [kg] of the specified volume (default: world).

Definition at line 538 of file GeometryCore.cxx.

539  {
540  //the TGeoNode::GetVolume() returns the TGeoVolume of the detector outline and ROOT
541  //calculates the mass in kg for you
542  TGeoVolume* gvol = gGeoManager->FindVolumeFast(vol.c_str());
543  if (gvol) return gvol->Weight();
544 
545  throw cet::exception("GeometryCore")
546  << "could not find specified volume '" << vol << " 'to determine total mass\n";
547  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int geo::GeometryCore::TotalNTPC ( ) const

Returns the total number of TPCs in the detector.

Definition at line 390 of file GeometryCore.cxx.

References fCryostats, and sum.

Referenced by GetElementPtr().

391  {
392  // it looks like C++11 lambdas have made STL algorithms easier to use, but only so
393  // much:
394  return std::accumulate(
395  fCryostats.begin(), fCryostats.end(), 0U, [](unsigned int sum, CryostatGeo const& cryo) {
396  return sum + cryo.NTPC();
397  });
398  }
CryostatList_t fCryostats
Definition: GeometryCore.h:605
Double_t sum
Definition: plot.C:31
TPCGeo const& geo::GeometryCore::TPC ( TPCID const &  tpcid = details::tpc_zero) const
inline

Returns the specified TPC.

Parameters
tpcidID of the tpc
Returns
a constant reference to the specified TPC
Exceptions
cet::exception(GeometryCore category) if cryostat not present
cet::exception(TPCOutOfRange category) if no such TPC

The GetElement() method is overloaded and its return depends on the type of ID.

Definition at line 448 of file GeometryCore.h.

References Cryostat(), and geo::CryostatGeo::TPC().

Referenced by lar::example::AnalysisExample::analyze(), larg4::ISCalcCorrelated::AngleToEFieldAtStep(), sce::SCECorrection::applyT0Shift(), trkf::SpacePointAna::bookHistograms(), pma::ProjectionMatchingAlg::buildShowerSeg(), phot::PropagationTimeModel::cathodeCentre(), LArStackingAction::ClassifyNewTrack(), evd::Display3DPad::Draw(), larg4::LArVoxelReadout::DriftIonizationElectrons(), larg4::ISCalcCorrelated::EFieldAtStep(), larg::LArSimChannelAna::ensureHists(), hit::MagDriftAna::ensureHists(), tca::FillWireHitRange(), simfilter::FilterNoDirtNeutrinos::filter(), util::GeometryUtilities::Get2DangleFrom3D(), trk::TrackContainmentAlg::GetCosmicTagID(), GetElement(), nnet::TrainingDataAlg::getProjection(), lar_pandora::LArPandoraInput::GetTrueX0(), cosmic::BeamFlashTrackMatchTaggerAlg::InDetector(), cosmic::BeamFlashTrackMatchTaggerAlg::InDriftWindow(), pma::Track3D::InitFromMiddle(), trk::TrackContainmentAlg::IsContained(), pma::PMAlgTracker::mergeCoLinear(), lar_cluster3d::StandardHit3DBuilder::NearestWireID(), lar_cluster3d::SnippetHit3DBuilder::NearestWireID(), larg4::OpFastScintillation::OpFastScintillation(), phot::PDFastSimPAR::PDFastSimPAR(), trkf::CCTrackMaker::PlnMatch(), trk::TrackContainmentAlg::ProcessTracks(), evgen::CosmicsGen::produce(), trkf::SpacePts::produce(), trkf::Track3Dreco::produce(), trkf::Track3DKalman::produce(), vertex::VertexFinder2D::produce(), detsim::SimDriftElectrons::produce(), detsim::DriftElectronstoPlane::produce(), trkf::Track3DKalmanSPS::produce(), trkf::PMAlgTrackMaker::produce(), evgen::ActiveVolumeVertexSampler::sample_vertex_pos(), tca::SaveCRInfo(), phot::SemiAnalyticalModel::SemiAnalyticalModel(), pma::Track3D::SetT0FromDx(), lar_pandora::LArPandoraGeometry::ShouldSwitchUV(), geo::WireReadoutGeom::SortPlanes(), trkf::CCTrackMaker::TagCosmics(), lar_pandora::ICARUS::TargetViewU(), lar_pandora::VintageLArTPCThreeView::TargetViewU(), lar_pandora::ICARUS::TargetViewV(), lar_pandora::VintageLArTPCThreeView::TargetViewV(), apa::APAGeometryAlg::ThreeChanPos(), calo::GnocchiCalorimetry::TrajectoryToWirePosition(), apa::DisambigAlg::TrivialDisambig(), apa::DisambigAlg::UseEndPts(), and evd::RecoBaseDrawer::Vertex2D().

449  {
450  return Cryostat(tpcid).TPC(tpcid);
451  }
CryostatGeo const & Cryostat(CryostatID const &cryoid=details::cryostat_zero) const
Returns the specified cryostat.
TPCGeo const & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:73
TPCGeo const* geo::GeometryCore::TPCPtr ( TPCID const &  tpcid) const
inline

Returns the specified TPC.

Parameters
tpcidTPC ID
Returns
a constant pointer to the specified TPC, or nullptr if none

The GetElementPtr() method is overloaded and its return depends on the type of ID.

Definition at line 463 of file GeometryCore.h.

References CryostatPtr(), and geo::CryostatGeo::TPCPtr().

Referenced by GetElementPtr().

464  {
465  CryostatGeo const* pCryo = CryostatPtr(tpcid);
466  return pCryo ? pCryo->TPCPtr(tpcid) : nullptr;
467  }
CryostatGeo const * CryostatPtr(CryostatID const &cryoid) const
Returns the specified cryostat.
Definition: GeometryCore.h:345
std::string geo::GeometryCore::VolumeName ( Point_t const &  point) const

Returns the name of the deepest volume containing specified point.

Parameters
pointthe location to query, in world coordinates
Returns
name of the volume containing the point
Todo:

what happens if none?

Unify the coordinates type

Definition at line 446 of file GeometryCore.cxx.

References util::abs(), and WorldVolume().

Referenced by larg4::LArG4Ana::analyze(), LArStackingAction::InsideTPC(), and SurfaceY().

447  {
448  // check that the given point is in the World volume at least
449  TGeoVolume const* volWorld = WorldVolume();
450  double halflength = ((TGeoBBox*)volWorld->GetShape())->GetDZ();
451  double halfheight = ((TGeoBBox*)volWorld->GetShape())->GetDY();
452  double halfwidth = ((TGeoBBox*)volWorld->GetShape())->GetDX();
453  if (std::abs(point.x()) > halfwidth || std::abs(point.y()) > halfheight ||
454  std::abs(point.z()) > halflength) {
455  mf::LogWarning("GeometryCoreBadInputPoint")
456  << "point (" << point.x() << "," << point.y() << "," << point.z() << ") "
457  << "is not inside the world volume "
458  << " half width = " << halfwidth << " half height = " << halfheight
459  << " half length = " << halflength << " returning unknown volume name";
460  return "unknownVolume";
461  }
462 
463  return gGeoManager->FindNode(point.X(), point.Y(), point.Z())->GetName();
464  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
TGeoVolume const * WorldVolume() const
Returns a pointer to the world volume.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void geo::GeometryCore::WorldBox ( double *  xlo,
double *  xhi,
double *  ylo,
double *  yhi,
double *  zlo,
double *  zhi 
) const

Fills the arguments with the boundaries of the world.

Parameters
xlo(output) pointer to the lower x coordinate
xlo(output) pointer to the upper x coordinate
ylo(output) pointer to the lower y coordinate
ylo(output) pointer to the upper y coordinate
zlo(output) pointer to the lower z coordinate
zlo(output) pointer to the upper z coordinate
Exceptions
cet::exception("GeometryCore" category) if no world found
See also
GetWorldVolumeName()

This method fills the boundaries of the world volume (GetWorldVolumeName()).

If a pointer is null, its coordinate is skipped.

Deprecated:
Use the version without arguments instead.

Definition at line 429 of file GeometryCore.cxx.

References geo::BoxBoundedGeo::MaxX(), geo::BoxBoundedGeo::MaxY(), geo::BoxBoundedGeo::MaxZ(), geo::BoxBoundedGeo::MinX(), geo::BoxBoundedGeo::MinY(), geo::BoxBoundedGeo::MinZ(), and WorldBox().

Referenced by evd_tool::ICARUSDrawer::DetOutline3D(), and evgen::CORSIKAGen::GetSample().

435  {
436  BoxBoundedGeo const box = WorldBox();
437  if (xlo) *xlo = box.MinX();
438  if (ylo) *ylo = box.MinY();
439  if (zlo) *zlo = box.MinZ();
440  if (xhi) *xhi = box.MaxX();
441  if (yhi) *yhi = box.MaxY();
442  if (zhi) *zhi = box.MaxZ();
443  }
BoxBoundedGeo WorldBox() const
BoxBoundedGeo geo::GeometryCore::WorldBox ( ) const

Returns a box with the extremes of the world volume (from shape axes).

See also
GetWorldVolumeName()

Definition at line 407 of file GeometryCore.cxx.

References GetWorldVolumeName(), WorldVolume(), x1, x2, y1, and y2.

Referenced by DetectorName(), MaterialName(), and WorldBox().

408  {
409  TGeoVolume const* world = WorldVolume();
410  if (!world) {
411  throw cet::exception("GeometryCore") << "no world volume '" << GetWorldVolumeName() << "'\n";
412  }
413  TGeoShape const* s = world->GetShape();
414  if (!s) {
415  throw cet::exception("GeometryCore")
416  << "world volume '" << GetWorldVolumeName() << "' is shapeless!!!\n";
417  }
418 
419  double x1, x2, y1, y2, z1, z2;
420  s->GetAxisRange(1, x1, x2);
421  s->GetAxisRange(2, y1, y2);
422  s->GetAxisRange(3, z1, z2);
423 
424  // BoxBoundedGeo constructor will sort the coordinates as needed
425  return BoxBoundedGeo{x1, x2, y1, y2, z1, z2};
426  }
std::string const & GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
TGeoVolume const * WorldVolume() const
Returns a pointer to the world volume.
Float_t y2[n_points_geant4]
Definition: compare.C:26
Float_t x2[n_points_geant4]
Definition: compare.C:26
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
TGeoVolume const * geo::GeometryCore::WorldVolume ( ) const

Returns a pointer to the world volume.

Definition at line 401 of file GeometryCore.cxx.

References GetWorldVolumeName().

Referenced by DetectorName(), VolumeName(), and WorldBox().

402  {
403  return gGeoManager->FindVolumeFast(GetWorldVolumeName().c_str());
404  }
std::string const & GetWorldVolumeName() const
Return the name of the world volume (needed by Geant4 simulation)

Member Data Documentation

std::unique_ptr<GeometryBuilder> geo::GeometryCore::fBuilder
private

Definition at line 607 of file GeometryCore.h.

Referenced by BuildGeometry(), and GeometryCore().

CryostatList_t geo::GeometryCore::fCryostats {}
private
std::string geo::GeometryCore::fDetectorName
private

Name of the detector.

Definition at line 612 of file GeometryCore.h.

Referenced by DetectorName(), and GeometryCore().

std::string geo::GeometryCore::fGDMLfile
private

path to geometry file used for Geant4 simulation

Definition at line 611 of file GeometryCore.h.

Referenced by GDMLFile(), GeometryCore(), and LoadGeometryFile().

TGeoManager* geo::GeometryCore::fManager {nullptr}
private

Definition at line 610 of file GeometryCore.h.

Referenced by LoadGeometryFile(), and ROOTGeoManager().

double geo::GeometryCore::fPositionWiggle
private

accounting for rounding errors when testing positions

Definition at line 614 of file GeometryCore.h.

Referenced by DefaultWiggle(), FindTPCAtPosition(), GeometryCore(), PositionToCryostatPtr(), and PositionToTPCptr().

std::unique_ptr<GeoObjectSorter> geo::GeometryCore::fSorter
private

Definition at line 608 of file GeometryCore.h.

Referenced by GeometryCore(), and SortGeometry().

double geo::GeometryCore::fSurfaceY
private

The point where air meets earth for this detector.

Definition at line 613 of file GeometryCore.h.

Referenced by GeometryCore(), and SurfaceY().


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