LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
CryostatGeo.h
Go to the documentation of this file.
1 
7 #ifndef LARCOREALG_GEOMETRY_CRYOSTATGEO_H
8 #define LARCOREALG_GEOMETRY_CRYOSTATGEO_H
9 
10 // LArSoft libraries
13 #include "larcorealg/Geometry/LocalTransformationGeo.h" // for LocalT...
17 #include "larcorealg/Geometry/WireGeo.h" // for WireGeo
18 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect
20 #include "larcoreobj/SimpleTypesAndConstants/geo_vectors.h" // geo::Point_t
21 
22 // ROOT libraries
23 #include "Math/GenVector/DisplacementVector3D.h"
24 #include "Math/GenVector/PositionVector3D.h"
25 #include "Math/GenVector/Transform3D.h"
26 #include "TGeoVolume.h"
27 
28 // C/C++ standard libraries
29 #include <string>
30 #include <vector>
31 
32 // forward declarations
33 class TGeoNode;
34 
35 namespace geo {
36 
37  class GeoObjectSorter;
38 
39  //......................................................................
42  class CryostatGeo : public BoxBoundedGeo {
43 
44  public:
45  using ID_t = CryostatID;
46 
48  using TPCList_t = std::vector<TPCGeo>;
49 
51  using OpDetList_t = std::vector<OpDetGeo>;
52 
54 
56  using ElementIteratorBox = TPCList_t const&;
57 
59 
74  struct CryostatGeoCoordinatesTag {};
76 
79 
82 
84 
86  CryostatGeo(TGeoNode const* node,
87  TransformationMatrix&& trans,
88  TPCList_t&& TPCs,
89  OpDetList_t&& OpDets);
90 
93 
95  double HalfWidth() const;
97  double HalfHeight() const;
99  double HalfLength() const;
101  double Width() const { return 2. * HalfWidth(); }
103  double Height() const { return 2. * HalfHeight(); }
105  double Length() const { return 2. * HalfLength(); }
107  double Mass() const { return fVolume->Weight(); }
109  const TGeoVolume* Volume() const { return fVolume; }
110 
113  BoxBoundedGeo const& Boundaries() const { return BoundingBox(); }
114 
117  void Boundaries(double* boundaries) const;
118 
120  Point_t GetCenter() const { return Boundaries().Center(); }
121 
123  BoxBoundedGeo const& BoundingBox() const { return static_cast<BoxBoundedGeo const&>(*this); }
124 
126  CryostatID const& ID() const { return fID; }
127 
149  template <typename Stream>
150  void PrintCryostatInfo(Stream&& out, std::string indent = "", unsigned int verbosity = 1) const;
151 
159  std::string CryostatInfo(std::string indent = "", unsigned int verbosity = 1) const;
160 
162  static constexpr unsigned int MaxVerbosity = 3;
163 
165 
166  // BEGIN TPC access --------------------------------------------------------
169 
171  unsigned int NTPC() const { return fTPCs.size(); }
173  unsigned int NElements() const { return fTPCs.size(); }
174 
180  bool HasTPC(unsigned int itpc) const { return itpc < NTPC(); }
181 
183  bool HasElement(unsigned int itpc) const { return HasTPC(itpc); }
184 
193  bool HasTPC(TPCID const& tpcid) const { return HasTPC(tpcid.TPC); }
195  bool HasElement(TPCID const& tpcid) const { return HasTPC(tpcid); }
196 
199  TPCGeo const& TPC(unsigned int itpc) const;
200 
210  TPCGeo const& TPC(TPCID const& tpcid) const { return TPC(tpcid.TPC); }
212  TPCGeo const& GetElement(TPCID const& tpcid) const { return TPC(tpcid); }
213 
230 
246 
252  TPCGeo const* TPCPtr(unsigned int itpc) const
253  {
254  return HasTPC(itpc) ? &(fTPCs[itpc]) : nullptr;
255  }
256 
265  TPCGeo const* TPCPtr(TPCID const& tpcid) const { return TPCPtr(tpcid.TPC); }
267  TPCGeo const* GetElementPtr(TPCID const& tpcid) const { return TPCPtr(tpcid); }
268 
275  TPCID PositionToTPCID(Point_t const& point, double wiggle) const;
276 
283  TPCGeo const& PositionToTPC(Point_t const& point, double wiggle) const;
290  TPCGeo const& PositionToTPC(double const worldLoc[3], double wiggle) const
291  {
292  return PositionToTPC(vect::makePointFromCoords(worldLoc), wiggle);
293  }
294 
301  TPCGeo const* PositionToTPCptr(Point_t const& point, double wiggle) const;
302 
304  unsigned int MaxPlanes() const;
305 
307  unsigned int MaxWires() const;
308 
310  // END TPC access ----------------------------------------------------------
311 
312  // BEGIN Optical detector access -------------------------------------------
315 
317  unsigned int NOpDet() const { return fOpDets.size(); }
318 
320  OpDetGeo const& OpDet(unsigned int iopdet) const;
321 
324  unsigned int GetClosestOpDet(Point_t const& point) const;
326  unsigned int GetClosestOpDet(double const* point) const;
327 
330  OpDetGeo const* GetClosestOpDetPtr(Point_t const& point) const;
331 
333  std::string OpDetGeoName() const { return fOpDetGeoName; }
334 
336  // END Optical detector access ---------------------------------------------
337 
338  // BEGIN Coordinate transformation -----------------------------------------
341 
343  Point_t toWorldCoords(LocalPoint_t const& local) const { return fTrans.toWorldCoords(local); }
344 
346  Vector_t toWorldCoords(LocalVector_t const& local) const { return fTrans.toWorldCoords(local); }
347 
349  LocalPoint_t toLocalCoords(Point_t const& world) const { return fTrans.toLocalCoords(world); }
350 
352  LocalVector_t toLocalCoords(Vector_t const& world) const { return fTrans.toLocalCoords(world); }
353 
355  // END Coordinate transformation -------------------------------------------
356 
358  void SortSubVolumes(GeoObjectSorter const& sorter);
359 
361  void UpdateAfterSorting(CryostatID cryoid);
362 
363  private:
364  void FindTPC(std::vector<const TGeoNode*>& path, unsigned int depth);
365  void MakeTPC(std::vector<const TGeoNode*>& path, int depth);
366 
367  void FindOpDet(std::vector<const TGeoNode*>& path, unsigned int depth);
368  void MakeOpDet(std::vector<const TGeoNode*>& path, int depth);
369 
371  void InitCryoBoundaries();
372 
373  private:
374  using LocalTransformation_t =
376 
380  TGeoVolume* fVolume;
381  std::string fOpDetGeoName{"volOpDetSensitive"};
383  };
384 }
385 
386 //------------------------------------------------------------------------------
387 //--- template implementation
388 //---
389 template <typename Stream>
391  std::string indent /* = "" */,
392  unsigned int verbosity /* = 1 */
393 ) const
394 {
395  //----------------------------------------------------------------------------
396  out << "Cryostat " << std::string(ID());
397 
398  if (verbosity-- <= 0) return; // 0
399 
400  //----------------------------------------------------------------------------
401  out << " (" << Width() << " x " << Height() << " x " << Length() << ") cm^3 at " << GetCenter();
402 
403  if (verbosity-- <= 0) return; // 1
404 
405  //----------------------------------------------------------------------------
406 
407  out << "\n" << indent << "hosts " << NTPC() << " TPCs and " << NOpDet() << " optical detectors";
408 
409  if (verbosity-- <= 0) return; // 2
410 
411  //----------------------------------------------------------------------------
412  // print also the containing box
413  BoxBoundedGeo const& box = BoundingBox();
414  out << "\n" << indent << "bounding box: " << box.Min() << " -- " << box.Max();
415 }
416 
417 //------------------------------------------------------------------------------
418 
419 #endif // LARCOREALG_GEOMETRY_CRYOSTATGEO_H
420 
void InitCryoBoundaries()
Fill the boundary information of the cryostat.
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
double HalfLength() const
Half height of the cryostat [cm].
Vector3DBase_t< CryostatGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML cryostat frame.
Definition: CryostatGeo.h:81
TPCGeo const * TPCPtr(TPCID const &tpcid) const
Returns the TPC in tpcid from this cryostat.
Definition: CryostatGeo.h:265
TPCGeo const & TPC(TPCID const &tpcid) const
Returns the TPC in tpcid from this cryostat.
Definition: CryostatGeo.h:210
bool HasTPC(TPCID const &tpcid) const
Returns whether the TPC in tpcid is present in this cryostat.
Definition: CryostatGeo.h:193
Point_t Center() const
Returns the center point of the box.
unsigned int MaxPlanes() const
Returns the largest number of planes among the TPCs in this cryostat.
OpDetGeo const & OpDet(unsigned int iopdet) const
Return the iopdet&#39;th optical detector in the cryostat.
Definition: CryostatGeo.cxx:83
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
Point_t Max() const
Returns the corner point with the largest coordinates.
unsigned int GetClosestOpDet(Point_t const &point) const
double Mass() const
Mass of the cryostat.
Definition: CryostatGeo.h:107
LocalVector_t toLocalCoords(Vector_t const &world) const
Transform direction vector from world to local.
Definition: CryostatGeo.h:352
TGeoVolume * fVolume
Total volume of cryostat, called volCryostat in GDML file.
Definition: CryostatGeo.h:380
GENVECTOR_CONSTEXPR Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: CryostatGeo.h:346
Geometry information for a single TPC.
Definition: TPCGeo.h:33
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
ElementIteratorBox IterateTPCs() const
Returns an object suitable for iterating through all TPCs.
Definition: CryostatGeo.h:245
OpDetList_t fOpDets
List of opdets in this cryostat.
Definition: CryostatGeo.h:379
CryostatGeo(TGeoNode const *node, TransformationMatrix &&trans, TPCList_t &&TPCs, OpDetList_t &&OpDets)
Construct a representation of a single cryostat of the detector.
Definition: CryostatGeo.cxx:31
std::vector< OpDetGeo > OpDetList_t
Type used internally to store the optical detectors.
Definition: CryostatGeo.h:51
OpDetGeo const * GetClosestOpDetPtr(Point_t const &point) const
Geometry information for a single cryostat.
Definition: CryostatGeo.h:42
TPCGeo const & PositionToTPC(double const worldLoc[3], double wiggle) const
Returns the ID of the TPC at specified location.
Definition: CryostatGeo.h:290
BoxBoundedGeo const & BoundingBox() const
Returns the bounding box of this cryostat.
Definition: CryostatGeo.h:123
TPCGeo const * GetElementPtr(TPCID const &tpcid) const
Alias for TPCPtr().
Definition: CryostatGeo.h:267
std::string fOpDetGeoName
Name of opdet geometry elements in gdml.
Definition: CryostatGeo.h:381
std::string OpDetGeoName() const
Get name of opdet geometry element.
Definition: CryostatGeo.h:333
Tag for vectors in the "local" GDML coordinate frame of the cryostat.
Definition: CryostatGeo.h:75
Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local cryostat frame to world frame.
Definition: CryostatGeo.h:343
bool HasElement(unsigned int itpc) const
Alias for HasTPC().
Definition: CryostatGeo.h:183
void PrintCryostatInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this cryostat.
Definition: CryostatGeo.h:390
const TGeoVolume * Volume() const
Pointer to ROOT&#39;s volume descriptor.
Definition: CryostatGeo.h:109
Local-to-world transformations with LArSoft geometry vectors.
Definitions of geometry vector data types.
double Height() const
Full height of the cryostat [cm].
Definition: CryostatGeo.h:103
TPCGeo const & PositionToTPC(Point_t const &point, double wiggle) const
Returns the ID of the TPC at specified location.
WireGeo::GeoNodePath_t GeoNodePath_t
Definition: CryostatGeo.h:53
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:173
Utilities to extend the interface of geometry vectors.This library provides facilities that can be us...
void UpdateAfterSorting(CryostatID cryoid)
Performs all needed updates after geometry has sorted the cryostats.
Definition: CryostatGeo.cxx:58
double Width() const
Full width of the cryostat [cm].
Definition: CryostatGeo.h:101
TPCGeo const * TPCPtr(unsigned int itpc) const
Returns the TPC number itpc from this cryostat.
Definition: CryostatGeo.h:252
Point_t GetCenter() const
Returns the geometrical center of the cryostat.
Definition: CryostatGeo.h:120
unsigned int NTPC() const
Number of TPCs in this cryostat.
Definition: CryostatGeo.h:171
CryostatID const & ID() const
Returns the identifier of this cryostat.
Definition: CryostatGeo.h:126
The data type to uniquely identify a TPC.
Definition: geo_types.h:306
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.
Provides a base class aware of world box coordinates.
Encapsulate the geometry of a wire .
double HalfHeight() const
Half height of the cryostat [cm].
TPCList_t const & ElementIteratorBox
Type returned by IterateElements().
Definition: CryostatGeo.h:56
Encapsulate the geometry of an optical detector.
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintCryostatInfo().
Definition: CryostatGeo.h:162
std::string CryostatInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with cryostat information.
TPCID PositionToTPCID(Point_t const &point, double wiggle) const
Returns the ID of the TPC at specified location.
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:180
Point_t Min() const
Returns the corner point with the smallest coordinates.
TPCGeo const & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:73
void FindTPC(std::vector< const TGeoNode * > &path, unsigned int depth)
Selection of the type of transformation matrix used in geometry.
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:31
std::vector< TGeoNode const * > GeoNodePath_t
Definition: WireGeo.h:115
TPCList_t fTPCs
List of tpcs in this cryostat.
Definition: CryostatGeo.h:378
unsigned int NOpDet() const
Number of optical detectors in this TPC.
Definition: CryostatGeo.h:317
bool HasElement(TPCID const &tpcid) const
Alias for HasTPC(geo::TPCID const&)
Definition: CryostatGeo.h:195
void MakeOpDet(std::vector< const TGeoNode * > &path, int depth)
Point3DBase_t< CryostatGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML cryostat frame.
Definition: CryostatGeo.h:78
std::vector< TPCGeo > TPCList_t
Type used internally to store the TPCs.
Definition: CryostatGeo.h:48
LocalPoint_t toLocalCoords(Point_t const &world) const
Transform point from world frame to local cryostat frame.
Definition: CryostatGeo.h:349
LocalTransformation_t fTrans
Cryostat-to-world transformation.
Definition: CryostatGeo.h:377
BoxBoundedGeo const & Boundaries() const
Returns boundaries of the cryostat (in centimetres).
Definition: CryostatGeo.h:113
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:88
GenVector3DBase_t< double, C > Vector3DBase_t
Definition: geo_vectors.h:83
void SortSubVolumes(GeoObjectSorter const &sorter)
Method to sort TPCGeo objects.
Definition: CryostatGeo.cxx:51
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:180
CryostatID fID
ID of this cryostat.
Definition: CryostatGeo.h:382
TPCGeo const * PositionToTPCptr(Point_t const &point, double wiggle) const
Returns a pointer to the TPC at specified location.
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:315
void MakeTPC(std::vector< const TGeoNode * > &path, int depth)
ROOT libraries.
TPCGeo const & GetElement(TPCID const &tpcid) const
Alias for TPC().
Definition: CryostatGeo.h:212
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
Specialization of local-to-world transformations for ROOT GenVector.This is a header-only library...
double Length() const
Length of the cryostat [cm].
Definition: CryostatGeo.h:105
Encapsulate the construction of a single detector plane .
The data type to uniquely identify a cryostat.
Definition: geo_types.h:187
ElementIteratorBox IterateElements() const
Returns an object suitable for iterating through all TPCs.
Definition: CryostatGeo.cxx:92