Skip to content

fix: validate the BinnedGroup navigation array - #5802

Open
andiwand wants to merge 4 commits into
acts-project:mainfrom
andiwand:fix/binned-group-navigation-validation
Open

fix: validate the BinnedGroup navigation array#5802
andiwand wants to merge 4 commits into
acts-project:mainfrom
andiwand:fix/binned-group-navigation-validation

Conversation

@andiwand

@andiwand andiwand commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

The navigation array handed to BinnedGroup lists, per axis, which local bins to visit and in which order. Those indices are 1-based — the default BinnedGroup fills in is a std::iota from 1ul, and GridBinFinder looks up val[locPosition[i] - 1ul] — but nothing enforced it.

Getting it wrong failed quietly. Index 0 is the underflow bin, which is never filled, so listing it just drops a slice of the detector from the seeding loop with no error or warning. The only guard was an assert in GridBinFinder::getSizePerAxis, compiled out in exactly the optimized builds where seeding runs. An index past the last bin, or a repeated one, was equally unreported.

This validates the array in both constructors, throwing std::invalid_argument naming the axis, the bin and the valid range. The empty-vector default is unchanged, and the fill-in logic is factored into one helper.

--- END COMMIT MESSAGE ---

Compatibility

All in-tree configs (itk.py pixel, pixel high-occupancy, strip) are already valid 1-based, so nothing that works today starts throwing. Same for the six seeding configurations that feed this array from Athena's GridTripletSeedingTool — though Athena's own guard is i >= zBinEdges.size(), which accepts 0, so a matching fix is going in there separately.

Note for reviewers

Rejecting duplicates is the one judgement call here rather than an obvious bug — say the word if you'd rather that stayed permissive and I'll drop it to out-of-range checking only.

Tests

BinnedGroup had no unit test coverage, so this adds Tests/UnitTests/Core/Seeding/BinnedGroupTests.cpp: the three rejection cases, the mask-constructor path, and two visiting-order tests.

@github-actions github-actions Bot added this to the next milestone Jul 30, 2026
@github-actions github-actions Bot added Component - Core Affects the Core module Seeding labels Jul 30, 2026
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

📊: Physics performance monitoring for 3573a09

Full contents

physmon summary

❗️: Downstream build failure

  • eic-shell EICrecon (cc @acts-project/epic-contacts)

The navigation array passed to `BinnedGroup` lists, per axis, the local bin
indices to visit and in which order. The indices are 1-based -- the default
that `BinnedGroup` fills in for an undefined axis is a `std::iota` from 1, and
`GridBinFinder` looks its per-bin neighbour vectors up as `val[locBin - 1]`.
Nothing enforced that convention: the array was moved into the member without
any check.

The consequences of getting it wrong were quiet rather than loud:

- Index 0 is the underflow bin. It is never filled, since the space point grid
  rejects out-of-range positions, so listing it silently drops a slice of the
  detector from the seeding loop with no diagnostic. The only guard was an
  `assert` in `GridBinFinder::getSizePerAxis`, which is compiled out in the
  optimized builds where this actually runs.
- An index past the last bin, or a repeated index, was equally unreported.

Validate the array in both constructors instead, throwing
`std::invalid_argument` with a message naming the axis, the offending bin and
the valid range. The empty-vector default is unchanged.

All in-tree configurations already respect the convention, including the ITk
pixel and strip setups in `Python/Examples/python/itk.py`, so this only rejects
inputs that were already misconfigured.

Also adds the first unit test coverage for `BinnedGroup`, pinning down the
visiting order for both the default and a custom navigation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Lf7fWANWDMYH8HaasmEb9c
@andiwand
andiwand force-pushed the fix/binned-group-navigation-validation branch from 19f2b90 to 93b2227 Compare August 4, 2026 07:01
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Public API surface diff

No change to the public API surface. ✅

benjaminhuth
benjaminhuth previously approved these changes Aug 4, 2026

@benjaminhuth benjaminhuth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, small naming suggestion

Comment thread Core/include/Acts/Seeding/BinnedGroup.ipp Outdated
Addresses review feedback: the name now says what is being validated and
completed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JtMZozesV2rxUdyjyy9mqJ

@benjaminhuth benjaminhuth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants