![]() |
|
|||
File indexing completed on 2025-10-13 08:15:56
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/Units.hpp" 0012 #include "Acts/EventData/SpacePointContainer2.hpp" 0013 #include "Acts/Utilities/KDTree.hpp" 0014 #include "Acts/Utilities/Logger.hpp" 0015 0016 #include <vector> 0017 0018 namespace Acts::Experimental { 0019 0020 /// A cylindrical space point KD-tree used for seeding in a cylindrical detector 0021 /// geometry. 0022 /// The tree is defined in cylindrical coordinates (phi, r, z) and allows for 0023 /// efficient access to space points based on their azimuthal angle, 0024 /// radial distance, and z-coordinate. 0025 class CylindricalSpacePointKDTree { 0026 public: 0027 /// Space point index type used in the grid. 0028 using SpacePointIndex = std::uint32_t; 0029 0030 /// @brief Set the number of dimensions in which to embed points. This is just 0031 /// 3 for now (phi, r, and z), but we might want to increase or decrease this 0032 /// number in the future. 0033 static constexpr std::size_t NDims = 3; 0034 0035 /// @brief Enumeration of the different dimensions in which we can apply cuts. 0036 enum Dim { DimPhi = 0, DimR = 1, DimZ = 2 }; 0037 0038 /// @brief The k-d tree type used by this seeder internally, which is 0039 /// three-dimensional, contains internal spacepoint pointers, uses the Acts 0040 /// scalar type for coordinates, stores its coordinates in std::arrays, and 0041 /// has leaf size 4. 0042 using Tree = KDTree<NDims, SpacePointIndex, float, std::array, 4>; 0043 0044 struct Options { 0045 /// maximum extension of sensitive detector layer relevant for seeding as 0046 /// distance from x=y=0 (i.e. in r) 0047 float rMax = 600 * UnitConstants::mm; 0048 /// minimum extension of sensitive detector layer relevant for seeding in 0049 /// negative direction in z 0050 float zMin = -2800 * UnitConstants::mm; 0051 /// maximum extension of sensitive detector layer relevant for seeding in 0052 /// positive direction in z 0053 float zMax = 2800 * UnitConstants::mm; 0054 /// minimum phi value for phiAxis construction 0055 float phiMin = -std::numbers::pi_v<float>; 0056 /// maximum phi value for phiAxis construction 0057 float phiMax = std::numbers::pi_v<float>; 0058 0059 /// Minimum radial distance between two doublet components 0060 float deltaRMin = 5 * UnitConstants::mm; 0061 /// Maximum radial distance between two doublet components 0062 float deltaRMax = 270 * UnitConstants::mm; 0063 0064 /// Minimal z distance between two doublet components 0065 float deltaZMin = -std::numeric_limits<float>::infinity(); 0066 /// Maximum z distance between two doublet components 0067 float deltaZMax = std::numeric_limits<float>::infinity(); 0068 0069 /// Limiting location of collision region in z-axis used to check if doublet 0070 /// origin is within reasonable bounds 0071 float collisionRegionMin = -150 * UnitConstants::mm; 0072 float collisionRegionMax = +150 * UnitConstants::mm; 0073 0074 /// Maximum allowed cotTheta between two space-points in doublet, used to 0075 /// check if forward angle is within bounds 0076 float cotThetaMax = 10.01788; // equivalent to eta = 3 (pseudorapidity) 0077 0078 /// Shrink the phi range of middle space-point (analogous to phi bin size in 0079 /// grid from default seeding + number of phi bins used in search) 0080 float deltaPhiMax = 0.085; 0081 }; 0082 0083 struct Candidates { 0084 /// denotes the candidates bottom seed points, assuming that the track has 0085 /// monotonically _increasing_ z position 0086 std::vector<SpacePointIndex> bottom_lh_v; 0087 /// denotes the candidate bottom points assuming that the track has 0088 /// monotonically _decreasing_ z position 0089 std::vector<SpacePointIndex> bottom_hl_v; 0090 /// are the candidate top points for an increasing z track 0091 std::vector<SpacePointIndex> top_lh_v; 0092 /// are the candidate top points for a decreasing z track 0093 std::vector<SpacePointIndex> top_hl_v; 0094 0095 void reserve(std::size_t n) { 0096 bottom_lh_v.reserve(n); 0097 bottom_hl_v.reserve(n); 0098 top_lh_v.reserve(n); 0099 top_hl_v.reserve(n); 0100 } 0101 0102 void clear() { 0103 bottom_lh_v.clear(); 0104 bottom_hl_v.clear(); 0105 top_lh_v.clear(); 0106 top_hl_v.clear(); 0107 } 0108 }; 0109 0110 /// Construct a cylindrical space point grid with the given configuration and 0111 /// an optional logger. 0112 explicit CylindricalSpacePointKDTree( 0113 Tree tree, std::unique_ptr<const Logger> logger = getDefaultLogger( 0114 "CylindricalSpacePointKDTree", Logging::Level::INFO)); 0115 0116 std::size_t size() const { return m_tree.size(); } 0117 0118 auto begin() const { return m_tree.begin(); } 0119 auto end() const { return m_tree.end(); } 0120 0121 Tree::range_t validTupleOrthoRangeLH(const Options& options, 0122 const ConstSpacePointProxy2& low) const; 0123 Tree::range_t validTupleOrthoRangeHL(const Options& options, 0124 const ConstSpacePointProxy2& high) const; 0125 0126 void validTuples(const Options& lhOptions, const Options& hlOptions, 0127 const ConstSpacePointProxy2& spM, std::size_t nTopSeedConf, 0128 Candidates& candidates) const; 0129 0130 private: 0131 Tree m_tree; 0132 0133 std::unique_ptr<const Logger> m_logger; 0134 0135 const Logger& logger() const { return *m_logger; } 0136 }; 0137 0138 class CylindricalSpacePointKDTreeBuilder { 0139 public: 0140 /// Space point index type used in the grid. 0141 using SpacePointIndex = CylindricalSpacePointKDTree::SpacePointIndex; 0142 0143 /// @brief Set the number of dimensions in which to embed points. This is just 0144 /// 3 for now (phi, r, and z), but we might want to increase or decrease 0145 /// this number in the future. 0146 static constexpr std::size_t NDims = CylindricalSpacePointKDTree::NDims; 0147 0148 /// @brief Enumeration of the different dimensions in which we can apply cuts. 0149 using Dim = CylindricalSpacePointKDTree::Dim; 0150 0151 /// @brief The k-d tree type used by this seeder internally, which is 0152 /// three-dimensional, contains internal spacepoint pointers, uses the Acts 0153 /// scalar type for coordinates, stores its coordinates in std::arrays, and 0154 /// has leaf size 4. 0155 using Tree = CylindricalSpacePointKDTree::Tree; 0156 0157 /// Construct a cylindrical space point grid with the given configuration 0158 /// and an optional logger. 0159 explicit CylindricalSpacePointKDTreeBuilder( 0160 std::unique_ptr<const Logger> logger = getDefaultLogger( 0161 "CylindricalSpacePointKDTree", Logging::Level::INFO)); 0162 0163 /// Get the number of space points in the grid. 0164 /// @return The number of space points in the grid 0165 std::size_t size() const { return m_points.size(); } 0166 0167 void reserve(std::size_t n) { m_points.reserve(n); } 0168 0169 /// Clear the grid and drop all state. The object will behave like a newly 0170 /// constructed one. 0171 void clear() { m_points.clear(); } 0172 0173 /// Insert a space point into the grid. 0174 /// @param index The index of the space point to insert 0175 /// @param phi The azimuthal angle of the space point in radians 0176 /// @param r The radial distance of the space point from the origin 0177 /// @param z The z-coordinate of the space point 0178 /// @return The index of the bin in which the space point was inserted, or 0179 /// `std::nullopt` if the space point is outside the grid bounds. 0180 void insert(SpacePointIndex index, float phi, float r, float z); 0181 /// Insert a space point into the grid. 0182 /// @param sp The space point to insert 0183 /// @return The index of the bin in which the space point was inserted, or 0184 /// `std::nullopt` if the space point is outside the grid bounds. 0185 void insert(const ConstSpacePointProxy2& sp) { 0186 return insert(sp.index(), sp.phi(), sp.r(), sp.z()); 0187 } 0188 0189 /// Fill the grid with space points from the container. 0190 /// @param spacePoints The space point container to fill the grid with 0191 void extend(const SpacePointContainer2::ConstRange& spacePoints); 0192 0193 CylindricalSpacePointKDTree build(); 0194 0195 private: 0196 std::unique_ptr<const Logger> m_logger; 0197 0198 std::vector<Tree::pair_t> m_points; 0199 0200 const Logger& logger() const { return *m_logger; } 0201 }; 0202 0203 } // namespace Acts::Experimental
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |