Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Plane surface merging #4037

Merged
merged 13 commits into from
Jan 21, 2025
Merged

feat: Plane surface merging #4037

merged 13 commits into from
Jan 21, 2025

Conversation

ssdetlab
Copy link
Contributor

@ssdetlab ssdetlab commented Jan 20, 2025

Adding mergedWith method for the PlaneSurface.

The logic is similar to that of the CylinderSurface -- to be merged two surfaces have to touch each other along the merging direction bound and same-sized aligned bounds along the direction that is orthogonal to the merging direction.

The main difference with the CylinderSurface implementation is in the requirement of relative rotation matrix to be exactly identity.

The convention for the binning values is defined by the local surface coordinates.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added surface merging capability for plane surfaces.
    • Introduced a method to combine compatible plane surfaces along specified directions.
  • Tests

    • Enhanced test coverage for surface merging scenarios.
    • Added comprehensive validation for surface alignment and merging conditions, including checks for misalignment and successful merges.
  • Bug Fixes

    • Implemented robust error handling for incompatible surface merging attempts.
  • Documentation

    • Updated terminology in method documentation for clarity.

Copy link

coderabbitai bot commented Jan 20, 2025

Walkthrough

A new method mergedWith, introduced it is, to the PlaneSurface class. Enables the merging of compatible plane surfaces, it does. The implementation adds functionality to combine two plane surfaces under specific geometric constraints, such as alignment and bounds compatibility. Changes span the header file, implementation file, and comprehensive unit tests to validate the merging behavior across various scenarios, they do.

Changes

File Change Summary
Core/include/Acts/Surfaces/PlaneSurface.hpp Added public mergedWith method declaration and updated documentation for referencePosition method
Core/src/Surfaces/PlaneSurface.cpp Implemented mergedWith method with detailed merging logic and compatibility checks, added necessary includes
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp Added new test suite PlaneSurfaceMerging with multiple test cases for surface merging scenarios

Sequence Diagram

sequenceDiagram
    participant S1 as Surface 1
    participant S2 as Surface 2
    participant Merger as mergedWith()
    participant Result as Merged Surface

    S1->>Merger: Provide surface parameters
    S2->>Merger: Provide surface parameters
    Merger->>Merger: Validate compatibility
    Merger-->>Result: Create new surface
    Result-->>S1: Return merged surface
Loading

Poem

Surfaces dance, align just right,
Merging planes with Jedi might! 🌟
Bounds check, no angle askew,
A geometric ballet true 🚀
Wisdom in each surface's flight! 🌈

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Component - Core Affects the Core module label Jan 20, 2025
@github-actions github-actions bot added this to the next milestone Jan 20, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3976a1 and 5d69338.

📒 Files selected for processing (3)
  • Core/include/Acts/Surfaces/PlaneSurface.hpp (1 hunks)
  • Core/src/Surfaces/PlaneSurface.cpp (2 hunks)
  • Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (3 hunks)
🧰 Additional context used
🪛 GitHub Actions: Analysis
Core/include/Acts/Surfaces/PlaneSurface.hpp

[error] 230-230: 'BinningValue' has not been declared in PlaneSurface class definition

🪛 GitHub Actions: Builds
Core/include/Acts/Surfaces/PlaneSurface.hpp

[error] 230-230: 'BinningValue' has not been declared in PlaneSurface.hpp

🪛 cppcheck (2.10-2)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp

[error] 383-383: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: missing_includes
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / clang_tidy
🔇 Additional comments (2)
Core/src/Surfaces/PlaneSurface.cpp (1)

235-239: ⚠️ Potential issue

'BinningValue' declared properly, it must be.

Compilation errors occur because 'BinningValue' undeclared it is. Include the correct header or fully qualify the type, you should.

Run this script to check for missing includes or namespace issues:

Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (1)

383-383: Configure Boost.Test properly, you should.

Static analysis tool hints at unknown macro. Ensure test module defined and Boost.Test configured correctly, you must.

🧰 Tools
🪛 cppcheck (2.10-2)

[error] 383-383: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

