![]() |
|
|||
File indexing completed on 2025-06-30 08:07:08
0001 // This file is part of the Acts project. 0002 // 0003 // Copyright (C) 2016-2020 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 http://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/Definitions/TrackParametrization.hpp" 0015 #include "Acts/Geometry/GeometryContext.hpp" 0016 #include "Acts/Geometry/Polyhedron.hpp" 0017 #include "Acts/Surfaces/BoundaryTolerance.hpp" 0018 #include "Acts/Surfaces/CylinderBounds.hpp" 0019 #include "Acts/Surfaces/RegularSurface.hpp" 0020 #include "Acts/Surfaces/Surface.hpp" 0021 #include "Acts/Surfaces/SurfaceConcept.hpp" 0022 #include "Acts/Utilities/BinningType.hpp" 0023 #include "Acts/Utilities/Logger.hpp" 0024 #include "Acts/Utilities/Result.hpp" 0025 #include "Acts/Utilities/detail/RealQuadraticEquation.hpp" 0026 0027 #include <cmath> 0028 #include <cstddef> 0029 #include <memory> 0030 #include <string> 0031 0032 namespace Acts { 0033 class DetectorElementBase; 0034 0035 /// @class CylinderSurface 0036 /// 0037 /// Class for a CylinderSurface in the TrackingGeometry. 0038 /// It inherits from Surface. 0039 /// 0040 /// The cylinder surface has a special role in the TrackingGeometry, 0041 /// since it builds the surfaces of all TrackingVolumes at container level 0042 /// for a cylindrical tracking geometry. 0043 /// 0044 /// @image html CylinderSurface.png 0045 0046 class CylinderSurface : public RegularSurface { 0047 friend class Surface; 0048 0049 protected: 0050 /// Constructor from Transform3 and CylinderBounds 0051 /// 0052 /// @param transform The transform to position the surface 0053 /// @param radius The radius of the cylinder 0054 /// @param halfz The half length in z 0055 /// @param halfphi The half opening angle 0056 /// @param avphi The phi value from which the opening angle spans (both sides) 0057 /// @param bevelMinZ (optional) The bevel on the negative z side 0058 /// @param bevelMaxZ (optional) The bevel on the positive z sid The bevel on the positive z side 0059 CylinderSurface(const Transform3& transform, double radius, double halfz, 0060 double halfphi = M_PI, double avphi = 0., 0061 double bevelMinZ = 0., double bevelMaxZ = 0.); 0062 0063 /// Constructor from Transform3 and CylinderBounds arguments 0064 /// 0065 /// @param transform The transform to position the surface 0066 /// @param cbounds is a shared pointer to a cylindeer bounds object, 0067 /// it must exist (assert test) 0068 CylinderSurface(const Transform3& transform, 0069 std::shared_ptr<const CylinderBounds> cbounds); 0070 0071 /// Constructor from DetectorElementBase: Element proxy 0072 /// 0073 /// @param cbounds are the provided cylinder bounds (shared) 0074 /// @param detelement is the linked detector element to this surface 0075 CylinderSurface(std::shared_ptr<const CylinderBounds> cbounds, 0076 const DetectorElementBase& detelement); 0077 0078 /// Copy constructor 0079 /// 0080 /// @param other is the source cylinder for the copy 0081 CylinderSurface(const CylinderSurface& other); 0082 0083 /// Copy constructor - with shift 0084 /// 0085 /// @param gctx The current geometry context object, e.g. alignment 0086 /// @param other is the source cone surface 0087 /// @param shift is the additional transform applied after copying 0088 CylinderSurface(const GeometryContext& gctx, const CylinderSurface& other, 0089 const Transform3& shift); 0090 0091 public: 0092 ~CylinderSurface() override = default; 0093 CylinderSurface() = delete; 0094 0095 /// Assignment operator 0096 /// 0097 /// @param other is the source cylinder for the copy 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 bValue is the type of global binning to be done 0104 /// 0105 /// @return is the global position to be used for binning 0106 Vector3 binningPosition(const GeometryContext& gctx, 0107 BinningValue bValue) 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 SurfaceType type() const override; 0123 0124 /// Return method for surface normal information 0125 /// @note for a Cylinder a local position is always required for the normal 0126 /// vector 0127 /// 0128 /// @param gctx The current geometry context object, e.g. alignment 0129 /// @param lposition is the local position for which the normal vector is 0130 /// requested 0131 /// 0132 /// @return normal vector at the local position by value 0133 Vector3 normal(const GeometryContext& gctx, 0134 const Vector2& lposition) const final; 0135 0136 /// Return method for surface normal information 0137 /// @note for a Cylinder a local position is always required for the normal 0138 /// vector 0139 /// 0140 /// @param gctx The current geometry context object, e.g. alignment 0141 /// @param position is the global position for which the normal vector is 0142 /// requested 0143 /// 0144 /// @return normal vector at the global position by value 0145 Vector3 normal(const GeometryContext& gctx, 0146 const Vector3& position) const final; 0147 0148 // Use overloads from `RegularSurface` 0149 using RegularSurface::globalToLocal; 0150 using RegularSurface::localToGlobal; 0151 using RegularSurface::normal; 0152 0153 /// Return method for the rotational symmetry axis 0154 /// 0155 /// @param gctx The current geometry context object, e.g. alignment 0156 /// 0157 /// @return the z-Axis of transform 0158 virtual Vector3 rotSymmetryAxis(const GeometryContext& gctx) const; 0159 0160 /// This method returns the CylinderBounds by reference 0161 const CylinderBounds& bounds() const final; 0162 0163 /// Local to global transformation 0164 /// 0165 /// @param gctx The current geometry context object, e.g. alignment 0166 /// @param lposition is the local position to be transformed 0167 /// 0168 /// @return The global position by value 0169 Vector3 localToGlobal(const GeometryContext& gctx, 0170 const Vector2& lposition) const final; 0171 0172 /// Global to local transformation 0173 /// 0174 /// @param gctx The current geometry context object, e.g. alignment 0175 /// @param position is the global position to be transformed 0176 /// @param tolerance optional tolerance within which a point is considered 0177 /// valid on surface 0178 /// 0179 /// @return a Result<Vector2> which can be !ok() if the operation fails 0180 Result<Vector2> globalToLocal( 0181 const GeometryContext& gctx, const Vector3& position, 0182 double tolerance = s_onSurfaceTolerance) const final; 0183 0184 /// Straight line intersection schema from position/direction 0185 /// 0186 /// @param gctx The current geometry context object, e.g. alignment 0187 /// @param position The position to start from 0188 /// @param direction The direction at start 0189 /// @param boundaryTolerance the Boundary Check Tolerance 0190 /// @param tolerance the tolerance used for the intersection 0191 /// 0192 /// If possible returns both solutions for the cylinder 0193 /// 0194 /// @return SurfaceIntersection object (contains intersection & surface) 0195 SurfaceMultiIntersection intersect( 0196 const GeometryContext& gctx, const Vector3& position, 0197 const Vector3& direction, 0198 const BoundaryTolerance& boundaryTolerance = 0199 BoundaryTolerance::Infinite(), 0200 ActsScalar tolerance = s_onSurfaceTolerance) const final; 0201 0202 /// Path correction due to incident of the track 0203 /// 0204 /// @param gctx The current geometry context object, e.g. alignment 0205 /// @param position is the global position as a starting point 0206 /// @param direction is the global momentum direction at the starting point 0207 /// 0208 /// @return is the correction factor due to incident 0209 double pathCorrection(const GeometryContext& gctx, const Vector3& position, 0210 const Vector3& direction) const final; 0211 0212 /// Return method for properly formatted output string 0213 std::string name() const override; 0214 0215 /// Return a Polyhedron for a cylinder 0216 /// 0217 /// @param gctx The current geometry context object, e.g. alignment 0218 /// @param lseg Number of segments along curved lines, it represents 0219 /// the full 2*M_PI coverange, if lseg is set to 1 only the extrema 0220 /// are given 0221 /// 0222 /// @return A list of vertices and a face/facett description of it 0223 Polyhedron polyhedronRepresentation(const GeometryContext& gctx, 0224 std::size_t lseg) const override; 0225 0226 /// Calculate the derivative of path length at the geometry constraint or 0227 /// point-of-closest-approach w.r.t. alignment parameters of the surface (i.e. 0228 /// local frame origin in global 3D Cartesian coordinates and its rotation 0229 /// represented with extrinsic Euler angles) 0230 /// 0231 /// @param gctx The current geometry context object, e.g. alignment 0232 /// @param position global 3D position 0233 /// @param direction global 3D momentum direction 0234 /// 0235 /// @return Derivative of path length w.r.t. the alignment parameters 0236 AlignmentToPathMatrix alignmentToPathDerivative( 0237 const GeometryContext& gctx, const Vector3& position, 0238 const Vector3& direction) const final; 0239 0240 /// Calculate the derivative of bound track parameters local position w.r.t. 0241 /// position in local 3D Cartesian coordinates 0242 /// 0243 /// @param gctx The current geometry context object, e.g. alignment 0244 /// @param position The position of the parameters in global 0245 /// 0246 /// @return Derivative of bound local position w.r.t. position in local 3D 0247 /// cartesian coordinates 0248 ActsMatrix<2, 3> localCartesianToBoundLocalDerivative( 0249 const GeometryContext& gctx, const Vector3& position) const final; 0250 0251 /// Merge two cylinder surfaces into a single one. 0252 /// @image html Cylinder_Merging.svg 0253 /// @note The surfaces need to be *compatible*, i.e. have cylinder bounds 0254 /// that align, and have the same radius 0255 /// @param other The other cylinder surface to merge with 0256 /// @param direction The binning direction: either @c binZ or @c binRPhi 0257 /// @param externalRotation If true, any phi rotation is done in the transform 0258 /// @param logger The logger to use 0259 /// @return The merged cylinder surface and a boolean indicating if surfaces are reversed 0260 /// @note The returned boolean is `false` if `this` is *left* or 0261 /// *counter-clockwise* of @p other, and `true` if not. 0262 std::pair<std::shared_ptr<CylinderSurface>, bool> mergedWith( 0263 const CylinderSurface& other, BinningValue direction, 0264 bool externalRotation, const Logger& logger = getDummyLogger()) const; 0265 0266 protected: 0267 std::shared_ptr<const CylinderBounds> m_bounds; //!< bounds (shared) 0268 0269 private: 0270 /// Implementation of the intersection solver 0271 /// 0272 /// <b>mathematical motivation:</b> 0273 /// 0274 /// The cylinder is given by : 0275 /// - cylinder center: ccenter (C) 0276 /// - the direction of the cylinder axis: cdirection (DZ) 0277 /// - the radius r 0278 /// The line is given by : 0279 /// - a reference position : lposition (L0) 0280 /// - the line direction: ldirection (DL) 0281 /// the parametric form for the line is then : L(t) = L0 + t * DL 0282 /// 0283 /// Any point P on infinite cylinder if : 0284 /// ((P - C) x DZ)^2 = r^2 * DZ^2 0285 /// We know that DZ is a unit vector: 0286 /// DZ^2 == 1 0287 /// When expanded with the line equation, this is : 0288 /// ((L0 - C) x DZ + t * (DL x DZ))^2 = r^2 * DZ^2 0289 /// which is a quadratic equation in the form (X + t * Y)^2 = d, where : 0290 /// X = (L0 - C) x DZ 0291 /// Y = DL x DZ 0292 /// d = r^2 * (DZ)^2 0293 /// Now, expand the equation : 0294 /// t^2 * (Y . Y) + t * (2 * (X . Y)) + (X . X) - d = 0 0295 /// => second order equation in the form : a*t^2 + b*t + c = 0 where 0296 /// a = (Y . Y) 0297 /// b = 2 * (X . Y) 0298 /// c = (X . X) - d 0299 /// finally solve the second order equation : a*t^2 + b*t + c = 0 0300 /// reinsertion into the line equation. 0301 /// 0302 /// @return the quadratic equation 0303 detail::RealQuadraticEquation intersectionSolver( 0304 const Transform3& transform, const Vector3& position, 0305 const Vector3& direction) const; 0306 }; 0307 0308 static_assert(RegularSurfaceConcept<CylinderSurface>, 0309 "CylinderSurface does not fulfill RegularSurfaceConcept"); 0310 0311 } // 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 |
![]() ![]() |