Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-09 07:49:46

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