Core/src/Surfaces/PlaneSurface.cpp Outdated Show resolved Hide resolved
Core/include/Acts/Surfaces/PlaneSurface.hpp Show resolved Hide resolved
Core/include/Acts/Surfaces/PlaneSurface.hpp Outdated Show resolved Hide resolved
Core/include/Acts/Surfaces/PlaneSurface.hpp Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
Core/src/Surfaces/PlaneSurface.cpp (2)

224-233: Safer bounds validation, implement you should.

Check for nullptr before dynamic_cast, wise it would be. Prevent undefined behavior, this will.

-const RectangleBounds* thisBounds =
-      dynamic_cast<const RectangleBounds*>(&bounds());
-const RectangleBounds* otherBounds =
-      dynamic_cast<const RectangleBounds*>(&other.bounds());
+const auto* thisBounds = &bounds();
+const auto* otherBounds = &other.bounds();
+
+if (thisBounds == nullptr || otherBounds == nullptr) {
+    throw SurfaceMergingException(
+        getSharedPtr(), other.getSharedPtr(),
+        "PlaneSurface::merge: bounds must not be null");
+}
+
+const RectangleBounds* thisRectBounds = dynamic_cast<const RectangleBounds*>(thisBounds);
+const RectangleBounds* otherRectBounds = dynamic_cast<const RectangleBounds*>(otherBounds);
+
+if (thisRectBounds == nullptr || otherRectBounds == nullptr) {

241-308: Improve readability of merging logic, we must.

Complex calculations, these are. Better variable names and comments, help future Jedi they will.

Suggestions for improvement:

  1. Rename variables to be more descriptive:
-double thisHalfMerge
+double thisHalfLengthInMergeDir
-double otherHalfMerge
+double otherHalfLengthInMergeDir
-double newMidMerge
+double newCenterPositionInMergeDir
  1. Add comments explaining the geometric calculations:
+  // Calculate the extent of the merged surface in the merging direction
   double newMaxMerge = std::max(thisMaxMerge, otherMaxMerge);
   double newMinMerge = std::min(thisMinMerge, otherMinMerge);

+  // Calculate the half-length and center position of the merged surface
   double newHalfMerge = (newMaxMerge - newMinMerge) / 2;
   double newMidMerge = (newMaxMerge + newMinMerge) / 2;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78ba38a and 2558eb0.

📒 Files selected for processing (2)
  • Core/include/Acts/Surfaces/PlaneSurface.hpp (2 hunks)
  • Core/src/Surfaces/PlaneSurface.cpp (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Core/include/Acts/Surfaces/PlaneSurface.hpp
⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: merge-sentinel
  • GitHub Check: unused_files
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: missing_includes
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: linux_ubuntu_extra (ubuntu2204_clang, 20)
  • GitHub Check: build_debug
  • GitHub Check: macos
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20)
  • GitHub Check: linux_ubuntu
  • GitHub Check: docs
🔇 Additional comments (4)
Core/src/Surfaces/PlaneSurface.cpp (4)

11-24: Approve the new includes and method signature, I do.

Well-structured and appropriate for the task at hand, the changes are. Clear documentation through logging, you have provided.

Also applies to: 197-202


203-208: Wise validation of detector elements, this is.

Prevent merging of surfaces with detector elements, you must. Clear error message, you provide.


210-222: Use tolerance when comparing rotations, you must.

A previous suggestion, this was. Yet, direct comparison of floating-point numbers, still you do. Numerical instabilities, this may cause.

Apply this diff to include a tolerance in the comparison:

-if (std::abs((otherLocal.rotation().matrix() - RotationMatrix3::Identity())
-                   .norm())) {
+constexpr double rotationTolerance = 1e-9;
+if ((otherLocal.rotation().matrix() - RotationMatrix3::Identity()).norm() > rotationTolerance) {

235-239: Valid direction checking, you have implemented.

Clear and concise validation of merging direction, this is. Good error message, you provide.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
Core/src/Surfaces/PlaneSurface.cpp (1)

216-223: Make the rotation tolerance configurable, you should.

Hardcoded tolerance value for rotation comparison, not ideal it is. Consider making it configurable through the BoundaryTolerance class or a dedicated configuration parameter.

Apply this diff to make the tolerance configurable:

-  if ((otherLocal.rotation().matrix() - RotationMatrix3::Identity()).norm() >
-      tolerance) {
+  const auto& boundaryTolerance = BoundaryTolerance::None();
+  if ((otherLocal.rotation().matrix() - RotationMatrix3::Identity()).norm() >
+      boundaryTolerance.rotationTolerance(tolerance)) {
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (1)

510-549: Add test cases for edge conditions, you should.

Good coverage of basic merging scenarios, the test has. But missing test cases for edge conditions, it is:

  • Surfaces touching at exactly the tolerance value
  • Surfaces with minimal overlap
  • Surfaces with maximum allowed size difference

Assistance in generating additional test cases, offer I do. Want me to help implement these test cases, do you?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2558eb0 and 2a940e5.

📒 Files selected for processing (3)
  • Core/include/Acts/Surfaces/PlaneSurface.hpp (1 hunks)
  • Core/src/Surfaces/PlaneSurface.cpp (2 hunks)
  • Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Core/include/Acts/Surfaces/PlaneSurface.hpp
🧰 Additional context used
🪛 cppcheck (2.10-2)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp

[error] 382-382: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: linux_ubuntu_extra (ubuntu2204_clang, 20)
  • GitHub Check: macos
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20)
  • GitHub Check: linux_ubuntu
  • GitHub Check: build_debug
  • GitHub Check: unused_files
  • GitHub Check: missing_includes
🔇 Additional comments (2)
Core/src/Surfaces/PlaneSurface.cpp (1)

213-214: Address the tolerance value uncertainty, you must.

Uncertain about the tolerance value, the TODO comment is. Investigate and document the rationale for using s_onSurfaceTolerance, we should.

Run this script to find other tolerance usages in the codebase:

✅ Verification successful

Appropriate the tolerance value is, young Padawan.

The Force reveals that s_onSurfaceTolerance value of 0.1 micrometers (1e-4 mm) is well-balanced it is:

  • Precise enough for surface geometry operations
  • Consistent with physical detector resolutions
  • Validated through extensive test coverage

Remove the TODO comment, you should. Trust in this tolerance value, we must.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for other usages of s_onSurfaceTolerance in rotation comparisons

# Test: Search for rotation comparison with s_onSurfaceTolerance
rg -A 5 'rotation.*s_onSurfaceTolerance|s_onSurfaceTolerance.*rotation'

Length of output: 73


Script:

#!/bin/bash
# Find definition and all usages of s_onSurfaceTolerance
echo "=== Searching for s_onSurfaceTolerance definition and usage ==="
rg "s_onSurfaceTolerance" -B 2 -A 2

echo -e "\n=== Searching for other tolerance constants ==="
rg "constexpr.*tolerance" -B 1 -A 1

echo -e "\n=== Searching for Surface-related tolerance definitions ==="
rg "Surface.*tolerance|tolerance.*Surface" -B 1 -A 1

Length of output: 66199

Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (1)

382-382: Include Boost.Test headers correctly, you must.

Unknown macro BOOST_AUTO_TEST_SUITE detected by static analysis tools, it is. Already included <boost/test/unit_test.hpp> at line 11, we have. False positive from static analysis, this is.

🧰 Tools
🪛 cppcheck (2.10-2)

[error] 382-382: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (1)

477-491: Additional test coverage, suggest I do.

Test Y direction merging for surfaces with different bounds, we should. More complete test coverage, this would provide.

Apply this diff to add Y direction test:

 BOOST_CHECK_THROW(plane->mergedWith(*planeOther, Acts::AxisDirection::AxisX),
                   SurfaceMergingException);
+BOOST_CHECK_THROW(plane->mergedWith(*planeOther, Acts::AxisDirection::AxisY),
+                  SurfaceMergingException);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a940e5 and f7c1601.

📒 Files selected for processing (2)
  • Core/src/Surfaces/PlaneSurface.cpp (2 hunks)
  • Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (3 hunks)
🧰 Additional context used
🪛 cppcheck (2.10-2)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp

[error] 382-382: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

⏰ Context from checks skipped due to timeout of 90000ms (21)
  • GitHub Check: CI Bridge / lcg_106a: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc14]
  • GitHub Check: CI Bridge / lcg_106a: [alma9, gcc13]
  • GitHub Check: CI Bridge / lcg_105: [alma9, clang16]
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: merge-sentinel
  • GitHub Check: linux_ubuntu_extra (ubuntu2204_clang, 20)
  • GitHub Check: macos
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20)
  • GitHub Check: linux_ubuntu
  • GitHub Check: build_debug
  • GitHub Check: unused_files
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: missing_includes
  • GitHub Check: CI Bridge / build_exatrkx_cpu
🔇 Additional comments (6)
Core/src/Surfaces/PlaneSurface.cpp (2)

196-309: Impressive, the implementation is. Approve it, I do.

A well-structured implementation of surface merging, this is. Thorough validation checks and clear merging logic, it has. The Force is strong with this code.

Key features, I observe:

  • Detector element association check
  • Transform existence validation
  • Relative rotation verification
  • Bounds compatibility validation
  • Surface alignment confirmation

213-214: Verify the tolerance value, you must.

Hmm, a TODO comment about tolerance, I see. The s_onSurfaceTolerance value, validate we must, to ensure proper surface alignment detection, we do.

Run this script to find the definition and usage of the tolerance value:

✅ Verification successful

Hmm, good tolerance value this is, young padawan.

A well-chosen value of 1e-4, s_onSurfaceTolerance is. Through extensive testing and widespread use in the codebase, proven its worth has been. For geometric operations and surface alignment, appropriate this tolerance is.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find the definition and usage of s_onSurfaceTolerance

# Search for the definition
rg -A 5 $'s_onSurfaceTolerance.*='

# Search for other usages
rg -A 5 $'s_onSurfaceTolerance'

Length of output: 64967

Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (4)

391-413: Well-crafted test case, this is.

Thorough validation of misaligned surface handling, it provides. Both X and Y directions, it tests. Both forward and reverse merging, it verifies.


415-444: Comprehensive test case for orthogonal misalignment, this is.

Thorough validation of orthogonally misaligned surfaces, it provides. X, Y, and Z translations, it tests. Both forward and reverse merging, it verifies.


446-475: Strong with angular misalignment testing, this test case is.

Thorough validation of surfaces with angular misalignment, it provides. Rotations around X, Y, and Z axes, it tests. Both forward and reverse merging, it verifies.


493-531: Most impressive test case for successful merging, this is.

Thorough validation of successful merging scenarios, it provides:

  • X and Y direction merging, it tests
  • Forward and reverse merging, it verifies
  • Bounds equality, it confirms
  • Merge direction indicator, it validates

Copy link

github-actions bot commented Jan 20, 2025

📊: Physics performance monitoring for ed5d4c3

Full contents

physmon summary

paulgessinger
paulgessinger previously approved these changes Jan 20, 2025
Copy link
Member

@paulgessinger paulgessinger left a comment

Choose a reason for hiding this comment

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

Very nice!

Core/include/Acts/Surfaces/PlaneSurface.hpp Outdated Show resolved Hide resolved
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (1)

494-542: Additional assertions for merged surface properties, needed they are.

Test verifies successful merging scenarios, it does. But more assertions for the merged surface properties, beneficial they would be.

Add these assertions to strengthen the test:

   BOOST_CHECK_EQUAL(planeXMerged->bounds(), *expectedBoundsX);
   BOOST_CHECK_EQUAL(planeXMerged->center(gctx), base * Vector3::UnitX() * 1);
+  BOOST_CHECK(planeXMerged->transform(gctx).rotation() == base.rotation());
+  BOOST_CHECK_EQUAL(planeXMerged->normal(gctx), plane->normal(gctx));

   auto expectedBoundsY = std::make_shared<const RectangleBounds>(1, 4);
   auto [planeYMerged, reversedY] =
       plane->mergedWith(*planeY, Acts::AxisDirection::AxisY, *logger);
   BOOST_REQUIRE_NE(planeYMerged, nullptr);
   BOOST_CHECK(!reversedY);
   BOOST_CHECK_EQUAL(planeYMerged->bounds(), *expectedBoundsY);
   BOOST_CHECK_EQUAL(planeYMerged->center(gctx), base * Vector3::UnitY() * 2);
+  BOOST_CHECK(planeYMerged->transform(gctx).rotation() == base.rotation());
+  BOOST_CHECK_EQUAL(planeYMerged->normal(gctx), plane->normal(gctx));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7c1601 and 8bc9f1b.

📒 Files selected for processing (2)
  • Core/include/Acts/Surfaces/PlaneSurface.hpp (2 hunks)
  • Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Core/include/Acts/Surfaces/PlaneSurface.hpp
🧰 Additional context used
🪛 cppcheck (2.10-2)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp

[error] 382-382: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: merge-sentinel
  • GitHub Check: macos
🔇 Additional comments (5)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (5)

391-413: Well-structured test for surface overlap detection, this is.

Test verifies that overlapping surfaces cannot be merged, it does. Both directions and both merge orders, it checks. Thorough testing, I sense.


415-444: Comprehensive test for misalignment detection, hmm.

Test verifies that surfaces with incorrect positioning cannot be merged, it does. All axes and both merge orders, it checks. Good coverage, this provides.


446-475: Thorough test for rotational misalignment, this is.

Test verifies that rotated surfaces cannot be merged, it does. Different rotation axes and both merge orders, it checks. Well-structured test cases, these are.


477-492: Test for incompatible bounds, I see.

Test verifies that surfaces with different bound sizes cannot be merged, it does. Single direction sufficient it is, as symmetry exists.


382-390: ⚠️ Potential issue

Missing Boost.Test header, I sense.

Include the proper header for Boost.Test macros, you must.

Apply this diff to fix the issue:

+#include <boost/test/unit_test.hpp>

Likely invalid or redundant comment.

🧰 Tools
🪛 cppcheck (2.10-2)

[error] 382-382: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (2)

384-384: Consider logger naming improvement, we should.

More specific logger name than "UnitTests" for better log filtering, suggest I do. Match it with test suite name "PlaneSurfaceMerging", we could.

-auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE);
+auto logger = Acts::getDefaultLogger("PlaneSurfaceMerging", Acts::Logging::VERBOSE);

494-542: Success cases testing, thorough and complete they are.

Test cases for successful merging in both X and Y directions with:

  • Proper bounds validation
  • Center position verification
  • Reversal flag checking
  • Bidirectional merging validation

Additional assertions for merged surface properties, suggest I do.

Add these assertions to strengthen the test:

 BOOST_CHECK_EQUAL(planeXMerged->center(gctx), base * Vector3::UnitX() * 1);
+BOOST_CHECK(planeXMerged->transform(gctx).rotation() == base.rotation());
+BOOST_CHECK_EQUAL(planeXMerged->normal(gctx), plane->normal(gctx));

 BOOST_CHECK_EQUAL(planeYMerged->center(gctx), base * Vector3::UnitY() * 2);
+BOOST_CHECK(planeYMerged->transform(gctx).rotation() == base.rotation());
+BOOST_CHECK_EQUAL(planeYMerged->normal(gctx), plane->normal(gctx));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8bc9f1b and f4e8b3d.

📒 Files selected for processing (1)
  • Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (3 hunks)
🧰 Additional context used
🪛 cppcheck (2.10-2)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp

[error] 382-382: There is an unknown macro here somewhere. Configuration is required. If BOOST_AUTO_TEST_SUITE is a macro then please configure it.

(unknownMacro)

🔇 Additional comments (5)
Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp (5)

9-9: Approve header inclusion, I do.

Fixed the missing Boost.Test header issue from previous review, you have. Pleased with this correction, I am.


391-413: Well-structured test for surface overlap detection, this is!

Test cases for both X and Y directions with bidirectional checks, comprehensive they are. Clear validation of overlap detection, it provides.


415-444: Thorough misalignment testing, observe I do.

Test cases for shifts in X, Y, and Z directions with bidirectional checks, complete they are. Good coverage of alignment requirements, this provides.


446-475: Rotation testing, comprehensive it is.

Test cases for rotations around different axes, thorough they are. Clear validation of rotation constraints, this provides.


477-492: Bounds validation testing, well-implemented it is.

Test case for different bounds sizes, proper validation it provides. Clear assertion of bounds compatibility requirements, this ensures.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
Core/src/Surfaces/PlaneSurface.cpp (2)

236-240: Optimize direction validation using switch statement, we could.

More efficient validation using switch statement, achieve we can.

-  if (direction != AxisDirection::AxisX && direction != AxisDirection::AxisY) {
-    throw SurfaceMergingException(getSharedPtr(), other.getSharedPtr(),
-                                  "PlaneSurface::merge: invalid direction " +
-                                      axisDirectionName(direction));
-  }
+  switch (direction) {
+    case AxisDirection::AxisX:
+    case AxisDirection::AxisY:
+      break;
+    default:
+      throw SurfaceMergingException(getSharedPtr(), other.getSharedPtr(),
+                                   "PlaneSurface::merge: invalid direction " +
+                                       axisDirectionName(direction));
+  }

242-291: Extract helper methods for better organization, we should.

Long and complex this segment is. Extract validation logic into helper methods, improve readability it would.

+ private:
+  void validateNonMergingDimensions(const RectangleBounds* thisBounds,
+                                   const RectangleBounds* otherBounds,
+                                   bool mergeX,
+                                   double tolerance) const {
+    double thisHalfNonMerge =
+        mergeX ? thisBounds->halfLengthY() : thisBounds->halfLengthX();
+    double otherHalfNonMerge =
+        mergeX ? otherBounds->halfLengthY() : otherBounds->halfLengthX();
+
+    if (std::abs(thisHalfNonMerge - otherHalfNonMerge) > tolerance) {
+      throw SurfaceMergingException(
+          getSharedPtr(), other.getSharedPtr(),
+          "PlaneSurface::merge: surfaces have different non-merging lengths");
+    }
+  }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4e8b3d and ed5d4c3.

📒 Files selected for processing (1)
  • Core/src/Surfaces/PlaneSurface.cpp (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: CI Bridge / lcg_105: [alma9, gcc13]
  • GitHub Check: merge-sentinel
  • GitHub Check: CI Bridge / linux_ubuntu_2204_clang
  • GitHub Check: CI Bridge / linux_ubuntu_2204
  • GitHub Check: CI Bridge / build_linux_ubuntu
  • GitHub Check: CI Bridge / build_exatrkx
  • GitHub Check: CI Bridge / build_exatrkx_cpu
  • GitHub Check: CI Bridge / clang_tidy
  • GitHub Check: linux_ubuntu_extra (ubuntu2204_clang, 20)
  • GitHub Check: macos
  • GitHub Check: linux_ubuntu_extra (ubuntu2204, 20)
  • GitHub Check: linux_ubuntu
  • GitHub Check: build_debug
  • GitHub Check: missing_includes
🔇 Additional comments (5)
Core/src/Surfaces/PlaneSurface.cpp (5)

197-208: Approve the initial validation, I do!

Wise validation of detector elements, this is. Prevent unexpected behavior in detector-associated surfaces, it does.


214-215: Address the TODO comment about tolerance, you must.

Uncertainty about tolerance value, expressed in TODO comment it is. Document the reasoning for chosen tolerance value or adjust it based on geometric considerations, you should.


217-224: Use tolerance when comparing rotations, you must.

Directly comparing floating-point numbers, wise it is not. Introduce a small tolerance to account for numerical inaccuracies, you should.


226-234: Clear and precise bounds validation, this is!

Restrict merging to rectangle bounds only, it does. Clear error messages for unsupported cases, it provides.


293-308: Elegant final surface creation, this is!

Clear and efficient implementation for creating merged surface, you have achieved. Well-chosen variable names and helper functions, you have used.

@kodiakhq kodiakhq bot merged commit fc18b59 into acts-project:main Jan 21, 2025
42 checks passed
@paulgessinger paulgessinger modified the milestones: next, v39.0.0 Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Core Affects the Core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants