Skip to content

Commit f63b91e

Browse files
committed
Adapted traccc::performance to the SoA track fit EDM.
1 parent 7ff62fe commit f63b91e

16 files changed

+381
-143
lines changed

performance/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ traccc_add_library( traccc_performance performance TYPE SHARED
4444
"src/performance/details/is_same_scalar.cpp"
4545
"include/traccc/performance/details/is_same_object.hpp"
4646
"include/traccc/performance/impl/is_same_object.ipp"
47-
"include/traccc/performance/impl/is_same_fitting_result.ipp"
4847
"include/traccc/performance/impl/is_same_seed.ipp"
4948
"include/traccc/performance/impl/is_same_measurement.ipp"
5049
"include/traccc/performance/impl/is_same_spacepoint.ipp"
5150
"include/traccc/performance/impl/is_same_track_candidate.ipp"
51+
"include/traccc/performance/impl/is_same_track_fit.ipp"
5252
"include/traccc/performance/impl/is_same_track_parameters.ipp"
53+
"include/traccc/performance/impl/is_same_track_state.ipp"
5354
"src/performance/details/is_same_object.cpp"
5455
"include/traccc/performance/details/comparator_factory.hpp"
5556
"include/traccc/performance/impl/comparator_factory.ipp"
5657
"include/traccc/performance/impl/seed_comparator_factory.ipp"
58+
"include/traccc/performance/impl/track_candidate_comparator_factory.ipp"
59+
"include/traccc/performance/impl/track_fit_comparator_factory.ipp"
5760
# Collection/container comparison code.
5861
"include/traccc/performance/collection_comparator.hpp"
5962
"include/traccc/performance/impl/collection_comparator.ipp"

performance/include/traccc/efficiency/finding_performance_writer.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
#include "traccc/utils/truth_matching_config.hpp"
1515

1616
// Project include(s).
17+
#include "traccc/edm/measurement.hpp"
1718
#include "traccc/edm/track_candidate_collection.hpp"
18-
#include "traccc/edm/track_state.hpp"
19+
#include "traccc/edm/track_fit_collection.hpp"
20+
#include "traccc/edm/track_state_collection.hpp"
1921
#include "traccc/utils/event_data.hpp"
2022

2123
// System include(s).
@@ -73,8 +75,13 @@ class finding_performance_writer : public messaging {
7375
const measurement_collection_types::const_view& measurements_view,
7476
const event_data& evt_data);
7577

76-
void write(const track_state_container_types::const_view& track_states_view,
77-
const event_data& evt_data);
78+
void write(
79+
const edm::track_fit_collection<default_algebra>::const_view&
80+
track_fit_view,
81+
const edm::track_state_collection<default_algebra>::const_view&
82+
track_states_view,
83+
const measurement_collection_types::const_view& measurements_view,
84+
const event_data& evt_data);
7885

7986
void finalize();
8087

performance/include/traccc/performance/details/comparator_factory.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ class comparator_factory {
4242
// Include the specialised implementation(s).
4343
#include "traccc/performance/impl/seed_comparator_factory.ipp"
4444
#include "traccc/performance/impl/track_candidate_comparator_factory.ipp"
45+
#include "traccc/performance/impl/track_fit_comparator_factory.ipp"

performance/include/traccc/performance/details/is_same_object.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ class is_same_object {
4545
#include "traccc/performance/impl/is_same_object.ipp"
4646

4747
// Include specialisations for the core library types
48-
#include "traccc/performance/impl/is_same_fitting_result.ipp"
4948
#include "traccc/performance/impl/is_same_measurement.ipp"
5049
#include "traccc/performance/impl/is_same_seed.ipp"
5150
#include "traccc/performance/impl/is_same_spacepoint.ipp"
5251
#include "traccc/performance/impl/is_same_track_candidate.ipp"
52+
#include "traccc/performance/impl/is_same_track_fit.ipp"
5353
#include "traccc/performance/impl/is_same_track_parameters.ipp"
54+
#include "traccc/performance/impl/is_same_track_state.ipp"

performance/include/traccc/performance/details/projector.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,4 @@ struct projector<traccc::bound_track_parameters<algebra_t>> {
4747
}
4848
};
4949

50-
template <>
51-
struct projector<fitting_result<traccc::default_algebra>> {
52-
static constexpr bool exists = true;
53-
54-
float operator()(const fitting_result<traccc::default_algebra>& i) {
55-
return static_cast<float>(i.trk_quality.ndf);
56-
}
57-
};
5850
} // namespace traccc::details

performance/include/traccc/performance/impl/is_same_fitting_result.ipp

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2023-2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Project include(s).
11+
#include "traccc/edm/measurement.hpp"
12+
#include "traccc/edm/track_fit_collection.hpp"
13+
#include "traccc/edm/track_state_collection.hpp"
14+
15+
// Local include(s).
16+
#include "traccc/performance/impl/is_same_track_state.ipp"
17+
18+
namespace traccc::details {
19+
20+
/// @c traccc::is_same_object specialisation for @c traccc::edm::track_fit<T>
21+
template <typename T>
22+
class is_same_object<edm::track_fit<T>> {
23+
24+
public:
25+
/// Constructor with a reference object, and an allowed uncertainty
26+
is_same_object(
27+
const measurement_collection_types::const_view& ref_meas,
28+
const measurement_collection_types::const_view& test_meas,
29+
const edm::track_state_collection<default_algebra>::const_view&
30+
ref_states,
31+
const edm::track_state_collection<default_algebra>::const_view&
32+
test_states,
33+
const edm::track_fit<T>& ref, scalar unc = float_epsilon)
34+
: m_ref_meas(ref_meas),
35+
m_test_meas(test_meas),
36+
m_ref_states(ref_states),
37+
m_test_states(test_states),
38+
m_ref(ref),
39+
m_unc(unc) {}
40+
41+
/// Specialised implementation for @c traccc::edm::track_fit<T>
42+
bool operator()(const edm::track_fit<T>& obj) const {
43+
44+
// Compare the fit outcomes.
45+
if (obj.fit_outcome() != m_ref.fit_outcome()) {
46+
return false;
47+
}
48+
// Compare the parameters.
49+
if (!is_same_object<bound_track_parameters<>>(m_ref.params(),
50+
m_unc)(obj.params())) {
51+
return false;
52+
}
53+
// Compare the scalar values.
54+
if (!is_same_scalar(obj.ndf(), m_ref.ndf(), m_unc) ||
55+
!is_same_scalar(obj.chi2(), m_ref.chi2(), m_unc) ||
56+
!is_same_scalar(obj.pval(), m_ref.pval(), m_unc)) {
57+
return false;
58+
}
59+
// Compare the number of holes.
60+
if (obj.nholes() != m_ref.nholes()) {
61+
return false;
62+
}
63+
64+
// The two tracks need to have the same number of states.
65+
if (obj.state_indices().size() != m_ref.state_indices().size()) {
66+
return false;
67+
}
68+
69+
// Now compare the track states one by one.
70+
const edm::track_state_collection<default_algebra>::const_device
71+
ref_states{m_ref_states};
72+
const edm::track_state_collection<default_algebra>::const_device
73+
test_states{m_test_states};
74+
for (unsigned int i = 0; i < obj.state_indices().size(); ++i) {
75+
if (!is_same_object<edm::track_state_collection<
76+
default_algebra>::const_device::const_proxy_type>(
77+
m_ref_meas, m_test_meas,
78+
ref_states.at(m_ref.state_indices()[i]),
79+
m_unc)(test_states.at(obj.state_indices()[i]))) {
80+
return false;
81+
}
82+
}
83+
84+
// If we got here, the two track fits are the same.
85+
return true;
86+
}
87+
88+
private:
89+
/// Measurements for the reference object
90+
const measurement_collection_types::const_view m_ref_meas;
91+
/// Measurements for the test object
92+
const measurement_collection_types::const_view m_test_meas;
93+
/// States for the reference object
94+
const edm::track_state_collection<default_algebra>::const_view m_ref_states;
95+
/// States for the test object
96+
const edm::track_state_collection<default_algebra>::const_view
97+
m_test_states;
98+
/// The reference object
99+
const edm::track_fit<T> m_ref;
100+
/// The uncertainty
101+
scalar m_unc;
102+
103+
}; // class is_same_object<edm::track_fit<T>>
104+
105+
} // namespace traccc::details
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2023-2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Project include(s).
11+
#include "traccc/edm/measurement.hpp"
12+
#include "traccc/edm/track_state_collection.hpp"
13+
14+
// Local include(s).
15+
#include "traccc/performance/impl/is_same_measurement.ipp"
16+
17+
namespace traccc::details {
18+
19+
/// @c traccc::is_same_object specialisation for
20+
/// @c traccc::edm::track_state_collection
21+
template <typename T>
22+
class is_same_object<edm::track_state<T>> {
23+
24+
public:
25+
/// Constructor with a reference object, and an allowed uncertainty
26+
is_same_object(const measurement_collection_types::const_view& ref_meas,
27+
const measurement_collection_types::const_view& test_meas,
28+
const edm::track_state<T>& ref, scalar unc = float_epsilon)
29+
: m_ref_meas(ref_meas),
30+
m_test_meas(test_meas),
31+
m_ref(ref),
32+
m_unc(unc) {}
33+
34+
/// Specialised implementation for @c traccc::edm::track_state<T>
35+
bool operator()(const edm::track_state<T>& obj) const {
36+
37+
// Compare the state words.
38+
if (obj.state() != m_ref.state()) {
39+
return false;
40+
}
41+
// Compare the chi2 values.
42+
if (!is_same_scalar(obj.filtered_chi2(), m_ref.filtered_chi2(),
43+
m_unc) ||
44+
!is_same_scalar(obj.smoothed_chi2(), m_ref.smoothed_chi2(),
45+
m_unc) ||
46+
!is_same_scalar(obj.backward_chi2(), m_ref.backward_chi2(),
47+
m_unc)) {
48+
return false;
49+
}
50+
// Compare the fitted parameters.
51+
if (!is_same_object<bound_track_parameters<>>(
52+
m_ref.filtered_params(), m_unc)(obj.filtered_params()) ||
53+
!is_same_object<bound_track_parameters<>>(
54+
m_ref.smoothed_params(), m_unc)(obj.smoothed_params())) {
55+
return false;
56+
}
57+
// Compare the measurements that they point at.
58+
const measurement_collection_types::const_device ref_meas{m_ref_meas};
59+
const measurement_collection_types::const_device test_meas{m_test_meas};
60+
if (!is_same_object<measurement>(
61+
ref_meas.at(m_ref.measurement_index()),
62+
m_unc)(test_meas.at(obj.measurement_index()))) {
63+
return false;
64+
}
65+
66+
// If we got here, the two track states are the same.
67+
return true;
68+
}
69+
70+
private:
71+
/// Measurements for the reference object
72+
const measurement_collection_types::const_view m_ref_meas;
73+
/// Measurements for the test object
74+
const measurement_collection_types::const_view m_test_meas;
75+
/// The reference object
76+
const edm::track_state<T> m_ref;
77+
/// The uncertainty
78+
scalar m_unc;
79+
80+
}; // class is_same_object<edm::track_state<T>>
81+
82+
} // namespace traccc::details
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Project include(s).
11+
#include "traccc/edm/measurement.hpp"
12+
#include "traccc/edm/track_fit_collection.hpp"
13+
#include "traccc/edm/track_state_collection.hpp"
14+
15+
// Local include(s).
16+
#include "traccc/performance/details/is_same_object.hpp"
17+
18+
namespace traccc::details {
19+
20+
/// @c traccc::details::comparator_factory specialisation for
21+
/// @c traccc::edm::track_fit
22+
template <typename T>
23+
class comparator_factory<edm::track_fit<T>> {
24+
25+
public:
26+
/// Constructor with all necessary arguments
27+
comparator_factory(
28+
const measurement_collection_types::const_view& ref_meas,
29+
const measurement_collection_types::const_view& test_meas,
30+
const edm::track_state_collection<default_algebra>::const_view&
31+
ref_states,
32+
const edm::track_state_collection<default_algebra>::const_view&
33+
test_states)
34+
: m_ref_meas(ref_meas),
35+
m_test_meas(test_meas),
36+
m_ref_states(ref_states),
37+
m_test_states(test_states) {}
38+
39+
/// Instantiate an instance of a comparator object
40+
is_same_object<edm::track_fit<T>> make_comparator(
41+
const edm::track_fit<T>& ref, scalar unc = float_epsilon) const {
42+
43+
return is_same_object<edm::track_fit<T>>(
44+
m_ref_meas, m_test_meas, m_ref_states, m_test_states, ref, unc);
45+
}
46+
47+
private:
48+
/// Measurement container for the reference track candidates
49+
const measurement_collection_types::const_view m_ref_meas;
50+
/// Measurement container for the test track candidates
51+
const measurement_collection_types::const_view m_test_meas;
52+
/// States for the reference object
53+
const edm::track_state_collection<default_algebra>::const_view m_ref_states;
54+
/// States for the test object
55+
const edm::track_state_collection<default_algebra>::const_view
56+
m_test_states;
57+
58+
}; // class comparator_factory
59+
60+
} // namespace traccc::details

0 commit comments

Comments
 (0)