Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-13 07:50:20

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