LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CryostatGeo.h
Go to the documentation of this file.
1 #ifndef LARCOREALG_GEOMETRY_CRYOSTATGEO_H
9 #define LARCOREALG_GEOMETRY_CRYOSTATGEO_H
10 
11 // LArSoft libraries
16 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect
18 #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t
19 
20 // ROOT libraries
21 #include "TGeoVolume.h"
22 #include "TGeoMatrix.h" // TGeoHMatrix
23 
24 // C/C++ standard libraries
25 #include <vector>
26 #include <string>
27 
28 // forward declarations
29 class TGeoNode;
30 
31 namespace geo {
32 
33  //......................................................................
37 
39  using TPCList_t = std::vector<TPCGeo>;
40 
41  public:
42 
44 
46 
61  struct CryostatGeoCoordinatesTag {};
63 
66 
69 
71 
72 
74  CryostatGeo(std::vector<const TGeoNode*>& path, int depth);
75 
76 
79 
81  double HalfWidth() const;
83  double HalfHeight() const;
85  double HalfLength() const;
87  double Width() const { return 2. * HalfWidth(); }
89  double Height() const { return 2. * HalfHeight(); }
91  double Length() const { return 2. * HalfLength(); }
93  double Mass() const { return fVolume->Weight(); }
95  const TGeoVolume* Volume() const { return fVolume; }
96 
100  { return BoundingBox(); }
101 
104  void Boundaries(double* boundaries) const;
105 
106 
109  { return Boundaries().Center(); }
110 
113  { return static_cast<geo::BoxBoundedGeo const&>(*this); }
114 
116  geo::CryostatID const& ID() const { return fID; }
117 
118 
140  template <typename Stream>
141  void PrintCryostatInfo
142  (Stream&& out, std::string indent = "", unsigned int verbosity = 1) const;
143 
145  static constexpr unsigned int MaxVerbosity = 3;
146 
148 
149 
150  // BEGIN TPC access --------------------------------------------------------
153 
155  unsigned int NTPC() const { return fTPCs.size(); }
157  unsigned int NElements() const { return fTPCs.size(); }
158 
164  bool HasTPC(unsigned int itpc) const { return itpc < NTPC(); }
165 
167  bool HasElement(unsigned int itpc) const { return HasTPC(itpc); }
168 
177  bool HasTPC(geo::TPCID const& tpcid) const { return HasTPC(tpcid.TPC); }
179  bool HasElement(geo::TPCID const& tpcid) const { return HasTPC(tpcid); }
180 
183  const TPCGeo& TPC(unsigned int itpc) const;
184 
194  const TPCGeo& TPC(TPCID const& tpcid) const
195  { return TPC(tpcid.TPC); }
197  const TPCGeo& GetElement(TPCID const& tpcid) const
198  { return TPC(tpcid); }
199 
200 
210  auto const& TPCs() const { return fTPCs; }
211 
217  TPCGeo const* TPCPtr(unsigned int itpc) const
218  { return HasTPC(itpc)? &(fTPCs[itpc]): nullptr; }
219 
228  TPCGeo const* TPCPtr(TPCID const& tpcid) const
229  { return TPCPtr(tpcid.TPC); }
231  TPCGeo const* GetElementPtr(TPCID const& tpcid) const
232  { return TPCPtr(tpcid); }
233 
242  (double const worldLoc[3], double const wiggle) const;
243 
251  (geo::Point_t const& point, double wiggle) const;
252 
259  TPCGeo const& PositionToTPC
260  (geo::Point_t const& point, double wiggle) const;
267  TPCGeo const& PositionToTPC
268  (double const worldLoc[3], double wiggle) const
269  { return PositionToTPC(geo::vect::makePointFromCoords(worldLoc), wiggle); }
270 
278  (geo::Point_t const& point, double wiggle) const;
279 
281  unsigned int MaxPlanes() const;
282 
284  unsigned int MaxWires() const;
285 
287  // END TPC access ----------------------------------------------------------
288 
289 
290  // BEGIN Optical detector access -------------------------------------------
293 
295  unsigned int NOpDet() const { return fOpDets.size(); }
296 
298  const OpDetGeo& OpDet(unsigned int iopdet) const;
299 
302  unsigned int GetClosestOpDet(geo::Point_t const& point) const;
304  unsigned int GetClosestOpDet(double const* point) const;
305 
308  geo::OpDetGeo const* GetClosestOpDetPtr(geo::Point_t const& point) const;
309 
311  std::string OpDetGeoName() const { return fOpDetGeoName; }
312 
314  // END Optical detector access ---------------------------------------------
315 
316  // BEGIN Coordinate transformation -----------------------------------------
319 
321  void LocalToWorld(const double* cryo, double* world) const
322  { fTrans.LocalToWorld(cryo, world); }
323 
331  template <typename Point>
332  [[deprecated("use toWorldCoords() instead")]]
333  Point LocalToWorld(Point const& local) const
334  { return fTrans.LocalToWorld(local); }
335 
338  { return fTrans.toWorldCoords(local); }
339 
341  void LocalToWorldVect(const double* cryo, double* world) const
342  { fTrans.LocalToWorldVect(cryo, world); }
343 
346  { return fTrans.toWorldCoords(local); }
347 
349  void WorldToLocal(const double* world, double* cryo) const
350  { fTrans.WorldToLocal(world, cryo); }
351 
359  template <typename Point>
360  [[deprecated("use toLocalCoords() instead")]]
361  Point WorldToLocal(Point const& world) const
362  { return fTrans.WorldToLocal(world); }
363 
366  { return fTrans.toLocalCoords(world); }
367 
369  void WorldToLocalVect(const double* world, double* cryo) const
370  { fTrans.WorldToLocalVect(world, cryo); }
371 
374  { return fTrans.toLocalCoords(world); }
375 
377  // END Coordinate transformation -------------------------------------------
378 
379 
381  void SortSubVolumes(geo::GeoObjectSorter const& sorter);
382 
383 
385  void UpdateAfterSorting(geo::CryostatID cryoid);
386 
387  private:
388 
389  void FindTPC(std::vector<const TGeoNode*>& path,
390  unsigned int depth);
391  void MakeTPC(std::vector<const TGeoNode*>& path,
392  int depth);
393 
394  void FindOpDet(std::vector<const TGeoNode*>& path,
395  unsigned int depth);
396  void MakeOpDet(std::vector<const TGeoNode*>& path,
397  int depth);
398 
400  void InitCryoBoundaries();
401 
402 
403  private:
404 
407 
410  std::vector<OpDetGeo> fOpDets;
411  TGeoVolume* fVolume;
412  std::string fOpDetGeoName;
414 
415  };
416 }
417 
418 
419 //------------------------------------------------------------------------------
420 //--- template implementation
421 //---
422 template <typename Stream>
424  Stream&& out,
425  std::string indent /* = "" */,
426  unsigned int verbosity /* = 1 */
427 ) const {
428 
429  //----------------------------------------------------------------------------
430  out << "Cryostat " << std::string(ID());
431 
432  if (verbosity-- <= 0) return; // 0
433 
434  //----------------------------------------------------------------------------
435  out
436  << " (" << Width() << " x " << Height() << " x " << Length() << ") cm^3 at "
437  << GetCenter();
438 
439  if (verbosity-- <= 0) return; // 1
440 
441  //----------------------------------------------------------------------------
442 
443  out << "\n" << indent
444  << "hosts " << NTPC() << " TPCs (largest number of planes: " << MaxPlanes()
445  << ", of wires: " << MaxWires() << ") and "
446  << NOpDet() << " optical detectors"
447  ;
448 
449  if (verbosity-- <= 0) return; // 2
450 
451  //----------------------------------------------------------------------------
452  // print also the containing box
453  geo::BoxBoundedGeo const& box = BoundingBox();
454  out << "\n" << indent
455  << "bounding box: " << box.Min() << " -- " << box.Max();
456 
457 // if (verbosity-- <= 0) return; // 3
458 
459  //----------------------------------------------------------------------------
460 } // geo::CryostatGeo::PrintCryostatInfo()
461 
462 
463 //------------------------------------------------------------------------------
464 
465 
466 #endif // LARCOREALG_GEOMETRY_CRYOSTATGEO_H
467 
CryostatGeo(std::vector< const TGeoNode * > &path, int depth)
Construct a representation of a single cryostat of the detector.
Definition: CryostatGeo.cxx:66
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local cryostat frame.
Definition: CryostatGeo.h:365
void InitCryoBoundaries()
Fill the boundary information of the cryostat.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:167
unsigned int GetClosestOpDet(geo::Point_t const &point) const
geo::Point_t GetCenter() const
Returns the geometrical center of the cryostat.
Definition: CryostatGeo.h:108
double HalfLength() const
Half height of the cryostat [cm].
TPCGeo const * TPCPtr(TPCID const &tpcid) const
Returns the TPC in tpcid from this cryostat.
Definition: CryostatGeo.h:228
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: CryostatGeo.h:345
unsigned int MaxPlanes() const
Returns the largest number of planes among the TPCs in this cryostat.
double Mass() const
Mass of the cryostat.
Definition: CryostatGeo.h:93
TGeoVolume * fVolume
Total volume of cryostat, called volCryostat in GDML file.
Definition: CryostatGeo.h:411
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
Definition: CryostatGeo.h:373
Geometry information for a single TPC.
Definition: TPCGeo.h:37
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
void LocalToWorld(double const *local, double *world) const
Transforms a point from local frame to world frame.
void LocalToWorldVect(double const *local, double *world) const
Transforms a vector from local frame to world frame.
Geometry information for a single cryostat.
Definition: CryostatGeo.h:36
geo::BoxBoundedGeo const & BoundingBox() const
Returns the bounding box of this cryostat.
Definition: CryostatGeo.h:112
geo::TPCGeo const * PositionToTPCptr(geo::Point_t const &point, double wiggle) const
Returns a pointer to the TPC at specified location.
Point LocalToWorld(Point const &local) const
Definition: CryostatGeo.h:333
TPCGeo const * GetElementPtr(TPCID const &tpcid) const
Alias for TPCPtr().
Definition: CryostatGeo.h:231
std::string fOpDetGeoName
Name of opdet geometry elements in gdml.
Definition: CryostatGeo.h:412
std::vector< OpDetGeo > fOpDets
List of opdets in this cryostat.
Definition: CryostatGeo.h:410
Interface to algorithm class for sorting geo::XXXGeo objects.
void SortSubVolumes(geo::GeoObjectSorter const &sorter)
Method to sort TPCGeo objects.
std::string OpDetGeoName() const
Get name of opdet geometry element.
Definition: CryostatGeo.h:311
Tag for vectors in the "local" GDML coordinate frame of the cryostat.
Definition: CryostatGeo.h:62
bool HasElement(unsigned int itpc) const
Alias for HasTPC().
Definition: CryostatGeo.h:167
void PrintCryostatInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this cryostat.
Definition: CryostatGeo.h:423
geo::OpDetGeo const * GetClosestOpDetPtr(geo::Point_t const &point) const
const TGeoVolume * Volume() const
Pointer to ROOT&#39;s volume descriptor.
Definition: CryostatGeo.h:95
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet&#39;th optical detector in the cryostat.
Definitions of geometry vector data types.
double Height() const
Full height of the cryostat [cm].
Definition: CryostatGeo.h:89
unsigned int TPCID_t
Type for the ID number.
Definition: geo_types.h:196
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:34
geo::Point3DBase_t< CryostatGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML cryostat frame.
Definition: CryostatGeo.h:65
std::string indent(std::size_t const i)
double HalfWidth() const
Half width of the cryostat [cm].
unsigned int NElements() const
Alias for NTPC().
Definition: CryostatGeo.h:157
Utilities to extend the interface of geometry vectors.
double Width() const
Full width of the cryostat [cm].
Definition: CryostatGeo.h:87
TPCGeo const * TPCPtr(unsigned int itpc) const
Returns the TPC number itpc from this cryostat.
Definition: CryostatGeo.h:217
unsigned int NTPC() const
Number of TPCs in this cryostat.
Definition: CryostatGeo.h:155
geo::CryostatID fID
ID of this cryostat.
Definition: CryostatGeo.h:413
geo::Point_t Min() const
Returns the corner point with the smallest coordinates.
void WorldToLocal(const double *world, double *cryo) const
Transform point from world frame to local cryostat frame.
Definition: CryostatGeo.h:349
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
void FindOpDet(std::vector< const TGeoNode * > &path, unsigned int depth)
Definition of data types for geometry description.
unsigned int MaxWires() const
Returns the largest number of wires among the TPCs in this cryostat.
void UpdateAfterSorting(geo::CryostatID cryoid)
Performs all needed updates after geometry has sorted the cryostats.
Provides a base class aware of world box coordinates.
double HalfHeight() const
Half height of the cryostat [cm].
Encapsulate the geometry of an optical detector.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintCryostatInfo().
Definition: CryostatGeo.h:145
geo::TPCID::TPCID_t FindTPCAtPosition(double const worldLoc[3], double const wiggle) const
Returns the index of the TPC at specified location.
void LocalToWorld(const double *cryo, double *world) const
Transform point from local cryostat frame to world frame.
Definition: CryostatGeo.h:321
auto const & TPCs() const
Returns a container with references to all TPCs.
Definition: CryostatGeo.h:210
void FindTPC(std::vector< const TGeoNode * > &path, unsigned int depth)
void WorldToLocal(double const *world, double *local) const
Transforms a point from world frame to local frame.
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:35
std::vector< TGeoNode const * > GeoNodePath_t
Definition: WireGeo.h:68
TPCList_t fTPCs
List of tpcs in this cryostat.
Definition: CryostatGeo.h:409
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
unsigned int NOpDet() const
Number of optical detectors in this TPC.
Definition: CryostatGeo.h:295
void MakeOpDet(std::vector< const TGeoNode * > &path, int depth)
geo::Vector3DBase_t< CryostatGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML cryostat frame.
Definition: CryostatGeo.h:68
bool HasElement(geo::TPCID const &tpcid) const
Alias for HasTPC(geo::TPCID const&)
Definition: CryostatGeo.h:179
std::vector< TPCGeo > TPCList_t
Type used internally to store the TPCs.
Definition: CryostatGeo.h:39
const TPCGeo & TPC(TPCID const &tpcid) const
Returns the TPC in tpcid from this cryostat.
Definition: CryostatGeo.h:194
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether the TPC in tpcid is present in this cryostat.
Definition: CryostatGeo.h:177
LocalTransformation_t fTrans
Cryostat-to-world transformation.
Definition: CryostatGeo.h:408
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:95
geo::BoxBoundedGeo const & Boundaries() const
Returns boundaries of the cryostat (in centimetres).
Definition: CryostatGeo.h:99
GenVector3DBase_t< double, C > Vector3DBase_t
Definition: geo_vectors.h:90
void LocalToWorldVect(const double *cryo, double *world) const
Transform direction vector from local to world.
Definition: CryostatGeo.h:341
GlobalPoint_t toWorldCoords(LocalPoint_t const &local) const
Transforms a point from local frame to world frame.
bool HasTPC(unsigned int itpc) const
Returns whether a TPC with index itpc is present in this cryostat.
Definition: CryostatGeo.h:164
geo::WireGeo::GeoNodePath_t GeoNodePath_t
Definition: CryostatGeo.h:43
TPCGeo const & PositionToTPC(geo::Point_t const &point, double wiggle) const
Returns the ID of the TPC at specified location.
void WorldToLocalVect(const double *world, double *cryo) const
Transform direction vector from world to local.
Definition: CryostatGeo.h:369
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:203
void MakeTPC(std::vector< const TGeoNode * > &path, int depth)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:187
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Namespace collecting geometry-related classes utilities.
void WorldToLocalVect(const double *world, double *local) const
Transforms a vector from world frame to local frame.
geo::Point_t Max() const
Returns the corner point with the largest coordinates.
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local cryostat frame to world frame.
Definition: CryostatGeo.h:337
geo::TPCID PositionToTPCID(geo::Point_t const &point, double wiggle) const
Returns the ID of the TPC at specified location.
double Length() const
Length of the cryostat [cm].
Definition: CryostatGeo.h:91
Encapsulate the construction of a single detector plane.
Point WorldToLocal(Point const &world) const
Definition: CryostatGeo.h:361
The data type to uniquely identify a cryostat.
Definition: geo_types.h:120
const TPCGeo & GetElement(TPCID const &tpcid) const
Alias for TPC().
Definition: CryostatGeo.h:197
geo::Point_t Center() const
Returns the center point of the box.
geo::CryostatID const & ID() const
Returns the identifier of this cryostat.
Definition: CryostatGeo.h:116