Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
geo::AuxDetGeometryCore Class Reference

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

#include <AuxDetGeometryCore.h>

Public Types

using AuxDetList_t = AuxDetGeometryData_t::AuxDetList_t
 Type of list of auxiliary detectors. More...
 

Public Member Functions

 AuxDetGeometryCore (fhicl::ParameterSet const &pset)
 Initialize geometry from a given configuration. More...
 
 AuxDetGeometryCore (AuxDetGeometryCore const &)=delete
 
 AuxDetGeometryCore (AuxDetGeometryCore &&)=delete
 
AuxDetGeometryCoreoperator= (AuxDetGeometryCore const &)=delete
 
AuxDetGeometryCoreoperator= (AuxDetGeometryCore &&)=delete
 
std::string ROOTFile () const
 Returns the full directory path to the geometry file source. More...
 
std::string GDMLFile () const
 Returns the full directory path to the GDML file source. More...
 
std::string DetectorName () const
 Returns a string with the name of the detector, as configured. More...
 
unsigned int NAuxDets () const
 Returns the number of auxiliary detectors. More...
 
unsigned int NAuxDetSensitive (size_t const &aid) 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 (unsigned int const ad=0) const
 Returns the specified auxiliary detector. More...
 
unsigned int FindAuxDetAtPosition (double const worldLoc[3], double tolerance=0) const
 Returns the index of the auxiliary detector at specified location. More...
 
void FindAuxDetSensitiveAtPosition (double const worldLoc[3], size_t &adg, size_t &sv, double tolerance=0) const
 Fills the indices of the sensitive auxiliary detector at location. More...
 
AuxDetGeo const & PositionToAuxDet (double const worldLoc[3], unsigned int &ad, double tolerance=0) const
 Returns the auxiliary detector at specified location. More...
 
const AuxDetSensitiveGeoPositionToAuxDetSensitive (double const worldLoc[3], size_t &ad, size_t &sv, double tolerance=0) const
 Returns the auxiliary detector at specified location. More...
 
uint32_t PositionToAuxDetChannel (double const worldLoc[3], size_t &ad, size_t &sv) const
 
TVector3 AuxDetChannelToPosition (uint32_t const &channel, std::string const &auxDetName) const
 
const AuxDetGeoChannelToAuxDet (std::string const &auxDetName, uint32_t const &channel) const
 
const AuxDetSensitiveGeoChannelToAuxDetSensitive (std::string const &auxDetName, uint32_t const &channel) const
 
Geometry initialization
void LoadGeometryFile (std::string gdmlfile, std::string rootfile)
 Loads the geometry information from the specified files. More...
 
bool hasAuxDetChannelMap () const
 Returns whether we have a channel map. More...
 
void ApplyChannelMap (std::unique_ptr< geo::AuxDetChannelMapAlg > pChannelMap)
 Initializes the geometry to work with this channel map. More...
 

Protected Member Functions

geo::AuxDetChannelMapAlg const * AuxDetChannelMap () const
 Returns the object handling the channel map. More...
 
AuxDetList_tAuxDets ()
 Return the internal auxiliary detectors list. More...
 
AuxDetList_t const & AuxDets () const
 

Private Member Functions

void ClearGeometry ()
 Deletes the detector geometry structures. More...
 

Private Attributes

AuxDetGeometryData_t fGeoData
 The detector description data. More...
 
std::string fDetectorName
 Name of the detector. More...
 
std::string fGDMLfile
 path to geometry file used for Geant4 simulation More...
 
std::string fROOTfile
 path to geometry file for geometry in GeometryCore More...
 
fhicl::ParameterSet fBuilderParameters
 Configuration of geometry builder. More...
 
std::unique_ptr< const geo::AuxDetChannelMapAlgfChannelMapAlg
 Object containing the channel to wire mapping. More...
 

Detailed Description

Description of geometry of one set of auxiliary detectors.


Note
All lengths are specified in centimetres

How to correctly instantiate a GeometryCore object

