Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:45:26

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/Tolerance.hpp"
0013 #include "Acts/Geometry/GeometryContext.hpp"
0014 #include "Acts/Geometry/Polyhedron.hpp"
0015 #include "Acts/Surfaces/BoundaryTolerance.hpp"
0016 #include "Acts/Surfaces/RegularSurface.hpp"
0017 #include "Acts/Surfaces/Surface.hpp"
0018 #include "Acts/Surfaces/SurfaceConcept.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 PlanarBounds;
0028 class SurfaceBounds;
0029 
0030 /// @class PlaneSurface
0031 ///
0032 /// Class for a planaer in the TrackingGeometry.
0033 ///
0034 /// The PlaneSurface extends the Surface class with the possibility to
0035 /// convert local to global positions (vice versa).
0036 ///
0037 /// @image html PlaneSurface.png
0038 ///
0039 class PlaneSurface : public RegularSurface {
0040   friend class Surface;
0041 
0042  protected:
0043   /// Copy Constructor
0044   ///
0045   /// @param other is the source surface for the copy
0046   PlaneSurface(const PlaneSurface& other);
0047 
0048   /// Copy constructor - with shift
0049   ///
0050   /// @param gctx The current geometry context object, e.g. alignment
0051   /// @param other is the source cone surface
0052   /// @param transform is the additional transform applied after copying
0053   PlaneSurface(const GeometryContext& gctx, const PlaneSurface& other,
0054                const Transform3& transform);
0055 
0056   /// Constructor from SurfacePlacementBase : Element proxy
0057   ///
0058   /// @param pbounds are the provided planar bounds
0059   /// @param placement Reference to the surface placement
0060   /// @note The Surface does not take any ownership over the
0061   ///       `SurfacePlacementBase` it is expected that the user
0062   ///        ensures the life-time of the `SurfacePlacementBase`
0063   ///        and that the `Surface` is actually owned by
0064   ///        the `SurfacePlacementBase` instance
0065   PlaneSurface(std::shared_ptr<const PlanarBounds> pbounds,
0066                const SurfacePlacementBase& placement);
0067 
0068   /// Constructor for Planes with (optional) shared bounds object
0069   ///
0070   /// @param transform transform in 3D that positions this surface
0071   /// @param pbounds bounds object to describe the actual surface area
0072   explicit PlaneSurface(const Transform3& transform,
0073                         std::shared_ptr<const PlanarBounds> pbounds = nullptr);
0074 
0075  public:
0076   /// Assignment operator
0077   ///
0078   /// @param other The source PlaneSurface for assignment
0079   /// @return Reference to this PlaneSurface after assignment
0080   PlaneSurface& operator=(const PlaneSurface& other);
0081 
0082   // Use overloads from `RegularSurface`
0083   using RegularSurface::globalToLocal;
0084   using RegularSurface::localToGlobal;
0085   using RegularSurface::normal;
0086 
0087   /// Get the normal vector of this surface at a given local position
0088   ///
0089   /// @param gctx The current geometry context object, e.g. alignment
0090   /// @param lposition is the local position is ignored
0091   ///
0092   /// @return Normal vector as Vector3 by value
0093   Vector3 normal(const GeometryContext& gctx,
0094                  const Vector2& lposition) const final;
0095 
0096   /// Get the normal vector of this surface at a given global position
0097   /// @note The @p position is required to be on-surface.
0098   /// @param gctx The current geometry context object, e.g. alignment
0099   /// @param position is the global positiono (for @ref PlaneSurface this is ignored)
0100   /// @return The normal vector
0101   Vector3 normal(const GeometryContext& gctx,
0102                  const Vector3& position) const final;
0103 
0104   /// Get the normal vector, independent of the location
0105   /// @param gctx The current geometry context object, e.g. alignment
0106   /// @return The normal vector
0107   Vector3 normal(const GeometryContext& gctx) const;
0108 
0109   /// The axis position is the position calculated
0110   /// for a certain axis type
0111   ///
0112   /// @param gctx The current geometry context object, e.g. alignment
0113   /// @param aDir is the axis direction of reference position request
0114   ///
0115   /// @return position that can be used for this axis
0116   Vector3 referencePosition(const GeometryContext& gctx,
0117                             AxisDirection aDir) const final;
0118 
0119   /// Return the surface type
0120   /// @return Surface type identifier
0121   SurfaceType type() const override;
0122 
0123   /// Return method for bounds object of this surfrace
0124   /// @return Reference to the surface bounds
0125   const SurfaceBounds& bounds() const override;
0126   /// This method returns the shared_ptr to the DiscBounds
0127   /// @return Shared pointer to the planar bounds
0128   const std::shared_ptr<const PlanarBounds>& boundsPtr() const;
0129   /// Overwrite the existing surface bounds with new ones
0130   /// @param newBounds: Pointer to the new bounds
0131   void assignSurfaceBounds(std::shared_ptr<const PlanarBounds> newBounds);
0132 
0133   /// Local to global transformation
0134   ///
0135   /// @note For planar surfaces the momentum direction is ignored in the local to global
0136   /// transformation
0137   ///
0138   /// @param gctx The current geometry context object, e.g. alignment
0139   /// @param lposition local 2D position in specialized surface frame
0140   ///
0141   /// @return the global position by value
0142   Vector3 localToGlobal(const GeometryContext& gctx,
0143                         const Vector2& lposition) const override;
0144 
0145   /// Global to local transformation
0146   ///
0147   /// @note For planar surfaces the momentum direction is ignored in the global to local
0148   /// transformation
0149   ///
0150   /// @param gctx The current geometry context object, e.g. alignment
0151   /// @param position global 3D position - considered to be on surface but not
0152   /// inside bounds (check is done)
0153   /// @param tolerance optional tolerance within which a point is considered
0154   /// valid on surface
0155   ///
0156   /// @return a Result<Vector2> which can be !ok() if the operation fails
0157   Result<Vector2> globalToLocal(
0158       const GeometryContext& gctx, const Vector3& position,
0159       double tolerance = s_onSurfaceTolerance) const override;
0160 
0161   /// Method that calculates the correction due to incident angle
0162   ///
0163   /// @param gctx The current geometry context object, e.g. alignment
0164   /// @param position global 3D position (ignored for @ref PlaneSurface)
0165   /// @param direction global 3D momentum direction (ignored for @ref PlaneSurface)
0166   /// @return a double representing the scaling factor
0167   double pathCorrection(const GeometryContext& gctx, const Vector3& position,
0168                         const Vector3& direction) const final;
0169 
0170   /// @brief Straight line intersection
0171   ///
0172   /// @param gctx The current geometry context object, e.g. alignment
0173   /// @param position The start position of the intersection attempt
0174   /// @param direction The direction of the intersection attempt,
0175   /// (@note expected to be normalized)
0176   /// @param boundaryTolerance The boundary check directive
0177   /// @param tolerance the tolerance used for the intersection
0178   ///
0179   /// <b>mathematical motivation:</b>
0180   ///
0181   /// the equation of the plane is given by: <br>
0182   /// @f$ \vec n \cdot \vec x = \vec n \cdot \vec p,@f$ <br>
0183   /// where @f$ \vec n = (n_{x}, n_{y}, n_{z})@f$ denotes the normal vector of
0184   /// the plane,  @f$ \vec p = (p_{x}, p_{y}, p_{z})@f$ one specific point
0185   /// on the plane and @f$ \vec x = (x,y,z) @f$ all possible points
0186   /// on the plane.<br>
0187   ///
0188   /// Given a line with:<br>
0189   /// @f$ \vec l(u) = \vec l_{1} + u \cdot \vec v @f$, <br>
0190   /// the solution for @f$ u @f$ can be written:
0191   /// @f$ u = \frac{\vec n (\vec p - \vec l_{1})}{\vec n \vec v}@f$ <br>
0192   /// If the denominator is 0 then the line lies:
0193   /// - either in the plane
0194   /// - perpendicular to the normal of the plane
0195   ///
0196   /// @return the @c MultiIntersection3D object
0197   MultiIntersection3D intersect(
0198       const GeometryContext& gctx, const Vector3& position,
0199       const Vector3& direction,
0200       const BoundaryTolerance& boundaryTolerance =
0201           BoundaryTolerance::Infinite(),
0202       double tolerance = s_onSurfaceTolerance) 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 is the number of segments used to describe curved
0208   /// segments in a quarter of the phi range. If it is 1, then only the extrema
0209   /// points in phi are inserted next to the segment corners.
0210   ///
0211   /// @note for planar surfaces without curved segments @c quarterSegments is ignored
0212   ///
0213   /// @return A list of vertices and a face/facett description of it
0214   Polyhedron polyhedronRepresentation(
0215       const GeometryContext& gctx, unsigned int quarterSegments) const override;
0216 
0217   /// Return properly formatted class name for screen output
0218   /// @return String representation of the class name
0219   std::string name() const override;
0220 
0221   /// Calculate the derivative of bound track parameters local position w.r.t.
0222   /// position in local 3D Cartesian coordinates
0223   ///
0224   /// @param gctx The current geometry context object, e.g. alignment
0225   /// @param position The position of the parameters in global
0226   ///
0227   /// @return Derivative of bound local position w.r.t. position in local 3D
0228   /// cartesian coordinates
0229   Matrix<2, 3> localCartesianToBoundLocalDerivative(
0230       const GeometryContext& gctx, const Vector3& position) const final;
0231 
0232   /// Merge two plane surfaces into a single one.
0233   /// @note The surfaces need to be *compatible*, i.e. have bounds
0234   ///       that align along merging direction, and have the same bound size
0235   ///       along the non-merging direction
0236   /// @param other The other plane surface to merge with
0237   /// @param direction The direction: either @c AxisX or @c AxisY
0238   /// @param logger The logger to use
0239   /// @return The merged plane surface and a boolean indicating if surfaces are reversed
0240   /// @note The returned boolean is `false` if `this` is *left* or
0241   ///       *counter-clockwise* of @p other, and `true` if not.
0242   std::pair<std::shared_ptr<PlaneSurface>, bool> mergedWith(
0243       const PlaneSurface& other, AxisDirection direction,
0244       const Logger& logger = getDummyLogger()) const;
0245 
0246  protected:
0247   /// the bounds of this surface
0248   std::shared_ptr<const PlanarBounds> m_bounds;
0249 
0250  private:
0251 };
0252 
0253 static_assert(RegularSurfaceConcept<PlaneSurface>,
0254               "PlaneSurface does not fulfill RegularSurfaceConcept");
0255 
0256 }  // namespace Acts