Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-03 09:50:01

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   using Surface::referenceFrame;
0120 
0121   /// Return method for the reference frame
0122   /// This is the frame in which the covariance matrix is defined (specialized
0123   /// by all surfaces)
0124   ///
0125   /// @param gctx The current geometry context object, e.g. alignment
0126   ///
0127   /// @return RotationMatrix3 which defines the three axes of the measurement
0128   /// frame
0129   RotationMatrix3 referenceFrame(const GeometryContext& gctx) const;
0130 
0131   /// Return the surface type
0132   /// @return Surface type identifier
0133   SurfaceType type() const override;
0134 
0135   /// Return method for bounds object of this surfrace
0136   /// @return Reference to the surface bounds
0137   const SurfaceBounds& bounds() const override;
0138   /// This method returns the shared_ptr to the DiscBounds
0139   /// @return Shared pointer to the planar bounds
0140   const std::shared_ptr<const PlanarBounds>& boundsPtr() const;
0141   /// Overwrite the existing surface bounds with new ones
0142   /// @param newBounds: Pointer to the new bounds
0143   void assignSurfaceBounds(std::shared_ptr<const PlanarBounds> newBounds);
0144 
0145   /// Local to global transformation
0146   ///
0147   /// @note For planar surfaces the momentum direction is ignored in the local to global
0148   /// transformation
0149   ///
0150   /// @param gctx The current geometry context object, e.g. alignment
0151   /// @param lposition local 2D position in specialized surface frame
0152   ///
0153   /// @return the global position by value
0154   Vector3 localToGlobal(const GeometryContext& gctx,
0155                         const Vector2& lposition) const override;
0156 
0157   /// Global to local transformation
0158   ///
0159   /// @note For planar surfaces the momentum direction is ignored in the global to local
0160   /// transformation
0161   ///
0162   /// @param gctx The current geometry context object, e.g. alignment
0163   /// @param position global 3D position - considered to be on surface but not
0164   /// inside bounds (check is done)
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 override;
0172 
0173   /// Method that calculates the correction due to incident angle
0174   ///
0175   /// @param gctx The current geometry context object, e.g. alignment
0176   /// @param position global 3D position (ignored for @ref PlaneSurface)
0177   /// @param direction global 3D momentum direction (ignored for @ref PlaneSurface)
0178   /// @return a double representing the scaling factor
0179   double pathCorrection(const GeometryContext& gctx, const Vector3& position,
0180                         const Vector3& direction) const final;
0181 
0182   /// @brief Straight line intersection
0183   ///
0184   /// @param gctx The current geometry context object, e.g. alignment
0185   /// @param position The start position of the intersection attempt
0186   /// @param direction The direction of the intersection attempt,
0187   /// (@note expected to be normalized)
0188   /// @param boundaryTolerance The boundary check directive
0189   /// @param tolerance the tolerance used for the intersection
0190   ///
0191   /// <b>mathematical motivation:</b>
0192   ///
0193   /// the equation of the plane is given by: <br>
0194   /// @f$ \vec n \cdot \vec x = \vec n \cdot \vec p,@f$ <br>
0195   /// where @f$ \vec n = (n_{x}, n_{y}, n_{z})@f$ denotes the normal vector of
0196   /// the plane,  @f$ \vec p = (p_{x}, p_{y}, p_{z})@f$ one specific point
0197   /// on the plane and @f$ \vec x = (x,y,z) @f$ all possible points
0198   /// on the plane.<br>
0199   ///
0200   /// Given a line with:<br>
0201   /// @f$ \vec l(u) = \vec l_{1} + u \cdot \vec v @f$, <br>
0202   /// the solution for @f$ u @f$ can be written:
0203   /// @f$ u = \frac{\vec n (\vec p - \vec l_{1})}{\vec n \vec v}@f$ <br>
0204   /// If the denominator is 0 then the line lies:
0205   /// - either in the plane
0206   /// - perpendicular to the normal of the plane
0207   ///
0208   /// @return the @c MultiIntersection3D object
0209   MultiIntersection3D intersect(
0210       const GeometryContext& gctx, const Vector3& position,
0211       const Vector3& direction,
0212       const BoundaryTolerance& boundaryTolerance =
0213           BoundaryTolerance::Infinite(),
0214       double tolerance = s_onSurfaceTolerance) const final;
0215 
0216   /// Return a Polyhedron for the surfaces
0217   ///
0218   /// @param gctx The current geometry context object, e.g. alignment
0219   /// @param quarterSegments is the number of segments used to describe curved
0220   /// segments in a quarter of the phi range. If it is 1, then only the extrema
0221   /// points in phi are inserted next to the segment corners.
0222   ///
0223   /// @note for planar surfaces without curved segments @c quarterSegments is ignored
0224   ///
0225   /// @return A list of vertices and a face/facett description of it
0226   Polyhedron polyhedronRepresentation(
0227       const GeometryContext& gctx, unsigned int quarterSegments) const override;
0228 
0229   /// Return properly formatted class name for screen output
0230   /// @return String representation of the class name
0231   std::string name() const override;
0232 
0233   /// Calculate the derivative of bound track parameters local position w.r.t.
0234   /// position in local 3D Cartesian coordinates
0235   ///
0236   /// @param gctx The current geometry context object, e.g. alignment
0237   /// @param position The position of the parameters in global
0238   ///
0239   /// @return Derivative of bound local position w.r.t. position in local 3D
0240   /// cartesian coordinates
0241   Matrix<2, 3> localCartesianToBoundLocalDerivative(
0242       const GeometryContext& gctx, const Vector3& position) const final;
0243 
0244   /// Merge two plane surfaces into a single one.
0245   /// @note The surfaces need to be *compatible*, i.e. have bounds
0246   ///       that align along merging direction, and have the same bound size
0247   ///       along the non-merging direction
0248   /// @param other The other plane surface to merge with
0249   /// @param direction The direction: either @c AxisX or @c AxisY
0250   /// @param logger The logger to use
0251   /// @return The merged plane surface and a boolean indicating if surfaces are reversed
0252   /// @note The returned boolean is `false` if `this` is *left* or
0253   ///       *counter-clockwise* of @p other, and `true` if not.
0254   std::pair<std::shared_ptr<PlaneSurface>, bool> mergedWith(
0255       const PlaneSurface& other, AxisDirection direction,
0256       const Logger& logger = getDummyLogger()) const;
0257 
0258  protected:
0259   /// the bounds of this surface
0260   std::shared_ptr<const PlanarBounds> m_bounds;
0261 
0262   /// @copydoc Surface::localAxes
0263   std::array<AxisDirection, 2> localAxes() const override {
0264     return {AxisDirection::AxisX, AxisDirection::AxisY};
0265   }
0266 };
0267 
0268 static_assert(RegularSurfaceConcept<PlaneSurface>,
0269               "PlaneSurface does not fulfill RegularSurfaceConcept");
0270 
0271 }  // namespace Acts