Skip to content

Commit e176791

Browse files
committed
Split track_finding_analysis into multiple pieces.
So that it would be easier to introduce additional performance measurements in the next step(s).
1 parent 26b6061 commit e176791

10 files changed

+477
-286
lines changed

examples/run/cpu/seq_example.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "traccc/seeding/track_params_estimation.hpp"
2424

2525
// performance
26-
#include "traccc/efficiency/track_finding_analysis.hpp"
26+
#include "traccc/efficiency/track_finding_efficiency.hpp"
2727
#include "traccc/performance/timer.hpp"
2828

2929
// options
@@ -160,12 +160,14 @@ int seq_run(const traccc::opts::input_data& input_opts,
160160
traccc::greedy_ambiguity_resolution_algorithm resolution_alg;
161161

162162
// Performance analysis object(s).
163-
std::unique_ptr<traccc::performance::track_finding_analysis>
163+
std::unique_ptr<traccc::performance::track_finding_efficiency>
164164
track_finding_efficiency;
165165
if (performance_opts.run) {
166166
track_finding_efficiency =
167-
std::make_unique<traccc::performance::track_finding_analysis>(
168-
traccc::performance::track_finding_analysis::config{});
167+
std::make_unique<traccc::performance::track_finding_efficiency>(
168+
traccc::performance::track_finding_efficiency::config{},
169+
traccc::performance::truth_filtering::config{},
170+
traccc::performance::truth_matching::config{});
169171
}
170172

171173
// Timers

performance/CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ traccc_add_library( traccc_performance performance TYPE SHARED
2121
"src/efficiency/nseed_performance_writer.cpp"
2222
"src/efficiency/track_filter.cpp"
2323
"src/efficiency/track_matcher.cpp"
24-
"include/traccc/efficiency/track_finding_analysis.hpp"
25-
"src/efficiency/track_finding_analysis.cpp"
24+
"include/traccc/efficiency/track_finding_efficiency.hpp"
25+
"src/efficiency/track_finding_efficiency.cpp"
2626
# Resolution calculation code.
2727
"include/traccc/resolution/fitting_performance_writer.hpp"
2828
"include/traccc/resolution/res_plot_tool_config.hpp"
@@ -37,6 +37,11 @@ traccc_add_library( traccc_performance performance TYPE SHARED
3737
"include/traccc/utils/helpers.hpp"
3838
"src/utils/helpers.hpp"
3939
"src/utils/helpers.cpp"
40+
# Reconstruction performance measurement helper/base code.
41+
"include/traccc/performance/truth_filtering.hpp"
42+
"src/performance/truth_filtering.cpp"
43+
"include/traccc/performance/truth_matching.hpp"
44+
"src/performance/truth_matching.cpp"
4045
# Value/object comparison code.
4146
"include/traccc/performance/details/is_same_angle.hpp"
4247
"src/performance/details/is_same_angle.cpp"

performance/include/traccc/efficiency/track_finding_analysis.hpp

-108
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Library include(s).
11+
#include "traccc/performance/truth_filtering.hpp"
12+
#include "traccc/performance/truth_matching.hpp"
13+
#include "traccc/utils/helpers.hpp"
14+
15+
// Project include(s).
16+
#include "traccc/definitions/common.hpp"
17+
#include "traccc/edm/particle.hpp"
18+
#include "traccc/edm/track_candidate.hpp"
19+
20+
// System include(s).
21+
#include <cmath>
22+
#include <memory>
23+
#include <string>
24+
25+
namespace traccc::performance {
26+
27+
// Forward declaration(s).
28+
namespace details {
29+
struct track_finding_efficiency_data;
30+
}
31+
32+
/// Tool for analyzing the track finding efficiency
33+
class track_finding_efficiency : public truth_filtering, public truth_matching {
34+
35+
public:
36+
/// Configuration for the efficiency analysis
37+
struct config {
38+
39+
/// Name of the output file to write
40+
std::string m_output_name{"track_finding_efficiency.root"};
41+
42+
/// Binning for the efficiency vs. eta plot
43+
plot_helpers::binning m_eta_binning{
44+
"Track Finding Efficiency vs. #eta;#eta", 40, -3.f, 3.f};
45+
/// Binning for the efficiency vs. phi plot
46+
plot_helpers::binning m_phi_binning{
47+
"Track Finding Efficiency vs. #phi;#phi", 40, -M_PI, M_PI};
48+
/// Binning for the efficiency vs. pT plot
49+
plot_helpers::binning m_pt_binning{
50+
"Track Finding Efficiency vs. p_{T};p_{T}", 40, 0.f, 120.f};
51+
52+
}; // struct config
53+
54+
/// Constructor with a configuration
55+
track_finding_efficiency(const config& eff_cfg,
56+
const truth_filtering::config& filter_cfg,
57+
const truth_matching::config& matching_cfg);
58+
/// Destructor
59+
~track_finding_efficiency();
60+
61+
/// Analyze the tracks found in a specific event.
62+
///
63+
/// @param reco The reconstructed particle tracks
64+
/// @param truth The truth particles
65+
///
66+
void analyze(const track_candidate_container_types::const_view& reco,
67+
const particle_container_types::const_view& truth);
68+
69+
private:
70+
/// Configuration for the track finding efficiency measurement
71+
config m_config;
72+
/// Internal data used by the class
73+
std::unique_ptr<details::track_finding_efficiency_data> m_data;
74+
75+
}; // class track_finding_efficiency
76+
77+
} // namespace traccc::performance
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 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/definitions/common.hpp"
12+
#include "traccc/edm/particle.hpp"
13+
14+
// System include(s).
15+
#include <vector>
16+
17+
namespace traccc::performance {
18+
19+
/// Class providing truth particle filtering
20+
class truth_filtering {
21+
22+
public:
23+
/// Configuration for the truth particle filtering.
24+
struct config {
25+
/// Truth particle PDG IDs to take into consideration
26+
std::vector<int> m_truth_pdgids{-13, 13};
27+
/// Minimum truth pT to take into consideration
28+
float m_truth_pt_min{500.f * unit<float>::MeV};
29+
/// Maximum (absolute) truth pseudorapidity to take into consideration
30+
float m_truth_eta_max{3.0f};
31+
}; // struct config
32+
33+
/// Constructor with a configuration
34+
truth_filtering(const config& cfg);
35+
36+
/// Function checking whether a truth particle passes the filter
37+
///
38+
/// @param truth The truth particle
39+
///
40+
/// @return Whether the truth particle passes the filter
41+
///
42+
bool passes(const particle& truth) const;
43+
44+
private:
45+
/// Configuration for the truth particle filtering.
46+
config m_config;
47+
48+
}; // class truth_filtering
49+
50+
} // namespace traccc::performance
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024 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/definitions/common.hpp"
12+
#include "traccc/edm/measurement.hpp"
13+
#include "traccc/edm/particle.hpp"
14+
#include "traccc/edm/seed.hpp"
15+
#include "traccc/edm/track_candidate.hpp"
16+
17+
namespace traccc::performance {
18+
19+
/// Class providing reco <-> truth track matching
20+
///
21+
/// It can be used either on its own to check the match between reconstructed
22+
/// and truth tracks, or as a base class for classes that do some higher level
23+
/// performance analysis.
24+
///
25+
class truth_matching {
26+
27+
public:
28+
/// Configuration for the track matching
29+
struct config {
30+
/// Uncertainty in millimeters, withing which measurements would match
31+
float m_measurement_uncertainty{1.f * unit<float>::mm};
32+
/// Fraction of reco measurements required to match truth measurements
33+
float m_measurement_match{1.0};
34+
}; // struct config
35+
36+
/// Constructor with a configuration
37+
truth_matching(const config& cfg);
38+
39+
/// Function checking whether a truth particle and a track seed match
40+
///
41+
/// @param reco The track seed
42+
/// @param spacepoints The spacepoint collection that the seeds refer to
43+
/// @param truth The truth particle
44+
///
45+
/// @return Whether the seed matches the truth particle
46+
///
47+
bool matches(
48+
const seed& reco,
49+
const spacepoint_collection_types::const_view spacepoints,
50+
const particle_container_types::const_device::const_element_view& truth)
51+
const;
52+
53+
/// Function checking whether a truth particle and reconstructed track match
54+
///
55+
/// @param reco The reconstructed track
56+
/// @param truth The truth particle
57+
///
58+
/// @return Whether the reconstructed track matches the truth particle
59+
///
60+
bool matches(
61+
const track_candidate_container_types::const_device::const_element_view&
62+
reco,
63+
const particle_container_types::const_device::const_element_view& truth)
64+
const;
65+
66+
/// Function checking whether two measurement objects match
67+
///
68+
/// @param reco The reconstructed measurement
69+
/// @param truth The truth measurement
70+
///
71+
/// @return Wehther the measurements match
72+
///
73+
bool matches(const measurement& reco, const measurement& truth) const;
74+
75+
private:
76+
/// Configuration for the tool
77+
config m_config;
78+
79+
}; // class truth_matching
80+
81+
} // namespace traccc::performance

0 commit comments

Comments
 (0)