WireGeo.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file larcorealg/Geometry/WireGeo.h
3 /// \brief Encapsulate the geometry of a wire
4 /// \ingroup Geometry
5 ///
6 /// \author brebel@fnal.gov
7 ////////////////////////////////////////////////////////////////////////
8 
9 #ifndef LARCOREALG_GEOMETRY_WIREGEO_H
10 #define LARCOREALG_GEOMETRY_WIREGEO_H
11 
12 // LArSoft
16 #include "larcorealg/Geometry/geo_vectors_utils.h" // geo::vect
17 
18 // ROOT
19 #include "TVector3.h"
20 #include "Math/GenVector/Transform3D.h"
21 
22 // C/C++ libraries
23 #include <vector>
24 #include <string>
25 #include <type_traits> // std::is_nothrow_move_constructible<>
26 #include <cmath> // std::sin(), ...
27 
28 
29 // forward declarations
30 class TGeoNode;
31 
32 
33 namespace geo {
34 
35  struct WireID; // forward declaration
36 
37 
38  /** **************************************************************************
39  * @brief Geometry description of a TPC wire
40  * @ingroup Geometry
41  *
42  * The wire is a single straight segment on a wire plane.
43  * Different wires may be connected to the same readout channel. That is of
44  * no relevance for the geometry description.
45  *
46  * The wire has a start and an end point. Their definition of them is related
47  * to the other wires in the plane and to the TPC itself.
48  *
49  * The direction of increasing wire coordinate, defined in the wire plane,
50  * is orthogonal to the wire direction and of course points to the direction
51  * where the wire number within the plane increases. This direction is
52  * indirectly defined when sorting the wires in the plane, which is done by
53  * the plane (geo::PlaneGeo). This direction lies by definition on the wire
54  * plane. The direction normal to the wire plane is defined by the TPC so that
55  * it points inward the TPC rather than outward.
56  * Finally, the wire direction is defined so that the triplet of unit vectors
57  * direction of the wire @f$ \hat{l} @f$, direction of increasing wire number
58  * @f$ \hat{w} @f$, and normal to the plane @f$ \hat{n} @f$ is positively
59  * defined (@f$ \hat{l} \times \hat{w} \cdot \hat{n} = +1 @f$).
60  * The start @f$ \vec{a}_{w} @f$ and the end of the wire @f$ \vec{b}_{w} @f$
61  * are defined so that their difference @f$ \vec{b}_{w} - \vec{a}_{w} @f$
62  * points in the same direction as @f$ \hat{l} @f$.
63  *
64  */
65  class WireGeo {
66 
67  using DefaultVector_t = TVector3; // ... not for long
68  using DefaultPoint_t = TVector3; // ... not for long
69 
70  public:
71 
72  using GeoNodePath_t = std::vector<TGeoNode const*>;
73 
74  // -- BEGIN -- Types for geometry-local reference vectors ------------------
75  /// @{
76  /**
77  * @name Types for geometry-local reference vectors.
78  *
79  * These types represents points and displacement vectors in the reference
80  * frame defined in the wire geometry "box" from the GDML geometry
81  * description.
82  *
83  * No alias is explicitly defined for the LArSoft global vector types,
84  * `geo::Point_t` and `geo::Vector_t`.
85  *
86  * Remember the `LocalPoint_t` and `LocalVector_t` vectors from different
87  * instances of `geo::WireGeo` have the same type but are not compatible.
88  */
89 
90  /// Tag for vectors in the "local" GDML coordinate frame of the plane.
92 
93  /// Type of points in the local GDML wire plane frame.
95 
96  /// Type of displacement vectors in the local GDML wire plane frame.
98 
99  ///@}
100  // -- END ---- Types for geometry-local reference vectors ------------------
101 
102  /**
103  * @brief Constructor from a ROOT geometry node and a transformation.
104  * @param node ROOT geometry node
105  * @param trans transformation matrix (local to world)
106  *
107  * The node describes the shape of the wire (the only relevant information
108  * is in fact the length), while the transformation described its
109  * positioning in the world (both position and orientation).
110  *
111  * A pointer to the node and a copy of the transformation matrix are kept
112  * in the `WireGeo` object.
113  */
114  WireGeo(TGeoNode const& node, geo::TransformationMatrix&& trans);
115 
116 
117  // -- BEGIN -- Size and coordinates ----------------------------------------
118  /// @name Size and coordinates
119  /// @{
120 
121  //@{
122  /// Returns the outer half-size of the wire [cm]
123  double RMax() const;
124  //@}
125 
126  //@{
127  /// Returns half the length of the wire [cm]
128  double HalfL() const { return fHalfL; }
129  //@}
130 
131  //@{
132  /// Returns the inner radius of the wire (usually 0) [cm]
133  double RMin() const;
134  //@}
135 
136  //@{
137  /**
138  * @brief Fills the world coordinate of a point on the wire
139  * @param xyz _(output)_ the position to be filled, as [ x, y, z ] (in cm)
140  * @param localz distance of the requested point from the middle of the wire
141  * @see `GetCenter()`, `GetStart()`, `GetEnd()`, `GetPositionFromCenter()`
142  *
143  * The center of the wires corresponds to `localz` equal to `0`; negative
144  * positions head toward the start of the wire, positive toward the end.
145  *
146  * If the `localz` position would put the point outside the wire, the
147  * returned position is the wire end closest to the requested position.
148  *
149  * @deprecated Use the version returning a vector instead.
150  */
151  void GetCenter(double* xyz, double localz=0.0) const;
152  //@}
153 
154  //@{
155  /// Fills the world coordinate of one end of the wire
156  /// @deprecated Use the version returning a vector instead.
157  void GetStart(double* xyz) const { GetCenter(xyz, -fHalfL); }
158  //@}
159 
160  //@{
161  /// Fills the world coordinate of one end of the wire
162  /// @deprecated Use the version returning a vector instead.
163  void GetEnd(double* xyz) const { GetCenter(xyz, +fHalfL); }
164  //@}
165 
166  //@{
167  /**
168  * @brief Returns the position (world coordinate) of a point on the wire
169  * @tparam Point type of vector to be returned (current default: `TVector3`)
170  * @param localz distance of the requested point from the middle of the wire
171  * @return the position of the requested point (in cm)
172  * @see `GetCenter()`, `GetStart()`, `GetEnd()`,
173  * `GetPositionFromCenterUnbounded()`
174  *
175  * The center of the wires corresponds to `localz` equal to `0`; negative
176  * positions head toward the start of the wire, positive toward the end.
177  *
178  * If the `localz` position would put the point outside the wire, the
179  * returned position is the wire end closest to the requested position.
180  */
181  template <typename Point>
182  Point GetPositionFromCenter(double localz) const
183  { return GetPositionFromCenterUnbounded<Point>(capLength(localz)); }
185  { return GetPositionFromCenter<DefaultPoint_t>(localz); }
186  //@}
187 
188  //@{
189  /**
190  * @brief Returns the position (world coordinate) of a point on the wire
191  * @tparam Point type of vector to be returned (current default: `TVector3`)
192  * @param localz distance of the requested point from the middle of the wire
193  * @return the position of the requested point (in cm)
194  * @see `GetCenter()`, `GetStart()`, `GetEnd()`, `GetPositionFromCenter()`
195  *
196  * The center of the wires corresponds to `localz` equal to `0`; negative
197  * positions head toward the start of the wire, positive toward the end.
198  *
199  * If the `localz` position would put the point outside the wire, the
200  * returned position will lie beyond the end of the wire.
201  */
202  template <typename Point>
203  Point GetPositionFromCenterUnbounded(double localz) const;
205  { return GetPositionFromCenterUnbounded<DefaultPoint_t>(localz); }
206  //@}
207 
208  //@{
209  /// Returns the world coordinate of the center of the wire [cm]
210  /// @tparam Point type of the point being returned
211  template <typename Point>
212  Point GetCenter() const { return geo::vect::convertTo<Point>(fCenter); }
213  DefaultPoint_t GetCenter() const { return GetCenter<DefaultPoint_t>(); }
214  //@}
215 
216  //@{
217  /// Returns the world coordinate of one end of the wire [cm]
218  /// @tparam Point type of the point being returned
219  template <typename Point>
220  Point GetStart() const
221  { return GetPositionFromCenterUnbounded<Point>(-HalfL()); }
222  DefaultPoint_t GetStart() const { return GetStart<DefaultPoint_t>(); }
223  //@}
224 
225  //@{
226  /// Returns the world coordinate of one end of the wire [cm]
227  /// @tparam Point type of the point being returned
228  template <typename Point>
229  Point GetEnd() const
230  { return GetPositionFromCenterUnbounded<Point>(+HalfL()); }
231  DefaultPoint_t GetEnd() const { return GetEnd<DefaultPoint_t>(); }
232  //@}
233 
234  //@{
235  /// Returns the wire length in centimeters
236  double Length() const { return 2. * HalfL(); }
237  //@}
238 
239 
240  /// @}
241  // -- END ---- Size and coordinates ---------------------------------------
242 
243 
244  // -- BEGIN -- Orientation and angles --------------------------------------
245  /// @name Orientation and angles
246  /// @{
247 
248  //@{
249  /// Returns angle of wire with respect to z axis in the Y-Z plane in radians
250  double ThetaZ() const { return fThetaZ; }
251  //@}
252 
253  //@{
254  /**
255  * Returns angle of wire with respect to z axis in the Y-Z plane
256  * @param degrees return the angle in degrees rather than radians
257  * @return wire angle
258  */
259  double ThetaZ(bool degrees) const;
260  //@}
261 
262  //@{
263  /// Returns trigonometric operations on ThetaZ()
264  double CosThetaZ() const { return std::cos(ThetaZ()); }
265  double SinThetaZ() const { return std::sin(ThetaZ()); }
266  double TanThetaZ() const { return std::tan(ThetaZ()); }
267  //@}
268 
269  //@{
270  /// Returns if this wire is horizontal (theta_z ~ 0)
271  bool isHorizontal() const { return std::abs(SinThetaZ()) < 1e-5; }
272  //@}
273 
274  //@{
275  /// Returns if this wire is vertical (theta_z ~ pi/2)
276  bool isVertical() const { return std::abs(CosThetaZ()) < 1e-5; }
277  //@}
278 
279  //@{
280  /// Returns if this wire is parallel to another
281  bool isParallelTo(geo::WireGeo const& wire) const
282  {
283  return // parallel if the dot product of the directions is about +/- 1
284  std::abs(std::abs(Direction<geo::Vector_t>().Dot(wire.Direction<geo::Vector_t>())) - 1.) < 1e-5;
285  }
286  //@}
287 
288  //@{
289  /// Returns the wire direction as a norm-one vector.
290  /// @tparam Vector type of the vector being returned
291  template <typename Vector>
292  Vector Direction() const;
293  DefaultVector_t Direction() const { return Direction<DefaultVector_t>(); }
294  //@}
295 
296  /// @}
297  // -- END ---- Orientation and angles --------------------------------------
298 
299 
300  // -- BEGIN -- Printing ----------------------------------------------------
301  /// @name Printing
302  /// @{
303 
304  /**
305  * @brief Prints information about this wire.
306  * @tparam Stream type of output stream to use
307  * @param out stream to send the information to
308  * @param indent prepend each line with this string
309  * @param verbosity amount of information printed
310  *
311  * Note that the first line out the output is _not_ indented.
312  *
313  * Verbosity levels
314  * -----------------
315  *
316  * * 0: only start and end
317  * * 1 _(default)_: also length
318  * * 2: also angle with z axis
319  * * 3: also center
320  * * 4: also direction
321  *
322  * The constant `MaxVerbosity` is set to the highest supported verbosity
323  * level.
324  */
325  template <typename Stream>
326  void PrintWireInfo
327  (Stream&& out, std::string indent = "", unsigned int verbosity = 1) const;
328 
329  /**
330  * @brief Returns a string with all the information of the wire.
331  * @see `PrintWireInfo()`
332  *
333  * All arguments are equivalent to the ones of `PrintWireInfo`.
334  */
335  std::string WireInfo(std::string indent = "", unsigned int verbosity = 1) const;
336 
337  /// Maximum verbosity supported by `PrintWireInfo()`.
338  static constexpr unsigned int MaxVerbosity = 4;
339 
340  /// @}
341  // -- END ---- Printing ----------------------------------------------------
342 
343 
344  // -- BEGIN -- Coordinate transformation -----------------------------------
345  /**
346  * @name Coordinate transformation
347  *
348  * Local points and displacement vectors are described by the types
349  * `geo::WireGeo::LocalPoint_t` and `geo::WireGeo::LocalVector_t`,
350  * respectively.
351  */
352  /// @{
353 
354  /// Transform point from local wire frame to world frame.
355  void LocalToWorld(const double* wire, double* world) const
356  { fTrans.LocalToWorld(wire, world); }
357 
358  /// Transform point from local wire frame to world frame.
360  { return fTrans.toWorldCoords(local); }
361 
362  /// Transform direction vector from local to world.
363  void LocalToWorldVect(const double* wire, double* world) const
364  { fTrans.LocalToWorldVect(wire, world); }
365 
366  /// Transform direction vector from local to world.
368  { return fTrans.toWorldCoords(local); }
369 
370  /// Transform point from world frame to local wire frame.
371  void WorldToLocal(const double* world, double* wire) const
372  { fTrans.WorldToLocal(world, wire); }
373 
374  /// Transform point from world frame to local wire frame.
376  { return fTrans.toLocalCoords(world); }
377 
378  /// Transform direction vector from world to local.
379  void WorldToLocalVect(const double* world, double* wire) const
380  { fTrans.WorldToLocalVect(world, wire); }
381 
382  /// Transform direction vector from world to local.
384  { return fTrans.toLocalCoords(world); }
385 
386  /// @}
387  // -- END ---- Coordinate transformation -----------------------------------
388 
389 
390  const TGeoNode* Node() const { return fWireNode; }
391 
392 
393  // -- BEGIN -- Geometric properties and algorithms -------------------------
394  /// @name Geometric properties and algorithms
395  /// @{
396 
397  /// Returns the z coordinate, in centimetres, at the point where y = 0.
398  /// Assumes the wire orthogonal to x axis and the wire not parallel to z.
399  double ComputeZatY0() const
400  { return fCenter.Z() - fCenter.Y() / TanThetaZ(); }
401 
402  /**
403  * @brief Returns 3D distance from the specified wire
404  * @return the signed distance in centimetres (0 if wires are not parallel)
405  *
406  * If the specified wire is "ahead" in z respect to this, the distance is
407  * returned negative.
408  */
409  double DistanceFrom(geo::WireGeo const& wire) const;
410 
411  /**
412  * @brief Returns the point of this wire that is closest to `other` wire.
413  * @tparam Point the type of point returned
414  * @param other the other wire
415  * @return the point of this wire closest to `other`
416  * @see IntersectionAndOffsetsWith()
417  *
418  * The point of this wire that is closest to any point of the `other` wire
419  * is returned.
420  *
421  * The `other` wire is _assumed_ not to be parallel to this one, and when
422  * this prerequisite is not met the behaviour is undefined.
423  *
424  * Another method, `IntersectionAndOffsetsWith()`, also returns the offset
425  * of the intersection from the two wire centers.
426  */
427  template <typename Point = DefaultPoint_t>
429 
430  /**
431  * @brief Returns the point of this wire that is closest to `other` wire.
432  * @tparam Point the type of point returned
433  * @param other the other wire
434  * @return a data structure with three fields:
435  * `point`: the point of this wire closest to `other`;
436  * `offset1`: its offset on this wire [cm];
437  * `offset2`: its offset on the `other` wire [cm]
438  * @see IntersectionWith()
439  *
440  * The point of this wire that is closest to any point of the `other` wire
441  * is returned.
442  * The returned intersection point is the same as for
443  * `IntersectionWith(other)`. The return value is actually triplet, though,
444  * which is most easily unpacked immediately:
445  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
446  * auto [ point, offset, otherOffset ]
447  * = wire.IntersectionAndOffsetsWith(otherWire);
448  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
449  *
450  * The two other elements of the triplets are the distances of the
451  * intersection point from the center of this wire (`offset` in the example)
452  * and from the center of the `other` wire (`otherOffset`), in centimeters.
453  * The sign of the offsets are positive if the intersection points lie on
454  * the side pointed by the `Direction()` of the respective wires.
455  *
456  * To reassign the variables after they have been defined, instead:
457  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
458  * std::tie(point, otherOffset, offset)
459  * = otherWire.IntersectionAndOffsetsWith(wire);
460  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
461  *
462  */
463  template <typename Point = DefaultPoint_t>
465  (geo::WireGeo const& other) const;
466 
467  /// @}
468  // -- END ---- Geometric properties and algorithms -------------------------
469 
470 
471  /// Internal updates after the relative position of the wire is known
472  /// (currently no-op)
473  void UpdateAfterSorting(geo::WireID const&, bool flip);
474 
475  /// Returns the pitch (distance on y/z plane) between two wires, in cm
476  static double WirePitch(geo::WireGeo const& w1, geo::WireGeo const& w2)
477  { return std::abs(w2.DistanceFrom(w1)); }
478 
479  private:
481  <ROOT::Math::Transform3D, LocalPoint_t, LocalVector_t>;
482 
483  const TGeoNode* fWireNode; ///< Pointer to the wire node
484  double fThetaZ; ///< angle of the wire with respect to the z direction
485  double fHalfL; ///< half length of the wire
486  geo::Point_t fCenter; ///< Center of the wire in world coordinates.
487  LocalTransformation_t fTrans; ///< Wire to world transform.
488  bool flipped; ///< whether start and end are reversed
489 
490  /// Returns whether ( 0, 0, fHalfL ) identifies end (false) or start (true)
491  /// of the wire.
492  bool isFlipped() const { return flipped; }
493 
494  /// Returns the relative length from center to be used when transforming.
495  double relLength(double local) const { return isFlipped()? -local: local; }
496 
497  /// Caps the specified local length coordinate to lay on the wire.
498  double capLength(double local) const
499  { return std::min(+HalfL(), std::max(-HalfL(), local)); }
500 
501  /// Stacked `capLength()` and `relLength()`.
502  double capRelLength(double local) const
503  { return capLength(relLength(local)); }
504 
505  /// Set to swap the start and end wire
506  void Flip();
507 
508 
509  static double gausSum(double a, double b) { return std::sqrt(a*a + b*b); }
510 
511  }; // class WireGeo
512 
513  static_assert(std::is_move_assignable_v<geo::WireGeo>);
514  static_assert(std::is_move_constructible_v<geo::WireGeo>);
515 
516 
517  /**
518  * @brief Returns the point of `wireA` that is closest to `wireB`.
519  * @param wireA the first wire
520  * @param wireB the other wire
521  * @return the point of `wireA` closest to `wireB`
522  * @see WiresIntersectionAndOffsets()
523  *
524  * The point of `wireA` that is closest to `wireB` is returned.
525  *
526  * The two wires are _assumed_ not to be parallel, and when this prerequisite
527  * is not met the behaviour is undefined.
528  *
529  * A separate function, `WiresIntersectionAndOffsets()`,
530  * also returns the offset of the intersection from the two reference points.
531  *
532  */
534  (geo::WireGeo const& wireA, geo::WireGeo const& wireB);
535 
536  /**
537  * @brief Returns the point of `wireA` that is closest to `wireB`.
538  * @param wireA the first wire
539  * @param wireB the other wire
540  * @return a data structure with three fields:
541  * `point`: the point of `wireA` closest to `wireB`;
542  * `offset1`: its offset on `wireA` [cm];
543  * `offset2`: its offset on `wireB` [cm]
544  * @see WiresIntersection()
545  *
546  * Computes the point of `wireA` that is closest to `wireB`.
547  *
548  * The returned intersection point is the same as for
549  * `geo::WiresIntersection()`. The return value is actually triplet, though,
550  * which is most easily unpacked immediately:
551  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
552  * auto [ point, offsetA, offsetB ] = geo::WiresIntersection(wireA, wireB);
553  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
554  *
555  * The two other elements of the triplets are the distances of the
556  * intersection point from the center of this wire (`offset` in the example)
557  * and from the center of the `other` wire (`otherOffset`), in centimeters.
558  * The sign of the offsets are positive if the intersection points lie on the
559  * side pointed by the `Direction()` of the respective wires.
560  *
561  * To reassign the variables after they have been defined, instead:
562  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
563  * std::tie(point, offsetB, offsetA) = geo::WiresIntersection(wireB, wireA);
564  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
565  *
566  */
568  (geo::WireGeo const& wireA, geo::WireGeo const& wireB);
569 
570 
571 } // namespace geo
572 
573 
574 //------------------------------------------------------------------------------
575 //--- template implementation
576 //---
577 //------------------------------------------------------------------------------
578 template <typename Point>
580  return geo::vect::convertTo<Point>
581  (toWorldCoords(LocalPoint_t{ 0.0, 0.0, relLength(localz) }));
582 } // geo::WireGeo::GetPositionFromCenterImpl()
583 
584 
585 //------------------------------------------------------------------------------
586 template <typename Vector>
588  // maybe (GetCenter() - GetStart()) / HalfL() would be faster;
589  // strangely, TVector3 does not implement operator/ (double).
590  return geo::vect::convertTo<Vector>(GetEnd<geo::Point_t>() - GetStart<geo::Point_t>()) * (1.0 / Length());
591 } // geo::WireGeo::Direction()
592 
593 
594 //------------------------------------------------------------------------------
595 template <typename Stream>
597  Stream&& out,
598  std::string indent /* = "" */,
599  unsigned int verbosity /* = 1 */
600 ) const {
601 
602  //----------------------------------------------------------------------------
603  out << "wire from " << GetStart<geo::Point_t>()
604  << " to " << GetEnd<geo::Point_t>();
605 
606  if (verbosity-- <= 0) return; // 0
607 
608  //----------------------------------------------------------------------------
609  out << " (" << Length() << " cm long)";
610 
611  if (verbosity-- <= 0) return; // 1
612 
613  //----------------------------------------------------------------------------
614  out << ", theta(z)=" << ThetaZ() << " rad";
615 
616  if (verbosity-- <= 0) return; // 2
617 
618  //----------------------------------------------------------------------------
619  out << "\n" << indent
620  << " center at " << GetCenter<geo::Point_t>() << " cm";
621 
622  if (verbosity-- <= 0) return; // 3
623 
624  //----------------------------------------------------------------------------
625  out << ", direction: " << Direction<geo::Vector_t>();
626  if (isHorizontal()) out << " (horizontal)";
627  if (isVertical()) out << " (vertical)";
628 
629 // if (verbosity-- <= 0) return; // 4
630 
631  //----------------------------------------------------------------------------
632 } // geo::WireGeo::PrintWireInfo()
633 
634 
635 //------------------------------------------------------------------------------
636 template <typename Point /* = DefaultPoint_t */>
638  return geo::vect::convertTo<Point>(WiresIntersection(*this, other));
639 } // geo::WireGeo::IntersectionWith()
640 
641 
642 //------------------------------------------------------------------------------
643 template <typename Point /* = DefaultPoint_t */>
645  (geo::WireGeo const& other) const
646 {
647  auto const& [ point, ofsA, ofsB ] = WiresIntersectionAndOffsets(*this, other);
648  return { geo::vect::convertTo<Point>(point), ofsA, ofsB };
649 } // geo::WireGeo::IntersectionAndOffsetsWith()
650 
651 
652 //------------------------------------------------------------------------------
654  (geo::WireGeo const& wireA, geo::WireGeo const& wireB)
655 {
656 
658  wireA.GetCenter<geo::Point_t>(), wireA.Direction<geo::Vector_t>(),
659  wireB.GetCenter<geo::Point_t>(), wireB.Direction<geo::Vector_t>()
660  );
661 
662 } // geo::WiresIntersection()
663 
664 
665 //------------------------------------------------------------------------------
668  (geo::WireGeo const& wireA, geo::WireGeo const& wireB)
669 {
670 
672  wireA.GetCenter<geo::Point_t>(), wireA.Direction<geo::Vector_t>(),
673  wireB.GetCenter<geo::Point_t>(), wireB.Direction<geo::Vector_t>()
674  );
675 
676 } // geo::WiresIntersectionAndOffsets()
677 
678 
679 //------------------------------------------------------------------------------
680 
681 #endif // LARCOREALG_GEOMETRY_WIREGEO_H
bool isVertical() const
Returns if this wire is vertical (theta_z ~ pi/2)
Definition: WireGeo.h:276
void Flip()
Set to swap the start and end wire.
Definition: WireGeo.cxx:144
void GetStart(double *xyz) const
Definition: WireGeo.h:157
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
Utilities to extend the interface of geometry vectors.
void PrintWireInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this wire.
Definition: WireGeo.h:596
TVector3 DefaultPoint_t
Definition: WireGeo.h:68
Point GetCenter() const
Definition: WireGeo.h:212
double fThetaZ
angle of the wire with respect to the z direction
Definition: WireGeo.h:484
geo::Point_t fCenter
Center of the wire in world coordinates.
Definition: WireGeo.h:486
std::string string
Definition: nybbler.cc:12
Point GetEnd() const
Definition: WireGeo.h:229
double DistanceFrom(geo::WireGeo const &wire) const
Returns 3D distance from the specified wire.
Definition: WireGeo.cxx:113
double Length() const
Returns the wire length in centimeters.
Definition: WireGeo.h:236
const TGeoNode * Node() const
Definition: WireGeo.h:390
double SinThetaZ() const
Definition: WireGeo.h:265
LocalPoint_t toLocalCoords(GlobalPoint_t const &world) const
Transforms a point from world frame to local frame.
DefaultPoint_t GetEnd() const
Definition: WireGeo.h:231
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
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.
static double WirePitch(geo::WireGeo const &w1, geo::WireGeo const &w2)
Returns the pitch (distance on y/z plane) between two wires, in cm.
Definition: WireGeo.h:476
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local wire frame to world frame.
Definition: WireGeo.h:359
double ThetaZ() const
Returns angle of wire with respect to z axis in the Y-Z plane in radians.
Definition: WireGeo.h:250
DefaultVector_t Direction() const
Definition: WireGeo.h:293
double fHalfL
half length of the wire
Definition: WireGeo.h:485
geo::Point_t WiresIntersection(geo::WireGeo const &wireA, geo::WireGeo const &wireB)
Returns the point of wireA that is closest to wireB.
Definition: WireGeo.h:654
std::string WireInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with all the information of the wire.
Definition: WireGeo.cxx:104
DefaultPoint_t GetCenter() const
Definition: WireGeo.h:213
void LocalToWorldVect(const double *wire, double *world) const
Transform direction vector from local to world.
Definition: WireGeo.h:363
IntersectionPointAndOffsets< Point > LineClosestPointAndOffsetsWithUnitVectors(Point const &startA, UnitVector const &dirA, Point const &startB, UnitVector const &dirB)
Returns the point of a line that is closest to a second line.
Point GetPositionFromCenter(double localz) const
Returns the position (world coordinate) of a point on the wire.
Definition: WireGeo.h:182
void UpdateAfterSorting(geo::WireID const &, bool flip)
Definition: WireGeo.cxx:136
T abs(T value)
void LocalToWorld(const double *wire, double *world) const
Transform point from local wire frame to world frame.
Definition: WireGeo.h:355
Point IntersectionWith(geo::WireGeo const &other) const
Returns the point of this wire that is closest to other wire.
Definition: WireGeo.h:637
const double e
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
bool isHorizontal() const
Returns if this wire is horizontal (theta_z ~ 0)
Definition: WireGeo.h:271
Local-to-world transformations with LArSoft geometry vectors.
geo::Vector3DBase_t< WireGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML wire plane frame.
Definition: WireGeo.h:97
double RMax() const
Returns the outer half-size of the wire [cm].
Definition: WireGeo.cxx:91
static double gausSum(double a, double b)
Definition: WireGeo.h:509
const double a
Utility for intersection of two 3D lines.
DefaultPoint_t GetStart() const
Definition: WireGeo.h:222
double capRelLength(double local) const
Stacked capLength() and relLength().
Definition: WireGeo.h:502
Point LineClosestPointWithUnitVectors(Point const &startA, UnitVector const &dirA, Point const &startB, UnitVector const &dirB)
Returns the point of a line that is closest to a second line.
static int max(int a, int b)
bool isFlipped() const
Definition: WireGeo.h:492
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
Definition: WireGeo.h:383
Vector Direction() const
Definition: WireGeo.h:587
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local wire frame.
Definition: WireGeo.h:375
void WorldToLocalVect(const double *world, double *wire) const
Transform direction vector from world to local.
Definition: WireGeo.h:379
double HalfL() const
Returns half the length of the wire [cm].
Definition: WireGeo.h:128
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
double TanThetaZ() const
Definition: WireGeo.h:266
void WorldToLocal(double const *world, double *local) const
Transforms a point from world frame to local frame.
Selection of the type of transformation matrix used in geometry.
Point GetPositionFromCenterUnbounded(double localz) const
Returns the position (world coordinate) of a point on the wire.
Definition: WireGeo.h:579
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
double relLength(double local) const
Returns the relative length from center to be used when transforming.
Definition: WireGeo.h:495
std::vector< TGeoNode const * > GeoNodePath_t
Definition: WireGeo.h:72
geo::IntersectionPointAndOffsets< Point > IntersectionAndOffsetsWith(geo::WireGeo const &other) const
Returns the point of this wire that is closest to other wire.
Definition: WireGeo.h:645
void GetEnd(double *xyz) const
Definition: WireGeo.h:163
LocalTransformation_t fTrans
Wire to world transform.
Definition: WireGeo.h:487
DefaultPoint_t GetPositionFromCenter(double localz) const
Definition: WireGeo.h:184
double capLength(double local) const
Caps the specified local length coordinate to lay on the wire.
Definition: WireGeo.h:498
Point GetStart() const
Definition: WireGeo.h:220
WireGeo(TGeoNode const &node, geo::TransformationMatrix &&trans)
Constructor from a ROOT geometry node and a transformation.
Definition: WireGeo.cxx:32
static bool * b
Definition: config.cpp:1043
geo::Point3DBase_t< WireGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML wire plane frame.
Definition: WireGeo.h:94
Data structure for return values of LineClosestPointAndOffsets().
Tag for vectors in the "local" GDML coordinate frame of the plane.
Definition: WireGeo.h:91
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Definition: WireGeo.h:367
static constexpr unsigned int MaxVerbosity
Maximum verbosity supported by PrintWireInfo().
Definition: WireGeo.h:338
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
Definition: geo_vectors.h:92
TVector3 DefaultVector_t
Definition: WireGeo.h:67
GenVector3DBase_t< double, C > Vector3DBase_t
Definition: geo_vectors.h:87
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 CosThetaZ() const
Returns trigonometric operations on ThetaZ()
Definition: WireGeo.h:264
double ComputeZatY0() const
Definition: WireGeo.h:399
LArSoft geometry interface.
Definition: ChannelGeo.h:16
void WorldToLocalVect(const double *world, double *local) const
Transforms a vector from world frame to local frame.
DefaultPoint_t GetPositionFromCenterUnbounded(double localz) const
Definition: WireGeo.h:204
bool isParallelTo(geo::WireGeo const &wire) const
Returns if this wire is parallel to another.
Definition: WireGeo.h:281
double RMin() const
Returns the inner radius of the wire (usually 0) [cm].
Definition: WireGeo.cxx:95
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
const TGeoNode * fWireNode
Pointer to the wire node.
Definition: WireGeo.h:483
bool flipped
whether start and end are reversed
Definition: WireGeo.h:488
geo::IntersectionPointAndOffsets< geo::Point_t > WiresIntersectionAndOffsets(geo::WireGeo const &wireA, geo::WireGeo const &wireB)
Returns the point of wireA that is closest to wireB.
Definition: WireGeo.h:668
void WorldToLocal(const double *world, double *wire) const
Transform point from world frame to local wire frame.
Definition: WireGeo.h:371