Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-27 07:26:29

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/EventData/SpacePointMutableData.hpp"
0012 #include "Acts/Seeding/SeedFilter.hpp"
0013 #include "Acts/Seeding/SeedFinderConfig.hpp"
0014 #include "Acts/Seeding/SeedFinderOrthogonalConfig.hpp"
0015 #include "Acts/Utilities/KDTree.hpp"
0016 #include "Acts/Utilities/Logger.hpp"
0017 
0018 #include <array>
0019 #include <memory>
0020 #include <string>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 /// Orthogonal range-search based seed finder.
0026 template <typename external_space_point_t>
0027 class [[deprecated(
0028     "Will be dropped soon and is replaced by "
0029     "TripletSeeder")]] SeedFinderOrthogonal {
0030  public:
0031   /**
0032    * @brief Set the number of dimensions in which to embed points. This is just
0033    * 3 for now (phi, r, and z), but we might want to increase or decrease this
0034    * number in the future.
0035    */
0036   static constexpr std::size_t NDims = 3;
0037 
0038   /**
0039    * @brief The seed type used by this seeder internally.
0040    */
0041   using seed_t = Seed<external_space_point_t>;
0042 
0043   /**
0044    * @brief The k-d tree type used by this seeder internally, which is
0045    * three-dimensional, contains internal space point pointers, uses the Acts
0046    * scalar type for coordinates, stores its coordinates in std::arrays, and
0047    * has leaf size 4.
0048    */
0049   using tree_t =
0050       KDTree<NDims, const external_space_point_t *, double, std::array, 4>;
0051 
0052   /**
0053    * @brief Construct a new orthogonal seed finder.
0054    *
0055    * @param config The configuration parameters for this seed finder.
0056    * @param logger The ACTS logger.
0057    */
0058   explicit SeedFinderOrthogonal(
0059       const Acts::SeedFinderOrthogonalConfig<external_space_point_t> &config,
0060       std::unique_ptr<const Acts::Logger> logger =
0061           Acts::getDefaultLogger("Finder", Logging::Level::INFO));
0062   /**
0063    * @brief Destroy the orthogonal seed finder object.
0064    */
0065   ~SeedFinderOrthogonal() = default;
0066 
0067   SeedFinderOrthogonal() = default;
0068   SeedFinderOrthogonal(const SeedFinderOrthogonal<external_space_point_t> &) =
0069       delete;
0070   SeedFinderOrthogonal<external_space_point_t> &operator=(
0071       const SeedFinderOrthogonal<external_space_point_t> &) = delete;
0072   /// Move constructor
0073   SeedFinderOrthogonal(
0074       SeedFinderOrthogonal<external_space_point_t> &&) noexcept = default;
0075   /// Move assignment operator
0076   /// @return Reference to this object
0077   SeedFinderOrthogonal<external_space_point_t> &operator=(
0078       SeedFinderOrthogonal<external_space_point_t> &&) noexcept = default;
0079 
0080   /**
0081    * @brief Perform seed finding, appending seeds to a container.
0082    *
0083    * This method performs seed finding through an orthogonal range search
0084    * strategy. This strategy differs from binning approaches because it selects
0085    * seeds _constructively_ rather than _destructively_; instead of trying a
0086    * large number of possible space point combinations and then rejecting many
0087    * of them, this algorithm tries to only consider valid seed candidates to
0088    * reduce combinatorics.
0089    *
0090    * In addition, this algorithm replaces the binning step used in other seed
0091    * finding algorithms with the construction of a k-d tree, which allows us to
0092    * efficiently search for space points within a given range.
0093    *
0094    * The core idea behind this algorithm is to create axis-aligned bounding
0095    * boxes around the region of validity for a seed candidate (be it a bottom
0096    * space point for a given middle, a top for a given middle, a middle for a
0097    * given bottom, or any other combination), and then searching the detector
0098    * volume for points that lie inside that AABB.
0099    *
0100    * @tparam input_container_t The type of the input space point container.
0101    * @tparam output_container_t The type of the output seed container.
0102    *
0103    * @param options frequently changing configuration (like beam position)
0104    * @param spacePoints The input space points from which to create seeds.
0105    * @param out_cont The output container to write seeds to.
0106    * covariance of the external space point
0107    */
0108   template <typename input_container_t, typename output_container_t>
0109   void createSeeds(const Acts::SeedFinderOptions &options,
0110                    const input_container_t &spacePoints,
0111                    output_container_t &out_cont) const;
0112 
0113   /**
0114    * @brief Perform seed finding, returning a new container of seeds.
0115    *
0116    * This is a filterCandidates method for scenarios where a non-inserter API is
0117    * more ergonomic. In general, the inserter-based method should be preferred
0118    * as it is more flexible and usually more performant. For more information
0119    * about the seeding algorithm, please see that function.
0120    *
0121    * @tparam input_container_t The type of the input space point container.
0122    * @param options frequently changing configuration (like beam position)
0123    * @param spacePoints The input space points from which to create seeds.
0124    * covariance of the external space point
0125    *
0126    * @return A vector of seeds.
0127    */
0128   template <typename input_container_t>
0129   std::vector<seed_t> createSeeds(const Acts::SeedFinderOptions &options,
0130                                   const input_container_t &spacePoints) const;
0131 
0132  private:
0133   /**
0134    * @brief Enumeration of the different dimensions in which we can apply cuts.
0135    */
0136   enum Dim { DimPhi = 0, DimR = 1, DimZ = 2 };
0137 
0138   /**
0139    * @brief Return the AABB search range for a given space point, searching
0140    * upwards.
0141    *
0142    * This function calculates an axis-aligned bounding box around the volume of
0143    * validity for the next space point in a pair, given that the lower
0144    * space point is given. Thus, this method either takes a bottom space point
0145    * and returns a range for the middle space point, or it takes a middle
0146    * space point and returns the range for the top space point.
0147    *
0148    * @param low The lower space point to find a partner for.
0149    *
0150    * @return An N-dimensional axis-aligned search range.
0151    */
0152   typename tree_t::range_t validTupleOrthoRangeLH(
0153       const external_space_point_t &low) const;
0154 
0155   /**
0156    * @brief Return the AABB search range for a given space point, searching
0157    * downward.
0158    *
0159    * This function calculates an axis-aligned bounding box around the volume of
0160    * validity for the next space point in a pair, given that the upper
0161    * space point is given. Thus, this method either takes a middle space point
0162    * and returns a range for the bottom space point, or it takes a top
0163    * space point and returns the range for the middle space point.
0164    *
0165    * @param high The upper space point to find a partner for.
0166    *
0167    * @return An N-dimensional axis-aligned search range.
0168    */
0169   typename tree_t::range_t validTupleOrthoRangeHL(
0170       const external_space_point_t &high) const;
0171 
0172   /**
0173    * @brief Check whether two space points form a valid tuple.
0174    *
0175    * This method checks whether the cuts that we have for pairs of space points
0176    * hold.
0177    *
0178    * @warning This method checks ONLY those constraints that cannot be exactly
0179    * represented as bounding boxes. Thus, this method should not be used on
0180    * pairs of points that were not generated using a constrained spatial search
0181    * strategy.
0182    *
0183    * @param options frequently changing configuration (like beam position)
0184    * @param low The lower space point.
0185    * @param high The upper space point.
0186    * @param isMiddleInverted If middle space point is in the negative z region
0187    *
0188    * @return True if the two points form a valid pair, false otherwise.
0189    */
0190   bool validTuple(const SeedFinderOptions &options,
0191                   const external_space_point_t &low,
0192                   const external_space_point_t &high,
0193                   bool isMiddleInverted) const;
0194 
0195   /**
0196    * @brief Create a k-d tree from a set of space points.
0197    *
0198    * @param spacePoints The space points to create a tree from.
0199    *
0200    * @return A k-d tree containing the given space points.
0201    */
0202   tree_t createTree(
0203       const std::vector<const external_space_point_t *> &spacePoints) const;
0204 
0205   /**
0206    * @brief Filter potential candidate pairs, and output seeds into an
0207    * iterator.
0208    *
0209    * @param options frequently changing configuration (like beam position)
0210    * @param mutableData Container for mutable variables used in the seeding
0211    * @param middle The (singular) middle space point.
0212    * @param bottom The (vector of) candidate bottom space points.
0213    * @param top The (vector of) candidate top space points.
0214    * @param seedFilterState  holds quantities used in seed filter
0215    * @param candidates_collector The container to write the resulting
0216    * seed candidates to.
0217    */
0218   void filterCandidates(
0219       const SeedFinderOptions &options,
0220       Acts::SpacePointMutableData &mutableData,
0221       const external_space_point_t &middle,
0222       const std::vector<const external_space_point_t *> &bottom,
0223       const std::vector<const external_space_point_t *> &top,
0224       SeedFilterState seedFilterState,
0225       CandidatesForMiddleSp<const external_space_point_t> &candidates_collector)
0226       const;
0227 
0228   /**
0229    * @brief Search for seeds starting from a given middle space point.
0230    *
0231    * @param options frequently changing configuration (like beam position)
0232    * @param mutableData Container for mutable variables used in the seeding
0233    * @tparam NDims Number of dimensions for our spatial embedding (probably 3).
0234    * @tparam output_container_t Type of the output container.
0235    *
0236    * @param tree The k-d tree to use for searching.
0237    * @param out_cont The container write output seeds to.
0238    * @param middle_p The middle space point to find seeds for.
0239    */
0240   template <typename output_container_t>
0241   void processFromMiddleSP(const SeedFinderOptions &options,
0242                            Acts::SpacePointMutableData &mutableData,
0243                            const tree_t &tree, output_container_t &out_cont,
0244                            const typename tree_t::pair_t &middle_p) const;
0245 
0246   /**
0247    * @brief The configuration for the seeding algorithm.
0248    */
0249   Acts::SeedFinderOrthogonalConfig<external_space_point_t> m_config;
0250 
0251   /**
0252    * @brief Get the logger.
0253    */
0254   const Logger &logger() const { return *m_logger; }
0255 
0256   /**
0257    * @brief The logger
0258    */
0259   std::unique_ptr<const Acts::Logger> m_logger{getDummyLogger().clone()};
0260 };
0261 }  // namespace Acts
0262 
0263 #include "Acts/Seeding/SeedFinderOrthogonal.ipp"