Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ include( traccc-functions )
set( TRACCC_CUSTOM_SCALARTYPE "float" CACHE STRING
"Scalar type to use in the TRACCC code" )

# Temporary setting for the traccc device log level, until it can be removed.
set( TRACCC_DEVICE_LOG_LVL "NONE" CACHE STRING
"Log level for traccc and detray device code" )

# Flags controlling which parts of traccc to build.
option( TRACCC_BUILD_CUDA "Build the CUDA sources included in traccc" FALSE )
option( TRACCC_BUILD_HIP "Build the HIP sources included in traccc" FALSE)
Expand Down
17 changes: 7 additions & 10 deletions core/include/traccc/edm/track_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/definitions/track_parametrization.hpp"
#include "traccc/edm/container.hpp"
#include "traccc/utils/trigonometric_helpers.hpp"

// detray include(s).
#include <detray/tracks/tracks.hpp>
Expand Down Expand Up @@ -48,19 +49,15 @@ using bound_track_parameters_collection_types =

// Wrap the phi of track parameters to [-pi,pi]
template <detray::concepts::algebra algebra_t>
TRACCC_HOST_DEVICE inline void wrap_phi(
TRACCC_HOST_DEVICE constexpr void normalize_angles(
bound_track_parameters<algebra_t>& param) {
traccc::scalar phi;
traccc::scalar theta;

std::tie(phi, theta) = detail::wrap_phi_theta(param.phi(), param.theta());

traccc::scalar phi = param.phi();
static constexpr traccc::scalar TWOPI =
2.f * traccc::constant<traccc::scalar>::pi;
phi = math::fmod(phi, TWOPI);
if (phi > traccc::constant<traccc::scalar>::pi) {
phi -= TWOPI;
} else if (phi < -traccc::constant<traccc::scalar>::pi) {
phi += TWOPI;
}
param.set_phi(phi);
param.set_theta(theta);
}

/// Covariance inflation used for track fitting
Expand Down
12 changes: 6 additions & 6 deletions core/include/traccc/finding/actors/ckf_aborter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
// Project include(s)
#include "traccc/definitions/primitives.hpp"
#include "traccc/definitions/qualifiers.hpp"
#include "traccc/utils/logging.hpp"

// detray include(s)
#include <detray/definitions/indexing.hpp>
#include <detray/propagator/base_actor.hpp>

// System include(s)
Expand All @@ -38,10 +40,10 @@ struct ckf_aborter : detray::actor {
propagator_state_t &prop_state) const {

auto &navigation = prop_state._navigation;
const auto &stepping = prop_state._stepping;

abrt_state.count++;
abrt_state.path_from_surface += stepping.step_size();

TRACCC_VERBOSE_HOST_DEVICE("Checking CKF aborter");

// Stop at the next sensitive surface
if (navigation.is_on_sensitive() &&
Expand All @@ -50,10 +52,8 @@ struct ckf_aborter : detray::actor {
abrt_state.success = true;
}

// Reset path from surface
if (navigation.is_on_sensitive()) {
abrt_state.path_from_surface = 0.f;
}
TRACCC_VERBOSE_HOST_DEVICE("-> Found sensitive surface: %d",
navigation.barcode().index());

if (abrt_state.count > abrt_state.max_count) {
prop_state._heartbeat &= navigation.abort(
Expand Down
118 changes: 87 additions & 31 deletions core/include/traccc/finding/details/combinatorial_kalman_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "traccc/finding/candidate_link.hpp"
#include "traccc/finding/details/combinatorial_kalman_filter_types.hpp"
#include "traccc/finding/finding_config.hpp"
#include "traccc/finding/propagation_data.hpp"
#include "traccc/fitting/kalman_filter/gain_matrix_updater.hpp"
#include "traccc/fitting/kalman_filter/is_line_visitor.hpp"
#include "traccc/fitting/status_codes.hpp"
Expand Down Expand Up @@ -63,7 +64,7 @@ combinatorial_kalman_filter(
const measurement_collection_types::const_view& measurements_view,
const bound_track_parameters_collection_types::const_view& seeds_view,
const finding_config& config, vecmem::memory_resource& mr,
const Logger& log) {
const Logger& /*log*/) {

assert(config.min_step_length_for_next_surface >
math::fabs(config.propagation.navigation.overstep_tolerance) &&
Expand All @@ -77,7 +78,8 @@ combinatorial_kalman_filter(
using scalar_type = detray::dscalar<algebra_type>;

// Create a logger.
auto logger = [&log]() -> const Logger& { return log; };
// @TODO: Turn back on, once detray can use the ACTS logger
// auto logger = [&log]() -> const Logger& { return log; };

/*****************************************************************
* Measurement Operations
Expand Down Expand Up @@ -126,8 +128,10 @@ combinatorial_kalman_filter(
std::vector<std::pair<unsigned int, unsigned int>> tips;

// Create propagator
auto prop_cfg{config.propagation};
prop_cfg.navigation.estimate_scattering_noise = false;
traccc::details::ckf_propagator_t<detector_t, bfield_t> propagator(
config.propagation);
prop_cfg);

// Create the input seeds container.
bound_track_parameters_collection_types::const_device seeds{seeds_view};
Expand All @@ -142,12 +146,13 @@ combinatorial_kalman_filter(
for (unsigned int step = 0u; step < config.max_track_candidates_per_track;
step++) {

TRACCC_VERBOSE("Starting step "
<< step + 1 << " / "
<< config.max_track_candidates_per_track);
TRACCC_VERBOSE_HOST("Starting step "
<< step + 1 << " / "
<< config.max_track_candidates_per_track);

// Iterate over input parameters
const std::size_t n_in_params = in_params.size();
TRACCC_VERBOSE_HOST("No. Params: " << n_in_params);

// Terminate if there is no parameter to proceed
if (n_in_params == 0) {
Expand Down Expand Up @@ -197,10 +202,13 @@ combinatorial_kalman_filter(
: links[step - 1][param_to_link[step - 1][in_param_id]]
.ndf_sum);

TRACCC_VERBOSE("Processing input parameter "
<< in_param_id + 1 << " / " << n_in_params << ": "
<< in_param << " (orig_param_id=" << orig_param_id
<< ", skip_counter=" << skip_counter << ")");
TRACCC_VERBOSE_HOST("Processing input parameter "
<< in_param_id + 1 << " / " << n_in_params);
TRACCC_VERBOSE_HOST("-> orig_param_id="
<< orig_param_id << ", skip_counter="
<< skip_counter << "\nVec:\n"
<< in_param.vector());
TRACCC_DEBUG_HOST("Cov:\n" << in_param.covariance());

/*************************
* Material interaction
Expand All @@ -209,8 +217,8 @@ combinatorial_kalman_filter(
// Get surface corresponding to bound params
const detray::tracking_surface sf{det, in_param.surface_link()};

TRACCC_VERBOSE(
" free params: " << sf.bound_to_free_vector({}, in_param));
TRACCC_VERBOSE_HOST(" Free params:\n"
<< sf.bound_to_free_vector({}, in_param));

// Apply interactor
if (sf.has_material()) {
Expand Down Expand Up @@ -239,7 +247,9 @@ combinatorial_kalman_filter(
best_links;

// Iterate over the measurements
TRACCC_VERBOSE_HOST("No. measurements: " << (up - lo));
for (unsigned int meas_id = lo; meas_id < up; meas_id++) {
TRACCC_VERBOSE_HOST("Testing measurement: " << meas_id);

// The measurement on surface to handle.
const measurement& meas = measurements.at(meas_id);
Expand All @@ -248,7 +258,7 @@ combinatorial_kalman_filter(
auto trk_state =
edm::make_track_state<algebra_type>(measurements, meas_id);

const bool is_line = sf.template visit_mask<is_line_visitor>();
const bool is_line = detail::is_line(sf);

// Run the Kalman update on a copy of the track parameters
const kalman_fitter_status res =
Expand All @@ -257,9 +267,13 @@ combinatorial_kalman_filter(

const traccc::scalar chi2 = trk_state.filtered_chi2();

TRACCC_DEBUG_HOST("KF status: " << fitter_debug_msg{res}());

// The chi2 from Kalman update should be less than chi2_max
if (res == kalman_fitter_status::SUCCESS &&
chi2 < config.chi2_max) {
(chi2 < config.chi2_max)) {

TRACCC_VERBOSE_HOST("Found measurement: " << meas_id);

best_links.push_back(
{{.step = step,
Expand All @@ -284,9 +298,9 @@ combinatorial_kalman_filter(
const unsigned int n_branches =
std::min(config.max_num_branches_per_surface,
static_cast<unsigned int>(best_links.size()));
TRACCC_VERBOSE("Found " << n_branches << " branches for step "
<< step << " and input parameter "
<< in_param_id);
TRACCC_VERBOSE_HOST("Found " << n_branches << " branches for step "
<< step << " and input parameter "
<< in_param_id + 1);
for (unsigned int i = 0; i < n_branches; ++i) {
const auto& [link, filtered_params] = best_links[i];

Expand All @@ -295,9 +309,9 @@ combinatorial_kalman_filter(

// Add the updated parameter to the updated parameters
updated_params.push_back(filtered_params);
TRACCC_VERBOSE("updated_params["
<< updated_params.size() - 1
<< "] = " << updated_params.back());
TRACCC_DEBUG_HOST("updated_params["
<< updated_params.size() - 1
<< "] = " << updated_params.back());
}

/*****************************************************************
Expand All @@ -318,10 +332,12 @@ combinatorial_kalman_filter(
.chi2_sum = prev_chi2_sum,
.ndf_sum = prev_ndf_sum});

TRACCC_VERBOSE_HOST("Hole state created");

updated_params.push_back(in_param);
TRACCC_VERBOSE("updated_params["
<< updated_params.size() - 1
<< "] = " << updated_params.back());
TRACCC_DEBUG_HOST("updated_params["
<< updated_params.size() - 1
<< "] = " << updated_params.back());
}
}

Expand Down Expand Up @@ -438,6 +454,8 @@ combinatorial_kalman_filter(
}

if (this_is_dominated) {
TRACCC_VERBOSE_HOST(
"Track is dead (deduplication)!");
param_liveness.at(tracks.at(i)) = 0u;
break;
}
Expand Down Expand Up @@ -465,11 +483,15 @@ combinatorial_kalman_filter(
// link to be a tip
if (links.at(step).at(link_id).n_skipped >
config.max_num_skipping_per_cand) {
TRACCC_WARNING_HOST(
"Create tip: Max no. of holes reached! Bound param:\n"
<< updated_params[link_id].vector());
tips.push_back({step, link_id});
continue;
}

const auto& param = updated_params[link_id];

// Create propagator state
typename traccc::details::ckf_propagator_t<
detector_t, bfield_t>::state propagation(param, field, det);
Expand All @@ -484,39 +506,73 @@ combinatorial_kalman_filter(
traccc::details::ckf_interactor_t::state s2;
typename interaction_register<
traccc::details::ckf_interactor_t>::state s1{s2};
// typename detray::parameter_resetter<
// typename detector_t::algebra_type>::state s3{};
typename detray::parameter_resetter<
typename detector_t::algebra_type>::state s3{prop_cfg};
typename detray::momentum_aborter<scalar_type>::state s4{};
typename ckf_aborter::state s5;

// Update the actor config
s4.min_pT(static_cast<scalar_type>(config.min_pT));
s4.min_p(static_cast<scalar_type>(config.min_p));
s5.min_step_length = config.min_step_length_for_next_surface;
s5.max_count = config.max_step_counts_for_next_surface;

// Propagate to the next surface
propagator.propagate(propagation, detray::tie(s0, s1, s2, s4, s5));
TRACCC_DEBUG_HOST("Propagating... ");
propagator.propagate(propagation,
detray::tie(s0, s1, s2, s3, s4, s5));
TRACCC_DEBUG_HOST("Finished propagation: On surface "
<< propagation._navigation.barcode());

// If a surface found, add the parameter for the next
// step
if (s5.success) {
bool valid_track{s5.success};
if (valid_track) {
assert(propagation._navigation.is_on_sensitive());
assert(!propagation._stepping.bound_params().is_invalid());

out_params.push_back(propagation._stepping.bound_params());
param_to_link[step].push_back(link_id);
const auto& out_param = propagation._stepping.bound_params();

const scalar theta = out_param.theta();
if (theta <= 0.f ||
theta >= 2.f * constant<traccc::scalar>::pi) {
TRACCC_ERROR_HOST("Theta is hit pole after propagation");
valid_track = false;
}

if (!std::isfinite(out_param.phi())) {
TRACCC_ERROR_HOST(
"Phi is infinite after propagation (Matrix inversion)");
valid_track = false;
}

if (math::fabs(out_param.qop()) == 0.f) {
TRACCC_ERROR_HOST("q over p is zero after propagation");
valid_track = false;
}

if (valid_track) {
out_params.push_back(out_param);
param_to_link[step].push_back(link_id);
}
}
// Unless the track found a surface, it is considered a
// tip
else if (!s5.success &&
(step >= (config.min_track_candidates_per_track - 1u))) {
if (!valid_track &&
(step >= (config.min_track_candidates_per_track - 1u))) {
if (!s5.success) {
TRACCC_VERBOSE_HOST("Create tip: No next sensitive found");
} else {
TRACCC_VERBOSE_HOST("Create tip: Encountered error");
}
tips.push_back({step, link_id});
}

// If no more CKF step is expected, current candidate is
// kept as a tip
if (s5.success &&
(step == (config.max_track_candidates_per_track - 1u))) {
TRACCC_ERROR_HOST("Create tip: Max no. candidates");
tips.push_back({step, link_id});
}
}
Expand Down
25 changes: 25 additions & 0 deletions core/include/traccc/finding/propagation_data.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/** TRACCC library, part of the ACTS project (R&D line)
*
* (c) 2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Detray include(s).
#include <detray/definitions/indexing.hpp>

namespace traccc {

/// Data from the propagation loop that has to be kept between CKF steps
struct propagation_data {
/// The surface that was visited before the current one (overlaps
/// resolution)
detray::dindex prev_surface{detray::dindex_invalid};

/// Is the current surface hit in the extended tolerance band?
bool is_edge{false};
};

} // namespace traccc
2 changes: 1 addition & 1 deletion core/include/traccc/fitting/details/kalman_fitting.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ typename edm::track_container<algebra_t>::host kalman_fitting(
result_tracks_device.at(result_tracks_device.size() - 1),
typename edm::track_state_collection<algebra_t>::device{
vecmem::get_data(result.states)},
measurements, seqs_buffer);
measurements, seqs_buffer, fitter.config().propagation);

// Run the fitter. The status that it returns is not used here. The main
// failure modes are saved onto the fitted track itself. Not sure what
Expand Down
2 changes: 1 addition & 1 deletion core/include/traccc/fitting/fitting_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct fitting_config {
std::size_t barcode_sequence_size_factor = 5;
std::size_t min_barcode_sequence_capacity = 100;
traccc::scalar backward_filter_mask_tolerance =
5.f * traccc::unit<scalar>::mm;
10.f * traccc::unit<scalar>::m;
};

} // namespace traccc
Loading
Loading