Skip to content

test: assert all placement rotations preserve handedness#72

Merged
olantwin merged 2 commits into
mainfrom
test/rotations-right-handed
Jul 24, 2026
Merged

test: assert all placement rotations preserve handedness#72
olantwin merged 2 commits into
mainfrom
test/rotations-right-handed

Conversation

@olantwin

@olantwin olantwin commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Motivation

Follow-up to #70. That PR fixed a left-handed placement frame in SBTStructureBuilder (columns (b, n, d) with b = d × n, giving det < 0), which GeoModel2G4 forwarded to CLHEP::HepRotation as an improper rotation — 180 ZMpvImproperRotation warnings per Geant4 job. Nothing in CI prevents that class of bug from returning, and the frame construction is duplicated across two sites in SBTStructureBuilder.cpp, so any future builder could reintroduce it.

Change

Add ConsistencyTest.AllRotationsRightHanded, which builds the full geometry via SHiPGeometryBuilder and recursively walks the entire world tree, asserting that the linear part of every getXToChildVol transform has positive determinant. A reflection anywhere in the tree fails the test, naming the offending volume path. This covers all subsystems, not just the SBT structure, and pins the 180 → 0 property permanently.

Verification

The walk visits all ~930k nodes and takes ~190 s, dominated by getXToChildVol materializing GeoSerialTransformer replicas. Global scope is intentional, to guard every current and future builder.

Summary by CodeRabbit

  • Tests
    • Added a geometry consistency check to ensure all nested placement transforms preserve proper right-handed rotations.
    • Added validation to confirm the world volume is available before traversing and verifying the full geometry hierarchy.

Recursively walk the assembled world tree and check that the linear part
of every getXToChildVol transform has positive determinant, so a reflection
(left-handed frame) fails the build. This pins the fix from #70 permanently
and covers any future builder, not just the SBT structure.
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bef9f8d3-0bc1-411d-9dc2-2d58ad9362d0

📥 Commits

Reviewing files that changed from the base of the PR and between c83b7df and c33445d.

📒 Files selected for processing (1)
  • tests/test_consistency.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_consistency.cpp

📝 Walkthrough

Walkthrough

Adds a recursive geometry consistency check that asserts every nested placement transform has a strictly positive linear-part determinant, and runs it from a non-null world volume in a new Catch2 test.

Changes

Geometry consistency validation

Layer / File(s) Summary
Recursive placement determinant test
tests/test_consistency.cpp
Traverses the volume hierarchy, logs placement determinants, asserts they are positive, and applies the check to the geometry builder’s world volume.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • ShipSoft/Geometry#70: Fixes beam placement rotation frames to use right-handed cross-product ordering, which this test validates.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: a test that asserts placement rotations preserve handedness.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/rotations-right-handed

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@olantwin

Copy link
Copy Markdown
Contributor Author

Note: This currently takes several minutes, because the scattering detector is implemented with every single fiber.

@olantwin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/test_consistency.cpp (1)

71-74: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the invariant description with what is tested.

det > 0 rejects reflections, but it does not prove the transform is a pure rotation; positive-scale or shear transforms also pass. Either describe this as an orientation-preserving check or add orthonormality/unit-scale assertions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_consistency.cpp` around lines 71 - 74, Update the invariant
comment for the recursive placement-transform check to describe it as verifying
positive determinant/orientation preservation, not as proving a pure rotation.
Keep the existing determinant-based test unchanged unless adding the requested
orthonormality and unit-scale assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_consistency.cpp`:
- Around line 75-82: Update checkRightHanded to carry the placement path through
recursive calls, including each child index and logical-volume name. Build the
path from the root to the current child and include it in the INFO diagnostic
alongside the determinant, while preserving the existing handedness check and
recursion.
- Around line 88-94: Update ConsistencyTest.AllRotationsRightHanded so its
several-minute full-geometry traversal is excluded from default Catch2/CI runs.
Add the project’s dedicated slow/integration classification, such as a slow tag
or separate target, and ensure default test configuration excludes it while
retaining the test for explicit execution.

---

Nitpick comments:
In `@tests/test_consistency.cpp`:
- Around line 71-74: Update the invariant comment for the recursive
placement-transform check to describe it as verifying positive
determinant/orientation preservation, not as proving a pure rotation. Keep the
existing determinant-based test unchanged unless adding the requested
orthonormality and unit-scale assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d0be9e98-0070-4869-9d0e-bcbd76bfeeec

📥 Commits

Reviewing files that changed from the base of the PR and between c6d866b and c83b7df.

📒 Files selected for processing (1)
  • tests/test_consistency.cpp

Comment thread tests/test_consistency.cpp Outdated
Comment thread tests/test_consistency.cpp
@olantwin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@olantwin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@olantwin
olantwin merged commit ac21fb2 into main Jul 24, 2026
4 checks passed
@olantwin
olantwin deleted the test/rotations-right-handed branch July 24, 2026 14:33
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.

1 participant