From 245c41a8925b79262cab460c9eaf1c1456858b82 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 28 Oct 2025 18:57:37 -0500 Subject: [PATCH 1/2] refactor: use std::map for deterministic ordering in SimCalorimeterHitProcessor --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index ca295a51b7..81c1745599 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -166,8 +167,10 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input auto [out_hits, out_hit_contribs] = output; // Map for staging output information. We have 2 levels of structure: - // - top level: (MCParticle, Merged Hit CellID) + // - top level: (MCParticle, Merged Hit CellID, TimeID) // - second level: (Merged Contributions) + // We use std::map instead of std::unordered_map to ensure deterministic ordering + // and reproducible results between single-threaded and multi-threaded execution. // Ideally we would want immediately create our output objects and modify the // contributions when needed. That could reduce the following code to a single loop // (instead of 2 consecutive loops). However, this is not possible as we may have to merge @@ -175,9 +178,7 @@ void SimCalorimeterHitProcessor::process(const SimCalorimeterHitProcessor::Input // reasonable contribution merging, at least the intermediary structure should be // quite a bit smaller than the original hit collection. using HitIndex = std::tuple; - std::unordered_map> - hit_map; + std::map> hit_map; for (const auto& ih : *in_hits) { // the cell ID of the new superhit we are making From 72891b8b63b3b70758629d9cf23251c95508c181 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 28 Oct 2025 19:15:16 -0500 Subject: [PATCH 2/2] refactor: use std::map for deterministic ordering in SimCalorimeterHitProcessor (fix: iwyu) (#2162) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/18892744942. Please merge this PR into the branch `SimCalorimeterHitProcessor-map` to resolve failures in PR #2161. Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index 81c1745599..524f2d9593 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -20,10 +20,9 @@ #include #include #include +#include #include #include -#include -#include #include #include