Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:24:13

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