Skip to content

fix: use find_if instead of iterator loops with break - #2383

Merged
wdconinc merged 7 commits into
mainfrom
find_if
Feb 17, 2026
Merged

fix: use find_if instead of iterator loops with break#2383
wdconinc merged 7 commits into
mainfrom
find_if

Conversation

@wdconinc

@wdconinc wdconinc commented Jan 31, 2026

Copy link
Copy Markdown
Contributor

Briefly, what does this PR introduce?

Needs:

In a few places, due to historical limitations of podio collections, we were still using iterator-based loops with tests and early break to do things that are more nicely done with find_if nowadays. This PR introduces the find_if based approach in a few cases, and removes a comment block complaints about all that used to not work...

What kind of change does this PR introduce?

  • Bug fix (issue: tech debt)
  • New feature (issue #__)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

Copilot AI review requested due to automatic review settings January 31, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors a few remaining “iterator loop + break” patterns into std::find_if-based lookups now that podio collections support this more cleanly, and removes outdated commented examples.

Changes:

  • Replace manual association-search loops with std::find_if in scattered-electron association logic.
  • Update beam-particle selection helpers in Beam.h to use std::find_if.
  • Remove a large block of obsolete commented-out iteration examples.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/algorithms/reco/ScatteredElectronsTruth.cc Uses std::find_if to locate the truth↔reco association instead of a manual loop.
src/algorithms/reco/InclusiveKinematicsElectron.cc Removes outdated commented code demonstrating older iteration patterns.
src/algorithms/reco/HadronicFinalState.cc Uses std::find_if for truth↔reco association lookup instead of a manual loop.
src/algorithms/reco/Beam.h Refactors “find first with PDG/status” helpers to std::find_if and adds <algorithm>.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/algorithms/reco/HadronicFinalState.cc
Comment thread src/algorithms/reco/ScatteredElectronsTruth.cc
Comment thread src/algorithms/reco/Beam.h
Comment thread src/algorithms/reco/HadronicFinalState.cc
Copilot AI review requested due to automatic review settings January 31, 2026 21:29

This comment was marked as resolved.

Copilot AI review requested due to automatic review settings January 31, 2026 21:32

This comment was marked as resolved.

@wdconinc
wdconinc marked this pull request as draft January 31, 2026 21:45
@wdconinc
wdconinc marked this pull request as ready for review February 14, 2026 20:24
Copilot AI review requested due to automatic review settings February 14, 2026 20:24
@wdconinc
wdconinc enabled auto-merge February 14, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

wdconinc pushed a commit that referenced this pull request Feb 14, 2026
)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/22023709298.
Please merge this PR into the branch `find_if`
to resolve failures in PR #2383.

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>
@wdconinc
wdconinc requested review from a team and simonge and removed request for a team February 14, 2026 23:26

@simonge simonge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Capybara differences appear to be from other simultaneous PRs.

@wdconinc
wdconinc added this pull request to the merge queue Feb 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 17, 2026
@wdconinc
wdconinc added this pull request to the merge queue Feb 17, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Feb 17, 2026
### Briefly, what does this PR introduce?
Needs:
- [x] podio-1.3 (AIDASoft/podio#626), in
eic-shell as of 2025.09

In a few places, due to historical limitations of podio collections, we
were still using iterator-based loops with tests and early break to do
things that are more nicely done with `find_if` nowadays. This PR
introduces the `find_if` based approach in a few cases, and removes a
comment block complaints about all that used to not work...

### What kind of change does this PR introduce?
- [x] Bug fix (issue: tech debt)
- [ ] New feature (issue #__)
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [ ] Tests for the changes have been added
- [ ] Documentation has been added / updated
- [ ] Changes have been communicated to collaborators

### Does this PR introduce breaking changes? What changes might users
need to make to their code?
No.

### Does this PR change default behavior?
No.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: epic-capybara <139920704+epic-capybara@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 17, 2026
@wdconinc

Copy link
Copy Markdown
Contributor Author

It seems GitHub is having issues with checkout. I'll keep retrying the merge queue...

@wdconinc
wdconinc added this pull request to the merge queue Feb 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 17, 2026
wdconinc and others added 7 commits February 17, 2026 11:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
)

This PR applies the include-what-you-use fixes as suggested by
https://github.com/eic/EICrecon/actions/runs/22023709298.
Please merge this PR into the branch `find_if`
to resolve failures in PR #2383.

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>
Copilot AI review requested due to automatic review settings February 17, 2026 17:19
@wdconinc
wdconinc enabled auto-merge February 17, 2026 17:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wdconinc
wdconinc added this pull request to the merge queue Feb 17, 2026
Merged via the queue into main with commit c63be14 Feb 17, 2026
149 of 151 checks passed
@wdconinc
wdconinc deleted the find_if branch February 17, 2026 18:48
jsobajic pushed a commit that referenced this pull request May 14, 2026
### Briefly, what does this PR introduce?
Needs:
- [x] podio-1.3 (AIDASoft/podio#626), in
eic-shell as of 2025.09

In a few places, due to historical limitations of podio collections, we
were still using iterator-based loops with tests and early break to do
things that are more nicely done with `find_if` nowadays. This PR
introduces the `find_if` based approach in a few cases, and removes a
comment block complaints about all that used to not work...

### What kind of change does this PR introduce?
- [x] Bug fix (issue: tech debt)
- [ ] New feature (issue #__)
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [ ] Tests for the changes have been added
- [ ] Documentation has been added / updated
- [ ] Changes have been communicated to collaborators

### Does this PR introduce breaking changes? What changes might users
need to make to their code?
No.

### Does this PR change default behavior?
No.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: epic-capybara <139920704+epic-capybara@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants