Skip to content

Commit

Permalink
De-Template Spacepoint Formation, main branch (2024.10.23.) (#749)
Browse files Browse the repository at this point in the history
* Re-wrote spacepoint formation as a non-templated algorithm.

Renamed the algorithm to traccc::host::silicon_pixel_spacepoint_formation_algorithm,
to make it very clear what the algorithm is doing. Once we introduce logic
for creating spacepoints off of silicon strip measurements, we can see
what to do. (Rename this algorithm, or add a separate algorithm that does
the strip spacepoint creation.)

* Updated all clients to the new (host) spacepoint formation algorithm.
  • Loading branch information
krasznaa authored Oct 24, 2024
1 parent c627770 commit 7bf2c1b
Show file tree
Hide file tree
Showing 18 changed files with 220 additions and 183 deletions.
7 changes: 5 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ traccc_add_library( traccc_core core TYPE SHARED
"src/seeding/seed_finding.cpp"
"include/traccc/seeding/spacepoint_binning.hpp"
"src/seeding/spacepoint_binning.cpp"
"include/traccc/seeding/spacepoint_formation_algorithm.hpp"
"include/traccc/seeding/impl/spacepoint_formation_algorithm.ipp"
"include/traccc/seeding/detail/spacepoint_formation.hpp"
"include/traccc/seeding/impl/spacepoint_formation.ipp"
"src/seeding/silicon_pixel_spacepoint_formation.hpp"
"include/traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"
"src/seeding/silicon_pixel_spacepoint_formation_algorithm.cpp"
"src/seeding/silicon_pixel_spacepoint_formation_algorithm_defdet.cpp"
"src/seeding/silicon_pixel_spacepoint_formation_algorithm_teldet.cpp"
# Ambiguity resolution
"include/traccc/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.hpp"
"src/ambiguity_resolution/greedy_ambiguity_resolution_algorithm.cpp" )
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2021-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Library include(s).
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/spacepoint.hpp"
#include "traccc/geometry/detector.hpp"
#include "traccc/utils/algorithm.hpp"

// VecMem include(s).
#include <vecmem/memory/memory_resource.hpp>

// System include(s).
#include <functional>

namespace traccc::host {

/// Algorithm forming space points out of measurements
///
/// This algorithm performs the local-to-global transformation of the 2D
/// measurements made on every detector module, into 3D spacepoint coordinates.
///
class silicon_pixel_spacepoint_formation_algorithm
: public algorithm<spacepoint_collection_types::host(
const default_detector::host&,
const measurement_collection_types::const_view&)>,
public algorithm<spacepoint_collection_types::host(
const telescope_detector::host&,
const measurement_collection_types::const_view&)> {

public:
/// Output type
using output_type = spacepoint_collection_types::host;

/// Constructor for spacepoint_formation
///
/// @param mr is the memory resource
///
silicon_pixel_spacepoint_formation_algorithm(vecmem::memory_resource& mr);

/// Construct spacepoints from 2D silicon pixel measurements
///
/// @param det Detector object
/// @param measurements A collection of measurements
/// @return A spacepoint container, with one spacepoint for every
/// silicon pixel measurement
///
output_type operator()(
const default_detector::host& det,
const measurement_collection_types::const_view&) const override;

/// Construct spacepoints from 2D silicon pixel measurements
///
/// @param det Detector object
/// @param measurements A collection of measurements
/// @return A spacepoint container, with one spacepoint for every
/// silicon pixel measurement
///
output_type operator()(
const telescope_detector::host& det,
const measurement_collection_types::const_view&) const override;

private:
/// Memory resource to use for the output container
std::reference_wrapper<vecmem::memory_resource> m_mr;

}; // class silicon_pixel_spacepoint_formation_algorithm

} // namespace traccc::host
58 changes: 0 additions & 58 deletions core/include/traccc/seeding/spacepoint_formation_algorithm.hpp

This file was deleted.

55 changes: 55 additions & 0 deletions core/src/seeding/silicon_pixel_spacepoint_formation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Local include(s).
#include "traccc/edm/measurement.hpp"
#include "traccc/edm/spacepoint.hpp"
#include "traccc/seeding/detail/spacepoint_formation.hpp"

// VecMem include(s).
#include <vecmem/memory/memory_resource.hpp>

namespace traccc::host::details {

/// Common implementation for the spacepoint formation algorithm's execute
/// functions
///
/// @tparam detector_t The detector type to use
///
/// @param det The detector object
/// @param measurements_view The view of the measurements to process
/// @param mr The memory resource to create the output with
/// @return A container of the created spacepoints
///
template <typename detector_t>
spacepoint_collection_types::host silicon_pixel_spacepoint_formation(
const detector_t& det,
const measurement_collection_types::const_view& measurements_view,
vecmem::memory_resource& mr) {

// Create a device container for the input.
const measurement_collection_types::const_device measurements{
measurements_view};

// Create the result container.
spacepoint_collection_types::host result(&mr);
result.reserve(measurements.size());

// Set up each spacepoint in the result container.
for (const auto& meas : measurements) {
if (traccc::details::is_valid_measurement(meas)) {
result.push_back(traccc::details::create_spacepoint(det, meas));
}
}

// Return the created container.
return result;
}

} // namespace traccc::host::details
17 changes: 17 additions & 0 deletions core/src/seeding/silicon_pixel_spacepoint_formation_algorithm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Library include(s).
#include "traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"

namespace traccc::host {

silicon_pixel_spacepoint_formation_algorithm::
silicon_pixel_spacepoint_formation_algorithm(vecmem::memory_resource& mr)
: m_mr(mr) {}

} // namespace traccc::host
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Library include(s).
#include "silicon_pixel_spacepoint_formation.hpp"
#include "traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"

namespace traccc::host {

silicon_pixel_spacepoint_formation_algorithm::output_type
silicon_pixel_spacepoint_formation_algorithm::operator()(
const default_detector::host& det,
const measurement_collection_types::const_view& meas) const {

return details::silicon_pixel_spacepoint_formation(det, meas, m_mr);
}

} // namespace traccc::host
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2022-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

// Library include(s).
#include "silicon_pixel_spacepoint_formation.hpp"
#include "traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"

namespace traccc::host {

silicon_pixel_spacepoint_formation_algorithm::output_type
silicon_pixel_spacepoint_formation_algorithm::operator()(
const telescope_detector::host& det,
const measurement_collection_types::const_view& meas) const {

return details::silicon_pixel_spacepoint_formation(det, meas, m_mr);
}

} // namespace traccc::host
43 changes: 0 additions & 43 deletions core/src/seeding/spacepoint_formation_algorithm.cpp

This file was deleted.

8 changes: 3 additions & 5 deletions examples/run/alpaka/seq_example_alpaka.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "traccc/performance/container_comparator.hpp"
#include "traccc/performance/timer.hpp"
#include "traccc/seeding/seeding_algorithm.hpp"
#include "traccc/seeding/spacepoint_formation_algorithm.hpp"
#include "traccc/seeding/silicon_pixel_spacepoint_formation_algorithm.hpp"
#include "traccc/seeding/track_params_estimation.hpp"

// VecMem include(s).
Expand Down Expand Up @@ -121,8 +121,7 @@ int seq_run(const traccc::opts::detector& detector_opts,

// Type definitions
using host_spacepoint_formation_algorithm =
traccc::host::spacepoint_formation_algorithm<
traccc::default_detector::host>;
traccc::host::silicon_pixel_spacepoint_formation_algorithm;
using device_spacepoint_formation_algorithm =
traccc::alpaka::spacepoint_formation_algorithm<
traccc::default_detector::device>;
Expand Down Expand Up @@ -156,8 +155,7 @@ int seq_run(const traccc::opts::detector& detector_opts,
// Instantiate host containers/collections
traccc::host::clusterization_algorithm::output_type
measurements_per_event;
traccc::host::spacepoint_formation_algorithm<
traccc::default_detector::host>::output_type spacepoints_per_event;
host_spacepoint_formation_algorithm::output_type spacepoints_per_event;
traccc::seeding_algorithm::output_type seeds;
traccc::track_params_estimation::output_type params;

Expand Down
Loading

0 comments on commit 7bf2c1b

Please sign in to comment.