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

Description of physical geometry of one set of auxiliary detectors. More...

#include "AuxDetGeometryCore.h"

Public Member Functions

 AuxDetGeometryCore (fhicl::ParameterSet const &pset, std::unique_ptr< AuxDetGeoObjectSorter > sorter=nullptr, std::unique_ptr< AuxDetInitializer > initializer=nullptr)
 Initialize geometry from a given configuration. More...
 
 AuxDetGeometryCore (AuxDetGeometryCore const &)=delete
 
 AuxDetGeometryCore (AuxDetGeometryCore &&)=delete
 
AuxDetGeometryCoreoperator= (AuxDetGeometryCore const &)=delete
 
AuxDetGeometryCoreoperator= (AuxDetGeometryCore &&)=delete
 
std::string const & GDMLFile () const
 Returns the full directory path to the GDML file source. More...
 
std::string const & DetectorName () const
 Returns a string with the name of the detector, as configured. More...
 
std::size_t NAuxDets () const
 Returns the number of auxiliary detectors. More...
 
std::size_t NAuxDetSensitive (size_t ad) const
 Returns the number of sensitive components of auxiliary detector. More...
 
std::vector< AuxDetGeo > const & AuxDetGeoVec () const
 Returns the full list of pointer to the auxiliary detectors. More...
 
AuxDetGeo const & AuxDet (std::size_t const ad=0) const
 Returns the specified auxiliary detector. More...
 
Point_t AuxDetChannelToPosition (std::string const &auxDetName, uint32_t channel) const
 
AuxDetSensitiveGeo const & ChannelToAuxDetSensitive (std::string const &auxDetName, uint32_t channel) const
 
std::size_t FindAuxDetAtPosition (Point_t const &point, double tolerance=0) const
 Returns the index of the auxiliary detector at specified location. More...
 
AuxDetGeo const & PositionToAuxDet (Point_t const &point, double tolerance=0.) const
 Returns the auxiliary detector at specified location. More...
 
void FindAuxDetSensitiveAtPosition (Point_t const &point, std::size_t &adg, std::size_t &sv, double tolerance=0) const
 Fills the indices of the sensitive auxiliary detector at location. More...
 
Geometry initialization
bool hasAuxDetChannelMap () const
 Returns whether we have a channel map. More...
 

Private Member Functions

void LoadGeometryFile ()
 
void ApplyChannelMap ()
 

Private Attributes

std::vector< AuxDetGeofAuxDets
 
std::unique_ptr< AuxDetGeoObjectSorterfSorter
 
std::unique_ptr< AuxDetInitializerfInitializer
 
std::string fGDMLfile
 path to geometry file used for Geant4 simulation More...
 
std::string fDetectorName
 
fhicl::ParameterSet fBuilderParameters
 Configuration of geometry builder. More...
 
std::unique_ptr< AuxDetReadoutGeom const > fReadoutGeom
 Object containing the channel to wire mapping. More...
 
bool fThrowIfAbsent
 

Detailed Description

Description of physical geometry of one set of auxiliary detectors.


Note
All lengths are specified in centimeters

AuxDetGeometryCore construction

The constructor of the AuxDetGeometryCore performs two steps:

  1. It initializes a AuxDetGeometryCoreobject (the "service provider") with the configuration parameters, a user-provided geometry builder, and a user-provided geometry sorter.
  2. It loads the geometry with AuxDetGeometryCore::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.
  • Builder (parameter set; default: {}): parameters used in constructing GeometryBuilderStandard
  • ThrowIfAbsent (boolean; default: true) if true throws when the requested AuxDet element is not available; otherwise logs a message and returns a nonsense value when possible.

Definition at line 69 of file AuxDetGeometryCore.h.

Constructor & Destructor Documentation

geo::AuxDetGeometryCore::AuxDetGeometryCore ( fhicl::ParameterSet const &  pset,
std::unique_ptr< AuxDetGeoObjectSorter sorter = nullptr,
std::unique_ptr< AuxDetInitializer initializer = nullptr 
)

Initialize geometry from a given configuration.

Parameters
psetconfiguration parameters
sortersorter used for sorting AuxDet elements
initializerinitializer used to construct AuxDetReadoutGeom object
See also
AuxDetReadoutGeom.cxx

Definition at line 39 of file AuxDetGeometryCore.cxx.

References fBuilderParameters, fDetectorName, fGDMLfile, fInitializer, fThrowIfAbsent, LoadGeometryFile(), geo::details::maybe_default_detector_name(), and lar::searchPathPlusRelative().

