Skip to content

Commit ed4e53d

Browse files
authored
Various seeding performance writer improvements (#1104)
This commit makes the following changes to the seeding performance writer (and some related code): 1. The class now accepts the same truth matching configuration as the finding efficiency writer. 2. Relevant example executables were updated to forward the aforementioned configuration to the efficiency writer. 3. ROOT plots outputted now have clearer names. 4. Printouts have been added of the seeding performance. 5. In tandem with point 4, the finding efficiency writer has had its printouts more clearly differentiated, and the cut optimiser has been updated accordingly.
2 parents e8a4c66 + 9fcdf83 commit ed4e53d

File tree

9 files changed

+87
-27
lines changed

9 files changed

+87
-27
lines changed

examples/run/alpaka/seeding_example_alpaka.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
7979

8080
// Performance writer
8181
traccc::seeding_performance_writer sd_performance_writer(
82-
traccc::seeding_performance_writer::config{},
82+
traccc::seeding_performance_writer::config{.truth_config =
83+
truth_finding_opts},
8384
logger().clone("SeedingPerformanceWriter"));
8485
traccc::finding_performance_writer find_performance_writer(
8586
traccc::finding_performance_writer::config{.truth_config =

examples/run/cpu/seeding_example.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
7777

7878
// Performance writer
7979
traccc::seeding_performance_writer sd_performance_writer(
80-
traccc::seeding_performance_writer::config{},
80+
traccc::seeding_performance_writer::config{.truth_config =
81+
truth_finding_opts},
8182
logger().clone("SeedingPerformanceWriter"));
8283
traccc::finding_performance_writer find_performance_writer(
8384
traccc::finding_performance_writer::config{.truth_config =

examples/run/cpu/seq_example.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ int seq_run(const traccc::opts::input_data& input_opts,
158158

159159
// performance writer
160160
traccc::seeding_performance_writer sd_performance_writer(
161-
traccc::seeding_performance_writer::config{},
161+
traccc::seeding_performance_writer::config{.truth_config =
162+
truth_finding_opts},
162163
logger().clone("SeedingPerformanceWriter"));
163164
traccc::finding_performance_writer find_performance_writer(
164165
traccc::finding_performance_writer::config{.truth_config =

examples/run/cuda/seeding_example_cuda.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ int seq_run(const traccc::opts::track_seeding& seeding_opts,
8383

8484
// Performance writer
8585
traccc::seeding_performance_writer sd_performance_writer(
86-
traccc::seeding_performance_writer::config{},
86+
traccc::seeding_performance_writer::config{.truth_config =
87+
truth_finding_opts},
8788
logger().clone("SeedingPerformanceWriter"));
8889
traccc::finding_performance_writer find_performance_writer(
8990
traccc::finding_performance_writer::config{.truth_config =

extras/cut_optimiser/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,23 @@ def main():
275275

276276
stdout = result.stdout.decode("utf-8")
277277

278-
if match := re.search(r"Total efficiency was (\d+(?:\.\d*)?)%", stdout):
278+
if match := re.search(
279+
r"Total track efficiency was (\d+(?:\.\d*)?)%", stdout
280+
):
279281
result_efficiency = float(match.group(1)) / 100.0
280282
else:
281283
raise ValueError("Efficiency could not be parsed from stdout!")
282284

283285
if match := re.search(
284-
r"Total duplicate rate was (\d+(?:\.\d*)?)", stdout
286+
r"Total track duplicate rate was (\d+(?:\.\d*)?)", stdout
285287
):
286288
result_duplicate_rate = float(match.group(1))
287289
else:
288290
raise ValueError("Dupliacate rate could not be parsed from stdout!")
289291

290-
if match := re.search(r"Total fake rate was (\d+(?:\.\d*)?)", stdout):
292+
if match := re.search(
293+
r"Total track fake rate was (\d+(?:\.\d*)?)", stdout
294+
):
291295
result_fake_rate = float(match.group(1))
292296
else:
293297
raise ValueError("Fake rate could not be parsed from stdout!")

performance/include/traccc/efficiency/seeding_performance_writer.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// Local include(s).
1111
#include "traccc/utils/helpers.hpp"
1212
#include "traccc/utils/messaging.hpp"
13+
#include "traccc/utils/truth_matching_config.hpp"
1314

1415
// Project include(s).
1516
#include "traccc/edm/measurement.hpp"
@@ -51,11 +52,7 @@ class seeding_performance_writer : public messaging {
5152
{"Num", plot_helpers::binning("N", 30, -0.5f, 29.5f)}};
5253

5354
/// Cut values
54-
scalar pT_cut = 0.5f * traccc::unit<scalar>::GeV;
55-
scalar z_min = -500.f * traccc::unit<scalar>::mm;
56-
scalar z_max = 500.f * traccc::unit<scalar>::mm;
57-
scalar r_max = 200.f * traccc::unit<scalar>::mm;
58-
scalar matching_ratio = 0.5f;
55+
truth_matching_config truth_config;
5956
};
6057

6158
/// Construct from configuration and log level.

performance/src/efficiency/eff_plot_tool.hpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,28 @@ class eff_plot_tool {
6363
(void)cache;
6464

6565
#ifdef TRACCC_HAVE_ROOT
66+
std::string header;
67+
68+
if (name == "finding") {
69+
header = "Track finding efficiency";
70+
} else if (name == "seeding") {
71+
header = "Seed finding efficiency";
72+
} else {
73+
header = "Tracking efficiency";
74+
}
75+
6676
// efficiency vs pT
6777
cache.track_eff_vs_pT = plot_helpers::book_eff(
6878
TString(name) + "_trackeff_vs_pT",
69-
"Tracking efficiency;Truth pT [GeV/c];Efficiency", b_pt);
79+
header + ";Truth pT [GeV/c];Efficiency", b_pt);
7080
// efficiency vs eta
71-
cache.track_eff_vs_eta = plot_helpers::book_eff(
72-
TString(name) + "_trackeff_vs_eta",
73-
"Tracking efficiency;Truth #eta;Efficiency", b_eta);
81+
cache.track_eff_vs_eta =
82+
plot_helpers::book_eff(TString(name) + "_trackeff_vs_eta",
83+
header + ";Truth #eta;Efficiency", b_eta);
7484
// efficiency vs phi
75-
cache.track_eff_vs_phi = plot_helpers::book_eff(
76-
TString(name) + "_trackeff_vs_phi",
77-
"Tracking efficiency;Truth #phi;Efficiency", b_phi);
85+
cache.track_eff_vs_phi =
86+
plot_helpers::book_eff(TString(name) + "_trackeff_vs_phi",
87+
header + ";Truth #phi;Efficiency", b_phi);
7888
#endif // TRACCC_HAVE_ROOT
7989
}
8090

performance/src/efficiency/finding_performance_writer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,19 @@ void finding_performance_writer::write_common(
287287
TRACCC_INFO("Total number of truth particles was "
288288
<< total_truth_particles);
289289
TRACCC_INFO("Total number of found tracks was " << n_tracks);
290-
TRACCC_INFO("Total number of matched particles was "
290+
TRACCC_INFO("Total number of track-matched particles was "
291291
<< total_matched_truth_particles);
292292
TRACCC_INFO("Total number of duplicated tracks was "
293293
<< total_duplicate_tracks);
294294
TRACCC_INFO("Total number of fake tracks was " << total_fake_tracks);
295-
TRACCC_INFO("Total efficiency was "
295+
TRACCC_INFO("Total track efficiency was "
296296
<< (100. * static_cast<double>(total_matched_truth_particles) /
297297
static_cast<double>(total_truth_particles))
298298
<< "%");
299-
TRACCC_INFO("Total duplicate rate was "
299+
TRACCC_INFO("Total track duplicate rate was "
300300
<< (static_cast<double>(total_duplicate_tracks) /
301301
static_cast<double>(total_matched_truth_particles)));
302-
TRACCC_INFO("Total fake rate was "
302+
TRACCC_INFO("Total track fake rate was "
303303
<< (static_cast<double>(total_fake_tracks) /
304304
static_cast<double>(total_truth_particles)));
305305
}

performance/src/efficiency/seeding_performance_writer.cpp

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ void seeding_performance_writer::write(
7777
const measurement_collection_types::const_device measurements(
7878
measurements_view);
7979

80+
const std::size_t n_seeds = seeds.size();
81+
82+
std::size_t total_fake_seeds = 0;
83+
8084
// Iterate over the seeds.
8185
for (edm::seed_collection::const_device::size_type i = 0u; i < seeds.size();
8286
++i) {
@@ -143,34 +147,75 @@ void seeding_performance_writer::write(
143147
assert(seed_measurements.size() > 0u);
144148
if (static_cast<double>(particle_hit_counts.at(0).hit_counts) /
145149
static_cast<double>(seed_measurements.size()) >
146-
m_cfg.matching_ratio) {
150+
m_cfg.truth_config.matching_ratio) {
147151
auto pid = particle_hit_counts.at(0).ptc.particle_id;
148152
match_counter[pid]++;
153+
} else {
154+
total_fake_seeds++;
149155
}
150156
}
151157

158+
std::size_t total_truth_particles = 0;
159+
std::size_t total_matched_truth_particles = 0;
160+
std::size_t total_duplicate_seeds = 0;
161+
152162
for (auto const& [pid, ptc] : evt_data.m_particle_map) {
163+
std::size_t num_measurements = 0;
164+
165+
// Find the number of measurements belonging to this track
166+
if (auto it = evt_data.m_ptc_to_meas_map.find(ptc);
167+
it != evt_data.m_ptc_to_meas_map.end()) {
168+
num_measurements = it->second.size();
169+
} else {
170+
continue;
171+
}
153172

154173
// Count only charged particles which satisfiy pT_cut
155-
if (ptc.charge == 0 || vector::perp(ptc.momentum) < m_cfg.pT_cut ||
156-
ptc.vertex[2] < m_cfg.z_min || ptc.vertex[2] > m_cfg.z_max ||
157-
vector::perp(ptc.vertex) > m_cfg.r_max) {
174+
if (ptc.charge == 0 ||
175+
vector::perp(ptc.momentum) < m_cfg.truth_config.pT_min ||
176+
ptc.vertex[2] < m_cfg.truth_config.z_min ||
177+
ptc.vertex[2] > m_cfg.truth_config.z_max ||
178+
vector::perp(ptc.vertex) > m_cfg.truth_config.r_max ||
179+
num_measurements < m_cfg.truth_config.min_track_candidates) {
158180
continue;
159181
}
160182

183+
total_truth_particles++;
184+
161185
bool is_matched = false;
162186
std::size_t n_matched_seeds_for_particle = 0;
163187
auto it = match_counter.find(pid);
164188
if (it != match_counter.end()) {
165189
is_matched = true;
166190
n_matched_seeds_for_particle = it->second;
191+
total_matched_truth_particles++;
192+
total_duplicate_seeds += n_matched_seeds_for_particle - 1;
167193
}
168194

169195
m_data->m_eff_plot_tool.fill(m_data->m_eff_plot_cache, ptc, is_matched);
170196
m_data->m_duplication_plot_tool.fill(m_data->m_duplication_plot_cache,
171197
ptc,
172198
n_matched_seeds_for_particle - 1);
173199
}
200+
201+
TRACCC_INFO("Total number of truth particles was "
202+
<< total_truth_particles);
203+
TRACCC_INFO("Total number of found seeds was " << n_seeds);
204+
TRACCC_INFO("Total number of seed-matched particles was "
205+
<< total_matched_truth_particles);
206+
TRACCC_INFO("Total number of duplicate seeds was "
207+
<< total_duplicate_seeds);
208+
TRACCC_INFO("Total number of fake seeds was " << total_fake_seeds);
209+
TRACCC_INFO("Total seed efficiency was "
210+
<< (100. * static_cast<double>(total_matched_truth_particles) /
211+
static_cast<double>(total_truth_particles))
212+
<< "%");
213+
TRACCC_INFO("Total seed duplicate rate was "
214+
<< (static_cast<double>(total_duplicate_seeds) /
215+
static_cast<double>(total_matched_truth_particles)));
216+
TRACCC_INFO("Total seed fake rate was "
217+
<< (static_cast<double>(total_fake_seeds) /
218+
static_cast<double>(total_truth_particles)));
174219
}
175220

176221
void seeding_performance_writer::finalize() {

0 commit comments

Comments
 (0)