Instantiation is a multi-step procedure:

  1. construct a GeometryCore object (the "service provider"), with the full configuration; at this step, configuration is just stored
  2. load a geometry with GeometryCore::LoadGeometryFile(); this loads the detector geometry information
  3. prepare a channel map algorithm object (might use for example GeometryCore::DetectorName() or the detector geometry from the newly created object, but any use of channel mapping related functions is forbidden and it would yield undefined behaviour (expected to be catastrophic)
  4. acquire the channel mapping algorithm with GeometryCore::ApplyChannelMap(); at this point, the ChannelMapAlg object is asked to initialize itself and to perform whatever modifications to the geometry provider is needed.

Step 3 (creation of the channel mapping algorithm object) can be performed at any time before step 4, provided that no GeometryCore instance is needed for it.

Configuration parameters

Definition at line 91 of file AuxDetGeometryCore.h.

Member Typedef Documentation

Type of list of auxiliary detectors.

Definition at line 95 of file AuxDetGeometryCore.h.

Constructor & Destructor Documentation

geo::AuxDetGeometryCore::AuxDetGeometryCore ( fhicl::ParameterSet const &  pset)

Initialize geometry from a given configuration.

Parameters
psetconfiguration parameters

This constructor does not load any geometry description. The next step is to do exactly that, by GeometryCore::LoadGeometryFile().

Definition at line 41 of file AuxDetGeometryCore.cxx.

42  : fDetectorName(pset.get< std::string >("Name"))
44  {
45  std::transform(fDetectorName.begin(), fDetectorName.end(), fDetectorName.begin(), ::tolower);
46  }
std::string string
Definition: nybbler.cc:12
std::string fDetectorName
Name of the detector.
fhicl::ParameterSet fBuilderParameters
Configuration of geometry builder.
geo::AuxDetGeometryCore::AuxDetGeometryCore ( AuxDetGeometryCore const &  )
delete
geo::AuxDetGeometryCore::AuxDetGeometryCore ( AuxDetGeometryCore &&  )
delete

Member Function Documentation

void geo::AuxDetGeometryCore::ApplyChannelMap ( std::unique_ptr< geo::AuxDetChannelMapAlg pChannelMap)

Initializes the geometry to work with this channel map.

Parameters
pChannelMapa pointer to the channel mapping algorithm to be used
See also
LoadGeometryFile()

The specified channel mapping is used with this geometry. The algorithm object is asked and allowed to make the necessary modifications to the geometry description. These modifications typically involve some resorting of the objects.

The ownership of the algorithm object is shared, usually with a calling framework: we maintain it alive as long as we need it (and no other code can delete it), and we delete it only if no other code is sharing the ownership.

This method needs to be called after LoadGeometryFile() to complete the geometry initialization.

Definition at line 49 of file AuxDetGeometryCore.cxx.

50  {
51  pChannelMap->Initialize(fGeoData);
52  fChannelMapAlg = move(pChannelMap);
53  }
AuxDetGeometryData_t fGeoData
The detector description data.
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
virtual void Initialize(AuxDetGeometryData_t &geodata)=0
def move(depos, offset)
Definition: depos.py:107
const AuxDetGeo & geo::AuxDetGeometryCore::AuxDet ( unsigned int const  ad = 0) const

Returns the specified auxiliary detector.

Parameters
adthe auxiliary detector index
Returns
a constant reference to the specified auxiliary detector
Todo:

what happens if it does not exist?

remove the default parameter?

Definition at line 127 of file AuxDetGeometryCore.cxx.

128  {
129  if(ad >= NAuxDets())
130  throw cet::exception("AuxDetGeometryCore") << "AuxDet "
131  << ad
132  << " does not exist\n";
133 
134  return AuxDets()[ad];
135  }
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
geo::AuxDetChannelMapAlg const* geo::AuxDetGeometryCore::AuxDetChannelMap ( ) const
inlineprotected

Returns the object handling the channel map.

Definition at line 301 of file AuxDetGeometryCore.h.

301 { return fChannelMapAlg.get(); }
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
TVector3 geo::AuxDetGeometryCore::AuxDetChannelToPosition ( uint32_t const &  channel,
std::string const &  auxDetName 
) const

Definition at line 185 of file AuxDetGeometryCore.cxx.

187  {
188  return fChannelMapAlg->AuxDetChannelToPosition(channel, auxDetName, AuxDets());
189  }
uint8_t channel
Definition: CRTFragment.hh:201
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
std::vector<AuxDetGeo> const& geo::AuxDetGeometryCore::AuxDetGeoVec ( ) const
inline

Returns the full list of pointer to the auxiliary detectors.

Definition at line 168 of file AuxDetGeometryCore.h.

168 { return AuxDets(); }
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
AuxDetList_t& geo::AuxDetGeometryCore::AuxDets ( )
inlineprotected

Return the internal auxiliary detectors list.

Definition at line 305 of file AuxDetGeometryCore.h.

305 { return fGeoData.auxDets; }
AuxDetGeometryData_t fGeoData
The detector description data.
AuxDetList_t auxDets
The auxiliary detectors.
AuxDetList_t const& geo::AuxDetGeometryCore::AuxDets ( ) const
inlineprotected

Definition at line 306 of file AuxDetGeometryCore.h.

306 { return fGeoData.auxDets; }
AuxDetGeometryData_t fGeoData
The detector description data.
AuxDetList_t auxDets
The auxiliary detectors.
const AuxDetGeo & geo::AuxDetGeometryCore::ChannelToAuxDet ( std::string const &  auxDetName,
uint32_t const &  channel 
) const

Definition at line 192 of file AuxDetGeometryCore.cxx.

194  {
195  size_t adIdx = fChannelMapAlg->ChannelToAuxDet(AuxDets(), auxDetName, channel);
196  return this->AuxDet(adIdx);
197  }
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
uint8_t channel
Definition: CRTFragment.hh:201
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
const AuxDetSensitiveGeo & geo::AuxDetGeometryCore::ChannelToAuxDetSensitive ( std::string const &  auxDetName,
uint32_t const &  channel 
) const

Definition at line 200 of file AuxDetGeometryCore.cxx.

202  {
203  auto idx = fChannelMapAlg->ChannelToSensitiveAuxDet(AuxDets(), auxDetName, channel);
204  return this->AuxDet(idx.first).SensitiveVolume(idx.second);
205  }
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:171
uint8_t channel
Definition: CRTFragment.hh:201
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
void geo::AuxDetGeometryCore::ClearGeometry ( )
private

Deletes the detector geometry structures.

Definition at line 102 of file AuxDetGeometryCore.cxx.

103  {
104  AuxDets().clear();
105  }
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
std::string geo::AuxDetGeometryCore::DetectorName ( ) const
inline

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

Definition at line 133 of file AuxDetGeometryCore.h.

133 { return fDetectorName; }
std::string fDetectorName
Name of the detector.
unsigned int geo::AuxDetGeometryCore::FindAuxDetAtPosition ( double const  worldLoc[3],
double  tolerance = 0 
) const

Returns the index of the auxiliary detector at specified location.

Parameters
worldLoc3D coordinates of the point (world reference frame)
Returns
the index of the detector, or UINT_MAX if no detector is there
Todo:
replace with numeric_limits<>?

Definition at line 139 of file AuxDetGeometryCore.cxx.

140  {
141  return fChannelMapAlg->NearestAuxDet(worldPos, AuxDets(), tolerance);
142  }
auto const tolerance
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
void geo::AuxDetGeometryCore::FindAuxDetSensitiveAtPosition ( double const  worldLoc[3],
size_t &  adg,
size_t &  sv,
double  tolerance = 0 
) const

Fills the indices of the sensitive auxiliary detector at location.

Parameters
worldLoc3D coordinates of the point (world reference frame)
adg(output) auxiliary detector index
sv(output) sensitive volume index
tolerancetolerance (cm) for matches. Default 0.

Definition at line 156 of file AuxDetGeometryCore.cxx.

160  {
161  adg = this->FindAuxDetAtPosition(worldPos, tolerance);
162  sv = fChannelMapAlg->NearestSensitiveAuxDet(worldPos, AuxDets(), adg, tolerance);
163  }
auto const tolerance
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
unsigned int FindAuxDetAtPosition(double const worldLoc[3], double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
std::string 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 129 of file AuxDetGeometryCore.h.

129 { 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 273 of file AuxDetGeometryCore.h.

273 { return bool(fChannelMapAlg); }
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
int bool
Definition: qglobal.h:345
void geo::AuxDetGeometryCore::LoadGeometryFile ( std::string  gdmlfile,
std::string  rootfile 
)

Loads the geometry information from the specified files.

Parameters
gdmlfilepath to file to be used for Geant4 simulation
rootfilepath to file for internal geometry representation
See also
ApplyChannelMap()

Both paths must directly resolve to an available file, as no search is performed for them.

The gdmlfile parameter does not have to necessarily be in GDML format, as long as it's something supported by Geant4. This file is not used by the geometry, but its path is provided on request by the simulation modules (see LArSoft LArG4 module). The rootfile also does not need to be a ROOT file, but just anything that TGeoManager::Import() supports. This file is parsed immediately and the internal geometry representation is built out of it.

Note
After calling this method, the detector geometry information can be considered complete, but the geometry service provider is not fully initialized yet, since it's still necessary to provide or update the channel mapping.

Definition at line 56 of file AuxDetGeometryCore.cxx.

57  {
58 
59  if (gdmlfile.empty()) {
60  throw cet::exception("AuxDetGeometryCore") << "No GDML Geometry file specified!\n";
61  }
62 
63  if (rootfile.empty()) {
64  throw cet::exception("AuxDetGeometryCore") << "No ROOT Geometry file specified!\n";
65  }
66 
67  ClearGeometry();
68 
69  // Open the GDML file, and convert it into ROOT TGeoManager format.
70  // try to be efficient - if the GeometryCore object already imported
71  // the file, then the gGeoManager will be non-null. If not, import it.
72  // Then lock the gGeoManager to prevent future imports.
73  if( !gGeoManager ){
74  // [20210701, petrillo@slac.stanford.edu]
75  // same code, same comment as in `geo::GeometryCore::LoadGeometryFile()`.
76  TGeoManager::LockDefaultUnits(false);
77  TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits);
78  TGeoManager::LockDefaultUnits(true);
79  TGeoManager::Import(rootfile.c_str());
80  gGeoManager->LockGeometry();
81  }
82 
85  (fBuilderParameters, { "tool_type" })
86  ()
87  );
88  geo::GeoNodePath path{ gGeoManager->GetTopNode() };
89 
90  AuxDets() = builder.extractAuxiliaryDetectors(path);
91 
92  fGDMLfile = gdmlfile;
93  fROOTfile = rootfile;
94 
95  mf::LogInfo("AuxDetGeometryCore") << "New detector geometry loaded from "
96  << "\n\t" << fROOTfile
97  << "\n\t" << fGDMLfile << "\n";
98 
99  } // AuxDetGeometryCore::LoadGeometryFile()
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
#define Import
fhicl::ParameterSet fBuilderParameters
Configuration of geometry builder.
std::string fROOTfile
path to geometry file for geometry in GeometryCore
void ClearGeometry()
Deletes the detector geometry structures.
std::string fGDMLfile
path to geometry file used for Geant4 simulation
Representation of a node and its ancestry.
Definition: GeoNodePath.h:38
Extracts of LArSoft geometry information from ROOT.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int 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

Todo:
Change return type to size_t

Definition at line 153 of file AuxDetGeometryCore.h.

153 { return AuxDets().size(); }
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
unsigned int geo::AuxDetGeometryCore::NAuxDetSensitive ( size_t const &  aid) const

Returns the number of sensitive components of auxiliary detector.

Parameters
aidID of the auxiliary detector
Returns
number of sensitive components in the auxiliary detector aid
Exceptions
cet::exception(category "Geometry") if aid does not exist

Definition at line 109 of file AuxDetGeometryCore.cxx.

110  {
111  if( aid > NAuxDets() - 1)
112  throw cet::exception("Geometry") << "Requested AuxDet index " << aid
113  << " is out of range: " << NAuxDets();
114 
115  return AuxDets()[aid].NSensitiveVolume();
116  }
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
AuxDetGeometryCore& geo::AuxDetGeometryCore::operator= ( AuxDetGeometryCore const &  )
delete
AuxDetGeometryCore& geo::AuxDetGeometryCore::operator= ( AuxDetGeometryCore &&  )
delete
const AuxDetGeo & geo::AuxDetGeometryCore::PositionToAuxDet ( double const  worldLoc[3],
unsigned int &  ad,
double  tolerance = 0 
) const

Returns the auxiliary detector at specified location.

Parameters
worldLoc3D coordinates of the point (world reference frame)
ad(output) the auxiliary detector index
tolerancetolerance (cm) for matches. Default 0
Returns
constant reference to AuxDetGeo object of the auxiliary detector
Todo:
what happens if it does not exist?

Definition at line 145 of file AuxDetGeometryCore.cxx.

148  {
149  // locate the desired Auxiliary Detector
150  ad = this->FindAuxDetAtPosition(worldLoc, tolerance);
151 
152  return this->AuxDet(ad);
153  }
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
auto const tolerance
unsigned int FindAuxDetAtPosition(double const worldLoc[3], double tolerance=0) const
Returns the index of the auxiliary detector at specified location.
uint32_t geo::AuxDetGeometryCore::PositionToAuxDetChannel ( double const  worldLoc[3],
size_t &  ad,
size_t &  sv 
) const

Definition at line 177 of file AuxDetGeometryCore.cxx.

180  {
181  return fChannelMapAlg->PositionToAuxDetChannel(worldLoc, AuxDets(), ad, sv);
182  }
std::unique_ptr< const geo::AuxDetChannelMapAlg > fChannelMapAlg
Object containing the channel to wire mapping.
AuxDetList_t & AuxDets()
Return the internal auxiliary detectors list.
const AuxDetSensitiveGeo & geo::AuxDetGeometryCore::PositionToAuxDetSensitive ( double const  worldLoc[3],
size_t &  ad,
size_t &  sv,
double  tolerance = 0 
) const

Returns the auxiliary detector at specified location.

Parameters
worldLoc3D coordinates of the point (world reference frame
tolerancetolerance (cm) for matches. Default 0.
ad(output) the auxiliary detector index
sv(output) the auxiliary detector sensitive volume index
Returns
reference to AuxDetSensitiveGeo object of the auxiliary detector
Todo:
what happens if it does not exist?

Definition at line 166 of file AuxDetGeometryCore.cxx.

170  {
171  // locate the desired Auxiliary Detector
172  this->FindAuxDetSensitiveAtPosition(worldLoc, ad, sv, tolerance);
173  return this->AuxDet(ad).SensitiveVolume(sv);
174  }
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:171
auto const tolerance
void FindAuxDetSensitiveAtPosition(double const worldLoc[3], size_t &adg, size_t &sv, double tolerance=0) const
Fills the indices of the sensitive auxiliary detector at location.
std::string geo::AuxDetGeometryCore::ROOTFile ( ) const
inline

Returns the full directory path to the geometry file source.

Returns
the full directory path to the geometry file source

This is the full path of the source of the detector geometry GeometryCore relies on.

Definition at line 120 of file AuxDetGeometryCore.h.

120 { return fROOTfile; }
std::string fROOTfile
path to geometry file for geometry in GeometryCore

Member Data Documentation

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

Configuration of geometry builder.

Definition at line 319 of file AuxDetGeometryCore.h.

std::unique_ptr<const geo::AuxDetChannelMapAlg> geo::AuxDetGeometryCore::fChannelMapAlg
private

Object containing the channel to wire mapping.

Definition at line 320 of file AuxDetGeometryCore.h.

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

Name of the detector.

Definition at line 316 of file AuxDetGeometryCore.h.

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

path to geometry file used for Geant4 simulation

Definition at line 317 of file AuxDetGeometryCore.h.

AuxDetGeometryData_t geo::AuxDetGeometryCore::fGeoData
private

The detector description data.

Definition at line 314 of file AuxDetGeometryCore.h.

std::string geo::AuxDetGeometryCore::fROOTfile
private

path to geometry file for geometry in GeometryCore

Definition at line 318 of file AuxDetGeometryCore.h.


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