Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:34

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 #include "Acts/Definitions/Algebra.hpp"
0011 #include "Acts/Definitions/Alignment.hpp"
0012 #include "Acts/Definitions/Tolerance.hpp"
0013 #include "Acts/Definitions/TrackParametrization.hpp"
0014 #include "Acts/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/Polyhedron.hpp"
0016 #include "Acts/Surfaces/BoundaryCheck.hpp"
0017 #include "Acts/Surfaces/InfiniteBounds.hpp"
0018 #include "Acts/Surfaces/LineBounds.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Utilities/BinningType.hpp"
0021 #include "Acts/Utilities/Result.hpp"
0022 
0023 #include <memory>
0024 #include <string>
0025 
0026 namespace Acts {
0027 
0028 class LineBounds;
0029 class DetectorElementBase;
0030 class SurfaceBounds;
0031 
0032 ///  @class LineSurface
0033 ///
0034 ///  Base class for a linear surfaces in the TrackingGeometry
0035 ///  to describe dirft tube, straw like detectors or the Perigee
0036 ///  It inherits from Surface.
0037 ///
0038 ///  @note It leaves the type() method virtual, so it can not be instantiated
0039 ///
0040 /// @image html LineSurface.png
0041 class LineSurface : public Surface {
0042   friend class Surface;
0043 
0044  protected:
0045   /// Constructor from Transform3 and bounds
0046   ///
0047   /// @param transform The transform that positions the surface in the global
0048   /// frame
0049   /// @param radius The straw radius
0050   /// @param halez The half length in z
0051   LineSurface(const Transform3& transform, double radius, double halez);
0052 
0053   /// Constructor from Transform3 and a shared bounds object
0054   ///
0055   /// @param transform The transform that positions the surface in the global
0056   /// frame
0057   /// @param lbounds The bounds describing the straw dimensions, can be
0058   /// optionally nullptr
0059   LineSurface(const Transform3& transform,
0060               std::shared_ptr<const LineBounds> lbounds = nullptr);
0061 
0062   /// Constructor from DetectorElementBase : Element proxy
0063   ///
0064   /// @param lbounds The bounds describing the straw dimensions
0065   /// @param detelement for which this surface is (at least) one representation
0066   LineSurface(std::shared_ptr<const LineBounds> lbounds,
0067               const DetectorElementBase& detelement);
0068 
0069   /// Copy constructor
0070   ///
0071   /// @param other The source surface for copying
0072   LineSurface(const LineSurface& other);
0073 
0074   /// Copy constructor - with shift
0075   ///
0076   /// @param gctx The current geometry context object, e.g. alignment
0077   /// @param other is the source cone surface
0078   /// @param shift is the additional transform applied after copying
0079   LineSurface(const GeometryContext& gctx, const LineSurface& other,
0080               const Transform3& shift);
0081 
0082  public:
0083   ~LineSurface() override = default;
0084   LineSurface() = delete;
0085 
0086   /// Assignment operator
0087   ///
0088   /// @param other is the source surface dor copying
0089   LineSurface& operator=(const LineSurface& other);
0090 
0091   Vector3 normal(const GeometryContext& gctx, const Vector3& pos,
0092                  const Vector3& direction) const override;
0093 
0094   /// The binning position is the position calculated
0095   /// for a certain binning type
0096   ///
0097   /// @param gctx The current geometry context object, e.g. alignment
0098   /// @param bValue is the binning type to be used
0099   ///
0100   /// @return position that can beused for this binning
0101   Vector3 binningPosition(const GeometryContext& gctx,
0102                           BinningValue bValue) const final;
0103 
0104   /// Return the measurement frame - this is needed for alignment, in particular
0105   ///
0106   /// for StraightLine and Perigee Surface
0107   ///  - the default implementation is the RotationMatrix3 of the transform
0108   ///
0109   /// @param gctx The current geometry context object, e.g. alignment
0110   /// @param position is the global position where the measurement frame is
0111   /// constructed
0112   /// @param direction is the momentum direction used for the measurement frame
0113   /// construction
0114   ///
0115   /// @return is a rotation matrix that indicates the measurement frame
0116   RotationMatrix3 referenceFrame(const GeometryContext& gctx,
0117                                  const Vector3& position,
0118                                  const Vector3& direction) const final;
0119 
0120   /// Calculate the jacobian from local to global which the surface knows best,
0121   /// hence the calculation is done here.
0122   ///
0123   /// @param gctx The current geometry context object, e.g. alignment
0124   /// @param position global 3D position
0125   /// @param direction global 3D momentum direction
0126   ///
0127   /// @return Jacobian from local to global
0128   BoundToFreeMatrix boundToFreeJacobian(const GeometryContext& gctx,
0129                                         const Vector3& position,
0130                                         const Vector3& direction) const final;
0131 
0132   /// Calculate the derivative of path length at the geometry constraint or
0133   /// point-of-closest-approach w.r.t. free parameters
0134   ///
0135   /// @param gctx The current geometry context object, e.g. alignment
0136   /// @param position global 3D position
0137   /// @param direction global 3D momentum direction
0138   ///
0139   /// @return Derivative of path length w.r.t. free parameters
0140   FreeToPathMatrix freeToPathDerivative(const GeometryContext& gctx,
0141                                         const Vector3& position,
0142                                         const Vector3& direction) const final;
0143 
0144   /// Local to global transformation
0145   ///
0146   /// @note for line surfaces the momentum direction is used in order to interpret the
0147   /// drift radius
0148   ///
0149   /// @param gctx The current geometry context object, e.g. alignment
0150   /// @param lposition is the local position to be transformed
0151   /// @param direction is the global momentum direction (used to sign the closest approach)
0152   ///
0153   /// @return global position by value
0154   Vector3 localToGlobal(const GeometryContext& gctx, const Vector2& lposition,
0155                         const Vector3& direction) const final;
0156 
0157   /// Specified for `LineSurface`: global to local method without dynamic
0158   /// memory allocation.
0159   ///
0160   /// This method is the true global -> local transformation. It makes use of
0161   /// @c globalToLocal and indicates the sign of the @c Acts::eBoundLoc0
0162   /// by the given momentum direction.
0163   ///
0164   /// The calculation of the sign of the radius (or @f$ d_0 @f$) can be done as
0165   /// follows:
0166   /// May @f$ \vec d = \vec m - \vec c @f$ denote the difference between the
0167   /// center of the line and the global position of the measurement/predicted
0168   /// state. Then, @f$ \vec d @f$ lies in the so-called measurement plane.
0169   /// The latter is determined by the two orthogonal vectors @f$
0170   /// \vec{\texttt{measY}} = \vec{e}_z @f$ and @f$
0171   /// \vec{\texttt{measX}} = \vec{\texttt{measY}} \times
0172   /// \frac{\vec{p}}{|\vec{p}|} @f$.
0173   ///
0174   /// The sign of the radius (or @f$ d_{0} @f$ ) is then defined by the projection
0175   /// of @f$ \vec{d} @f$ on @f$ \vec{measX} @f$:<br> @f$ sign = -sign(\vec{d}
0176   /// \cdot \vec{measX}) @f$
0177   ///
0178   /// @image html SignOfDriftCircleD0.gif
0179   ///
0180   /// @param gctx The current geometry context object, e.g. alignment
0181   /// @param position global 3D position - considered to be on surface but not
0182   /// inside bounds (check is done)
0183   /// @param direction global 3D momentum direction (optionally ignored)
0184   /// @param tolerance (unused)
0185   ///
0186   /// @return A `Result<Vector2>`, which is set to `!ok()` if the @p position is not
0187   /// the point of closest approach to the line surface.
0188   Result<Vector2> globalToLocal(
0189       const GeometryContext& gctx, const Vector3& position,
0190       const Vector3& direction,
0191       double tolerance = s_onSurfaceTolerance) const final;
0192 
0193   /// Calculate the straight-line intersection with the line surface.
0194   ///
0195   /// <b>Mathematical motivation:</b>
0196   ///
0197   /// Given two lines in parameteric form:<br>
0198   ///
0199   /// @f$ \vec l_{a}(u) = \vec m_a + u \cdot \vec e_{a} @f$
0200   ///
0201   /// @f$ \vec l_{b}(\mu) = \vec m_b + \mu \cdot \vec e_{b} @f$
0202   ///
0203   /// The vector between any two points on the two lines is given by:
0204   ///
0205   /// @f$ \vec s(u, \mu) = \vec l_{b} - l_{a} = \vec m_{ab} + \mu
0206   /// \cdot
0207   /// \vec e_{b} - u \cdot \vec e_{a} @f$,
0208   ///
0209   /// where @f$ \vec m_{ab} = \vec m_{b} - \vec m_{a} @f$.
0210   ///
0211   /// @f$ \vec s(u_0, \mu_0) @f$ denotes the vector between the two
0212   /// closest points
0213   ///
0214   /// @f$ \vec l_{a,0} = l_{a}(u_0) @f$ and @f$ \vec l_{b,0} =
0215   /// l_{b}(\mu_0) @f$
0216   ///
0217   /// and is perpendicular to both, @f$ \vec e_{a} @f$ and @f$ \vec e_{b} @f$.
0218   ///
0219   /// This results in a system of two linear equations:
0220   ///
0221   /// - (i) @f$ 0 = \vec s(u_0, \mu_0) \cdot \vec e_a = \vec m_{ab} \cdot
0222   /// \vec e_a + \mu_0 \vec e_a \cdot \vec e_b - u_0 @f$ <br>
0223   /// - (ii) @f$ 0 = \vec s(u_0, \mu_0) \cdot \vec e_b = \vec m_{ab} \cdot
0224   /// \vec e_b + \mu_0  - u_0 \vec e_b \cdot \vec e_a @f$ <br>
0225   ///
0226   /// Solving (i) and (ii) for @f$ u @f$ and @f$ \mu_0 @f$ yields:
0227   ///
0228   /// - @f$ u_0 = \frac{(\vec m_{ab} \cdot \vec e_a)-(\vec m_{ab} \cdot \vec
0229   /// e_b)(\vec e_a \cdot \vec e_b)}{1-(\vec e_a \cdot \vec e_b)^2} @f$ <br>
0230   /// - @f$ \mu_0 = - \frac{(\vec m_{ab} \cdot \vec e_b)-(\vec m_{ab} \cdot \vec
0231   /// e_a)(\vec e_a \cdot \vec e_b)}{1-(\vec e_a \cdot \vec e_b)^2} @f$ <br>
0232   ///
0233   /// The function checks if @f$ u_0 \simeq 0@f$ to check if the current @p
0234   /// position is at the point of closest approach, i.e. the intersection
0235   /// point, in which case it will return an @c onSurace intersection result.
0236   /// Otherwise, the path length from @p position to the point of closest
0237   /// approach (@f$ u_0 @f$) is returned in a @c reachable intersection.
0238   ///
0239   /// @param gctx The current geometry context object, e.g. alignment
0240   /// @param position The global position as a starting point
0241   /// @param direction The global direction at the starting point
0242   ///        @note expected to be normalized
0243   /// @param bcheck The boundary check directive for the estimate
0244   /// @param tolerance the tolerance used for the intersection
0245   /// @return is the intersection object
0246   SurfaceMultiIntersection intersect(
0247       const GeometryContext& gctx, const Vector3& position,
0248       const Vector3& direction,
0249       const BoundaryCheck& bcheck = BoundaryCheck(false),
0250       ActsScalar tolerance = s_onSurfaceTolerance) const final;
0251 
0252   /// the pathCorrection for derived classes with thickness
0253   /// is by definition 1 for LineSurfaces
0254   ///
0255   /// @note input parameters are ignored
0256   /// @note there's no material associated to the line surface
0257   double pathCorrection(const GeometryContext& gctx, const Vector3& position,
0258                         const Vector3& direction) const override;
0259 
0260   /// This method returns the bounds of the surface by reference
0261   const SurfaceBounds& bounds() const final;
0262 
0263   /// Return properly formatted class name for screen output
0264   std::string name() const override;
0265 
0266   /// Calculate the derivative of path length at the geometry constraint or
0267   /// point-of-closest-approach w.r.t. alignment parameters of the surface (i.e.
0268   /// local frame origin in global 3D Cartesian coordinates and its rotation
0269   /// represented with extrinsic Euler angles)
0270   ///
0271   /// @param gctx The current geometry context object, e.g. alignment
0272   /// @param position global 3D position
0273   /// @param direction global 3D momentum direction
0274   ///
0275   /// @return Derivative of path length w.r.t. the alignment parameters
0276   AlignmentToPathMatrix alignmentToPathDerivative(
0277       const GeometryContext& gctx, const Vector3& position,
0278       const Vector3& direction) const final;
0279 
0280   /// Calculate the derivative of bound track parameters local position w.r.t.
0281   /// position in local 3D Cartesian coordinates
0282   ///
0283   /// @param gctx The current geometry context object, e.g. alignment
0284   /// @param position The position of the parameters in global
0285   ///
0286   /// @return Derivative of bound local position w.r.t. position in local 3D
0287   /// cartesian coordinates
0288   ActsMatrix<2, 3> localCartesianToBoundLocalDerivative(
0289       const GeometryContext& gctx, const Vector3& position) const final;
0290 
0291   Vector3 lineDirection(const GeometryContext& gctx) const;
0292 
0293  protected:
0294   std::shared_ptr<const LineBounds> m_bounds;  ///< bounds (shared)
0295 
0296  private:
0297   /// helper function to apply the globalToLocal with out transform
0298   ///
0299   /// @param gctx The current geometry context object, e.g. alignment
0300   /// @param position is the global position
0301   /// @param direction is the momentum direction
0302   /// @param lposition is the local position to be filled
0303   bool globalToLocalPlain(const GeometryContext& gctx, const Vector3& position,
0304                           const Vector3& direction, Vector2& lposition) const;
0305 };
0306 
0307 }  // namespace Acts