Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-08 08:03:19

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/Geometry/GeometryContext.hpp"
0015 #include "Acts/Geometry/Polyhedron.hpp"
0016 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0017 #include "Acts/Surfaces/ConeBounds.hpp"
0018 #include "Acts/Surfaces/RegularSurface.hpp"
0019 #include "Acts/Surfaces/Surface.hpp"
0020 #include "Acts/Surfaces/SurfaceConcept.hpp"
0021 #include "Acts/Utilities/AxisDefinitions.hpp"
0022 #include "Acts/Utilities/Result.hpp"
0023 #include "Acts/Utilities/detail/RealQuadraticEquation.hpp"
0024 
0025 #include <memory>
0026 #include <numbers>
0027 #include <string>
0028 
0029 namespace Acts {
0030 
0031 /// @class ConeSurface
0032 ///
0033 /// Class for a conical surface in the Tracking geometry.
0034 /// It inherits from Surface.
0035 ///
0036 /// The ConeSurface is special since no corresponding
0037 /// Track parameters exist since they're numerical instable
0038 /// at the tip of the cone.
0039 /// Propagations to a cone surface will be returned in
0040 /// curvilinear coordinates.
0041 ///
0042 class ConeSurface : public RegularSurface {
0043   friend class Surface;
0044 
0045  protected:
0046   /// Constructor form HepTransform and an opening angle
0047   ///
0048   /// @param transform is the transform to place to cone in a 3D frame
0049   /// @param alpha is the opening angle of the cone
0050   /// @param symmetric indicates if the cones are built to +/1 z
0051   ConeSurface(const Transform3& transform, double alpha,
0052               bool symmetric = false);
0053 
0054   /// Constructor form HepTransform and an opening angle
0055   ///
0056   /// @param transform is the transform that places the cone in the global frame
0057   /// @param alpha is the opening angle of the cone
0058   /// @param zmin is the z range over which the cone spans
0059   /// @param zmax is the z range over which the cone spans
0060   /// @param halfPhi is the opening angle for cone ssectors
0061   ConeSurface(const Transform3& transform, double alpha, double zmin,
0062               double zmax, double halfPhi = std::numbers::pi);
0063 
0064   /// Constructor from HepTransform and ConeBounds
0065   ///
0066   /// @param transform is the transform that places the cone in the global frame
0067   /// @param cbounds is the boundary class, the bounds must exit
0068   ConeSurface(const Transform3& transform,
0069               std::shared_ptr<const ConeBounds> cbounds);
0070 
0071   /// Copy constructor
0072   ///
0073   /// @param other is the source cone surface
0074   ConeSurface(const ConeSurface& other);
0075 
0076   /// Copy constructor - with shift
0077   ///
0078   /// @param gctx The current geometry context object, e.g. alignment
0079   /// @param other is the source cone surface
0080   /// @param shift is the additional transform applied after copying
0081   ConeSurface(const GeometryContext& gctx, const ConeSurface& other,
0082               const Transform3& shift);
0083 
0084  public:
0085   /// Assignment operator
0086   ///
0087   /// @param other is the source surface for the assignment
0088   /// @return Reference to this ConeSurface after assignment
0089   ConeSurface& operator=(const ConeSurface& other);
0090 
0091   /// The binning position method - is overloaded for r-type binning
0092   ///
0093   /// @param gctx The current geometry context object, e.g. alignment
0094   /// @param aDir defines the direction of binning applied in the global frame
0095   ///
0096   /// @return The return type is a vector for positioning in the global frame
0097   Vector3 referencePosition(const GeometryContext& gctx,
0098                             AxisDirection aDir) const final;
0099 
0100   /// Return the surface type
0101   /// @return Surface type identifier
0102   SurfaceType type() const override;
0103 
0104   /// Return the measurement frame - this is needed for alignment, in particular
0105   ///  for StraightLine and Perigee Surface
0106   ///  - the default implementation is the RotationMatrix3 of the transform
0107   ///
0108   /// @param gctx The current geometry context object, e.g. alignment
0109   /// @param position is the global position where the measurement frame is
0110   /// constructed
0111   /// @param direction is the momentum direction used for the measurement frame
0112   /// construction
0113   /// @return matrix that indicates the measurement frame
0114   RotationMatrix3 referenceFrame(const GeometryContext& gctx,
0115                                  const Vector3& position,
0116                                  const Vector3& direction) const final;
0117 
0118   /// Return method for surface normal information
0119   ///
0120   /// @param gctx The current geometry context object, e.g. alignment
0121   /// @param lposition is the local position at normal vector request
0122   /// @return Vector3 normal vector in global frame
0123   Vector3 normal(const GeometryContext& gctx,
0124                  const Vector2& lposition) const final;
0125 
0126   /// Return method for surface normal information
0127   ///
0128   /// @param gctx The current geometry context object, e.g. alignment
0129   /// @param position is the global position as normal vector base
0130   /// @return Vector3 normal vector in global frame
0131   Vector3 normal(const GeometryContext& gctx,
0132                  const Vector3& position) const final;
0133 
0134   // Return method for the rotational symmetry axis
0135   ///
0136   /// @param gctx The current geometry context object, e.g. alignment
0137   ///
0138   /// @return The local z axis vector
0139   virtual Vector3 rotSymmetryAxis(const GeometryContext& gctx) const;
0140 
0141   /// This method returns the ConeBounds by reference
0142   /// @return Reference to the cone bounds
0143   const ConeBounds& bounds() const final;
0144   /// This method returns the shared_ptr to the ConeBounds
0145   /// @return Shared pointer to the cone bounds
0146   const std::shared_ptr<const ConeBounds>& boundsPtr() const;
0147   /// Overwrite the existing surface bounds with new ones
0148   /// @param newBounds: Pointer to the new bounds
0149   void assignSurfaceBounds(std::shared_ptr<const ConeBounds> newBounds);
0150 
0151   /// Local to global transformation
0152   ///
0153   /// @param gctx The current geometry context object, e.g. alignment
0154   /// @param lposition is the local position to be transformed
0155   ///
0156   /// @return The global position by value
0157   Vector3 localToGlobal(const GeometryContext& gctx,
0158                         const Vector2& lposition) const final;
0159 
0160   // Use overloads from `RegularSurface`
0161   using RegularSurface::globalToLocal;
0162   using RegularSurface::localToGlobal;
0163   using RegularSurface::normal;
0164 
0165   /// Global to local transformation
0166   ///
0167   /// @param gctx The current geometry context object, e.g. alignment
0168   /// @param position is the global position to be transformed
0169   /// @param tolerance optional tolerance within which a point is considered
0170   /// valid on surface
0171   ///
0172   /// @return a Result<Vector2> which can be !ok() if the operation fails
0173   Result<Vector2> globalToLocal(
0174       const GeometryContext& gctx, const Vector3& position,
0175       double tolerance = s_onSurfaceTolerance) const final;
0176 
0177   /// Straight line intersection schema from position/direction
0178   ///
0179   /// @param gctx The current geometry context object, e.g. alignment
0180   /// @param position The position to start from
0181   /// @param direction The direction at start
0182   /// @param boundaryTolerance the Boundary Check
0183   /// @param tolerance the tolerance used for the intersection
0184   ///
0185   /// If possible returns both solutions for the cylinder
0186   ///
0187   /// @return @c MultiIntersection3D object (contains intersection & surface)
0188   MultiIntersection3D intersect(
0189       const GeometryContext& gctx, const Vector3& position,
0190       const Vector3& direction,
0191       const BoundaryTolerance& boundaryTolerance =
0192           BoundaryTolerance::Infinite(),
0193       double tolerance = s_onSurfaceTolerance) const final;
0194 
0195   /// The pathCorrection for derived classes with thickness
0196   ///
0197   /// @param gctx The current geometry context object, e.g. alignment
0198   /// @param position is the global potion at the correction point
0199   /// @param direction is the momentum direction at the correction point
0200   /// @return is the path correction due to incident angle
0201   double pathCorrection(const GeometryContext& gctx, const Vector3& position,
0202                         const Vector3& direction) const final;
0203 
0204   /// Return a Polyhedron for the surfaces
0205   ///
0206   /// @param gctx The current geometry context object, e.g. alignment
0207   /// @param quarterSegments Number of segments used to approximate a quarter
0208   ///
0209   /// @note The phi extrema points at (-pi, -1/2 pi, 0, 1/2 pi) that fall within
0210   /// the surface will be inserted to guarantee an appropriate extent
0211   /// measurement in x and y
0212   ///
0213   /// @return A list of vertices and a face/facett description of it
0214   Polyhedron polyhedronRepresentation(
0215       const GeometryContext& gctx,
0216       unsigned int quarterSegments = 2u) const override;
0217 
0218   /// Return properly formatted class name for screen output
0219   /// @return String representation of the class name
0220   std::string name() const override;
0221 
0222   /// Calculate the derivative of path length at the geometry constraint or
0223   /// point-of-closest-approach w.r.t. alignment parameters of the surface (i.e.
0224   /// local frame origin in global 3D Cartesian coordinates and its rotation
0225   /// represented with extrinsic Euler angles)
0226   ///
0227   /// @param gctx The current geometry context object, e.g. alignment
0228   /// @param position global 3D position
0229   /// @param direction global 3D momentum direction
0230   ///
0231   /// @return Derivative of path length w.r.t. the alignment parameters
0232   AlignmentToPathMatrix alignmentToPathDerivative(
0233       const GeometryContext& gctx, const Vector3& position,
0234       const Vector3& direction) const final;
0235 
0236   /// Calculate the derivative of bound track parameters local position w.r.t.
0237   /// position in local 3D Cartesian coordinates
0238   ///
0239   /// @param gctx The current geometry context object, e.g. alignment
0240   /// @param position The position of the parameters in global
0241   ///
0242   /// @return Derivative of bound local position w.r.t. position in local 3D
0243   /// cartesian coordinates
0244   Matrix<2, 3> localCartesianToBoundLocalDerivative(
0245       const GeometryContext& gctx, const Vector3& position) const final;
0246 
0247  protected:
0248   std::shared_ptr<const ConeBounds> m_bounds;  ///< bounds (shared)
0249 
0250  private:
0251   /// Implementation of the intersection solver
0252   ///
0253   /// <b>mathematical motivation:</b>
0254   ///
0255   ///   The calculation will be done in the 3-dim frame of the cone,
0256   ///   i.e. the symmetry axis of the cone is the z-axis, x- and y-axis are
0257   /// perpendicular
0258   ///   to the z-axis. In this frame the cone is centered around the origin.
0259   ///   Therefore the two points describing the line have to be first
0260   ///   recalculated
0261   /// into the new frame.
0262   ///   Suppose, this is done, the points of intersection can be
0263   ///   obtained as follows:<br>
0264   ///
0265   ///   The cone is described by the implicit equation
0266   ///   @f$x^2 + y^2 = z^2 \tan \alpha@f$
0267   ///   where @f$\alpha@f$ is opening half-angle of the cone  the and
0268   ///   the line by the parameter equation (with @f$t@f$ the
0269   ///   parameter and @f$x_1@f$ and @f$x_2@f$ are points on the line)
0270   ///   @f$(x,y,z) = \vec x_1 + (\vec x_2 - \vec x_2) t @f$.
0271   ///   The intersection is the given to the value of @f$t@f$ where
0272   ///   the @f$(x,y,z)@f$ coordinates of the line satisfy the implicit
0273   ///   equation of the cone. Inserting the expression for the points
0274   ///   on the line into the equation of the cone and rearranging to
0275   ///   the form of a  gives (letting @f$ \vec x_d = \frac{\vec x_2 - \vec
0276   ///   x_1}{|\vec x_2 - \vec x_1|} @f$):
0277   ///   @f$t^2 (x_d^2 + y_d^2 - z_d^2 \tan^2 \alpha) + 2 t (x_1 x_d +
0278   ///   y_1 y_d - z_1 z_d \tan^2 \alpha) + (x_1^2 + y_1^2 - z_1^2
0279   ///   \tan^2 \alpha) = 0 @f$
0280   ///   Solving the above for @f$t@f$ and putting the values into the
0281   ///   equation of the line gives the points of intersection. @f$t@f$
0282   ///   is also the length of the path, since we normalized @f$x_d@f$
0283   ///   to be unit length.
0284   ///
0285   /// @return the quadratic equation
0286   detail::RealQuadraticEquation intersectionSolver(
0287       const GeometryContext& gctx, const Vector3& position,
0288       const Vector3& direction) const;
0289 };
0290 
0291 static_assert(RegularSurfaceConcept<ConeSurface>,
0292               "ConeSurface does not fulfill RegularSurfaceConcept");
0293 
0294 }  // namespace Acts