42  : fSorter{std::move(sorter)}
43  , fInitializer{std::move(initializer)}
44  , fGDMLfile{lar::searchPathPlusRelative(pset.get<std::string>("RelativePath", ""),
45  pset.get<std::string>("GDML"))}
47  , fBuilderParameters(pset.get<fhicl::ParameterSet>("Builder", {}))
48  , fThrowIfAbsent(pset.get("ThrowIfAbsent", true))
49  {
50  std::transform(fDetectorName.begin(), fDetectorName.end(), fDetectorName.begin(), [](auto c) {
51  return std::tolower(c);
52  });
53 
55  }
std::string searchPathPlusRelative(std::string relativePath, std::string fileName)
std::unique_ptr< AuxDetGeoObjectSorter > fSorter
fhicl::ParameterSet fBuilderParameters
Configuration of geometry builder.
std::string maybe_default_detector_name(fhicl::ParameterSet const &pset, std::string const &filename)
std::string fGDMLfile
path to geometry file used for Geant4 simulation
std::unique_ptr< AuxDetInitializer > fInitializer
geo::AuxDetGeometryCore::AuxDetGeometryCore ( AuxDetGeometryCore const &  )
delete
geo::AuxDetGeometryCore::AuxDetGeometryCore ( AuxDetGeometryCore &&  )
delete

Member Function Documentation

void geo::AuxDetGeometryCore::ApplyChannelMap ( )
private

Definition at line 58 of file AuxDetGeometryCore.cxx.

References fAuxDets, fInitializer, and fReadoutGeom.

Referenced by hasAuxDetChannelMap(), and LoadGeometryFile().

59  {
60  auto initializers = fInitializer ? fInitializer->init(fAuxDets) : AuxDetReadoutInitializers{};
61  fReadoutGeom = std::make_unique<AuxDetReadoutGeom>(std::move(initializers));
62  }
std::unique_ptr< AuxDetReadoutGeom const > fReadoutGeom
Object containing the channel to wire mapping.
std::vector< AuxDetGeo > fAuxDets
std::unique_ptr< AuxDetInitializer > fInitializer
AuxDetGeo const & geo::AuxDetGeometryCore::AuxDet ( std::size_t const  ad = 0) const

Returns the specified auxiliary detector.

Parameters
adthe auxiliary detector index
Returns
a constant reference to the specified auxiliary detector
Exceptions
cet::exception(category "AuxDetGeometryCore") if ad is out of range
Todo:

what happens if it does not exist?

remove the default parameter?

Definition at line 109 of file AuxDetGeometryCore.cxx.

References fAuxDets, and NAuxDets().

Referenced by AuxDetGeoVec(), ChannelToAuxDetSensitive(), geo::WireReadoutDumper::dumpAuxiliaryDetectors(), and PositionToAuxDet().

110  {
111  if (ad >= NAuxDets()) {
112  throw cet::exception("AuxDetGeometryCore") << "AuxDet " << ad << " does not exist\n";
113  }
114  return fAuxDets[ad];
115  }
std::size_t NAuxDets() const
Returns the number of auxiliary detectors.
std::vector< AuxDetGeo > fAuxDets
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
Point_t geo::AuxDetGeometryCore::AuxDetChannelToPosition ( std::string const &  auxDetName,
uint32_t  channel 
) const

Definition at line 151 of file AuxDetGeometryCore.cxx.

References fAuxDets, and fReadoutGeom.

Referenced by AuxDetGeoVec().

153  {
154  return fReadoutGeom->AuxDetChannelToPosition(channel, auxDetName, fAuxDets);
155  }
std::unique_ptr< AuxDetReadoutGeom const > fReadoutGeom
Object containing the channel to wire mapping.
std::vector< AuxDetGeo > fAuxDets
std::vector<AuxDetGeo> const& geo::AuxDetGeometryCore::AuxDetGeoVec ( ) const
inline

Returns the full list of pointer to the auxiliary detectors.

Definition at line 131 of file AuxDetGeometryCore.h.

References AuxDet(), AuxDetChannelToPosition(), ChannelToAuxDetSensitive(), fAuxDets, FindAuxDetAtPosition(), FindAuxDetSensitiveAtPosition(), and PositionToAuxDet().

131 { return fAuxDets; }
std::vector< AuxDetGeo > fAuxDets
AuxDetSensitiveGeo const & geo::AuxDetGeometryCore::ChannelToAuxDetSensitive ( std::string const &  auxDetName,
uint32_t  channel 
) const

Definition at line 158 of file AuxDetGeometryCore.cxx.

References AuxDet(), fReadoutGeom, and geo::AuxDetGeo::SensitiveVolume().

Referenced by AuxDetGeoVec().

161  {
162  auto idx = fReadoutGeom->ChannelToSensitiveAuxDet(auxDetName, channel);
163  return AuxDet(idx.first).SensitiveVolume(idx.second);
164  }
AuxDetGeo const & AuxDet(std::size_t const ad=0) const
Returns the specified auxiliary detector.
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:123
std::unique_ptr< AuxDetReadoutGeom const > fReadoutGeom
Object containing the channel to wire mapping.
std::string const& geo::AuxDetGeometryCore::DetectorName ( ) const
inline

