Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:03

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2021-2025 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Local include(s).
0009 #include "traccc/seeding/detail/seed_finding.hpp"
0010 
0011 #include "doublet_finding.hpp"
0012 #include "seed_filtering.hpp"
0013 #include "triplet_finding.hpp"
0014 
0015 namespace traccc::host::details {
0016 
0017 struct seed_finding::impl {
0018   /// Constructor
0019   impl(const seedfinder_config& finder_config,
0020        const seedfilter_config& filter_config, vecmem::memory_resource& mr,
0021        std::unique_ptr<const Logger> logger)
0022       : m_midBot_finding(finder_config, mr,
0023                          logger->cloneWithSuffix("MidBotAlg")),
0024         m_midTop_finding(finder_config, mr,
0025                          logger->cloneWithSuffix("MidTopAlg")),
0026         m_triplet_finding(finder_config, filter_config, mr,
0027                           logger->cloneWithSuffix("TripletAlg")),
0028         m_seed_filtering(finder_config, filter_config, mr,
0029                          logger->cloneWithSuffix("FilterAlg")),
0030         m_mr{mr} {}
0031 
0032   /// Algorithm performing the mid bottom doublet finding
0033   doublet_finding<traccc::details::spacepoint_type::bottom> m_midBot_finding;
0034   /// Algorithm performing the mid top doublet finding
0035   doublet_finding<traccc::details::spacepoint_type::top> m_midTop_finding;
0036   /// Algorithm performing the triplet finding
0037   triplet_finding m_triplet_finding;
0038   /// Algorithm performing the seed selection
0039   seed_filtering m_seed_filtering;
0040   /// The memory resource to use
0041   vecmem::memory_resource& m_mr;
0042 };
0043 
0044 seed_finding::seed_finding(const seedfinder_config& finder_config,
0045                            const seedfilter_config& filter_config,
0046                            vecmem::memory_resource& mr,
0047                            std::unique_ptr<const Logger> logger)
0048     : messaging(logger->clone()),
0049       m_impl{std::make_unique<impl>(finder_config, filter_config, mr,
0050                                     std::move(logger))} {}
0051 
0052 seed_finding::seed_finding(seed_finding&&) noexcept = default;
0053 
0054 seed_finding::~seed_finding() = default;
0055 
0056 seed_finding& seed_finding::operator=(seed_finding&&) noexcept = default;
0057 
0058 edm::seed_collection::host seed_finding::operator()(
0059     const edm::spacepoint_collection::const_view& sp_view,
0060     const traccc::details::spacepoint_grid_types::host& sp_grid) const {
0061   // Create the result collection.
0062   edm::seed_collection::host seeds{m_impl->m_mr};
0063 
0064   // Create a device container for the spacepoints.
0065   const edm::spacepoint_collection::const_device spacepoints{sp_view};
0066 
0067   // Iterate over the spacepoint grid's bins.
0068   for (unsigned int i = 0; i < sp_grid.nbins(); ++i) {
0069     // Consider all spacepoints in this bin as "middle" spacepoints in the
0070     // seed.
0071     const auto& middle_indices = sp_grid.bin(i);
0072 
0073     // Evaluate these middle spacepoints one-by-one.
0074     for (unsigned int j = 0; j < middle_indices.size(); ++j) {
0075       // Internal identifier for this middle spacepoint.
0076       sp_location spM_location({i, j});
0077 
0078       // middule-bottom doublet search
0079       const auto mid_bot =
0080           m_impl->m_midBot_finding(spacepoints, sp_grid, spM_location);
0081 
0082       if (mid_bot.first.empty()) {
0083         continue;
0084       }
0085 
0086       // middule-top doublet search
0087       const auto mid_top =
0088           m_impl->m_midTop_finding(spacepoints, sp_grid, spM_location);
0089 
0090       if (mid_top.first.empty()) {
0091         continue;
0092       }
0093 
0094       triplet_collection_types::host triplets{&m_impl->m_mr};
0095 
0096       // triplet search from the combinations of two doublets which
0097       // share middle spacepoint
0098       for (unsigned int k = 0; k < mid_bot.first.size(); ++k) {
0099         const doublet& mid_bot_doublet = mid_bot.first[k];
0100         const lin_circle& mid_bot_lc = mid_bot.second[k];
0101 
0102         const triplet_collection_types::host triplets_for_mid_bot =
0103             m_impl->m_triplet_finding(spacepoints, sp_grid, mid_bot_doublet,
0104                                       mid_bot_lc, mid_top.first,
0105                                       mid_top.second);
0106 
0107         triplets.insert(triplets.end(), triplets_for_mid_bot.begin(),
0108                         triplets_for_mid_bot.end());
0109       }
0110 
0111       // seed filtering
0112       m_impl->m_seed_filtering(spacepoints, sp_grid, triplets, seeds);
0113     }
0114   }
0115 
0116   return seeds;
0117 }
0118 
0119 }  // namespace traccc::host::details