Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 08:17:56

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