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: TGeo python binding #3885

Merged
merged 13 commits into from
Dec 6, 2024
Merged

Conversation

asalzburger
Copy link
Contributor

@asalzburger asalzburger commented Nov 21, 2024

This PR adds some first python bindings for the TGeo plugin.

The added functionality is mainly for testing reason, it allows to you test whether sensitive elements from a TGeo description (or those one picks as sensitive) can be translated into TGeoDetectorElements.

--- END COMMIT MESSAGE ---

Summary by CodeRabbit

  • New Features

    • Introduced TGeo functionality in Python bindings for enhanced geometry integration.
    • Added methods for converting GDML files into TGeo detector elements.
    • Implemented a new conditional build option for TGeo plugin integration.
  • Bug Fixes

    • Improved error handling in the TGeo conversion process to ensure geometry manager initialization.
  • Documentation

    • Updated documentation to reflect new methods and classes related to TGeo integration.

Copy link

coderabbitai bot commented Nov 21, 2024

Walkthrough

A new conditional block, added to the CMake configuration for the ActsPythonBindings module, it is. Modular inclusion of the TGeo plugin based on the ACTS_BUILD_PLUGIN_TGEO option allows. If enabled, links to ActsPluginTGeo and includes src/TGeo.cpp; otherwise, src/TGeoStub.cpp it includes. A new function addTGeo(Context& ctx) in the Acts::Python namespace enhances Python bindings. The file TGeo.cpp defines the TGeoDetectorElement class and functions for TGeo geometry integration, while TGeoStub.cpp provides a forward declaration and an empty addTGeo function.

Changes

File Path Change Summary
Examples/Python/CMakeLists.txt Added conditional block for ACTS_BUILD_PLUGIN_TGEO to link ActsPluginTGeo and include TGeo.cpp or TGeoStub.cpp.
Examples/Python/src/ModuleEntry.cpp Added method void addTGeo(Context& ctx) in Acts::Python namespace.
Examples/Python/src/TGeo.cpp Introduced class TGeoDetectorElement, method def surface(self), and function def _convertToElements(...).
Examples/Python/src/TGeoStub.cpp Defined struct Context and added empty method void addTGeo(Context& /*ctx*/).

Poem

In the land of code, a change so bright,
TGeo now dances in the Python light.
Conditional builds, a modular grace,
New functions and classes take their place.
With stubs and elements, the future's in sight,
A symphony of coding, oh what a delight! 🎶✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 69ee3ef and d13b719.

📒 Files selected for processing (1)
  • Examples/Python/src/TGeo.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Examples/Python/src/TGeo.cpp

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 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 - Examples Affects the Examples module label Nov 21, 2024
@asalzburger asalzburger added this to the next milestone Nov 21, 2024
Copy link

github-actions bot commented Nov 21, 2024

📊: Physics performance monitoring for 9293170

Full contents

physmon summary

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

🧹 Outside diff range and nitpick comments (3)
Examples/Python/src/TGeo.cpp (3)

46-46: Typographical error in parameter description, there is.

"Scalor" misspelled is; "scalar" correct spelling is.


55-58: Ensure robust error handling for TGeoManager import, you must.

Import may fail, and gGeoManager null be. Helpful to log or handle error explicitly, it would be.


57-58: Check for null tVolume, you do. Yet, informative error provide, you should.

If tVolume null is, beneficial to notify the user why, it would be.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8895da1 and 40d7638.

📒 Files selected for processing (4)
  • Examples/Python/CMakeLists.txt (1 hunks)
  • Examples/Python/src/ModuleEntry.cpp (2 hunks)
  • Examples/Python/src/TGeo.cpp (1 hunks)
  • Examples/Python/src/TGeoStub.cpp (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Examples/Python/src/TGeoStub.cpp
🔇 Additional comments (4)
Examples/Python/src/TGeo.cpp (1)

59-59: Usage of TGeoIdentity, confirm correct, you should.

TGeoIdentity function accepting a parameter, unusual it is. Ensure API usage correct, you must.

Examples/Python/src/ModuleEntry.cpp (2)

78-78: Orderly inclusion of addTGeo function, you have.

Well-placed, this addition seems.


150-150: Integration of addTGeo into module initialization, good it is.

Enhances Python bindings, this addition does.

Examples/Python/CMakeLists.txt (1)

100-106: Conditional inclusion of TGeo plugin, wisely done, it is.

Build flexibility, this change adds.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

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: 2

🧹 Outside diff range and nitpick comments (2)
Examples/Python/src/TGeo.cpp (2)

31-38: Docstring for Python API, add you must!

Clear documentation for Python users, essential it is. Add docstring to surface() method, you should.

 py::class_<Acts::TGeoDetectorElement,
           std::shared_ptr<Acts::TGeoDetectorElement>>(
    tgeo, "TGeoDetectorElement")
    .def("surface", [](const Acts::TGeoDetectorElement& self) {
+         "Get the surface associated with this detector element"_doc,
          return self.surface().getSharedPtr();
        });

40-47: Documentation for parameters, improve we must!

More detailed documentation for parameters, helpful it would be. Add validation ranges and examples, we should.

     /// Helper function to test if the automatic geometry conversion works
     ///
     /// @param rootFileName is the name of the GDML file
+    /// @note rootFileName must be a valid path to a GDML file
     /// @param sensitiveMatches is a list of strings to match sensitive volumes
+    /// @note sensitiveMatches must not be empty
     /// @param localAxes is the TGeo->ACTS axis conversion convention
+    /// @note localAxes must be one of: "XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"
     /// @param scaleConversion is a unit scalor conversion factor
+    /// @note scaleConversion must be positive, typically 1.0 for mm or 0.1 for cm
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 40d7638 and 69ee3ef.

📒 Files selected for processing (1)
  • Examples/Python/src/TGeo.cpp (1 hunks)
🔇 Additional comments (1)
Examples/Python/src/TGeo.cpp (1)

1-24: Well-organized, the includes and setup are!

Proper license header and necessary includes, you have included. Clear namespace declarations, I see.

Examples/Python/src/TGeo.cpp Show resolved Hide resolved
Examples/Python/src/TGeo.cpp Outdated Show resolved Hide resolved
@asalzburger
Copy link
Contributor Author

@paulgessinger ping ping

Copy link

sonarcloud bot commented Dec 6, 2024

@kodiakhq kodiakhq bot merged commit 8eba09e into acts-project:main Dec 6, 2024
48 checks passed
@github-actions github-actions bot removed the automerge label Dec 6, 2024
@acts-project-service acts-project-service added the Fails Athena tests This PR causes a failure in the Athena tests label Dec 6, 2024
@paulgessinger paulgessinger modified the milestones: next, v38.1.0 Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Examples Affects the Examples module Fails Athena tests This PR causes a failure in the Athena tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants