Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:08:00

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