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: Bind some Gen1 geometry building functionality to python #3448

Merged
merged 19 commits into from
Aug 22, 2024

Conversation

benjaminhuth
Copy link
Member

@benjaminhuth benjaminhuth commented Jul 26, 2024

Gen1 Geometry building ist better than its reputation, if you bind it to python. Was used to build ITk from GeoModel.

image

Necessary changes to the GeoModel Plugin will come in a subsequent PR, the script that actually builds the ITk won't live in the ACTS repository.

@benjaminhuth
Copy link
Member Author

cc @asalzburger @noemina

@benjaminhuth benjaminhuth added this to the next milestone Jul 26, 2024
@github-actions github-actions bot added Component - Core Affects the Core module Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins labels Jul 26, 2024
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.

Sorry to push back on this a little bit, but I don't think we should substantially increase the amount of Core API surface that we expose to python, and then implement logic that can be implemented in C++ in python instead.

The python bindings are supposed to steer the examples, and help with configuration, not contain sophisticated logic and algorithms.

Aside from this, I see a number of unrelated changes, that should be broken out into one or more separate PRs, in my opinion.

Examples/Scripts/Python/itk_from_geomodel_gen1.py Outdated Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Show resolved Hide resolved
Examples/Scripts/Python/propagation.py Outdated Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Outdated Show resolved Hide resolved
Examples/Python/src/Detector.cpp Outdated Show resolved Hide resolved
Examples/Python/src/Base.cpp Outdated Show resolved Hide resolved
@paulgessinger
Copy link
Member

Can we hold this until Thursday so we can discuss how to proceed with this?

@benjaminhuth benjaminhuth marked this pull request as draft July 29, 2024 07:48
@benjaminhuth
Copy link
Member Author

Unfortunately I won't be there on thursday, and also not in the first week of August. But maybe we can resolve this online...

Regarding the question if it at all should be in python and cannot be in C++: I think that adding bindings to a few building structures does not substentially increase the API surface, and is well justified in that case: I don't think its good to have details like regex parsing of ITK database strings, number of layers, radii of volumes etc. in C++ rather then in a python script. I think the chosen approach is actually quite in the spirit of having configuration logic in python, and generic functionality in C++.
Last but not least I'm not super eager to rewrite the code in C++ now where it is already done in python^^

In todays standup meeting we also clarified, that the build script itself will not become part of the ACTS repository, but rather the ITk repository where also the database is located. Also from this perspective I think a python script is favourable over a C++-compiled version of the geometry building.

@benjaminhuth
Copy link
Member Author

For the record: build script has been removed, unrelated/propagation related changes have been reverted

Copy link

github-actions bot commented Jul 29, 2024

📊: Physics performance monitoring for dec0a63

Full contents

physmon summary

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.

@benjaminhuth Sure.

Mainly I'm concerned with creating volume bounds and tracking volumes directly in Python, and doing any of the sizing calculations in Python.

Especially the latter clearly deviates from configuration over calculation. If that's outside the repository and hence specific to the ITk test, I'm ok with that.

If you ask me, I would suggest to find a way to put the sizing logic into C++ with some form of configuration at the boundary and bind that to Python.

Examples/Python/src/GeometryBuildingGen1.cpp Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Outdated Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Outdated Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Outdated Show resolved Hide resolved
@benjaminhuth
Copy link
Member Author

I think the main difference here in our approach is that I only aime for "making it work until NextGen Geometry is ready", so the approach was never to port the full flexibility of Gen1 geometry building to python. I don't think we open the box of pandora with that.

I think it would be far from straight forward to do a generic C++ sizing logic for Gen1 geometry (I think that is done in the GenericDetector to some degree, but turned out to not be portable enough for this use case). Trying this would end up in an almost as complex system as the blueprint method or so... And I would not invest time in such a thing for an already deprecated geometry model.

In my opinion it is be okay to have incomplete and inconsistent bindings for this for the time being, just make things work in this geometry transistion phase that will be anyways a bit unpleasent...

@paulgessinger
Copy link
Member

I see your point. But to some degree the thing is that yes, the sizing logic it possibly non-trivial, I wrote the code to do that in Athena for the Gen1 ACTS geometry.

I think it would be far from straight forward to do a generic C++ sizing logic for Gen1 geometry

Correct, the interfaces were meant to be used in experiment specific code to write geometry construction. The dd4hep and TGeo plugins achieve this through configuration, which is necessary because we ship them as plugins.

GeoModel is a bit different because it's only used by ATLAS, but I don't think we should ship a plugin that's "GeoModel, but only for ITk kind of".

Now, with the Python building code gone from the repository, I don't have fundamental objections against the rest of this PR.

I would still encourage evaluating the code that we do put in, so that it makes sense, and is not just whatever needed to be added to get something done.

Examples/Python/src/GeometryBuildingGen1.cpp Outdated Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Outdated Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Outdated Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Show resolved Hide resolved
@benjaminhuth benjaminhuth changed the title feat: Build ITk with Gen1 geometry and geomodel feat: Expose some Gen1 geometry building functionality to python Aug 20, 2024
@benjaminhuth benjaminhuth changed the title feat: Expose some Gen1 geometry building functionality to python feat: Bind some Gen1 geometry building functionality to python Aug 20, 2024
@benjaminhuth
Copy link
Member Author

@paulgessinger @andiwand I changed the PR as follows:

  • Changes to the GeoModel Plugin are postponed to a subsequent PR
  • The PythonLogger is not used anymore

Is this good to go in from your perspective?

@github-actions github-actions bot removed the Component - Plugins Affects one or more Plugins label Aug 20, 2024
Examples/Python/src/Geometry.cpp Outdated Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Outdated Show resolved Hide resolved
Examples/Python/src/GeometryBuildingGen1.cpp Outdated Show resolved Hide resolved
@benjaminhuth
Copy link
Member Author

I think I addressed your comments, can you have a look again @paulgessinger ?

@benjaminhuth benjaminhuth marked this pull request as ready for review August 21, 2024 09:26
Copy link

sonarcloud bot commented Aug 21, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
9.5% Coverage on New Code (required ≥ 25%)
33.33% Line Coverage on New Code (required ≥ 50%)

See analysis details on SonarCloud

@paulgessinger
Copy link
Member

Merging this manually.

@paulgessinger paulgessinger merged commit ecad6fd into acts-project:main Aug 22, 2024
40 of 42 checks passed
@paulgessinger paulgessinger modified the milestones: next, v36.2.0 Aug 26, 2024
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 Component - Examples Affects the Examples module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants