fix: use std::map for deterministic digi raw hit ordering - #2808
Open
wdconinc wants to merge 2 commits into
Open
fix: use std::map for deterministic digi raw hit ordering#2808wdconinc wants to merge 2 commits into
wdconinc wants to merge 2 commits into
Conversation
Replace unordered_map with map in SiliconTrackerDigi and MPGDTrackerDigi. std::map iterates in ascending key order, making output ordering deterministic without a separate sort step or intermediate vector. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves multi-thread reproducibility in the tracking digitization stage by making RawTrackerHit emission order deterministic in SiliconTrackerDigi and MPGDTrackerDigi, and by ensuring links/associations reference the persisted RawTrackerHit objects in the output collections.
Changes:
- Replace
std::unordered_mapwithstd::mapfor per-cell hit aggregation to guarantee deterministic iteration order by cellID. - Update emission loops to bind to the persisted
raw_hitfrom the output collection when creating links/associations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/algorithms/digi/SiliconTrackerDigi.cc | Switch hit aggregation to std::map and ensure links/associations reference the persisted RawTrackerHit objects. |
| src/algorithms/digi/MPGDTrackerDigi.cc | Switch hit aggregation to std::map for deterministic emission order and ensure links/associations reference the persisted RawTrackerHit objects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…#2811) This PR applies the include-what-you-use fixes as suggested by https://github.com/eic/EICrecon/actions/runs/30480148342. Please merge this PR into the branch `wdconinc-fix-digi-determinism-map` to resolve failures in PR #2808. 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>
Contributor
Capybara summary for PR 2808
Last updated 2026-07-31T21:34-04:00 c73d3f2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Briefly, what does this PR introduce? Please link to any relevant presentations or discussions.
Alternative to #2805: make raw-hit emission deterministic in
SiliconTrackerDigiandMPGDTrackerDigiby replacingstd::unordered_mapwithstd::map. Becausestd::mapiterates in ascending key order, the output ordering is deterministic with no extra code — only a one-word change at the declaration site.Comparison with #2805 (explicit sort approach)
std::map)unordered_map+ sort)#include <unordered_map>std::ranges::sortIn practice M ≤ N and for typical tracking events M ≈ N (few cells merge), so the complexities are equivalent. The
std::mapapproach is favoured here because:vectorin fix: stabilize tracker digi raw hit ordering #2805 is gone).The only scenario where
unordered_map+ explicit sort would be strictly faster is when M ≪ N (heavy merging), because accumulation stays O(1) and you pay only O(M log M) at the very end. That is not the typical case for digitization, but if profiling ever shows it matters, the other approach is available.Both PRs also fix the pre-existing bug where links/associations referenced the temporary map value instead of the persisted
RawTrackerHitobject in the output collection.What is the urgency of this PR?
What kind of change does this PR introduce?
Please check if any of the following apply
AI was used to inspect the two digi algorithms, implement the minimal
std::mapalternative fix, and draft this PR description including the comparative tradeoff table.