Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2022-2024 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Library include(s).
0009 #include "traccc/clusterization/sparse_ccl_algorithm.hpp"
0010 
0011 #include "traccc/clusterization/details/sparse_ccl.hpp"
0012 #include "traccc/sanity/contiguous_on.hpp"
0013 #include "traccc/sanity/ordered_on.hpp"
0014 #include "traccc/utils/projections.hpp"
0015 #include "traccc/utils/relations.hpp"
0016 
0017 // VecMem include(s).
0018 #include <vecmem/containers/device_vector.hpp>
0019 #include <vecmem/containers/vector.hpp>
0020 
0021 namespace traccc::host {
0022 
0023 sparse_ccl_algorithm::sparse_ccl_algorithm(vecmem::memory_resource& mr,
0024                                            std::unique_ptr<const Logger> logger)
0025     : messaging(std::move(logger)), m_mr(mr) {}
0026 
0027 sparse_ccl_algorithm::output_type sparse_ccl_algorithm::operator()(
0028     const edm::silicon_cell_collection::const_view& cells_view,
0029     const detector_conditions_description::const_view& det_cond_view) const {
0030   // Construct the device view of the cells.
0031   const edm::silicon_cell_collection::const_device cells{cells_view};
0032   const detector_conditions_description::const_device det_cond{det_cond_view};
0033 
0034   // Run some sanity checks on it.
0035   assert(is_contiguous_on(cell_module_projection(), cells));
0036   assert(is_ordered_on(channel0_major_cell_order_relation(), cells));
0037 
0038   // Run SparseCCL to fill CCL indices.
0039   vecmem::vector<unsigned int> cluster_indices{cells.size(), &(m_mr.get())};
0040   vecmem::device_vector<unsigned int> cluster_indices_device{
0041       vecmem::get_data(cluster_indices)};
0042   const unsigned int num_clusters =
0043       details::sparse_ccl(cells, cluster_indices_device);
0044 
0045   // Create the result container.
0046   output_type clusters{m_mr.get()};
0047   clusters.resize(num_clusters);
0048 
0049   // Add cells to their clusters.
0050   for (unsigned int cell_idx = 0; cell_idx < cluster_indices.size();
0051        ++cell_idx) {
0052     clusters.cell_indices()[cluster_indices[cell_idx]].push_back(cell_idx);
0053   }
0054 
0055   // Return the clusters.
0056   return clusters;
0057 }
0058 
0059 }  // namespace traccc::host