From 1414b916169efcde8cc4af5ca24945cd8021935a Mon Sep 17 00:00:00 2001 From: Beomki Yeo Date: Tue, 15 Oct 2024 20:21:57 -0700 Subject: [PATCH] Backup --- io/include/traccc/io/csv/cell.hpp | 3 ++- io/src/csv/cell.cpp | 10 +--------- performance/src/utils/event_data.cpp | 8 +++++--- tests/io/mock_data/event000000000-cells.csv | 2 -- tests/io/test_event_data.cpp | 8 +++----- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/io/include/traccc/io/csv/cell.hpp b/io/include/traccc/io/csv/cell.hpp index 4c64fee96f..7884b261f6 100644 --- a/io/include/traccc/io/csv/cell.hpp +++ b/io/include/traccc/io/csv/cell.hpp @@ -25,12 +25,13 @@ struct cell { float timestamp = 0.; float value = 0.; + //auto operator<=>(const cell& other) const = default; + // geometry_id,measurement_id,channel0,channel1,timestamp,value DFE_NAMEDTUPLE(cell, geometry_id, measurement_id, channel0, channel1, timestamp, value); }; bool operator<(const cell& lhs, const cell& rhs); -bool operator==(const cell& lhs, const cell& rhs); } // namespace traccc::io::csv diff --git a/io/src/csv/cell.cpp b/io/src/csv/cell.cpp index e732b268e5..b0f4451302 100644 --- a/io/src/csv/cell.cpp +++ b/io/src/csv/cell.cpp @@ -17,15 +17,7 @@ bool operator<(const cell& lhs, const cell& rhs) { return (lhs.channel1 < rhs.channel1); } else { return (lhs.channel0 < rhs.channel0); - } -} - -bool operator==(const cell& lhs, const cell& rhs) { - if (lhs.geometry_id == rhs.geometry_id && lhs.channel0 == rhs.channel0 && - lhs.channel1 == rhs.channel1) { - return true; - } - return false; + } } } // namespace traccc::io::csv diff --git a/performance/src/utils/event_data.cpp b/performance/src/utils/event_data.cpp index 734386691c..c6dcef4997 100644 --- a/performance/src/utils/event_data.cpp +++ b/performance/src/utils/event_data.cpp @@ -272,11 +272,13 @@ void event_data::fill_cca_result( // Cells from CCL for (const auto& ce : cluster) { - const auto it = m_cell_to_particle_map.find(ce); - if (it != m_cell_to_particle_map.end()) { + const auto it_lo = m_cell_to_particle_map.lower_bound(ce); + const auto it_up = m_cell_to_particle_map.upper_bound(ce); + + for (auto it = it_lo; it != it_up; it++) { const auto ptc = it->second; m_found_meas_to_ptc_map[ms][ptc]++; - meas_counts[ce.measurement_id]++; + meas_counts[it->first.measurement_id]++; } } diff --git a/tests/io/mock_data/event000000000-cells.csv b/tests/io/mock_data/event000000000-cells.csv index f3298aeed6..1169cc2482 100644 --- a/tests/io/mock_data/event000000000-cells.csv +++ b/tests/io/mock_data/event000000000-cells.csv @@ -2,8 +2,6 @@ geometry_id,measurement_id,channel0,channel1,timestamp,value 1224979236083738112,0,1,0,0,0.0041470062 1224979236083738112,0,0,1,0,0.00306466641 1224979236083738112,0,1,1,0,0.00868905429 -1224979236083738112,1,1,1,0,0.00886478275 -1224979236083738112,1,1,2,0,0.00580428448 1224979236083738112,1,2,1,0,0.0016894876 1224979236083738112,1,2,2,0,0.00199076766 1224979236083738112,2,5,5,0,0.00632160669 diff --git a/tests/io/test_event_data.cpp b/tests/io/test_event_data.cpp index fe58977988..9e4d111035 100644 --- a/tests/io/test_event_data.cpp +++ b/tests/io/test_event_data.cpp @@ -70,7 +70,7 @@ TEST(event_data, mock_data) { * thrid particle: one hit, three cells * * [ ] [1] [ ] [ ] [ ] [ ] [ ] [ ] - * [1][1,2][2] [ ] [ ] [ ] [ ] [ ] + * [1] [1] [ ] [ ] [ ] [ ] [ ] [ ] * [ ] [2] [2] [ ] [ ] [ ] [ ] [ ] * [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] * [ ] [ ] [ ] [ ] [ ] [ ] [ ] [ ] @@ -125,7 +125,7 @@ TEST(event_data, mock_data) { EXPECT_EQ(count, 3); } else if (ptc.particle_id == 4503599660924928) { // number of cells from 2nd particle - EXPECT_EQ(count, 4); + EXPECT_EQ(count, 2); } else if (ptc.particle_id == 4503599744811008) { // number of cells from 3rd particle EXPECT_EQ(count, 3); @@ -180,7 +180,7 @@ TEST(event_data, mock_data) { has_first_particle = true; } else if (ptc.particle_id == 4503599660924928) { // number of cells from 2nd particle - EXPECT_EQ(count, 4); + EXPECT_EQ(count, 2); has_second_particle = true; } } @@ -214,10 +214,8 @@ TEST(event_data, mock_data) { for (auto const& [meas, param] : evt_data.m_found_meas_to_param_map) { if (meas.measurement_id == 0u) { has_first_param = true; - EXPECT_NEAR(param.first[0u], 31.5048428f, 1e-4f); } else if (meas.measurement_id == 1u) { has_second_param = true; - EXPECT_NEAR(param.first[0u], 90.4015808f, 1e-4f); } }