Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:03

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   ConeSurface& operator=(const ConeSurface& other);
0089 
0090   /// The binning position method - is overloaded for r-type binning
0091   ///
0092   /// @param gctx The current geometry context object, e.g. alignment
0093   /// @param aDir defines the direction of binning applied in the global frame
0094   ///
0095   /// @return The return type is a vector for positioning in the global frame
0096   Vector3 referencePosition(const GeometryContext& gctx,
0097                             AxisDirection aDir) const final;
0098 
0099   /// Return the surface type
0100   SurfaceType type() const override;
0101 
0102   /// Return the measurement frame - this is needed for alignment, in particular
0103   ///  for StraightLine and Perigee Surface
0104   ///  - the default implementation is the RotationMatrix3 of the transform
0105   ///
0106   /// @param gctx The current geometry context object, e.g. alignment
0107   /// @param position is the global position where the measurement frame is
0108   /// constructed
0109   /// @param direction is the momentum direction used for the measurement frame
0110   /// construction
0111   /// @return matrix that indicates the measurement frame
0112   RotationMatrix3 referenceFrame(const GeometryContext& gctx,
0113                                  const Vector3& position,
0114                                  const Vector3& direction) const final;
0115 
0116   /// Return method for surface normal information
0117   ///
0118   /// @param gctx The current geometry context object, e.g. alignment
0119   /// @param lposition is the local position at normal vector request
0120   /// @return Vector3 normal vector in global frame
0121   Vector3 normal(const GeometryContext& gctx,
0122                  const Vector2& lposition) const final;
0123 
0124   /// Return method for surface normal information
0125   ///
0126   /// @param gctx The current geometry context object, e.g. alignment
0127   /// @param position is the global position as normal vector base
0128   /// @return Vector3 normal vector in global frame
0129   Vector3 normal(const GeometryContext& gctx,
0130                  const Vector3& position) const final;
0131 
0132   // Return method for the rotational symmetry axis
0133   ///
0134   /// @param gctx The current geometry context object, e.g. alignment
0135   ///
0136   // @return This returns the local z axis
0137   virtual Vector3 rotSymmetryAxis(const GeometryContext& gctx) const;
0138 
0139   /// This method returns the ConeBounds by reference
0140   const ConeBounds& bounds() const final;
0141 
0142   /// Local to global transformation
0143   ///
0144   /// @param gctx The current geometry context object, e.g. alignment
0145   /// @param lposition is the local position to be transformed
0146   ///
0147   /// @return The global position by value
0148   Vector3 localToGlobal(const GeometryContext& gctx,
0149                         const Vector2& lposition) const final;
0150 
0151   // Use overloads from `RegularSurface`
0152   using RegularSurface::globalToLocal;
0153   using RegularSurface::localToGlobal;
0154   using RegularSurface::normal;
0155 
0156   /// Global to local transformation
0157   ///
0158   /// @param gctx The current geometry context object, e.g. alignment
0159   /// @param position is the global position to be transformed
0160   /// @param tolerance optional tolerance within which a point is considered
0161   /// valid on surface
0162   ///
0163   /// @return a Result<Vector2> which can be !ok() if the operation fails
0164   Result<Vector2> globalToLocal(
0165       const GeometryContext& gctx, const Vector3& position,
0166       double tolerance = s_onSurfaceTolerance) const final;
0167 
0168   /// Straight line intersection schema from position/direction
0169   ///
0170   /// @param gctx The current geometry context object, e.g. alignment
0171   /// @param position The position to start from
0172   /// @param direction The direction at start
0173   /// @param boundaryTolerance the Boundary Check
0174   /// @param tolerance the tolerance used for the intersection
0175   ///
0176   /// If possible returns both solutions for the cylinder
0177   ///
0178   /// @return @c SurfaceMultiIntersection object (contains intersection & surface)
0179   SurfaceMultiIntersection intersect(
0180       const GeometryContext& gctx, const Vector3& position,
0181       const Vector3& direction,
0182       const BoundaryTolerance& boundaryTolerance =
0183           BoundaryTolerance::Infinite(),
0184       double tolerance = s_onSurfaceTolerance) const final;
0185 
0186   /// The pathCorrection for derived classes with thickness
0187   ///
0188   /// @param gctx The current geometry context object, e.g. alignment
0189   /// @param position is the global potion at the correction point
0190   /// @param direction is the momentum direction at the correction point
0191   /// @return is the path correction due to incident angle
0192   double pathCorrection(const GeometryContext& gctx, const Vector3& position,
0193                         const Vector3& direction) const final;
0194 
0195   /// Return a Polyhedron for the surfaces
0196   ///
0197   /// @param gctx The current geometry context object, e.g. alignment
0198   /// @param quarterSegments Number of segments used to approximate a quarter
0199   ///
0200   /// @note The phi extrema points at (-pi, -1/2 pi, 0, 1/2 pi) that fall within
0201   /// the surface will be inserted to guarantee an appropriate extent
0202   /// measurement in x and y
0203   ///
0204   /// @return A list of vertices and a face/facett description of it
0205   Polyhedron polyhedronRepresentation(
0206       const GeometryContext& gctx,
0207       unsigned int quarterSegments = 2u) const override;
0208 
0209   /// Return properly formatted class name for screen output
0210   std::string name() const override;
0211 
0212   /// Calculate the derivative of path length at the geometry constraint or
0213   /// point-of-closest-approach w.r.t. alignment parameters of the surface (i.e.
0214   /// local frame origin in global 3D Cartesian coordinates and its rotation
0215   /// represented with extrinsic Euler angles)
0216   ///
0217   /// @param gctx The current geometry context object, e.g. alignment
0218   /// @param position global 3D position
0219   /// @param direction global 3D momentum direction
0220   ///
0221   /// @return Derivative of path length w.r.t. the alignment parameters
0222   AlignmentToPathMatrix alignmentToPathDerivative(
0223       const GeometryContext& gctx, const Vector3& position,
0224       const Vector3& direction) const final;
0225 
0226   /// Calculate the derivative of bound track parameters local position w.r.t.
0227   /// position in local 3D Cartesian coordinates
0228   ///
0229   /// @param gctx The current geometry context object, e.g. alignment
0230   /// @param position The position of the parameters in global
0231   ///
0232   /// @return Derivative of bound local position w.r.t. position in local 3D
0233   /// cartesian coordinates
0234   ActsMatrix<2, 3> localCartesianToBoundLocalDerivative(
0235       const GeometryContext& gctx, const Vector3& position) const final;
0236 
0237  protected:
0238   std::shared_ptr<const ConeBounds> m_bounds;  ///< bounds (shared)
0239 
0240  private:
0241   /// Implementation of the intersection solver
0242   ///
0243   /// <b>mathematical motivation:</b>
0244   ///
0245   ///   The calculation will be done in the 3-dim frame of the cone,
0246   ///   i.e. the symmetry axis of the cone is the z-axis, x- and y-axis are
0247   /// perpendicular
0248   ///   to the z-axis. In this frame the cone is centered around the origin.
0249   ///   Therefore the two points describing the line have to be first
0250   ///   recalculated
0251   /// into the new frame.
0252   ///   Suppose, this is done, the points of intersection can be
0253   ///   obtained as follows:<br>
0254   ///
0255   ///   The cone is described by the implicit equation
0256   ///   @f$x^2 + y^2 = z^2 \tan \alpha@f$
0257   ///   where @f$\alpha@f$ is opening half-angle of the cone  the and
0258   ///   the line by the parameter equation (with @f$t@f$ the
0259   ///   parameter and @f$x_1@f$ and @f$x_2@f$ are points on the line)
0260   ///   @f$(x,y,z) = \vec x_1 + (\vec x_2 - \vec x_2) t @f$.
0261   ///   The intersection is the given to the value of @f$t@f$ where
0262   ///   the @f$(x,y,z)@f$ coordinates of the line satisfy the implicit
0263   ///   equation of the cone. Inserting the expression for the points
0264   ///   on the line into the equation of the cone and rearranging to
0265   ///   the form of a  gives (letting @f$ \vec x_d = \frac{\vec x_2 - \vec
0266   ///   x_1}{|\vec x_2 - \vec x_1|} @f$):
0267   ///   @f$t^2 (x_d^2 + y_d^2 - z_d^2 \tan^2 \alpha) + 2 t (x_1 x_d +
0268   ///   y_1 y_d - z_1 z_d \tan^2 \alpha) + (x_1^2 + y_1^2 - z_1^2
0269   ///   \tan^2 \alpha) = 0 @f$
0270   ///   Solving the above for @f$t@f$ and putting the values into the
0271   ///   equation of the line gives the points of intersection. @f$t@f$
0272   ///   is also the length of the path, since we normalized @f$x_d@f$
0273   ///   to be unit length.
0274   ///
0275   /// @return the quadratic equation
0276   detail::RealQuadraticEquation intersectionSolver(
0277       const GeometryContext& gctx, const Vector3& position,
0278       const Vector3& direction) const;
0279 };
0280 
0281 static_assert(RegularSurfaceConcept<ConeSurface>,
0282               "ConeSurface does not fulfill RegularSurfaceConcept");
0283 
0284 }  // namespace Acts