Returns a string with the name of the detector, as configured.

Definition at line 98 of file AuxDetGeometryCore.h.

References fDetectorName.

98 { return fDetectorName; }
std::size_t geo::AuxDetGeometryCore::FindAuxDetAtPosition ( Point_t const &  point,
double  tolerance = 0 
) const

Returns the index of the auxiliary detector at specified location.

Parameters
pointlocation to be tested
tolerancetolerance (cm) for matches. Default 0
Returns
the index of the detector, or std::numeric_limits<unsigned int>::max() if no detector is there
Bug:
Actually, an exception is thrown.

Definition at line 128 of file AuxDetGeometryCore.cxx.

References fAuxDets, fReadoutGeom, and fThrowIfAbsent.

Referenced by AuxDetGeoVec(), larg4::AuxDetReadoutGeometry::FindAndMakeAuxDet(), FindAuxDetSensitiveAtPosition(), and PositionToAuxDet().

129  {
130  return fReadoutGeom->NearestAuxDet(point, fAuxDets, tolerance, fThrowIfAbsent);
131  }
std::unique_ptr< AuxDetReadoutGeom const > fReadoutGeom
Object containing the channel to wire mapping.
std::vector< AuxDetGeo > fAuxDets
void geo::AuxDetGeometryCore::FindAuxDetSensitiveAtPosition ( Point_t const &  point,
std::size_t &  adg,
std::size_t &  sv,
double  tolerance = 0 
) const

Fills the indices of the sensitive auxiliary detector at location.

Parameters
pointlocation to be tested
adg_(output)_ auxiliary detector index
sv_(output)_ sensitive volume index
tolerancetolerance (cm) for matches. Default 0.

Definition at line 141 of file AuxDetGeometryCore.cxx.

References fAuxDets, FindAuxDetAtPosition(), fReadoutGeom, and fThrowIfAbsent.

Referenced by AuxDetGeoVec(), larg4::AuxDetReadoutGeometry::FindAndMakeAuxDetSensitive(), and sim::GenericCRTUtility::GetAuxDetSimChannelByNumber().

