|
|
|||
File indexing completed on 2026-06-05 07:47:38
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/Alignment.hpp" 0013 #include "Acts/Definitions/Tolerance.hpp" 0014 #include "Acts/Geometry/GeometryContext.hpp" 0015 #include "Acts/Geometry/Polyhedron.hpp" 0016 #include "Acts/Surfaces/BoundaryTolerance.hpp" 0017 #include "Acts/Surfaces/CylinderBounds.hpp" 0018 #include "Acts/Surfaces/RegularSurface.hpp" 0019 #include "Acts/Surfaces/Surface.hpp" 0020 #include "Acts/Surfaces/SurfaceConcept.hpp" 0021 #include "Acts/Utilities/AxisDefinitions.hpp" 0022 #include "Acts/Utilities/Logger.hpp" 0023 #include "Acts/Utilities/Result.hpp" 0024 #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" 0025 0026 #include <memory> 0027 #include <numbers> 0028 #include <string> 0029 0030 namespace Acts { 0031 0032 /// @class CylinderSurface 0033 /// 0034 /// Class for a CylinderSurface in the TrackingGeometry. 0035 /// It inherits from Surface. 0036 /// 0037 /// The cylinder surface has a special role in the TrackingGeometry, 0038 /// since it builds the surfaces of all TrackingVolumes at container level 0039 /// for a cylindrical tracking geometry. 0040 /// 0041 /// @image html CylinderSurface.png 0042 0043 class CylinderSurface : public RegularSurface { 0044 friend class Surface; 0045 0046 protected: 0047 /// Constructor from Transform3 and CylinderBounds 0048 /// 0049 /// @param transform The transform to position the surface 0050 /// @param radius The radius of the cylinder 0051 /// @param halfz The half length in z 0052 /// @param halfphi The half opening angle 0053 /// @param avphi The phi value from which the opening angle spans (both sides) 0054 /// @param bevelMinZ (optional) The bevel on the negative z side 0055 /// @param bevelMaxZ (optional) The bevel on the positive z sid The bevel on the positive z side 0056 CylinderSurface(const Transform3& transform, double radius, double halfz, 0057 double halfphi = std::numbers::pi, double avphi = 0., 0058 double bevelMinZ = 0., double bevelMaxZ = 0.); 0059 0060 /// Constructor from Transform3 and CylinderBounds arguments 0061 /// 0062 /// @param transform The transform to position the surface 0063 /// @param cbounds is a shared pointer to a cylindeer bounds object, 0064 /// it must exist (assert test) 0065 CylinderSurface(const Transform3& transform, 0066 std::shared_ptr<const CylinderBounds> cbounds); 0067 0068 /// Constructor from SurfacePlacementBase: Element proxy 0069 /// 0070 /// @param cbounds are the provided cylinder bounds (shared) 0071 /// @param placement Reference to the surface placement 0072 /// @note The Surface does not take any ownership over the 0073 /// `SurfacePlacementBase` it is expected that the user 0074 /// ensures the life-time of the `SurfacePlacementBase` 0075 /// and that the `Surface` is actually owned by 0076 /// the `SurfacePlacementBase` instance 0077 CylinderSurface(std::shared_ptr<const CylinderBounds> cbounds, 0078 const SurfacePlacementBase& placement); 0079 0080 /// Copy constructor 0081 /// 0082 /// @param other is the source cylinder for the copy 0083 CylinderSurface(const CylinderSurface& other); 0084 0085 /// Copy constructor - with shift 0086 /// 0087 /// @param gctx The current geometry context object, e.g. alignment 0088 /// @param other is the source cone surface 0089 /// @param shift is the additional transform applied after copying 0090 CylinderSurface(const GeometryContext& gctx, const CylinderSurface& other, 0091 const Transform3& shift); 0092 0093 public: 0094 /// Assignment operator 0095 /// 0096 /// @param other is the source cylinder for the copy 0097 /// @return Reference to this CylinderSurface after assignment 0098 CylinderSurface& operator=(const CylinderSurface& other); 0099 0100 /// The binning position method - is overloaded for r-type binning 0101 /// 0102 /// @param gctx The current geometry context object, e.g. alignment 0103 /// @param aDir is the axis Direction of global binning to be done 0104 /// 0105 /// @return is the global position to be used for binning 0106 Vector3 referencePosition(const GeometryContext& gctx, 0107 AxisDirection aDir) const final; 0108 0109 /// Return the measurement frame - this is needed for alignment, in particular 0110 /// The measurement frame of a cylinder is the tangential plane at a given 0111 /// position 0112 /// 0113 /// @param gctx The current geometry context object, e.g. alignment 0114 /// @param position is the position where the measurement frame is defined 0115 /// @param direction is the momentum direction vector (ignored) 0116 /// @return rotation matrix that defines the measurement frame 0117 RotationMatrix3 referenceFrame(const GeometryContext& gctx, 0118 const Vector3& position, 0119 const Vector3& direction) const final; 0120 0121 /// Return the surface type 0122 /// @return Surface type identifier 0123 SurfaceType type() const override; 0124 0125 /// Return method for surface normal information 0126 /// @note for a Cylinder a local position is always required for the normal 0127 /// vector 0128 /// 0129 /// @param gctx The current geometry context object, e.g. alignment 0130 /// @param lposition is the local position for which the normal vector is 0131 /// requested 0132 /// 0133 /// @return normal vector at the local position by value 0134 Vector3 normal(const GeometryContext& gctx, 0135 const Vector2& lposition) const final; 0136 0137 /// Return method for surface normal information 0138 /// @note for a Cylinder a local position is always required for the normal 0139 /// vector 0140 /// 0141 /// @param gctx The current geometry context object, e.g. alignment 0142 /// @param position is the global position for which the normal vector is 0143 /// requested 0144 /// 0145 /// @return normal vector at the global position by value 0146 Vector3 normal(const GeometryContext& gctx, 0147 const Vector3& position) const final; 0148 0149 // Use overloads from `RegularSurface` 0150 using RegularSurface::globalToLocal; 0151 using RegularSurface::localToGlobal; 0152 using RegularSurface::normal; 0153 0154 /// Return method for the rotational symmetry axis 0155 /// 0156 /// @param gctx The current geometry context object, e.g. alignment 0157 /// 0158 /// @return the z-Axis of transform 0159 virtual Vector3 rotSymmetryAxis(const GeometryContext& gctx) const; 0160 0161 /// This method returns the CylinderBounds by reference 0162 /// @return Reference to the cylinder bounds 0163 const CylinderBounds& bounds() const final; 0164 0165 /// This method returns the shared_ptr to the CylinderBounds 0166 /// @return Shared pointer to the cylinder bounds 0167 const std::shared_ptr<const CylinderBounds>& boundsPtr() const; 0168 0169 /// Overwrite the existing surface bounds with new ones 0170 /// @param newBounds: Pointer to the new bounds 0171 void assignSurfaceBounds(std::shared_ptr<const CylinderBounds> newBounds); 0172 0173 /// Local to global transformation 0174 /// 0175 /// @param gctx The current geometry context object, e.g. alignment 0176 /// @param lposition is the local position to be transformed 0177 /// 0178 /// @return The global position by value 0179 Vector3 localToGlobal(const GeometryContext& gctx, 0180 const Vector2& lposition) const final; 0181 0182 /// Global to local transformation 0183 /// 0184 /// @param gctx The current geometry context object, e.g. alignment 0185 /// @param position is the global position to be transformed 0186 /// @param tolerance optional tolerance within which a point is considered 0187 /// valid on surface 0188 /// 0189 /// @return a Result<Vector2> which can be !ok() if the operation fails 0190 Result<Vector2> globalToLocal( 0191 const GeometryContext& gctx, const Vector3& position, 0192 double tolerance = s_onSurfaceTolerance) const final; 0193 0194 /// Straight line intersection schema from position/direction 0195 /// 0196 /// @param gctx The current geometry context object, e.g. alignment 0197 /// @param position The position to start from 0198 /// @param direction The direction at start 0199 /// @param boundaryTolerance the Boundary Check Tolerance 0200 /// @param tolerance the tolerance used for the intersection 0201 /// 0202 /// If possible returns both solutions for the cylinder 0203 /// 0204 /// @return SurfaceIntersection object (contains intersection & surface) 0205 MultiIntersection3D intersect( 0206 const GeometryContext& gctx, const Vector3& position, 0207 const Vector3& direction, 0208 const BoundaryTolerance& boundaryTolerance = 0209 BoundaryTolerance::Infinite(), 0210 double tolerance = s_onSurfaceTolerance) const final; 0211 0212 /// Path correction due to incident of the track 0213 /// 0214 /// @param gctx The current geometry context object, e.g. alignment 0215 /// @param position is the global position as a starting point 0216 /// @param direction is the global momentum direction at the starting point 0217 /// 0218 /// @return is the correction factor due to incident 0219 double pathCorrection(const GeometryContext& gctx, const Vector3& position, 0220 const Vector3& direction) const final; 0221 0222 /// Return method for properly formatted output string 0223 /// @return String representation of the class name 0224 std::string name() const override; 0225 0226 /// Return a Polyhedron for a cylinder 0227 /// 0228 /// This method represents the cylinder as a polyhedron with a given number 0229 /// of segments to represent a quarter of a full circle. The polyedron will 0230 /// consist of the vertices of the cylinder on both sides, and faces between 0231 /// them, both as rectangular faces and as triangular faces. 0232 /// 0233 /// @param gctx The current geometry context object, e.g. alignment 0234 /// @param quarterSegments The number of segments to approximate a quarter of the 0235 /// full circle; it's chosen to be 1, only the extrema points (-pi, -0.5pi, 0236 /// 0., 0.5pi) are inserted to capture the correct extent in the x-y plane 0237 /// 0238 /// @return A list of vertices and a face/facett description of it 0239 Polyhedron polyhedronRepresentation( 0240 const GeometryContext& gctx, 0241 unsigned int quarterSegments = 2u) const override; 0242 0243 /// Calculate the derivative of path length at the geometry constraint or 0244 /// point-of-closest-approach w.r.t. alignment parameters of the surface (i.e. 0245 /// local frame origin in global 3D Cartesian coordinates and its rotation 0246 /// represented with extrinsic Euler angles) 0247 /// 0248 /// @param gctx The current geometry context object, e.g. alignment 0249 /// @param position global 3D position 0250 /// @param direction global 3D momentum direction 0251 /// 0252 /// @return Derivative of path length w.r.t. the alignment parameters 0253 AlignmentToPathMatrix alignmentToPathDerivative( 0254 const GeometryContext& gctx, const Vector3& position, 0255 const Vector3& direction) const final; 0256 0257 /// Calculate the derivative of bound track parameters local position w.r.t. 0258 /// position in local 3D Cartesian coordinates 0259 /// 0260 /// @param gctx The current geometry context object, e.g. alignment 0261 /// @param position The position of the parameters in global 0262 /// 0263 /// @return Derivative of bound local position w.r.t. position in local 3D 0264 /// cartesian coordinates 0265 Matrix<2, 3> localCartesianToBoundLocalDerivative( 0266 const GeometryContext& gctx, const Vector3& position) const final; 0267 0268 /// Merge two cylinder surfaces into a single one. 0269 /// @image html Cylinder_Merging.svg 0270 /// @note The surfaces need to be *compatible*, i.e. have cylinder bounds 0271 /// that align, and have the same radius 0272 /// @param other The other cylinder surface to merge with 0273 /// @param direction The axis direction: either @c AxisZ or @c AxisRPhi 0274 /// @param externalRotation If true, any phi rotation is done in the transform 0275 /// @param logger The logger to use 0276 /// @return The merged cylinder surface and a boolean indicating if surfaces are reversed 0277 /// @note The returned boolean is `false` if `this` is *left* or 0278 /// *counter-clockwise* of @p other, and `true` if not. 0279 std::pair<std::shared_ptr<CylinderSurface>, bool> mergedWith( 0280 const CylinderSurface& other, AxisDirection direction, 0281 bool externalRotation, const Logger& logger = getDummyLogger()) const; 0282 0283 /// @copydoc Surface::assignSurfaceMaterial 0284 void assignSurfaceMaterial( 0285 std::shared_ptr<const ISurfaceMaterial> material) override; 0286 0287 protected: 0288 std::shared_ptr<const CylinderBounds> m_bounds; //!< bounds (shared) 0289 0290 /// @copydoc Surface::localAxes 0291 std::array<AxisDirection, 2> localAxes() const override { 0292 return {AxisDirection::AxisRPhi, AxisDirection::AxisZ}; 0293 } 0294 0295 /// @copydoc Surface::transformSurfaceLocalToMaterialLocal 0296 Vector2 transformSurfaceLocalToMaterialLocal( 0297 const Vector2& surfaceLocal) const override; 0298 0299 private: 0300 bool m_scaleMaterialAxis = false; 0301 0302 /// Implementation of the intersection solver 0303 /// 0304 /// <b>mathematical motivation:</b> 0305 /// 0306 /// The cylinder is given by : 0307 /// - cylinder center: ccenter (C) 0308 /// - the direction of the cylinder axis: cdirection (DZ) 0309 /// - the radius r 0310 /// The line is given by : 0311 /// - a reference position : lposition (L0) 0312 /// - the line direction: ldirection (DL) 0313 /// the parametric form for the line is then : L(t) = L0 + t * DL 0314 /// 0315 /// Any point P on infinite cylinder if : 0316 /// ((P - C) x DZ)^2 = r^2 * DZ^2 0317 /// We know that DZ is a unit vector: 0318 /// DZ^2 == 1 0319 /// When expanded with the line equation, this is : 0320 /// ((L0 - C) x DZ + t * (DL x DZ))^2 = r^2 * DZ^2 0321 /// which is a quadratic equation in the form (X + t * Y)^2 = d, where : 0322 /// X = (L0 - C) x DZ 0323 /// Y = DL x DZ 0324 /// d = r^2 * (DZ)^2 0325 /// Now, expand the equation : 0326 /// t^2 * (Y . Y) + t * (2 * (X . Y)) + (X . X) - d = 0 0327 /// => second order equation in the form : a*t^2 + b*t + c = 0 where 0328 /// a = (Y . Y) 0329 /// b = 2 * (X . Y) 0330 /// c = (X . X) - d 0331 /// finally solve the second order equation : a*t^2 + b*t + c = 0 0332 /// reinsertion into the line equation. 0333 /// 0334 /// @return the quadratic equation 0335 detail::RealQuadraticEquation intersectionSolver( 0336 const Transform3& transform, const Vector3& position, 0337 const Vector3& direction) const; 0338 }; 0339 0340 static_assert(RegularSurfaceConcept<CylinderSurface>, 0341 "CylinderSurface does not fulfill RegularSurfaceConcept"); 0342 0343 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|