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 
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/BoundaryCheck.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/Concepts.hpp"
0024 #include "Acts/Utilities/Result.hpp"
0025 #include "Acts/Utilities/detail/RealQuadraticEquation.hpp"
0026 
0027 #include <cmath>
0028 #include <cstddef>
0029 #include <memory>
0030 #include <string>
0031 
0032 namespace Acts {
0033 
0034 /// @class ConeSurface
0035 ///
0036 /// Class for a conical surface in the Tracking geometry.
0037 /// It inherits from Surface.
0038 ///
0039 /// The ConeSurface is special since no corresponding
0040 /// Track parameters exist since they're numerical instable
0041 /// at the tip of the cone.
0042 /// Propagations to a cone surface will be returned in
0043 /// curvilinear coordinates.
0044 
0045 class ConeSurface : public RegularSurface {
0046   friend class Surface;
0047 
0048  protected:
0049   /// Constructor form HepTransform and an opening angle
0050   ///
0051   /// @param transform is the transform to place to cone in a 3D frame
0052   /// @param alpha is the opening angle of the cone
0053   /// @param symmetric indicates if the cones are built to +/1 z
0054   ConeSurface(const Transform3& transform, double alpha,
0055               bool symmetric = false);
0056 
0057   /// Constructor form HepTransform and an opening angle
0058   ///
0059   /// @param transform is the transform that places the cone in the global frame
0060   /// @param alpha is the opening angle of the cone
0061   /// @param zmin is the z range over which the cone spans
0062   /// @param zmax is the z range over which the cone spans
0063   /// @param halfPhi is the opening angle for cone ssectors
0064   ConeSurface(const Transform3& transform, double alpha, double zmin,
0065               double zmax, double halfPhi = M_PI);
0066 
0067   /// Constructor from HepTransform and ConeBounds
0068   ///
0069   /// @param transform is the transform that places the cone in the global frame
0070   /// @param cbounds is the boundary class, the bounds must exit
0071   ConeSurface(const Transform3& transform,
0072               std::shared_ptr<const ConeBounds> cbounds);
0073 
0074   /// Copy constructor
0075   ///
0076   /// @param other is the source cone surface
0077   ConeSurface(const ConeSurface& other);
0078 
0079   /// Copy constructor - with shift
0080   ///
0081   /// @param gctx The current geometry context object, e.g. alignment
0082   /// @param other is the source cone surface
0083   /// @param shift is the additional transform applied after copying
0084   ConeSurface(const GeometryContext& gctx, const ConeSurface& other,
0085               const Transform3& shift);
0086 
0087  public:
0088   ~ConeSurface() override = default;
0089   ConeSurface() = delete;
0090 
0091   /// Assignment operator
0092   ///
0093   /// @param other is the source surface for the assignment
0094   ConeSurface& operator=(const ConeSurface& other);
0095 
0096   /// The binning position method - is overloaded for r-type binning
0097   ///
0098   /// @param gctx The current geometry context object, e.g. alignment
0099   /// @param bValue defines the type of binning applied in the global frame
0100   ///
0101   /// @return The return type is a vector for positioning in the global frame
0102   Vector3 binningPosition(const GeometryContext& gctx,
0103                           BinningValue bValue) const final;
0104 
0105   /// Return the surface type
0106   SurfaceType type() const override;
0107 
0108   /// Return the measurement frame - this is needed for alignment, in particular
0109   ///  for StraightLine and Perigee Surface
0110   ///  - the default implementation is the RotationMatrix3 of the transform
0111   ///
0112   /// @param gctx The current geometry context object, e.g. alignment
0113   /// @param position is the global position where the measurement frame is
0114   /// constructed
0115   /// @param direction is the momentum direction used for the measurement frame
0116   /// construction
0117   /// @return matrix that indicates the measurement frame
0118   RotationMatrix3 referenceFrame(const GeometryContext& gctx,
0119                                  const Vector3& position,
0120                                  const Vector3& direction) const final;
0121 
0122   /// Return method for surface normal information
0123   ///
0124   /// @param gctx The current geometry context object, e.g. alignment
0125   /// @param lposition is the local position at normal vector request
0126   /// @return Vector3 normal vector in global frame
0127   Vector3 normal(const GeometryContext& gctx,
0128                  const Vector2& lposition) const final;
0129 
0130   /// Return method for surface normal information
0131   ///
0132   /// @param gctx The current geometry context object, e.g. alignment
0133   /// @param position is the global position as normal vector base
0134   /// @return Vector3 normal vector in global frame
0135   Vector3 normal(const GeometryContext& gctx,
0136                  const Vector3& position) const final;
0137 
0138   // Return method for the rotational symmetry axis
0139   ///
0140   /// @param gctx The current geometry context object, e.g. alignment
0141   ///
0142   // @return This returns the local z axis
0143   virtual Vector3 rotSymmetryAxis(const GeometryContext& gctx) const;
0144 
0145   /// This method returns the ConeBounds by reference
0146   const ConeBounds& bounds() const final;
0147 
0148   /// Local to global transformation
0149   ///
0150   /// @param gctx The current geometry context object, e.g. alignment
0151   /// @param lposition is the local position to be transformed
0152   ///
0153   /// @return The global position by value
0154   Vector3 localToGlobal(const GeometryContext& gctx,
0155                         const Vector2& lposition) const final;
0156 
0157   // Use overloads from `RegularSurface`
0158   using RegularSurface::globalToLocal;
0159   using RegularSurface::localToGlobal;
0160   using RegularSurface::normal;
0161 
0162   /// Global to local transformation
0163   ///
0164   /// @param gctx The current geometry context object, e.g. alignment
0165   /// @param position is the global position to be transformed
0166   /// @param tolerance optional tolerance within which a point is considered
0167   /// valid on surface
0168   ///
0169   /// @return a Result<Vector2> which can be !ok() if the operation fails
0170   Result<Vector2> globalToLocal(
0171       const GeometryContext& gctx, const Vector3& position,
0172       double tolerance = s_onSurfaceTolerance) const final;
0173 
0174   /// Straight line intersection schema from position/direction
0175   ///
0176   /// @param gctx The current geometry context object, e.g. alignment
0177   /// @param position The position to start from
0178   /// @param direction The direction at start
0179   /// @param bcheck the Boundary Check
0180   /// @param tolerance the tolerance used for the intersection
0181   ///
0182   /// If possible returns both solutions for the cylinder
0183   ///
0184   /// @return @c SurfaceMultiIntersection object (contains intersection & surface)
0185   SurfaceMultiIntersection intersect(
0186       const GeometryContext& gctx, const Vector3& position,
0187       const Vector3& direction,
0188       const BoundaryCheck& bcheck = BoundaryCheck(false),
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 ACTS_STATIC_CHECK_CONCEPT(RegularSurfaceConcept, ConeSurface);
0286 
0287 }  // namespace Acts