Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:24:50

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/Geometry/GeometryContext.hpp"
0013 #include "Acts/Surfaces/detail/IntersectionHelper2D.hpp"
0014 #include "Acts/Utilities/Result.hpp"
0015 
0016 #include <array>
0017 #include <vector>
0018 
0019 namespace Acts {
0020 class Surface;
0021 class AnnulusBounds;
0022 class RadialBounds;
0023 class CylinderBounds;
0024 }  // namespace Acts
0025 
0026 namespace ActsFatras {
0027 
0028 /// A brief struct that allows to apply a surface bound mask.
0029 ///
0030 /// A single implementation handles all supported surface types, dispatched
0031 /// internally on `surface.type()`:
0032 ///   - Plane / Disc / DiscTrapezoid : polygon, radial or annulus masking in
0033 ///     the Cartesian / polar local frame.
0034 ///   - Cylinder : axis-aligned rectangle clipping in the unrolled (rPhi, z)
0035 ///     readout frame.
0036 struct SurfaceMask {
0037   /// Shorthand for a 2-d segment;
0038   using Segment2D = std::array<Acts::Vector2, 2>;
0039 
0040   /// Apply the mask on the segment
0041   /// - If the segment is fully inside the surface, return unchanged
0042   /// - Otherwise mask/clip the segment to fit into the bounds
0043   ///
0044   /// @note PlaneSurface/DiscSurface/CylinderSurface are supported
0045   ///
0046   /// @note If both end points of the segment are inside, the segment
0047   /// is not clipped/masked, even if it would cross a surface boundary.
0048   /// Examples for those would be non-covex polygons or segments on a
0049   /// radial bound, where the radial boundary is crossed. Such segments
0050   /// do not occur in Digitization, as the hit has to be inside the
0051   /// surface bounds to start with.
0052   ///
0053   /// @param surface The surface in question
0054   /// @param segment The track segment (on surface)
0055   ///
0056   /// @return a result wrapping a segment
0057   Acts::Result<Segment2D> apply(const Acts::Surface& surface,
0058                                 const Segment2D& segment) const;
0059 
0060   /// Apply the mask of a polygon
0061   ///
0062   /// @param vertices The vertices of the polygon
0063   /// @param segment The track segment (on surface)
0064   /// @param firstInside The indicator if the first is inside
0065   ///
0066   /// @return a result wrapping a segment
0067   Acts::Result<Segment2D> polygonMask(
0068       const std::vector<Acts::Vector2>& vertices, const Segment2D& segment,
0069       bool firstInside) const;
0070 
0071   /// Apply the mask of a Radial disk
0072   ///
0073   /// @param rBounds The radial disc for the masking
0074   /// @param segment The track segment (on surface)
0075   /// @param polarSegment The track segment (on surface, in polar)
0076   /// @param firstInside The indicator if the first is inside
0077   ///
0078   /// @return a result wrapping a segment
0079   Acts::Result<Segment2D> radialMask(const Acts::RadialBounds& rBounds,
0080                                      const Segment2D& segment,
0081                                      const Segment2D& polarSegment,
0082                                      bool firstInside) const;
0083 
0084   /// Apply the mask of an annulus disk
0085   ///
0086   /// @param aBounds The annulus disc for the masking
0087   /// @param segment The track segment (on surface)
0088   /// @param firstInside The indicator if the first is inside
0089   ///
0090   /// @return a result wrapping a segment
0091   Acts::Result<Segment2D> annulusMask(const Acts::AnnulusBounds& aBounds,
0092                                       const Segment2D& segment,
0093                                       bool firstInside) const;
0094 
0095   /// Apply the mask of a cylinder (axis-aligned rectangle in (rPhi, z))
0096   ///
0097   /// @param cBounds The cylinder bounds for the masking
0098   /// @param segment The track segment in the unrolled (rPhi, z) frame
0099   ///
0100   /// @return a result wrapping a segment
0101   Acts::Result<Segment2D> cylinderMask(const Acts::CylinderBounds& cBounds,
0102                                        const Segment2D& segment) const;
0103 
0104   /// 2D intersection helper for geometric calculations
0105   Acts::detail::IntersectionHelper2D intersector{};
0106 };
0107 
0108 }  // namespace ActsFatras