diff --git a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc index ca295a51b7..524f2d9593 100644 --- a/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc +++ b/src/algorithms/calorimetry/SimCalorimeterHitProcessor.cc @@ -20,9 +20,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -166,8 +166,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 +177,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