Skip to content

Commit bf6a8da

Browse files
committed
Fix and rework Kálmán filter p and pT cuts
This commit fixes the $p$ and $p_T$ cuts in the Kálmán filter, which were previously entirely broken. The CLI options could not correctly distinguish between the $p$ and $p_T$ cut, a distinction which is entirely unnecessary in the first place. This commit splits the cut up so that both can be supported at the same time, and sets a sensible default for the $p_T$ cut.
1 parent e6f5e34 commit bf6a8da

File tree

5 files changed

+20
-44
lines changed

5 files changed

+20
-44
lines changed

core/include/traccc/finding/details/combinatorial_kalman_filter.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,8 @@ combinatorial_kalman_filter(
507507
// Update the actor config
508508
s4.min_step_length = config.min_step_length_for_next_surface;
509509
s4.max_count = config.max_step_counts_for_next_surface;
510-
if (config.is_min_pT) {
511-
s3.min_pT(static_cast<scalar_type>(config.min_p_mag));
512-
} else {
513-
s3.min_p(static_cast<scalar_type>(config.min_p_mag));
514-
}
510+
s3.min_pT(static_cast<scalar_type>(config.min_pT));
511+
s3.min_p(static_cast<scalar_type>(config.min_p));
515512

516513
// Propagate to the next surface
517514
propagator.propagate(propagation, detray::tie(s0, s1, s2, s3, s4));

core/include/traccc/finding/finding_config.hpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ struct finding_config {
4646
detray::propagation::config propagation{};
4747

4848
/// Minimum momentum for reconstructed tracks
49-
bool is_min_pT = true;
50-
float min_p_mag = 100.f * traccc::unit<float>::MeV;
49+
float min_p = 100.f * traccc::unit<float>::MeV;
50+
float min_pT = 600.f * traccc::unit<float>::MeV;
5151

5252
/// Particle hypothesis
5353
traccc::pdg_particle<traccc::scalar> ptc_hypothesis =
@@ -75,20 +75,6 @@ struct finding_config {
7575
/// @note This parameter affects GPU-based track finding only.
7676
unsigned int initial_links_per_seed = 100;
7777
/// @}
78-
79-
/// Set the momentum limit to @param p
80-
TRACCC_HOST_DEVICE
81-
inline void min_p(const float p) {
82-
is_min_pT = false;
83-
min_p_mag = p;
84-
}
85-
86-
/// Set the transverse momentum limit to @param p
87-
TRACCC_HOST_DEVICE
88-
inline void min_pT(const float p) {
89-
is_min_pT = true;
90-
min_p_mag = p;
91-
}
9278
};
9379

9480
} // namespace traccc

device/common/include/traccc/finding/device/impl/propagate_to_next_surface.ipp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
8888
typename detray::detail::tuple_element<5, actor_tuple_type>::type::state s5;
8989
s5.min_step_length = cfg.min_step_length_for_next_surface;
9090
s5.max_count = cfg.max_step_counts_for_next_surface;
91-
if (cfg.is_min_pT) {
92-
s4.min_pT(static_cast<scalar_t>(cfg.min_p_mag));
93-
} else {
94-
s4.min_p(static_cast<scalar_t>(cfg.min_p_mag));
95-
}
91+
s4.min_pT(static_cast<scalar_t>(cfg.min_pT));
92+
s4.min_p(static_cast<scalar_t>(cfg.min_p));
9693

9794
// Propagate to the next surface
9895
propagator.propagate(propagation, detray::tie(s0, s2, s3, s4, s5));

examples/options/src/track_finding.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "traccc/utils/particle.hpp"
1313

1414
// System include(s).
15+
#include <format>
1516
#include <sstream>
1617

1718
namespace traccc::opts {
@@ -65,11 +66,11 @@ track_finding::track_finding() : interface("Track Finding Options") {
6566
"PDG number for the particle hypothesis");
6667
m_desc.add_options()(
6768
"min-total-momentum",
68-
po::value(&m_config.min_p_mag)->default_value(m_config.min_p_mag),
69+
po::value(&m_config.min_p)->default_value(m_config.min_p),
6970
"Minimum total track momentum [GeV]");
7071
m_desc.add_options()(
7172
"min-transverse-momentum",
72-
po::value(&m_config.min_p_mag)->default_value(m_config.min_p_mag),
73+
po::value(&m_config.min_pT)->default_value(m_config.min_pT),
7374
"Minimum transverse track momentum [GeV]");
7475
m_desc.add_options()(
7576
"duplicate-removal-minimum-length",
@@ -78,12 +79,9 @@ track_finding::track_finding() : interface("Track Finding Options") {
7879
"Minimum track length for deduplication (0 to disable) [cardinal]");
7980
}
8081

81-
void track_finding::read(const po::variables_map &vm) {
82-
83-
m_config.min_p_mag *= traccc::unit<float>::GeV;
84-
85-
// If not set as total momentum, interpret as transverse momentum
86-
m_config.is_min_pT = vm["min-total-momentum"].defaulted();
82+
void track_finding::read(const po::variables_map &) {
83+
m_config.min_p *= traccc::unit<float>::GeV;
84+
m_config.min_pT *= traccc::unit<float>::GeV;
8785
}
8886

8987
track_finding::operator finding_config() const {
@@ -126,16 +124,12 @@ std::unique_ptr<configuration_printable> track_finding::as_printable() const {
126124
std::to_string(m_config.duplicate_removal_minimum_length)));
127125
cat->add_child(std::make_unique<configuration_kv_pair>(
128126
"PDG number", std::to_string(m_pdg_number)));
129-
// How to interpret the minimum track momentum value
130-
if (m_config.is_min_pT) {
131-
cat->add_child(std::make_unique<configuration_kv_pair>(
132-
"Minimum transverse track momentum",
133-
std::to_string(m_config.min_p_mag)));
134-
} else {
135-
cat->add_child(std::make_unique<configuration_kv_pair>(
136-
"Minimum total track momentum",
137-
std::to_string(m_config.min_p_mag)));
138-
}
127+
cat->add_child(std::make_unique<configuration_kv_pair>(
128+
"Minimum pT",
129+
std::format("{} GeV", m_config.min_pT / traccc::unit<float>::GeV)));
130+
cat->add_child(std::make_unique<configuration_kv_pair>(
131+
"Minimum p",
132+
std::format("{} GeV", m_config.min_p / traccc::unit<float>::GeV)));
139133

140134
return cat;
141135
}

tests/cpu/test_ckf_sparse_tracks_telescope.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ TEST_P(CkfSparseTrackTelescopeTests, Run) {
127127
typename traccc::finding_config cfg;
128128
cfg.ptc_hypothesis = ptc;
129129
cfg.chi2_max = 200.f;
130+
cfg.min_p = 0;
131+
cfg.min_pT = 10.f * unit<float>::MeV;
130132

131133
// Finding algorithm object
132134
traccc::host::combinatorial_kalman_filter_algorithm host_finding(cfg,

0 commit comments

Comments
 (0)