145  {
146  adg = FindAuxDetAtPosition(point, tolerance);
147  sv = fReadoutGeom->NearestSensitiveAuxDet(point, fAuxDets, tolerance, fThrowIfAbsent);
148  }
std::size_t FindAuxDetAtPosition(Point_t const &point, double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
std::unique_ptr< AuxDetReadoutGeom const > fReadoutGeom
Object containing the channel to wire mapping.
std::vector< AuxDetGeo > fAuxDets
std::string const& geo::AuxDetGeometryCore::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 95 of file AuxDetGeometryCore.h.

References fGDMLfile.

95 { return fGDMLfile; }
std::string fGDMLfile
path to geometry file used for Geant4 simulation
bool geo::AuxDetGeometryCore::hasAuxDetChannelMap ( ) const
inline

Returns whether we have a channel map.

Definition at line 186 of file AuxDetGeometryCore.h.

References ApplyChannelMap(), fReadoutGeom, and LoadGeometryFile().

186 { return bool(fReadoutGeom); }
std::unique_ptr< AuxDetReadoutGeom const > fReadoutGeom
Object containing the channel to wire mapping.
void geo::AuxDetGeometryCore::LoadGeometryFile ( )
private

Definition at line 65 of file AuxDetGeometryCore.cxx.

References ApplyChannelMap(), geo::GeometryBuilder::extractAuxiliaryDetectors(), fAuxDets, fBuilderParameters, fGDMLfile, and fSorter.

Referenced by AuxDetGeometryCore(), and hasAuxDetChannelMap().

66  {
67 
68  if (fGDMLfile.empty()) {
69  throw cet::exception("AuxDetGeometryCore") << "No GDML Geometry file specified!\n";
70  }
71 
72  (void)gROOT; // <= Can be removed once ROOT 6.26/08 is adopted
73 
74  // Open the GDML file, and convert it into ROOT TGeoManager format. Try to be
75  // efficient - if the GeometryCore object already imported the file, then the
76  // gGeoManager will be non-null. If not, import it. Then lock the gGeoManager to
77  // prevent future imports.
78  if (!gGeoManager) {
79  // [20210701, petrillo@slac.stanford.edu]
80  // same code, same comment as in `geo::GeometryCore::LoadGeometryFile()`.
81  TGeoManager::LockDefaultUnits(false);
82  TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits);
83  TGeoManager::LockDefaultUnits(true);
84  TGeoManager::Import(fGDMLfile.c_str());
85  gGeoManager->LockGeometry();
86  }
87 
88  GeometryBuilderStandard builder(
90  GeoNodePath path{gGeoManager->GetTopNode()};
91 
92  fAuxDets = builder.extractAuxiliaryDetectors(path);
93  if (fSorter) { fSorter->sort(fAuxDets); }
94 
96 
97  mf::LogInfo("AuxDetGeometryCore") << "New detector geometry loaded from\n\t" << fGDMLfile;
98  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::unique_ptr< AuxDetGeoObjectSorter > fSorter
fhicl::ParameterSet fBuilderParameters
Configuration of geometry builder.
std::vector< AuxDetGeo > fAuxDets
std::string fGDMLfile
path to geometry file used for Geant4 simulation
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::size_t geo::AuxDetGeometryCore::NAuxDets ( ) const
inline

Returns the number of auxiliary detectors.

Todo:
use a AutDetID_t instead of unsigned int?

This method returns the total number of scintillator paddles (Auxiliary Detectors aka AuxDet) outside of the cryostat

Definition at line 116 of file AuxDetGeometryCore.h.

References fAuxDets, and NAuxDetSensitive().

Referenced by AuxDet(), geo::WireReadoutDumper::dumpAuxiliaryDetectors(), geo::WireReadoutDumper::dumpDetectorInfo(), and NAuxDetSensitive().

116 { return fAuxDets.size(); }
std::vector< AuxDetGeo > fAuxDets
std::size_t geo::AuxDetGeometryCore::NAuxDetSensitive ( size_t  ad) const

Returns the number of sensitive components of auxiliary detector.

Parameters
adID of the auxiliary detector
Returns
number of sensitive components in the auxiliary detector aid
Exceptions
cet::exception(category "AuxDetGeometryCore") if ad is out of range

Definition at line 118 of file AuxDetGeometryCore.cxx.

References fAuxDets, and NAuxDets().

Referenced by NAuxDets().

119  {
120  if (aid >= NAuxDets()) {
121  throw cet::exception("AuxDetGeometry")
122  << "Requested AuxDet index " << aid << " is out of range: " << NAuxDets();
123  }
124  return fAuxDets[aid].NSensitiveVolume();
125  }
std::size_t NAuxDets() const
Returns the number of auxiliary detectors.
std::vector< AuxDetGeo > fAuxDets
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
AuxDetGeometryCore& geo::AuxDetGeometryCore::operator= ( AuxDetGeometryCore const &  )
delete
AuxDetGeometryCore& geo::AuxDetGeometryCore::operator= ( AuxDetGeometryCore &&  )
delete
AuxDetGeo const & geo::AuxDetGeometryCore::PositionToAuxDet ( Point_t const &  point,
double  tolerance = 0. 
) const

Returns the auxiliary detector at specified location.

Parameters
pointlocation to be tested
tolerancetolerance (cm) for matches. Default 0.
Returns
constant reference to AuxDetGeo object of the auxiliary detector

Definition at line 134 of file AuxDetGeometryCore.cxx.

References AuxDet(), and FindAuxDetAtPosition().

Referenced by AuxDetGeoVec().

136  {
137  return AuxDet(FindAuxDetAtPosition(point, tolerance));
138  }
AuxDetGeo const & AuxDet(std::size_t const ad=0) const
Returns the specified auxiliary detector.
std::size_t FindAuxDetAtPosition(Point_t const &point, double tolerance=0) const
Returns the index of the auxiliary detector at specified location.

Member Data Documentation

fhicl::ParameterSet geo::AuxDetGeometryCore::fBuilderParameters
private

Configuration of geometry builder.

Definition at line 200 of file AuxDetGeometryCore.h.

Referenced by AuxDetGeometryCore(), and LoadGeometryFile().

std::string geo::AuxDetGeometryCore::fDetectorName
private

Definition at line 199 of file AuxDetGeometryCore.h.

Referenced by AuxDetGeometryCore(), and DetectorName().

std::string geo::AuxDetGeometryCore::fGDMLfile
private

path to geometry file used for Geant4 simulation

Definition at line 198 of file AuxDetGeometryCore.h.

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

std::unique_ptr<AuxDetInitializer> geo::AuxDetGeometryCore::fInitializer
private

Definition at line 197 of file AuxDetGeometryCore.h.

Referenced by ApplyChannelMap(), and AuxDetGeometryCore().

std::unique_ptr<AuxDetReadoutGeom const> geo::AuxDetGeometryCore::fReadoutGeom
private
std::unique_ptr<AuxDetGeoObjectSorter> geo::AuxDetGeometryCore::fSorter
private

Definition at line 196 of file AuxDetGeometryCore.h.

Referenced by LoadGeometryFile().

bool geo::AuxDetGeometryCore::fThrowIfAbsent
private

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