All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlaneGeo.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file larcorealg/Geometry/PlaneGeo.h
3 /// \brief Encapsulate the construction of a single detector plane
4 /// \ingroup Geometry
5 ///
6 /// \author brebel@fnal.gov
7 ////////////////////////////////////////////////////////////////////////
8 #ifndef LARCOREALG_GEOMETRY_PLANEGEO_H
9 #define LARCOREALG_GEOMETRY_PLANEGEO_H
10 
11 // LArSoft libraries
20 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect
22 
23 // ROOT libraries
24 #include "Math/GenVector/Cartesian2D.h"
25 #include "Math/GenVector/PositionVector2D.h"
26 #include "Math/GenVector/DisplacementVector2D.h"
27 
28 // ROOT libraries
29 #include "TGeoMatrix.h" // TGeoHMatrix
30 
31 // C/C++ standard libraries
32 #include <cmath> // std::atan2()
33 #include <vector>
34 #include <string>
35 
36 
37 class TGeoNode;
38 class TVector3;
39 
40 namespace geo {
41 
42  namespace details {
43  struct ActiveAreaCalculator;
44  } // namespace details
45 
46  //......................................................................
47  class WireGeo;
48  using WirePtr = WireGeo const*; // this will become an object in the future
49 
50 
51  /**
52  * @brief Geometry information for a single wire plane.
53  * @ingroup Geometry
54  *
55  * The plane is represented in the geometry by a solid which contains wires.
56  * Currently, only box solids are well supported.
57  * The box which is representation of the plane has some thickness, and it
58  * should not be assumed that the wires are in the median section of it,
59  * that is, the center of the box may not lie on the plane defined by the
60  * wires.
61  *
62  * The plane defines two local reference frames.
63  * The first, depending on wire directions and therefore called "wire base",
64  * is defined by the normal to the plane (pointing toward the center of the
65  * TPC), the direction of the wires, and the direction that the wires measure.
66  * This is a positive orthogonal base.
67  * Note that for this base to be correctly defined, the Geometry service has
68  * to provide external information (for example, where the center of the
69  * TPC is).
70  *
71  * The second, depending only on the shape of the plane and called "frame
72  * base", is defined by the normal (the same as for the previous one), and two
73  * orthogonal axes, "width" and "depth", aligned with the sides of the plane.
74  * If the plane has not the shape of a box, this reference frame is not
75  * available. This coordinate system is also positive defined.
76  * These components are all measured in centimeters.
77  *
78  */
79  // Note: SignalType() and SetSignalType() have been removed.
80  // Use `geo::GeometryCore::SignalType` instead.
81  // (see LArSoft issue #14365 at https://cdcvs.fnal.gov/redmine/issues/14365 )
82  class PlaneGeo {
83 
84  using DefaultVector_t = TVector3; // ... not for long
85  using DefaultPoint_t = TVector3; // ... not for long
86 
87  public:
88 
89  using WireCollection_t = std::vector<geo::WireGeo>;
90  using GeoNodePath_t = std::vector<TGeoNode const*>;
91 
92  /// Type returned by `IterateElements()`.
94 
95 
96  /// @{
97  /**
98  * @name Types for geometry-local reference vectors.
99  *
100  * These types represents points and displacement vectors in the reference
101  * frame defined in the plane geometry box from the GDML geometry
102  * description.
103  *
104  * No alias is explicitly defined for the LArSoft global vector types,
105  * `geo::Point_t` and `geo::Vector_t`.
106  *
107  * Remember the `LocalPoint_t` and `LocalVector_t` vectors from different
108  * instances of `geo::PlaneGeo` have the same type but are not compatible.
109  */
110 
111  /// Tag for vectors in the "local" GDML coordinate frame of the plane.
113 
114  /// Type of points in the local GDML wire plane frame.
116 
117  /// Type of displacement vectors in the local GDML wire plane frame.
119 
120  /// @}
121 
122  /// @{
123  /// @name Types for vectors in the wire coordinate frame.
124 
125  /// Tag for wire base vectors.
127 
128  /// Type for projections in the wire base representation.
129  using WireCoordProjection_t = ROOT::Math::DisplacementVector2D
130  <ROOT::Math::Cartesian2D<double>, WireCoordinateReferenceTag>;
131 
132  /// Type used for plane decompositions on wire base.
135 
136  /// Type describing a 3D point or vector decomposed on a plane on wire base.
138 
139  /// @}
140 
141 
142  /// @{
143  /// @name Types for vectors in the width/depth coordinate frame.
144 
145  /// Tag for plane frame base vectors.
147 
148  /// Type for projections in the plane frame base representation.
149  /// @todo the following should be a PositionVector2D
150  using WidthDepthProjection_t = ROOT::Math::DisplacementVector2D
151  <ROOT::Math::Cartesian2D<double>, WidthDepthReferenceTag>;
152 
153  /// Type for vector projections in the plane frame base representation.
154  using WidthDepthDisplacement_t = ROOT::Math::DisplacementVector2D
155  <ROOT::Math::Cartesian2D<double>, WidthDepthReferenceTag>;
156 
157  /// Type used for plane decompositions on plane frame (width/depth).
160 
161  /// Type describing a 3D point or vector decomposed on a plane
162  /// with plane frame base (width and depth).
164 
165  /// @}
166 
167 
168  /// Type for description of rectangles.
170 
171 
172  /// Construct a representation of a single plane of the detector
173  PlaneGeo(
174  TGeoNode const& node,
176  WireCollection_t&& wires
177  );
178 
179 
180  /// @{
181  /// @name Plane properties
182 
183  /// Which coordinate does this plane measure
184  View_t View() const { return fView; }
185 
186  /// What is the orientation of the plane
187  Orient_t Orientation() const { return fOrientation; }
188 
189  /// Angle of the wires from positive z axis; @f$ \theta_{z} \in [ 0, \pi ]@f$.
190  double ThetaZ() const;
191 
192  /// Angle from positive z axis of the wire coordinate axis, in radians
193  double PhiZ() const
194  { return std::atan2(fSinPhiZ, fCosPhiZ); }
195 
196  /// Sine of PhiZ()
197  double SinPhiZ() const { return fSinPhiZ; }
198 
199  /// Cosine of PhiZ()
200  double CosPhiZ() const { return fCosPhiZ; }
201 
202  /// Returns the identifier of this plane
203  geo::PlaneID const& ID() const { return fID; }
204 
205  /// @}
206 
207  /// @{
208  /// @name Plane size and coordinates
209 
210  //@{
211  /**
212  * @brief Return the direction of plane width.
213  * @tparam Vector the type of vector to return (current default: `TVector3`)
214  *
215  * The precise definition of the sides is arbitrary, but they are defined
216  * to lie on the wire plane and so that WidthDir(), DepthDir() and
217  * GetNormalDirection() make a orthonormal base.
218  * That base (width, depth, normal) is guaranteed to be positive defined.
219  */
220  template <typename Vector>
221  Vector WidthDir() const { return geo::vect::convertTo<Vector>(fDecompFrame.MainDir()); }
222  DefaultVector_t WidthDir() const { return WidthDir<DefaultVector_t>(); }
223  //@}
224 
225  //@{
226  /**
227  * @brief Return the direction of plane depth.
228  * @tparam Vector the type of vector to return (current default: `TVector3`)
229  *
230  * The precise definition of the sides is arbitrary, but they are defined
231  * to lie on the wire plane and so that WidthDir(), DepthDir() and
232  * GetNormalDirection() make a orthonormal base.
233  * That base (width, depth, normal) is guaranteed to be positive defined.
234  */
235  template <typename Vector>
236  Vector DepthDir() const { return geo::vect::convertTo<Vector>(fDecompFrame.SecondaryDir()); }
237  DefaultVector_t DepthDir() const { return DepthDir<DefaultVector_t>(); }
238  //@}
239 
240  /**
241  * @brief Return the width of the plane.
242  * @see Depth(), WidthDir(), DepthDir()
243  *
244  * The precise definition is arbitrary (see `WidthDir()`).
245  */
246  double Width() const { return fFrameSize.Width(); }
247 
248  /**
249  * @brief Return the depth of the plane.
250  * @see Width(), WidthDir(), DepthDir()
251  *
252  * The precise definition is arbitrary (see `DepthDir()`).
253  */
254  double Depth() const { return fFrameSize.Depth(); }
255 
256 
257  /// Returns the world coordinates of the box containing the plane.
258  /// @see GetBoxCenter()
260 
261  /// @}
262 
263 
264  /// @{
265  /// @name Wire access
266 
267  //@{
268  /// Number of wires in this plane
269  unsigned int Nwires() const { return fWire.size(); }
270  unsigned int NElements() const { return Nwires(); }
271  //@}
272 
273  //@{
274  /**
275  * @brief Returns whether a wire with index iwire is present in this plane.
276  * @param iwire index of wire in this plane
277  * @return whether the wire with index iwire is present in this plane
278  */
279  bool HasWire(unsigned int iwire) const { return iwire < Nwires(); }
280  bool HasElement(unsigned int iwire) const { return HasWire(iwire); }
281  //@}
282 
283  //@{
284  /**
285  * @brief Returns whether the wire in wireid is present in this plane.
286  * @param wireid full wire ID
287  * @return whether the wire in wireid is present in this plane
288  *
289  * The cryostat, TPC and plane numbers in wireid are ignored, as it is
290  * ignored whether wireid is invalid.
291  */
292  bool HasWire(geo::WireID const& wireid) const
293  { return HasWire(wireid.Wire); }
294  bool HasElement(geo::WireID const& wireid) const
295  { return HasWire(wireid); }
296  //@}
297 
298  /// Return the iwire'th wire in the plane.
299  /// @throws cet::exception (category "WireOutOfRange") if no such wire
300  /// @note In the past, no check was performed.
301  WireGeo const& Wire(unsigned int iwire) const;
302 
303  //@{
304  /**
305  * @brief Returns the wire in wireid from this plane.
306  * @param wireid full wire ID
307  * @return a constant reference to the wire in wireid
308  * @throws cet::exception (category "WireOutOfRange") if no such wire
309  *
310  * The cryostat, TPC and plane numbers in wireid are ignored, as it is
311  * ignored whether wireid is invalid.
312  */
313  WireGeo const& Wire(WireID const& wireid) const
314  { return Wire(wireid.Wire); }
315  WireGeo const& GetElement(WireID const& wireid) const
316  { return Wire(wireid); }
317  //@}
318 
319  /**
320  * @brief Returns the wire number iwire from this plane.
321  * @param iwire the number of local wire
322  * @return a constant pointer to the wire, or nullptr if it does not exist
323  */
324  geo::WirePtr WirePtr(unsigned int iwire) const
325  { return HasWire(iwire)? &(fWire[iwire]): nullptr; }
326 
327  //@{
328  /**
329  * @brief Returns the wire in wireid from this plane.
330  * @param wireid full wire ID
331  * @return a constant pointer to the wire, or nullptr if it does not exist
332  *
333  * The cryostat, TPC and plane numbers in wireid are ignored, as it is
334  * ignored whether wireid is invalid.
335  */
336  geo::WirePtr WirePtr(WireID const& wireid) const
337  { return WirePtr(wireid.Wire); }
338  geo::WirePtr GetElementPtr(WireID const& wireid) const
339  { return WirePtr(wireid); }
340  //@}
341 
342 
343  /// Return the first wire in the plane.
344  const WireGeo& FirstWire() const { return Wire(0); }
345 
346  /// Return the middle wire in the plane.
347  const WireGeo& MiddleWire() const { return Wire(Nwires()/2); }
348 
349  /// Return the last wire in the plane.
350  const WireGeo& LastWire() const { return Wire(Nwires()-1); }
351 
352  // @{
353  /**
354  * @brief Allows range-for iteration on all wires in this plane.
355  * @return an object suitable for range-for iteration on all wires
356  *
357  * This example uses geometry to iterate on all planes in an outer loop,
358  * and then iterates on all wires in the plane in the inner loop:
359  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360  *
361  * auto geom = lar::providerFrom<geo::Geometry>();
362  * for (geo::PlaneGeo const& plane: geom->IteratePlanes()) {
363  *
364  * // collect plane information
365  *
366  * for (geo::WireGeo const& wire: plane.IterateWires()) {
367  *
368  * // do something with each single wire
369  *
370  * }
371  * } // for planes
372  *
373  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
374  * (note that all data types here can be replaced with `auto`).
375  * The resulting sequence exposes the wires within the plane in their
376  * ID order, from plane `0` to `Nplanes() - 1`.
377  *
378  * Since the wire ID is not contained in `geo::WireGeo`, further steps are
379  * needed to obtain it if needed. For example:
380  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
381  *
382  * auto geom = lar::providerFrom<geo::Geometry>();
383  * for (geo::PlaneGeo const& plane: geom->IteratePlanes()) {
384  *
385  * // collect plane information
386  * geo::PlaneID const planeid { plane.ID() };
387  *
388  * for (auto&& iWire, wire: util::enumerate(plane.IterateWires())) {
389  *
390  * geo::WireID const wireid (planeID, iWire);
391  *
392  * // do something with each single wire and ID
393  *
394  * }
395  * } // for planes
396  *
397  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398  *
399  */
402  // @}
403 
404  /// @}
405 
406 
407  /// @{
408  /// @name Plane geometry properties
409 
410  /// Return the wire pitch (in centimeters). It is assumed constant.
411  double WirePitch() const { return fWirePitch; }
412 
413  /**
414  * @brief Returns whether the higher z wires have higher wire ID.
415  * @return whether the higher z wires have higher wire ID
416  * @see GetIncreasingWireDirection()
417  *
418  * This method is related to GetIncreasingWireDirection()
419  * (it might be expressed as "GetIncreasingWireDirection()[2] > 0"),
420  * but it is implemented in a faster and independent way.
421  */
422  bool WireIDincreasesWithZ() const;
423 
424  //@{
425  /**
426  * @brief Returns the direction normal to the plane.
427  * @tparam Vector the type of vector to return (current default: `TVector3`)
428  * @return a TVector3 versor with a direction normal to the plane
429  *
430  * The versor is orthogonal to the plane.
431  * The direction is defined so that the semi-space pointed to contains
432  * the TPC center.
433  *
434  * @note Each decomposition base (wire-based and frame-based) has its own
435  * normal, defined solely from its two decomposition plane axes.
436  * The wire-based frame is nevertheless required to have a normal
437  * matching this one, while the frame-based normal might happen to be
438  * in the opposite direction depending on the original geometry
439  * description.
440  */
441  template <typename Vector>
442  Vector GetNormalDirection() const { return geo::vect::convertTo<Vector>(fNormal); }
444  { return GetNormalDirection<DefaultVector_t>(); }
445  //@}
446 
447  //@{
448  /**
449  * @brief Returns the direction of increasing wires.
450  * @tparam Vector the type of vector to return (current default: `TVector3`)
451  * @return a TVector3 versor with the direction of increasing wires
452  *
453  * The versor is orthogonal to the wires (assumed parallel),
454  * lies on the plane and its direction goes toward increasing wire IDs.
455  */
456  template <typename Vector>
458  { return geo::vect::convertTo<Vector>(fDecompWire.SecondaryDir()); }
460  { return GetIncreasingWireDirection<DefaultVector_t>(); }
461  //@}
462 
463 
464  //@{
465  /**
466  * @brief Returns the centre of the wire plane in world coordinates [cm]
467  * @see GetBoxCenter()
468  *
469  * The center of the plane is defined so that it has width and depth
470  * coordinates in the middle of the plane box (that is, the geometrical
471  * representation of the plane in the geometry description), and the other
472  * coordinate set at drift distance 0.
473  *
474  * Note that this does not necessarily match the center of the box, if the
475  * geometry does not place the wires, which define the drift distance, in
476  * the plane in the middle of the box.
477  */
478  template <typename Point>
479  Point GetCenter() const
480  { return geo::vect::convertTo<Point>(fCenter); }
481  DefaultPoint_t GetCenter() const { return GetCenter<DefaultPoint_t>(); }
482  //@}
483 
484 
485  //@{
486  /**
487  * @brief Returns the centre of the box representing the plane.
488  * @tparam Point type of point to be returned (current default: `TVector3`)
489  * @return the centre of the box, in world coordinates [cm]
490  * @see GetCenter()
491  *
492  * This is the centre of the box representing the plane in the geometry
493  * description, in world coordinates.
494  * This is rarely of any use, as most of the times `GetCenter()` delivers
495  * the proper information, e.g. for simulation and reconstruction.
496  */
497  template <typename Point>
499  { return geo::vect::convertTo<Point>(toWorldCoords(LocalPoint_t{ 0.0, 0.0, 0.0 })); }
501  { return GetBoxCenter<DefaultPoint_t>(); }
502  //@}
503 
504  //@{
505  /**
506  * @brief Returns the direction of the wires.
507  * @tparam Vector the type of vector to return (current default: `TVector3`)
508  * @return a unit vector following the direction of the wires
509  *
510  * All wires in the plane are assumed parallel.
511  */
512  template <typename Vector>
513  Vector GetWireDirection() const { return geo::vect::convertTo<Vector>(fDecompWire.MainDir()); }
515  { return GetWireDirection<DefaultVector_t>(); }
516  //@}
517 
518 
519  //@{
520  /**
521  * @brief Returns the ID of wire closest to the specified position.
522  * @param pos world coordinates of the point [cm]
523  * @return the ID of the wire closest to the projection of pos on the plane
524  * @throw InvalidWireError (category: `"Geometry"`) if out of range
525  *
526  * The position is projected on the wire plane, and the ID of the nearest
527  * wire to the projected point is returned.
528  *
529  * If the wire does not exist, an exception is thrown that contains both the
530  * wire that would be the closest one (`badWireID()`), and also the wire
531  * that is actually the closest one (`betterWireID()`). When this happens,
532  * the specified position was outside the wire plane.
533  *
534  * Note that the caller should check for containment: this function may or
535  * may not report the position being outside the plane, depending on where
536  * it is. In the current implementation, the wires are considered infinitely
537  * long, and if the position projection is closer than half the wire pitch
538  * from any of these extrapolated wires, the method will not report error.
539  *
540  * @todo When the ID is out of range, instead of throwing an exception,
541  * return an invalid wire ID with the wire number set to the
542  * non-existing wire which _would_ be the nearest to `pos`.
543  */
544  geo::WireID NearestWireID(geo::Point_t const& pos) const;
545  geo::WireID NearestWireID(TVector3 const& pos) const
546  { return NearestWireID(geo::vect::toPoint(pos)); }
547  //@}
548 
549 
550  /**
551  * @brief Returns the wire closest to the specified position.
552  * @param pos world coordinates of the point [cm]
553  * @return the ID of the wire closest to the projection of pos on the plane
554  * @throw InvalidWireError (category: `"Geometry"`) if out of range
555  *
556  * The position is projected on the wire plane, and the nearest wire to the
557  * projected point is returned.
558  *
559  * If the wire is father than half a wire pitch from the point, an exception
560  * is thrown that contains both the wire that would be the closest one
561  * (`badWireID()`), and also the wire that is actually the closest one
562  * (`betterWireID()`). When this happens, the specified position was
563  * outside the wire plane.
564  *
565  * Note that the caller should check for containment: this function may or
566  * may not report the position being outside the plane, depending on where
567  * it is. In the current implementation, the wires are considered infinitely
568  * long, and if the position projection is closer than half the wire pitch
569  * from any of these extrapolated wires, the method will not report error.
570  */
571  geo::WireGeo const& NearestWire(geo::Point_t const& pos) const;
572 
573 
574  /**
575  * @brief Returns the closest valid wire ID to the specified wire.
576  * @param wireNo number of the wire on this plane
577  * @return complete wire ID of the closest wire on this plane
578  *
579  * If the wire number described a wire present on this plane, its complete
580  * wire ID is returned, valid. Otherwise, a valid wire ID is returned which
581  * points to the existing wire closest to the specified wire number: the
582  * first wire if the wire number is negative, or the last wire if the wire
583  * number is larger than the actual wires.
584  *
585  * Note that the argument `geo::WireID::WireID_t` type is an integral type,
586  * and if a floating point value is specified for it, it's subject to
587  * truncation.
588  */
589  geo::WireID ClosestWireID(geo::WireID::WireID_t wireNo) const; // inline
590 
591 
592  /**
593  * @brief Returns the closest valid wire ID to the specified wire.
594  * @param wireid the wire ID (must be on this plane)
595  * @return complete wire ID of the closest wire, invalid if not this plane
596  * @see `ClosestWireID(geo::WireID::WireID_t)`
597  *
598  * If `wireid` is not on this plane, it is returned but marked as invalid.
599  * Otherwise, the returned ID is the same as in
600  * `ClosestWireID(geo::WireID::WireID_t)`.
601  */
602  geo::WireID ClosestWireID(geo::WireID const& wireid) const; // inline
603 
604 
605  //@{
606  /**
607  * @brief Returns the distance of the specified point from the wire plane.
608  * @param point a point in world coordinates [cm]
609  * @return the signed distance from the wire plane
610  *
611  * The distance is defined positive if the point lies in the side the normal
612  * vector (GetNormalDirection()) points to.
613  *
614  * The distance is defined from the geometric plane where the wires lie, and
615  * it may not match the distance from the center of the geometry box
616  * representing the plane.
617  * It should always match the drift distance from this wire plane, and the
618  * result of `DriftPoint(point, DistanceFromPlane(point))` will bring the
619  * point to the plane.
620  */
621  double DistanceFromPlane(geo::Point_t const& point) const
622  { return fDecompWire.PointNormalComponent(point); }
623  double DistanceFromPlane(TVector3 const& point) const
624  { return DistanceFromPlane(geo::vect::toPoint(point)); }
625  //@}
626 
627 
628  //@{
629  /**
630  * @brief Shifts the position of an electron drifted by a distance.
631  * @param position _(modified)_ the position of the electron
632  * @param distance drift distance to shift the electron by [cm]
633  *
634  * This is a pure geometry computation: the position is shifted by the drift
635  * distance in the direction opposite to the normal to the plane (as
636  * returned by `GetNormalDirection()`), no matter where the position is
637  * relative to the plane.
638  * The wording about "electron position" is just meant to remind that the
639  * drift shift is taken with opposite sign: since the point is assumed to be
640  * an electron, a positive drift normally moves its position toward the wire
641  * plane.
642  */
643  void DriftPoint(geo::Point_t& position, double distance) const
644  { position -= distance * GetNormalDirection<geo::Vector_t>(); }
645  void DriftPoint(TVector3& position, double distance) const
646  { position -= distance * GetNormalDirection(); }
647  //@}
648 
649  //@{
650  /**
651  * @brief Shifts the position along drift direction to fall on the plane.
652  * @param position _(modified)_ the position to be shifted
653  *
654  * This is a pure geometry computation: the position is shifted by the drift
655  * distance in the direction opposite to the normal to the plane (as
656  * returned by `GetNormalDirection()`), no matter where the position is
657  * relative to the plane.
658  */
659  void DriftPoint(geo::Point_t& position) const
660  { DriftPoint(position, DistanceFromPlane(position)); }
661  void DriftPoint(TVector3& position) const
662  { DriftPoint(position, DistanceFromPlane(position)); }
663  //@}
664 
665 
666  //@{
667  /**
668  * @brief Returns the distance between wires along the specified direction.
669  * @param projDir the direction, projected on the plane (2D)
670  * @return the distance between wires along that direction [cm]
671  *
672  * The direction is specified as a `geo::PlaneGeo::WireCoordProjection_t`
673  * vector, defined as in `geo::PlaneGeo::Projection()`.
674  * The modulus of the projection is ignored but expected to be non null.
675  *
676  * The returned distance is the space that would be covered starting from
677  * a wire toward the `projDir` direction and stopping at the first wire met.
678  * This distance is returned in centimeters, always positive and
679  * not smaller than the wire pitch.
680  *
681  * @note If the direction is too close to the wire direction, the result
682  * will be numerically unstable and might be infinite (test with
683  * `std::isinf()`, `std::isfinite()` or `std::isnormal()`).
684  * It is recommended that the caller take special actions when the
685  * result is too large.
686  */
688  (WireCoordProjection_t const& projDir) const;
689  //@}
690 
691 
692  //@{
693  /**
694  * @brief Returns the distance between wires along the specified direction.
695  * @param dir the direction (3D)
696  * @return the distance between wires along that direction [cm]
697  *
698  * The direction is specified as a 3D vector in the world coordinate frame.
699  * The modulus of the vector is ignored but expected to be non null.
700  *
701  * The returned distance is the space that would be covered starting from
702  * a wire toward the `dir` direction and stopping when the projection on
703  * the wire plane reaches another wire.
704  * This distance is returned in centimeters, always positive and
705  * not smaller than the wire pitch.
706  *
707  * @note If the direction is too close to the wire direction, the result
708  * will be numerically unstable and might be infinite (test with
709  * `std::isinf()`, `std::isfinite()` or `std::isnormal()`).
710  * It is recommended that the caller take special actions when the
711  * result is too large.
712  */
713  double InterWireDistance(geo::Vector_t const& dir) const;
714  double InterWireDistance(TVector3 const& dir) const
715  { return InterWireDistance(geo::vect::toVector(dir)); }
716  //@}
717 
718 
719  //@{
720  /**
721  * @brief Returns the distance between wires along the specified direction.
722  * @tparam Vector type of 3D vector
723  * @param dir the direction in detector space (3D)
724  * @return the distance between wires along that direction [cm]
725  * @see `InterWireProjectedDistance(geo::PlaneGeo::WireCoordProjection_t const&) const`
726  *
727  * The direction is specified as a 3D vector.
728  * Its modulus is ignored but expected to be non null.
729  *
730  * The returned distance is the space that would be covered starting from
731  * a wire toward the direction projection of `dir` on the wire plane,
732  * and stopping at the first wire met.
733  * This distance is returned in centimeters and always positive.
734  *
735  * @note This is not a 3D distance (for example, it's not useful to compute
736  * @f$ ds @f$ of a track to get its ionization energy @f$ dE/ds @f$),
737  * but it is the distance projected on the wire plane.
738  */
739  template <typename Vector>
740  std::enable_if_t<geo::vect::dimension<Vector>() == 3U, double>
741  InterWireProjectedDistance(Vector const& dir) const
743  //@}
744 
745 
746 
747  /**
748  * @brief Returns an area covered by the wires in the plane.
749  *
750  * The returned value is conceptually akin of a projection of `Coverage()`
751  * volume. Yet, the precise definition of the area is not specified,
752  * therefore this area should not be uses for physics.
753  *
754  * The current implementation is documented in
755  * `details::ActiveAreaCalculator`.
756  *
757  */
758  Rect const& ActiveArea() const { return fActiveArea; }
759 
760  /// Returns a volume including all the wires in the plane.
762 
763  /**
764  * @brief Prints information about this plane.
765  * @tparam Stream type of output stream to use
766  * @param out stream to send the information to
767  * @param indent prepend each line with this string
768  * @param verbosity amount of information printed
769  *
770  * Information on single wires is not printed.
771  * Note that the first line out the output is _not_ indented.
772  *
773  * Verbosity levels
774  * -----------------
775  *
776  * * 0: only plane ID
777  * * 1 _(default)_: also center and wire angle
778  * * 2: also information about wires
779  * * 3: also information about normal and increasing coordinate direction
780  * * 4: also information about wire direction, width and depth
781  * * 5: also coverage
782  * * 6: also bounding box
783  *
784  */
785  template <typename Stream>
786  void PrintPlaneInfo
787  (Stream&& out, std::string indent = "", unsigned int verbosity = 1) const;
788 
789 
790  /**
791  * @brief Returns a string with plane information.
792  * @see `PrintPlaneInfo()`
793  *
794  * The information is provided by `PrintPlaneInfo()`, and the arguments
795  * have the same meaning.
796  */
797  std::string PlaneInfo
798  (std::string indent = "", unsigned int verbosity = 1) const;
799 
800 
801  /// Maximum value for print verbosity.
802  static constexpr unsigned int MaxVerbosity = 6;
803 
804  /// @}
805 
806 
807  /// @{
808  /// @name Projections on wire length/wire coordinate direction base
809  ///
810  /// These methods deal with projection of points and vectors on the plane,
811  /// using a geometric reference base which is dependent on the wire
812  /// direction. This is useful for plane reconstruction.
813  ///
814 
815  //@{
816  /**
817  * @brief Returns the coordinate of point on the plane respect to a wire.
818  * @param point world coordinate of the point to get the coordinate of [cm]
819  * @param refWire reference wire
820  * @return the coordinate of the point [cm]
821  * @see WireCoordinate()
822  *
823  * The method returns the coordinate of the point in the direction measured
824  * by the wires on this plane starting from the specified reference wire,
825  * in world units (that is, centimeters).
826  *
827  * The point does not need to be on the plane, and the projection of the
828  * point to the plane is considered.
829  * The reference wire, instead, must belong to this plane. This assumption
830  * is not checked, and if violated the results are undefined (in the current
831  * implementation, they are just wrong).
832  */
833  double PlaneCoordinateFrom
834  (geo::Point_t const& point, geo::WireGeo const& refWire) const
835  {
836  return
838  }
839  double PlaneCoordinateFrom
840  (TVector3 const& point, geo::WireGeo const& refWire) const
841  { return PlaneCoordinateFrom(geo::vect::toPoint(point), refWire); }
842  //@}
843 
844 
845  //@{
846  /**
847  * @brief Returns the coordinate of the point on the plane.
848  * @param point world coordinate of the point to get the coordinate of [cm]
849  * @return the coordinate of the point [cm]
850  * @see PlaneCoordinateFrom(TVector3 const&, geo::Wire const&)
851  *
852  * The method returns the coordinate of the point in the direction measured
853  * by the wires on this plane starting on the first wire, in world units
854  * (that is, centimeters). A point on the first wire will have coordinate
855  * 0.0, one on the next wire will have coordinate equal to a single wire
856  * pitch, etc.
857  *
858  * The point does not need to be on the plane, and the projection of the
859  * point to the plane is considered.
860  */
861  double PlaneCoordinate(geo::Point_t const& point) const
862  { return fDecompWire.PointSecondaryComponent(point); }
863  double PlaneCoordinate(TVector3 const& point) const
864  { return PlaneCoordinate(geo::vect::toPoint(point)); }
865  //@}
866 
867  /**
868  * @brief Returns the coordinate of the point on the plane, in wire units.
869  * @param point world coordinate of the point to get the coordinate of
870  * @return the coordinate of the point, in wire pitch units
871  * @see CoordinateFrom(TVector3 const&, geo::Wire const&)
872  *
873  * The method returns the coordinate of the point in the direction measured
874  * by the wires on this plane starting on the first wire, in wire units
875  * (that is, wire pitches). A point on the first wire will have coordinate
876  * 0.0, one on the next wire will have coordinate 1.0, etc.
877  *
878  * The point does not need to be on the plane, and the projection of the
879  * point to the plane is considered.
880  */
881  template <typename Point>
882  double WireCoordinate(Point const& point) const
883  { return PlaneCoordinate(point) / WirePitch(); }
884 
885 
886  //@{
887  /**
888  * @brief Decomposes a 3D point in two components.
889  * @param point the point to be decomposed
890  * @return the two components of point, on the plane and orthogonal to it
891  *
892  * The point is decomposed in:
893  *
894  * 1. a component orthogonal to the plane, expressed as a signed real number
895  * 2. a component lying on the plane, expressed as a 2D vector
896  *
897  * The distance is obtained as by DistanceFromPlane().
898  * The projection on the plane is obtained following the same convention
899  * as PointProjection().
900  */
902  { return fDecompWire.DecomposePoint(point); }
903  WireDecomposedVector_t DecomposePoint(TVector3 const& point) const
904  { return DecomposePoint(geo::vect::toPoint(point)); }
905 
906  //@}
907 
908  //@{
909  /**
910  * @brief Returns the reference point used by `PointProjection()`.
911  * @tparam Point the type of point to return (current default: `TVector3`)
912  *
913  * The returned point is such that its decomposition results in a null
914  * projection and a 0 distance from the plane.
915  */
916  template <typename Point>
918  { return geo::vect::convertTo<Point>(fDecompWire.ReferencePoint()); }
920  { return ProjectionReferencePoint<DefaultPoint_t>(); }
921  //@}
922 
923  //@{
924  /**
925  * @brief Returns the projection of the specified point on the plane.
926  * @param point the 3D point to be projected, in world coordinates
927  * @return a 2D vector representing the projection of point on the plane
928  *
929  * The returned vector is a 2D vector expressing the projection of the point
930  * (from world coordinates) on the wire plane.
931  * The vector is expressed as @f$ ( \ell, w ) @f$. The component
932  * @f$ \ell @f$ is measured on the direction of the first wire (see
933  * `WireGeo::Direction()`), using its center (see `WireGeo::GetCenter()`) as
934  * reference point. The component @f$ w @f$ is defined on the wire
935  * coordinate direction (see `GetIncreasingWireDirection()`), relative to
936  * the first wire, as it is returned by PlaneCoordinate().
937  *
938  * The reference point is also returned by ProjectionReferencePoint().
939  */
941  { return fDecompWire.ProjectPointOnPlane(point); }
943  { return Projection(point); }
944  WireCoordProjection_t PointProjection(TVector3 const& point) const
945  { return PointProjection(geo::vect::toPoint(point)); }
946  //@}
947 
948  //@{
949  /**
950  * @brief Returns the projection of the specified vector on the plane.
951  * @param v the 3D vector to be projected, in world units
952  * @return a 2D vector representing the projection of v on the plane
953  *
954  * The returned vector is a 2D vector expressing the projection of the
955  * vector (from world units) on the wire plane.
956  * The vector is expressed as @f$ ( \ell, w ) @f$. The component
957  * @f$ \ell @f$ is measured on the direction of the first wire (see
958  * `WireGeo::Direction()`). The component @f$ w @f$ is defined on the wire
959  * coordinate direction (see `GetIncreasingWireDirection()`).
960  */
962  { return fDecompWire.ProjectVectorOnPlane(v); }
964  { return Projection(v); }
965  WireCoordProjection_t VectorProjection(TVector3 const& v) const
966  { return VectorProjection(geo::vect::toVector(v)); }
967  //@}
968 
969  //@{
970  /**
971  * @brief Returns the 3D vector from composition of projection and distance.
972  * @tparam Vector the type of vector to return (current default: `TVector3`)
973  * @param decomp decomposed vector
974  * @return the 3D vector from composition of projection and distance
975  * @see DecomposePoint(),
976  * ComposeVector(double, WireCoordProjection_t const&),
977  * ComposePoint(WireDecomposedVector_t const&)
978  *
979  * See `ComposeVector(double, WireCoordProjection_t const&)` for details.
980  */
981  template <typename Vector>
982  Vector ComposeVector(WireDecomposedVector_t const& decomp) const
983  { return geo::vect::convertTo<Vector>(fDecompWire.ComposeVector(decomp)); }
985  { return ComposeVector<DefaultVector_t>(decomp); }
986  //@}
987 
988  //@{
989  /**
990  * @brief Returns the 3D vector from composition of projection and distance.
991  * @tparam Vector the type of vector to return (current default: `TVector3`)
992  * @param distance component of target vector orthogonal to the wire plane
993  * @param proj projection of the target vector on the wire plane
994  * @return the 3D vector from composition of projection and distance
995  * @see DecomposePoint()
996  *
997  * The returned vector is the sum of two 3D vectors:
998  *
999  * 1. a vector parallel to the plane normal, with norm the input distance
1000  * 2. a vector lying on the plane, whose projection via `VectorProjection()`
1001  * gives the input projection
1002  */
1003  template <typename Vector>
1004  Vector ComposeVector
1005  (double distance, WireCoordProjection_t const& proj) const
1006  { return geo::vect::convertTo<Vector>(fDecompWire.ComposeVector(distance, proj)); }
1008  (double distance, WireCoordProjection_t const& proj) const
1009  { return ComposeVector<DefaultVector_t>(distance, proj); }
1010  //@}
1011 
1012 
1013  //@{
1014  /**
1015  * @brief Returns the 3D point from composition of projection and distance.
1016  * @tparam Point the type of point to return (current default: `TVector3`)
1017  * @param decomp decomposed point
1018  * @return the 3D point from composition of projection and distance
1019  * @see DecomposePoint(), ComposePoint(double, WireCoordProjection_t const&)
1020  *
1021  * See `ComposePoint(double, WireCoordProjection_t const&)` for details.
1022  */
1023  template <typename Point>
1025  { return geo::vect::convertTo<Point>(fDecompWire.ComposePoint(decomp)); }
1027  { return ComposePoint<DefaultPoint_t>(decomp); }
1028  //@}
1029 
1030 
1031  //@{
1032  /**
1033  * @brief Returns the 3D point from composition of projection and distance.
1034  * @tparam Point the type of point to return (current default: `TVector3`)
1035  * @param distance distance of the target point from the wire plane
1036  * @param proj projection of the target point on the wire plane
1037  * @return the 3D point from composition of projection and distance
1038  * @see DecomposePoint()
1039  *
1040  * The returned point is the reference point of the frame system (that is,
1041  * the plane center), translated by two 3D vectors:
1042  *
1043  * 1. a vector parallel to the plane normal, with norm the input distance
1044  * 2. a vector lying on the plane, whose projection via `PointProjection()`
1045  * gives the input projection
1046  *
1047  * The choice of the projection reference point embodies the same convention
1048  * used in `PointProjection()` and `DecomposePoint()`.
1049  * In fact, the strict definition of the result of this method is a 3D point
1050  * whose decomposition on the plane frame base matches the method arguments.
1051  */
1052  template <typename Point>
1054  (double distance, WireCoordProjection_t const& proj) const
1055  { return geo::vect::convertTo<Point>(fDecompWire.ComposePoint(distance, proj)); }
1057  (double distance, WireCoordProjection_t const& proj) const
1058  { return ComposePoint<DefaultPoint_t>(distance, proj); }
1059  //@}
1060 
1061  /// @}
1062 
1063 
1064  /// @{
1065  /// @name Projection on width/depth plane
1066  ///
1067  /// These methods deal with projection of points and vectors on the plane,
1068  /// using a geometric reference base which is not dependent on the wire
1069  /// direction. This is more useful when comparing with the TPC or other
1070  /// planes.
1071  ///
1072 
1073  //@{
1074  /**
1075  * @brief Decomposes a 3D point in two components.
1076  * @param point the point to be decomposed
1077  * @return the two components of point, on the plane and orthogonal to it
1078  *
1079  * The point is decomposed in:
1080  *
1081  * 1. a component orthogonal to the plane, expressed as a signed real number
1082  * 2. a component lying on the plane, expressed as a 2D vector
1083  *
1084  * The distance is obtained as by DistanceFromPlane().
1085  * The projection on the plane is obtained following the same convention
1086  * as PointWidthDepthProjection().
1087  */
1089  { return fDecompFrame.DecomposePoint(point); }
1090  WDDecomposedVector_t DecomposePointWidthDepth(TVector3 const& point) const
1091  { return DecomposePointWidthDepth(geo::vect::toPoint(point)); }
1092  //@}
1093 
1094  //@{
1095  /**
1096  * @brief Returns the projection of the specified point on the plane.
1097  * @param point the 3D point to be projected, in world coordinates
1098  * @return a 2D vector representing the projection of point on the plane
1099  *
1100  * The returned vector is a 2D vector expressing the projection of the point
1101  * (from world coordinates) on the wire plane.
1102  * The vector is expressed as @f$ ( w, d ) @f$, components following the
1103  * width direction (`WidthDir()`) and the depth direction (`DepthDir()`)
1104  * respectively. The origin point is the center of the plane.
1105  */
1107  (geo::Point_t const& point) const
1108  { return fDecompFrame.ProjectPointOnPlane(point); }
1110  (TVector3 const& point) const
1111  { return PointWidthDepthProjection(geo::vect::toPoint(point)); }
1112  //@}
1113 
1114  //@{
1115  /**
1116  * @brief Returns the projection of the specified vector on the plane.
1117  * @param v the 3D vector to be projected, in world units
1118  * @return a 2D vector representing the projection of v on the plane
1119  *
1120  * The returned vector is a 2D vector expressing the projection of the
1121  * vector (from world units) on the wire plane.
1122  * The vector is expressed as @f$ ( w, d ) @f$, components following the
1123  * width direction (`WidthDir()`) and the depth direction (`DepthDir()`)
1124  * respectively.
1125  */
1127  (geo::Vector_t const& v) const
1128  { return fDecompFrame.ProjectVectorOnPlane(v); }
1130  (TVector3 const& v) const
1132  //@}
1133 
1134  //@{
1135  /**
1136  * @brief Returns if the projection of specified point is within the plane.
1137  * @param point world coordinate of the point to test [cm]
1138  * @return whether the projection of specified point is within the plane
1139  * @see PointWidthDepthProjection(), Width(), Height()
1140  *
1141  * The method extracts the projection of the specified point on the plane,
1142  * as in `PointWidthDepthProjection()`, and then verifies that the
1143  * projection falls within the wire plane area, as defined by the dimensions
1144  * from the geometry description.
1145  */
1146  bool isProjectionOnPlane(geo::Point_t const& point) const;
1147  bool isProjectionOnPlane(TVector3 const& point) const
1148  { return isProjectionOnPlane(geo::vect::toPoint(point)); }
1149  //@}
1150 
1151  /**
1152  * @brief Returns a projection vector that, added to the argument, gives a
1153  * projection inside (or at the border of) the plane.
1154  * @param proj starting projection
1155  * @param wMargin the point is brought this amount _inside_ the target area
1156  * @param dMargin the point is brought this amount _inside_ the target area
1157  * @return a projection displacement
1158  * @see `DeltaFromActivePlane()`
1159  *
1160  * The returned projection vector is guaranteed, when added to `proj`, to
1161  * yield a projection on or within the border of the plane (the "target
1162  * area"), as defined by the GDML geometry.
1163  *
1164  * The target plane area is reduced on each side by the specified margins.
1165  * If for example `wMargin` is `1.0`, the area lower border on the width
1166  * direction will be increased by 1 cm, and the upper border will be
1167  * decreased by 1 cm effectively making the area 2 cm narrowed on the width
1168  * direction.
1169  * The same independently applies to the depth direction with `dMargin`.
1170  * The main purpose of the margins is to accommodate for rounding errors.
1171  * A version of this method with default margins of 0 is also available.
1172  *
1173  * If the projection is already on the target area, the returned
1174  * displacement is null.
1175  */
1177  (WidthDepthProjection_t const& proj, double wMargin, double dMargin)
1178  const;
1179 
1180  /**
1181  * @brief Returns a projection vector that, added to the argument, gives a
1182  * projection inside (or at the border of) the area of plane.
1183  * @param proj starting projection
1184  * @param margin the point is brought this amount _inside_ the plane area
1185  * _(default: 0)_
1186  * @return a projection displacement
1187  * @see `DeltaFromPlane(WidthDepthProjection_t const&, double, double)`
1188  *
1189  * This is the implementation with default values for margins of
1190  * `DeltaFromPlane()`.
1191  * The depth and width margins are the same, and 0 by default.
1192  */
1194  (WidthDepthProjection_t const& proj, double margin = 0.0) const
1195  { return DeltaFromPlane(proj, margin, margin); }
1196 
1197  /**
1198  * @brief Returns a projection vector that, added to the argument, gives a
1199  * projection inside (or at the border of) the active area of plane.
1200  * @param proj starting projection
1201  * @param wMargin the point is brought this amount _inside_ the active area
1202  * @param dMargin the point is brought this amount _inside_ the active area
1203  * @return a projection displacement
1204  * @see `DeltaFromPlane()`
1205  *
1206  * The "active" area of the plane is the rectangular area which includes all
1207  * the wires. The area is obtained as the smallest rectangle including
1208  * the projection of both ends of all wires in the plane, less half a pitch.
1209  * This defines a "fiducial" area away from the borders of the plane.
1210  * The projection is in the frame reference (`PointWidthDepthProjection()`).
1211  * The area is reduced on each side by the specified margins. If for example
1212  * `wMargin` is `1.0`, the active area lower border on the width direction
1213  * will be increased by 1 cm, and the upper border will be decreased by 1 cm
1214  * effectively making the active area 2 cm narrowed on the width direction.
1215  * The same independently applies to the depth direction with `dMargin`.
1216  * The main purpose of the margins is to accommodate for rounding errors.
1217  * A version of this method with default margins of 0 is also available.
1218  *
1219  * If the projection is already on the active area of the plane, the
1220  * returned displacement is null.
1221  * Otherwise, the displacement, added to proj, will bring it on the active
1222  * plane area (in fact, on its border).
1223  */
1225  (WidthDepthProjection_t const& proj, double wMargin, double dMargin)
1226  const;
1227 
1228  /**
1229  * @brief Returns a projection vector that, added to the argument, gives a
1230  * projection inside (or at the border of) the active area of plane.
1231  * @param proj starting projection
1232  * @param margin the point is brought this amount _inside_ the active area
1233  * _(default: 0)_
1234  * @return a projection displacement
1235  * @see `DeltaFromActivePlane(WidthDepthProjection_t const&, double, double)`
1236  *
1237  * This is the implementation with default values for margins of
1238  * `DeltaFromActivePlane()`.
1239  * The depth and width margins are the same, and 0 by default.
1240  */
1242  (WidthDepthProjection_t const& proj, double margin = 0.0) const
1243  { return DeltaFromActivePlane(proj, margin, margin); }
1244 
1245  /**
1246  * @brief Returns the projection, moved onto the plane if necessary.
1247  * @param proj projection to be checked and moved
1248  * @return the new value of the projection
1249  * @see isProjectionOnPlane(), Width(), Height()
1250  *
1251  * The projection proj is defined as in the output of
1252  * `PointWidthDepthProjection()`.
1253  * The method caps width and depth of the projection so that it stays on
1254  * the plane. A new capped value is returned.
1255  * Since the reference point of the frame is defined as the center of the
1256  * plane, this action is equivalent to force the width component in
1257  * @f$ \left[ -\frac{w}{2}, \frac{w}{2} \right] @f$ range and the depth
1258  * component into @f$ \left[ -\frac{d}{2}, \frac{d}{2} \right] @f$, with
1259  * @f$ w @f$ and @f$ d @f$ the width and depth of the wire plane.
1260  */
1262  (WidthDepthProjection_t const& proj) const;
1263 
1264  //@{
1265  /**
1266  * @brief Returns the point, moved so that its projection is over the plane.
1267  * @param point point to be checked and moved
1268  * @return the new value of the point
1269  * @see isProjectionOnPlane(), MoveProjectionToPlane(), Width(), Height()
1270  *
1271  * If the projection of the point on the plane falls outside it, the
1272  * returned point is translated so that its projection is now on the border
1273  * of the plane. The translation happens along the directions of the plane
1274  * frame, as described in MoveProjectionToPlane().
1275  */
1276  geo::Point_t MovePointOverPlane(geo::Point_t const& point) const;
1277  TVector3 MovePointOverPlane(TVector3 const& point) const;
1278  //@}
1279 
1280  //@{
1281  /**
1282  * @brief Returns the 3D vector from composition of projection and distance.
1283  * @tparam Point type of point to be produced (current default is `TVector3`)
1284  * @param decomp decomposed point
1285  * @return the 3D vector from composition of projection and distance
1286  * @see DecomposePointWidthDepth(),
1287  * ComposePointWidthDepth(double, DecomposedVector_t::Projection_t const&)
1288  *
1289  * See
1290  * `ComposePointWidthDepth(double, DecomposedVector_t::Projection_t const&)`
1291  * for details.
1292  */
1293  template <typename Point>
1295  { return geo::vect::convertTo<Point>(fDecompFrame.ComposePoint(decomp)); }
1297  { return ComposePoint<DefaultPoint_t>(decomp); }
1298  //@}
1299 
1300  //@{
1301  /**
1302  * @brief Returns the 3D point from composition of projection and distance.
1303  * @tparam Point type of point to be produced (current default is `TVector3`)
1304  * @param distance distance of the target point from the wire plane
1305  * @param proj projection of the target point on the wire plane
1306  * @return the 3D vector from composition of projection and distance
1307  * @see DecomposePointWidthDepth()
1308  *
1309  * The returned vector is the sum of two 3D vectors:
1310  *
1311  * 1. a vector parallel to the plane normal, with norm the input distance
1312  * 2. a vector lying on the plane, whose projection via
1313  * `PointWidthDepthProjection()` gives the input projection
1314  *
1315  * Given the arbitrary definition of the projection reference, it is assumed
1316  * that the same convention is used as in PointWidthDepthProjection() and
1317  * DecomposePointWidthDepth().
1318  *
1319  */
1320  template <typename Point>
1322  (double distance, WidthDepthProjection_t const& proj) const
1323  { return geo::vect::convertTo<Point>(fDecompFrame.ComposePoint(distance, proj)); }
1325  (double distance, WidthDepthProjection_t const& proj) const
1326  { return ComposePoint<DefaultPoint_t>(distance, proj); }
1327  //@}
1328 
1329 
1330  /// @}
1331 
1332 
1333  /// @{
1334  /**
1335  * @name Coordinate transformation
1336  *
1337  * Local points and displacement vectors are described by the types
1338  * `geo::PlaneGeo::LocalPoint_t` and `geo::PlaneGeo::LocalVector_t`,
1339  * respectively.
1340  */
1341 
1342  /// Transform point from local plane frame to world frame.
1343  void LocalToWorld(const double* plane, double* world) const
1344  { fTrans.LocalToWorld(plane, world); }
1345 
1346  /// Transform point from local plane frame to world frame.
1347  TVector3 LocalToWorld(const TVector3& local) const
1348  { return fTrans.LocalToWorld<TVector3>(local); }
1349 
1350  /// Transform point from local plane frame to world frame.
1352  { return fTrans.toWorldCoords(local); }
1353 
1354  /// Transform direction vector from local to world.
1355  void LocalToWorldVect(const double* plane, double* world) const
1356  { fTrans.LocalToWorldVect(plane, world); }
1357 
1358  /// Transform direction vector from local to world.
1359  TVector3 LocalToWorldVect(const TVector3& local) const
1360  { return fTrans.LocalToWorldVect<TVector3>(local); }
1361 
1362  /// Transform direction vector from local to world.
1364  { return fTrans.toWorldCoords(local); }
1365 
1366  /// Transform point from world frame to local plane frame.
1367  void WorldToLocal(const double* world, double* plane) const
1368  { fTrans.WorldToLocal(world, plane); }
1369 
1370  /// Transform point from world frame to local plane frame.
1371  TVector3 WorldToLocal(TVector3 const& world) const
1372  { return fTrans.WorldToLocal<TVector3>(world); }
1373 
1374  /// Transform point from world frame to local plane frame.
1376  { return fTrans.toLocalCoords(world); }
1377 
1378  /// Transform direction vector from world to local.
1379  void WorldToLocalVect(const double* world, double* plane) const
1380  { fTrans.WorldToLocalVect(world, plane); }
1381 
1382  /// Transform direction vector from world to local.
1383  TVector3 WorldToLocalVect(TVector3 const& world) const
1384  { return fTrans.WorldToLocalVect<TVector3>(world); }
1385 
1386  /// Transform direction vector from world to local.
1388  { return fTrans.toLocalCoords(world); }
1389 
1390  /// @}
1391 
1392 
1393 
1394  /// @{
1395  /// @name Setters
1396 
1397  /// Set the signal view (for TPCGeo).
1398  void SetView(geo::View_t view) { fView = view; }
1399 
1400  /// @}
1401 
1402  /// Apply sorting to WireGeo objects.
1403  void SortWires(geo::GeoObjectSorter const& sorter);
1404 
1405  /// Performs all needed updates after the TPC has sorted the planes.
1406  void UpdateAfterSorting
1407  (geo::PlaneID planeid, geo::BoxBoundedGeo const& TPCbox);
1408 
1409  /// Returns the name of the specified view.
1410  static std::string ViewName(geo::View_t view);
1411 
1412  /// Returns the name of the specified orientation.
1413  static std::string OrientationName(geo::Orient_t orientation);
1414 
1415 
1416  private:
1417 
1418  /// Sets the geometry directions.
1419  void DetectGeometryDirections();
1420 
1421  /// Returns a direction normal to the plane (pointing is not defined).
1422  geo::Vector_t GetNormalAxis() const;
1423 
1424  /// Updates the cached normal to plane versor; needs the TPC box coordinates.
1425  void UpdatePlaneNormal(geo::BoxBoundedGeo const& TPCbox);
1426 
1427  /// Updates the cached depth and width direction.
1428  void UpdateWidthDepthDir();
1429 
1430  /// Updates the cached direction to increasing wires.
1431  void UpdateIncreasingWireDir();
1432 
1433  /// Updates the cached direction to wire.
1434  void UpdateWireDir();
1435 
1436  /// Updates plane orientation.
1437  void UpdateOrientation();
1438 
1439  /// Updates the stored wire pitch.
1440  void UpdateWirePitch();
1441 
1442  /// Updates the stored wire plane center.
1443  void UpdateWirePlaneCenter();
1444 
1445  /// Updates the stored @f$ \phi_{z} @f$.
1446  void UpdatePhiZ();
1447 
1448  /// Updates the stored view
1449  void UpdateView();
1450 
1451  /// Updates the stored wire pitch with a slower, more robust algorithm.
1452  void UpdateWirePitchSlow();
1453 
1454  /// Updates the position of the wire coordinate decomposition.
1455  void UpdateDecompWireOrigin();
1456 
1457  /// Updates the internally used active area.
1458  void UpdateActiveArea();
1459 
1460  /// Whether the specified wire should have start and end swapped.
1461  bool shouldFlipWire(geo::WireGeo const& wire) const;
1462 
1463  private:
1464 
1465  using LocalTransformation_t
1467 
1468  struct RectSpecs {
1469  double halfWidth;
1470  double halfDepth;
1471 
1472  double HalfWidth() const { return halfWidth; }
1473  double HalfDepth() const { return halfDepth; }
1474  double Width() const { return 2.0 * HalfWidth(); }
1475  double Depth() const { return 2.0 * HalfDepth(); }
1476  }; // RectSpecs
1477 
1478  LocalTransformation_t fTrans; ///< Plane to world transform.
1479  TGeoVolume const* fVolume; ///< Plane volume description.
1480  View_t fView; ///< Does this plane measure U, V, or W?
1481  Orient_t fOrientation; ///< Is the plane vertical or horizontal?
1482  WireCollection_t fWire; ///< List of wires in this plane.
1483  double fWirePitch; ///< Pitch of wires in this plane.
1484  double fSinPhiZ; ///< Sine of @f$ \phi_{z} @f$.
1485  double fCosPhiZ; ///< Cosine of @f$ \phi_{z} @f$.
1486 
1487  geo::Vector_t fNormal; ///< Normal to the plane, inward in TPC.
1488  /// Decomposition on wire coordinates; the main direction is along the wire,
1489  /// the secondary one is the one measured by the wire, the normal matches
1490  /// the plane's normal.
1492  /// Decomposition on frame coordinates; the main direction is a "width",
1493  /// the secondary one is just orthogonal to it ("depth").
1494  /// Normal can differ in sign from the plane one.
1496  RectSpecs fFrameSize; ///< Size of the frame of the plane.
1497  /// Area covered by wires in frame base.
1499  /// Center of the plane, lying on the wire plane.
1501 
1502  geo::PlaneID fID; ///< ID of this plane.
1503 
1505 
1506  /// Returns `min` if `v` < `min`, `max` if `v` > `max`, `v` otherwise.
1507  template <typename T>
1508  static T boundedValue(T v, T min, T max)
1509  { return std::min(max, std::max(min, v)); }
1510 
1511  }; // class PlaneGeo
1512 
1513 } // namespace geo
1514 
1515 
1516 //------------------------------------------------------------------------------
1517 //--- inline implementation
1518 //---
1520  (geo::WireID::WireID_t wireNo) const
1521 {
1522  return { ID(), boundedValue<geo::WireID::WireID_t>(wireNo, 0, Nwires()) };
1523 }
1524 
1526 {
1527  if (wireid.asPlaneID() != ID()) {
1528  geo::WireID invalid{ wireid };
1529  invalid.markInvalid();
1530  return invalid;
1531  }
1532  return ClosestWireID(wireid.Wire);
1533 } // geo::PlaneGeo::ClosestWireID()
1534 
1535 //------------------------------------------------------------------------------
1536 //--- template implementation
1537 //---
1538 template <typename Stream>
1540  Stream&& out,
1541  std::string indent /* = "" */,
1542  unsigned int verbosity /* = 1 */
1543 ) const {
1544 
1545  //----------------------------------------------------------------------------
1546  out << "plane " << std::string(ID());
1547 
1548  if (verbosity-- <= 0) return; // 0
1549 
1550  //----------------------------------------------------------------------------
1551  out
1552  << " at " << GetCenter<geo::Vector_t>() << " cm"
1553  << ", theta: " << ThetaZ() << " rad";
1554 
1555  if (verbosity-- <= 0) return; // 1
1556 
1557  //----------------------------------------------------------------------------
1558  unsigned int const nWires = Nwires();
1559 
1560  out << "\n" << indent
1561  << "normal to wire: " << PhiZ() << " rad"
1562  << ", with orientation " << OrientationName(Orientation())
1563  << ", has " << nWires << " wires measuring " << ViewName(View())
1564  << " with a wire pitch of " << WirePitch() << " cm"
1565  ;
1566 
1567  if (verbosity-- <= 0) return; // 2
1568 
1569  //----------------------------------------------------------------------------
1570  auto const& normal = GetNormalDirection<geo::Vector_t>();
1571  auto const& incrZdir = GetIncreasingWireDirection<geo::Vector_t>();
1572  auto const& wireNormalDir = fDecompWire.NormalDir();
1573  out << "\n" << indent
1574  << "normal to plane: " << normal
1575  << ", direction of increasing wire number: " << incrZdir
1576  << " [wire frame normal: " << wireNormalDir << "]"
1577  << " (" << (WireIDincreasesWithZ()? "increases": "decreases") << " with z)";
1578 
1579  if (verbosity-- <= 0) return; // 3
1580 
1581  //----------------------------------------------------------------------------
1582 
1583  auto const& wireDir = GetWireDirection<geo::Vector_t>();
1584  auto const& widthDir = WidthDir<geo::Vector_t>();
1585  auto const& depthDir = DepthDir<geo::Vector_t>();
1586  auto const& frameNormalDir = fDecompFrame.NormalDir();
1587 
1588  out << "\n" << indent
1589  << "wire direction: " << wireDir
1590  << "; width " << Width() << " cm in direction: " << widthDir
1591  << ", depth " << Depth() << " cm in direction: " << depthDir
1592  << " [normal: " << frameNormalDir << "]"
1593  ;
1594 
1595  if (verbosity-- <= 0) return; // 4
1596 
1597  //----------------------------------------------------------------------------
1598  // get the area spanned by the wires
1599  out << "\n" << indent << "wires cover width "
1600  << ActiveArea().width.lower << " to " << ActiveArea().width.upper
1601  << ", depth "
1602  << ActiveArea().depth.lower << " to " << ActiveArea().depth.upper
1603  << " cm";
1604  if (verbosity-- <= 0) return; // 5
1605 
1606  //----------------------------------------------------------------------------
1607  // print also the containing box
1608  auto const box = BoundingBox();
1609  out << "\n" << indent
1610  << "bounding box: " << box.Min() << " -- " << box.Max();
1611 
1612 // if (verbosity-- <= 0) return; // 6
1613 
1614  //----------------------------------------------------------------------------
1615 } // geo::PlaneGeo::PrintPlaneInfo()
1616 
1617 
1618 //------------------------------------------------------------------------------
1619 
1620 
1621 #endif // LARCOREALG_GEOMETRY_PLANEGEO_H
1622 ////////////////////////////////////////////////////////////////////////
WireGeo const * WirePtr
Definition: PlaneGeo.h:48
Point_t ComposePoint(DecomposedVector_t const &decomp) const
Returns the 3D point from composition of projection and distance.
Definition: Decomposer.h:611
static std::string OrientationName(geo::Orient_t orientation)
Returns the name of the specified orientation.
Definition: PlaneGeo.cxx:778
geo::WirePtr WirePtr(unsigned int iwire) const
Returns the wire number iwire from this plane.
Definition: PlaneGeo.h:324
unsigned int NElements() const
Definition: PlaneGeo.h:270
WireGeo const & Wire(WireID const &wireid) const
Returns the wire in wireid from this plane.
Definition: PlaneGeo.h:313
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
double HalfWidth() const
Definition: PlaneGeo.h:1472
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:164
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: PlaneGeo.h:1363
auto VectorSecondaryComponent(Vector_t const &v) const
Returns the secondary component of a vector.
Definition: Decomposer.h:531
WireDecomposedVector_t DecomposePoint(TVector3 const &point) const
Definition: PlaneGeo.h:903
void SetView(geo::View_t view)
Set the signal view (for TPCGeo).
Definition: PlaneGeo.h:1398
DefaultVector_t GetNormalDirection() const
Definition: PlaneGeo.h:443
WireCollection_t const & ElementIteratorBox
Type returned by IterateElements().
Definition: PlaneGeo.h:93
WidthDepthProjection_t VectorWidthDepthProjection(geo::Vector_t const &v) const
Returns the projection of the specified vector on the plane.
Definition: PlaneGeo.h:1127
geo::Point_t fCenter
Center of the plane, lying on the wire plane.
Definition: PlaneGeo.h:1500
static std::string ViewName(geo::View_t view)
Returns the name of the specified view.
Definition: PlaneGeo.cxx:763
auto PointNormalComponent(Point_t const &point) const
Returns the secondary component of a point.
Definition: Decomposer.h:486
std::string PlaneInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with plane information.
Definition: PlaneGeo.cxx:546
void UpdateIncreasingWireDir()
Updates the cached direction to increasing wires.
Definition: PlaneGeo.cxx:1087
double fWirePitch
Pitch of wires in this plane.
Definition: PlaneGeo.h:1483
WireCoordProjection_t PointProjection(TVector3 const &point) const
Definition: PlaneGeo.h:944
std::vector< geo::WireGeo > WireCollection_t
Definition: PlaneGeo.h:89
void UpdateWirePitch()
Updates the stored wire pitch.
Definition: PlaneGeo.cxx:923
void UpdateWidthDepthDir()
Updates the cached depth and width direction.
Definition: PlaneGeo.cxx:1067
DefaultPoint_t ComposePoint(WireDecomposedVector_t const &decomp) const
Definition: PlaneGeo.h:1026
WireGeo const & Wire(unsigned int iwire) const
Definition: PlaneGeo.cxx:506
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
DefaultVector_t WidthDir() const
Definition: PlaneGeo.h:222
double InterWireDistance(TVector3 const &dir) const
Definition: PlaneGeo.h:714
enum geo::_plane_orient Orient_t
double DistanceFromPlane(TVector3 const &point) const
Definition: PlaneGeo.h:623
void UpdateOrientation()
Updates plane orientation.
Definition: PlaneGeo.cxx:891
WireCoordProjection_t VectorProjection(TVector3 const &v) const
Definition: PlaneGeo.h:965
geo::PlaneID fID
ID of this plane.
Definition: PlaneGeo.h:1502
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Volume delimited by two points.
Definition: SimpleGeo.h:261
Point ProjectionReferencePoint() const
Returns the reference point used by PointProjection().
Definition: PlaneGeo.h:917
void DriftPoint(TVector3 &position, double distance) const
Definition: PlaneGeo.h:645
Vector_t ComposeVector(DecomposedVector_t const &decomp) const
Returns the 3D vector from composition of projection and distance.
Definition: Decomposer.h:648
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
Point GetBoxCenter() const
Returns the centre of the box representing the plane.
Definition: PlaneGeo.h:498
bool isProjectionOnPlane(geo::Point_t const &point) const
Returns if the projection of specified point is within the plane.
Definition: PlaneGeo.cxx:581
Point ComposePoint(WireDecomposedVector_t const &decomp) const
Returns the 3D point from composition of projection and distance.
Definition: PlaneGeo.h:1024
::geo::Vector_t toVector(Vector const &v)
Convert the specified vector into a geo::Vector_t.
TVector3 DefaultPoint_t
Definition: PlaneGeo.h:85
WidthDepthProjection_t PointWidthDepthProjection(geo::Point_t const &point) const
Returns the projection of the specified point on the plane.
Definition: PlaneGeo.h:1107
geo::WireGeo const & NearestWire(geo::Point_t const &pos) const
Returns the wire closest to the specified position.
Definition: PlaneGeo.cxx:681
DefaultPoint_t ComposePoint(WDDecomposedVector_t const &decomp) const
Definition: PlaneGeo.h:1296
ElementIteratorBox IterateWires() const
Definition: PlaneGeo.h:401
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
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.
Rect const & ActiveArea() const
Returns an area covered by the wires in the plane.
Definition: PlaneGeo.h:758
bool shouldFlipWire(geo::WireGeo const &wire) const
Whether the specified wire should have start and end swapped.
Definition: PlaneGeo.cxx:1212
Vector GetNormalDirection() const
Returns the direction normal to the plane.
Definition: PlaneGeo.h:442
bool HasElement(geo::WireID const &wireid) const
Definition: PlaneGeo.h:294
double Depth() const
Definition: PlaneGeo.h:1475
WireCoordProjection_t Projection(geo::Point_t const &point) const
Returns the projection of the specified point on the plane.
Definition: PlaneGeo.h:940
WidthDepthProjection_t MoveProjectionToPlane(WidthDepthProjection_t const &proj) const
Returns the projection, moved onto the plane if necessary.
Definition: PlaneGeo.cxx:593
Vector GetIncreasingWireDirection() const
Returns the direction of increasing wires.
Definition: PlaneGeo.h:457
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local plane frame.
Definition: PlaneGeo.h:1375
WDDecomposedVector_t DecomposePointWidthDepth(TVector3 const &point) const
Definition: PlaneGeo.h:1090
void WorldToLocal(const double *world, double *plane) const
Transform point from world frame to local plane frame.
Definition: PlaneGeo.h:1367
View_t fView
Does this plane measure U, V, or W?
Definition: PlaneGeo.h:1480
geo::BoxBoundedGeo BoundingBox() const
Definition: PlaneGeo.cxx:469
void DetectGeometryDirections()
Sets the geometry directions.
Definition: PlaneGeo.cxx:788
double InterWireProjectedDistance(WireCoordProjection_t const &projDir) const
Returns the distance between wires along the specified direction.
Definition: PlaneGeo.cxx:705
void DriftPoint(geo::Point_t &position, double distance) const
Shifts the position of an electron drifted by a distance.
Definition: PlaneGeo.h:643
geo::Vector_t fNormal
Definition: PlaneGeo.h:1487
Rect fActiveArea
Area covered by wires in frame base.
Definition: PlaneGeo.h:1498
double ThetaZ() const
Angle of the wires from positive z axis; .
Definition: PlaneGeo.cxx:726
Projection_t ProjectPointOnPlane(Point_t const &point) const
Returns the projection of the specified point on the plane.
Definition: Decomposer.h:500
double PlaneCoordinateFrom(geo::Point_t const &point, geo::WireGeo const &refWire) const
Returns the coordinate of point on the plane respect to a wire.
Definition: PlaneGeo.h:834
ElementIteratorBox IterateElements() const
Allows range-for iteration on all wires in this plane.
Definition: PlaneGeo.h:400
void UpdatePlaneNormal(geo::BoxBoundedGeo const &TPCbox)
Updates the cached normal to plane versor; needs the TPC box coordinates.
Definition: PlaneGeo.cxx:1046
then local
Interface to algorithm class for sorting geo::XXXGeo objects.
DefaultVector_t GetIncreasingWireDirection() const
Definition: PlaneGeo.h:459
TGeoVolume const * fVolume
Plane volume description.
Definition: PlaneGeo.h:1479
bool isProjectionOnPlane(TVector3 const &point) const
Definition: PlaneGeo.h:1147
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:184
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double >, WidthDepthReferenceTag > WidthDepthProjection_t
Definition: PlaneGeo.h:151
Offer iterators automatically dereferencing their values.
lar::util::simple_geo::Volume Coverage() const
Returns a volume including all the wires in the plane.
Definition: PlaneGeo.cxx:532
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
WireDecomposedVector_t DecomposePoint(geo::Point_t const &point) const
Decomposes a 3D point in two components.
Definition: PlaneGeo.h:901
geo::LocalTransformationGeo< ROOT::Math::Transform3D, LocalPoint_t, LocalVector_t > LocalTransformation_t
Definition: PlaneGeo.h:1466
Classes to project and compose a vector on a plane.
geo::WireID NearestWireID(geo::Point_t const &pos) const
Returns the ID of wire closest to the specified position.
Definition: PlaneGeo.cxx:649
WidthDepthDecomposer_t::DecomposedVector_t WDDecomposedVector_t
Definition: PlaneGeo.h:163
WidthDepthDecomposer_t fDecompFrame
Definition: PlaneGeo.h:1495
Local-to-world transformations with LArSoft geometry vectors.
void UpdatePhiZ()
Updates the stored .
Definition: PlaneGeo.cxx:935
geo::WirePtr GetElementPtr(WireID const &wireid) const
Definition: PlaneGeo.h:338
TVector3 DefaultVector_t
Definition: PlaneGeo.h:84
double PhiZ() const
Angle from positive z axis of the wire coordinate axis, in radians.
Definition: PlaneGeo.h:193
const WireGeo & MiddleWire() const
Return the middle wire in the plane.
Definition: PlaneGeo.h:347
RTree::BoundingBox BoundingBox
Definition: DBScanAlg.h:33
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1351
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double >, WireCoordinateReferenceTag > WireCoordProjection_t
Type for projections in the wire base representation.
Definition: PlaneGeo.h:130
Tag for vectors in the &quot;local&quot; GDML coordinate frame of the plane.
Definition: PlaneGeo.h:112
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:44
WireCollection_t fWire
List of wires in this plane.
Definition: PlaneGeo.h:1482
WireGeo const & GetElement(WireID const &wireid) const
Definition: PlaneGeo.h:315
WireCoordProjection_t Projection(geo::Vector_t const &v) const
Returns the projection of the specified vector on the plane.
Definition: PlaneGeo.h:961
double Depth() const
Return the depth of the plane.
Definition: PlaneGeo.h:254
DefaultPoint_t ProjectionReferencePoint() const
Definition: PlaneGeo.h:919
geo::Point_t MovePointOverPlane(geo::Point_t const &point) const
Returns the point, moved so that its projection is over the plane.
Definition: PlaneGeo.cxx:633
Point GetCenter() const
Returns the centre of the wire plane in world coordinates [cm].
Definition: PlaneGeo.h:479
double fSinPhiZ
Sine of .
Definition: PlaneGeo.h:1484
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
double Width() const
Return the width of the plane.
Definition: PlaneGeo.h:246
double InterWireDistance(geo::Vector_t const &dir) const
Returns the distance between wires along the specified direction.
Definition: PlaneGeo.cxx:713
Utilities to extend the interface of geometry vectors.
DecomposedVector_t DecomposePoint(Point_t const &point) const
Decomposes a 3D point in two components.
Definition: Decomposer.h:517
void DriftPoint(geo::Point_t &position) const
Shifts the position along drift direction to fall on the plane.
Definition: PlaneGeo.h:659
WireCoordProjection_t PointProjection(geo::Point_t const &point) const
Definition: PlaneGeo.h:942
geo::WirePtr WirePtr(WireID const &wireid) const
Returns the wire in wireid from this plane.
Definition: PlaneGeo.h:336
constexpr PlaneID const & asPlaneID() const
Conversion to PlaneID (for convenience of notation).
Definition: geo_types.h:534
double CosPhiZ() const
Cosine of PhiZ()
Definition: PlaneGeo.h:200
void UpdateWirePitchSlow()
Updates the stored wire pitch with a slower, more robust algorithm.
Definition: PlaneGeo.cxx:1135
const WireGeo & FirstWire() const
Return the first wire in the plane.
Definition: PlaneGeo.h:344
bool HasElement(unsigned int iwire) const
Definition: PlaneGeo.h:280
RectSpecs fFrameSize
Definition: PlaneGeo.h:1496
void UpdateAfterSorting(geo::PlaneID planeid, geo::BoxBoundedGeo const &TPCbox)
Performs all needed updates after the TPC has sorted the planes.
Definition: PlaneGeo.cxx:731
double SinPhiZ() const
Sine of PhiZ()
Definition: PlaneGeo.h:197
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double >, WidthDepthReferenceTag > WidthDepthDisplacement_t
Type for vector projections in the plane frame base representation.
Definition: PlaneGeo.h:155
std::vector< TGeoNode const * > GeoNodePath_t
Definition: PlaneGeo.h:90
void markInvalid()
Sets the ID as invalid.
Definition: geo_types.h:240
LocalTransformation_t fTrans
Plane to world transform.
Definition: PlaneGeo.h:1478
Definition of data types for geometry description.
Point_t ReferencePoint() const
Returns the reference point for the plane coordinate, as a 3D point.
Definition: Decomposer.h:457
static T boundedValue(T v, T min, T max)
Returns min if v &lt; min, max if v &gt; max, v otherwise.
Definition: PlaneGeo.h:1508
void UpdateView()
Updates the stored view.
Definition: PlaneGeo.cxx:950
Provides a base class aware of world box coordinates.
typename PlaneDecomposer_t::DecomposedVector_t DecomposedVector_t
Type representing a decomposition on the plane.
Definition: Decomposer.h:414
double HalfDepth() const
Definition: PlaneGeo.h:1473
tuple dir
Definition: dropbox.py:28
Orient_t Orientation() const
What is the orientation of the plane.
Definition: PlaneGeo.h:187
std::enable_if_t< geo::vect::dimension< Vector >)==3U, double > InterWireProjectedDistance(Vector const &dir) const
Returns the distance between wires along the specified direction.
Definition: PlaneGeo.h:741
Encapsulate the geometry of a wire.
Vector DepthDir() const
Return the direction of plane depth.
Definition: PlaneGeo.h:236
Tag for plane frame base vectors.
Definition: PlaneGeo.h:146
DefaultVector_t GetWireDirection() const
Definition: PlaneGeo.h:514
DefaultPoint_t GetBoxCenter() const
Definition: PlaneGeo.h:500
Vector_t const & SecondaryDir() const
Returns the plane secondary axis direction.
Definition: Decomposer.h:466
WidthDepthProjection_t DeltaFromPlane(WidthDepthProjection_t const &proj, double wMargin, double dMargin) const
Returns a projection vector that, added to the argument, gives a projection inside (or at the border ...
Definition: PlaneGeo.cxx:556
void WorldToLocal(double const *world, double *local) const
Transforms a point from world frame to local frame.
Vector_t const & MainDir() const
Returns the plane main axis direction.
Definition: Decomposer.h:463
WidthDepthProjection_t DeltaFromActivePlane(WidthDepthProjection_t const &proj, double wMargin, double dMargin) const
Returns a projection vector that, added to the argument, gives a projection inside (or at the border ...
Definition: PlaneGeo.cxx:569
WireCoordProjection_t VectorProjection(geo::Vector_t const &v) const
Definition: PlaneGeo.h:963
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:33
geo::Vector_t GetNormalAxis() const
Returns a direction normal to the plane (pointing is not defined).
Definition: PlaneGeo.cxx:871
auto PointSecondaryComponent(Point_t const &point) const
Returns the secondary component of a point.
Definition: Decomposer.h:482
Projection_t ProjectVectorOnPlane(Vector_t const &v) const
Returns the projection of the specified vector on the plane.
Definition: Decomposer.h:549
bool HasWire(unsigned int iwire) const
Returns whether a wire with index iwire is present in this plane.
Definition: PlaneGeo.h:279
void PrintPlaneInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this plane.
Definition: PlaneGeo.h:1539
double DistanceFromPlane(geo::Point_t const &point) const
Returns the distance of the specified point from the wire plane.
Definition: PlaneGeo.h:621
geo::PlaneID const & ID() const
Returns the identifier of this plane.
Definition: PlaneGeo.h:203
DefaultPoint_t GetCenter() const
Definition: PlaneGeo.h:481
unsigned int Nwires() const
Number of wires in this plane.
Definition: PlaneGeo.h:269
TVector3 WorldToLocal(TVector3 const &world) const
Transform point from world frame to local plane frame.
Definition: PlaneGeo.h:1371
geo::WireID ClosestWireID(geo::WireID::WireID_t wireNo) const
Returns the closest valid wire ID to the specified wire.
Definition: PlaneGeo.h:1520
bool WireIDincreasesWithZ() const
Returns whether the higher z wires have higher wire ID.
Definition: PlaneGeo.cxx:525
Some simple functions to represent geometry entities.
WireDecomposer_t::DecomposedVector_t WireDecomposedVector_t
Type describing a 3D point or vector decomposed on a plane on wire base.
Definition: PlaneGeo.h:137
double fCosPhiZ
Cosine of .
Definition: PlaneGeo.h:1485
TVector3 LocalToWorldVect(const TVector3 &local) const
Transform direction vector from local to world.
Definition: PlaneGeo.h:1359
Vector WidthDir() const
Return the direction of plane width.
Definition: PlaneGeo.h:221
WDDecomposedVector_t DecomposePointWidthDepth(geo::Point_t const &point) const
Decomposes a 3D point in two components.
Definition: PlaneGeo.h:1088
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:92
unsigned int WireID_t
Type for the ID number.
Definition: geo_types.h:561
void UpdateWirePlaneCenter()
Updates the stored wire plane center.
Definition: PlaneGeo.cxx:1183
GenVector3DBase_t< double, C > Vector3DBase_t
Definition: geo_vectors.h:87
WireDecomposer_t fDecompWire
Definition: PlaneGeo.h:1491
void LocalToWorldVect(const double *plane, double *world) const
Transform direction vector from local to world.
Definition: PlaneGeo.h:1355
GlobalPoint_t toWorldCoords(LocalPoint_t const &local) const
Transforms a point from local frame to world frame.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
double WireCoordinate(Point const &point) const
Returns the coordinate of the point on the plane, in wire units.
Definition: PlaneGeo.h:882
double Width() const
Definition: PlaneGeo.h:1474
void UpdateDecompWireOrigin()
Updates the position of the wire coordinate decomposition.
Definition: PlaneGeo.cxx:1157
Class computing the active area of the plane.
Definition: PlaneGeo.cxx:85
void UpdateActiveArea()
Updates the internally used active area.
Definition: PlaneGeo.cxx:1167
bool HasWire(geo::WireID const &wireid) const
Returns whether the wire in wireid is present in this plane.
Definition: PlaneGeo.h:292
geo::Vector3DBase_t< PlaneGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML wire plane frame.
Definition: PlaneGeo.h:118
Point ComposePoint(WDDecomposedVector_t const &decomp) const
Returns the 3D vector from composition of projection and distance.
Definition: PlaneGeo.h:1294
const WireGeo & LastWire() const
Return the last wire in the plane.
Definition: PlaneGeo.h:350
TVector3 WorldToLocalVect(TVector3 const &world) const
Transform direction vector from world to local.
Definition: PlaneGeo.h:1383
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:184
static constexpr unsigned int MaxVerbosity
Maximum value for print verbosity.
Definition: PlaneGeo.h:802
DefaultVector_t DepthDir() const
Definition: PlaneGeo.h:237
void DriftPoint(TVector3 &position) const
Definition: PlaneGeo.h:661
void SortWires(geo::GeoObjectSorter const &sorter)
Apply sorting to WireGeo objects.
Definition: PlaneGeo.cxx:518
void WorldToLocalVect(const double *world, double *local) const
Transforms a vector from world frame to local frame.
Orient_t fOrientation
Is the plane vertical or horizontal?
Definition: PlaneGeo.h:1481
Vector ComposeVector(WireDecomposedVector_t const &decomp) const
Returns the 3D vector from composition of projection and distance.
Definition: PlaneGeo.h:982
double PlaneCoordinate(geo::Point_t const &point) const
Returns the coordinate of the point on the plane.
Definition: PlaneGeo.h:861
TVector3 LocalToWorld(const TVector3 &local) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1347
void UpdateWireDir()
Updates the cached direction to wire.
Definition: PlaneGeo.cxx:1121
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1343
double PlaneCoordinate(TVector3 const &point) const
Definition: PlaneGeo.h:863
geo::Point3DBase_t< PlaneGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML wire plane frame.
Definition: PlaneGeo.h:115
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
Definition: PlaneGeo.h:1387
bnb BNB Stream
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411
void WorldToLocalVect(const double *world, double *plane) const
Transform direction vector from world to local.
Definition: PlaneGeo.h:1379
geo::WireID NearestWireID(TVector3 const &pos) const
Definition: PlaneGeo.h:545
Tag for wire base vectors.
Definition: PlaneGeo.h:126
PlaneGeo(TGeoNode const &node, geo::TransformationMatrix &&trans, WireCollection_t &&wires)
Construct a representation of a single plane of the detector.
Definition: PlaneGeo.cxx:435
Vector GetWireDirection() const
Returns the direction of the wires.
Definition: PlaneGeo.h:513
DefaultVector_t ComposeVector(WireDecomposedVector_t const &decomp) const
Definition: PlaneGeo.h:984