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: python binding for Detector #2198

Merged

Conversation

asalzburger
Copy link
Contributor

@asalzburger asalzburger commented Jun 12, 2023

This PR introduces python bindings for the new Experimental detectors:

  • It introduces a top level DetectorBuilder, its interface and appropriate python bindings.
  • In order to make this coherent, the formerly provided RootDetectorVolumes are now pushed into the DetectorComponents.
  • finally, it makes the DetectorInspectors redundant, as this can now be done purely in python

As an example, one can now build a detector with one volume simply as:

    surfaces = svlMap[volumeId][layerId]
    
    surfacesHolder = acts.SurfacesHolder(surfaces)
    
    # Volume internals
    rBinning = acts.ProtoBinning( acts.Binning.r, acts.Binning.bound, rRange[0], rRange[1], 2, 1 )    
    phiBinning = acts.ProtoBinning( acts.Binning.phi, acts.Binning.closed, -math.pi, math.pi, 78, 1)
    
    layerStructureConfig = acts.LayerStructureBuilder.Config()
    layerStructureConfig.surfacesProvider = surfacesHolder
    layerStructureConfig.binnings = [ rBinning, phiBinning ]

    layerStructureBuilder = acts.LayerStructureBuilder(layerStructureConfig, 'Test Layer Structure', acts.logging.VERBOSE)

    # Volume externals
    volumeStructureConfig = acts.VolumeStructureBuilder.Config()
    volumeStructureConfig.boundsType = acts.VolumeType.Cylinder
    volumeStructureConfig.boundValues = [ rRange[0], rRange[1], 0.5*(zRange[1]-zRange[0]), math.pi, 0. ]
    volumeStructureConfig.auxilliary = 'Test Shape'
    
    volumeStructureBuilder = acts.VolumeStructureBuilder(volumeStructureConfig, 'Test Volume Structure', acts.logging.VERBOSE)
    
    # Volume builder
    volumeBuilderConfig = acts.DetectorVolumeBuilder.Config()
    volumeBuilderConfig.internalsBuilder = layerStructureBuilder
    volumeBuilderConfig.externalsBuilder = volumeStructureBuilder
    
    volumeBuilder = acts.DetectorVolumeBuilder(volumeBuilderConfig, 'Test Volume Builder', acts.logging.VERBOSE)
            
   detectorBuilderConf = acts.DetectorBuilder.Config() 
   detectorBuilderConf.name = 'Test Detector'
   detectorBuilderConf.builder = volumeBuilder

   detectorBuilder = acts.DetectorBuilder(detectorBuilderConf, 'Test Detector Builder', acts.logging.VERBOSE)

   detector = detectorBuilder.construct(acts.GeometryContext())

@asalzburger asalzburger added this to the next milestone Jun 12, 2023
@github-actions github-actions bot added Component - Core Affects the Core module Component - Examples Affects the Examples module labels Jun 12, 2023
@github-actions
Copy link

github-actions bot commented Jun 12, 2023

📊 Physics performance monitoring for cbf868c

Summary
Full report
Seeding: seeded, truth estimated, orthogonal
CKF: seeded, truth smeared, truth estimated, orthogonal
IVF: seeded, truth smeared, truth estimated, orthogonal
AMVF: seeded, truth smeared, truth estimated, orthogonal
Ambiguity resolution: seeded, orthogonal
Truth tracking
Truth tracking (GSF)

Vertexing

Vertexing vs. mu
IVF seeded

IVF truth_smeared

IVF truth_estimated

IVF orthogonal

AMVF seeded

AMVF truth_smeared

AMVF truth_estimated

AMVF orthogonal

Seeding

Seeding seeded

Seeding truth_estimated

Seeding orthogonal

CKF

CKF seeded

CKF truth_smeared

CKF truth_estimated

CKF orthogonal

Ambiguity resolution

seeded

Truth tracking (Kalman Filter)

Truth tracking

Truth tracking (GSF)

Truth tracking

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Merging #2198 (cbf868c) into main (fc0e58c) will increase coverage by 0.05%.
The diff coverage is 52.63%.

@@            Coverage Diff             @@
##             main    #2198      +/-   ##
==========================================
+ Coverage   49.32%   49.37%   +0.05%     
==========================================
  Files         441      446       +5     
  Lines       25247    25290      +43     
  Branches    11643    11657      +14     
==========================================
+ Hits        12452    12488      +36     
+ Misses       4520     4515       -5     
- Partials     8275     8287      +12     
Impacted Files Coverage Δ
...lude/Acts/Detector/CylindricalContainerBuilder.hpp 100.00% <ø> (ø)
...e/include/Acts/Detector/VolumeStructureBuilder.hpp 100.00% <ø> (ø)
...s/Detector/interface/IDetectorComponentBuilder.hpp 100.00% <ø> (ø)
...nclude/Acts/Digitization/CartesianSegmentation.hpp 63.63% <ø> (ø)
...nclude/Acts/Geometry/GenericCuboidVolumeBounds.hpp 100.00% <ø> (ø)
Core/include/Acts/Propagator/Propagator.hpp 93.33% <ø> (ø)
...Propagator/detail/PointwiseMaterialInteraction.hpp 97.14% <ø> (ø)
Core/src/Detector/detail/PortalHelper.cpp 61.11% <ø> (ø)
Core/src/Detector/VolumeStructureBuilder.cpp 30.76% <18.18%> (+0.07%) ⬆️
Core/src/Detector/LayerStructureBuilder.cpp 38.00% <27.58%> (+2.42%) ⬆️
... and 11 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions github-actions bot added the Component - Plugins Affects one or more Plugins label Jun 14, 2023
@asalzburger asalzburger changed the title feat: introduce first python bindings for the Detector feat: python binding for Detector Jun 14, 2023
@asalzburger asalzburger force-pushed the feat-detector-python-bindings branch from 747180e to 79bd634 Compare June 14, 2023 13:20
Core/include/Acts/Detector/DetectorBuilder.hpp Outdated Show resolved Hide resolved
Core/include/Acts/Detector/interface/IDetectorBuilder.hpp Outdated Show resolved Hide resolved
Core/include/Acts/Detector/interface/ISurfacesProvider.hpp Outdated Show resolved Hide resolved
Core/include/Acts/Detector/interface/ISurfacesProvider.hpp Outdated Show resolved Hide resolved
Core/include/Acts/Detector/interface/ISurfacesProvider.hpp Outdated Show resolved Hide resolved
Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp Outdated Show resolved Hide resolved
Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp Outdated Show resolved Hide resolved
Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp Outdated Show resolved Hide resolved
Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp Outdated Show resolved Hide resolved
Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added Component - Documentation Affects the documentation Seeding labels Jun 15, 2023
Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

looks good! left a few formatting comments and questions. happy to re-review/approve

Core/include/Acts/Detector/LayerStructureBuilder.hpp Outdated Show resolved Hide resolved
Core/src/Detector/DetectorBuilder.cpp Outdated Show resolved Hide resolved
Core/src/Detector/CylindricalContainerBuilder.cpp Outdated Show resolved Hide resolved
Core/include/Acts/Detector/ProtoBinning.hpp Outdated Show resolved Hide resolved
Core/include/Acts/Detector/DetectorBuilder.hpp Outdated Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Outdated Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Outdated Show resolved Hide resolved
Examples/Python/src/Geometry.cpp Outdated Show resolved Hide resolved
@asalzburger
Copy link
Contributor Author

Hey @andiwand - I think I addressed all comments now.

@andiwand
Copy link
Contributor

there are a bunch on conflicts after IWYU fixes went in - I can approve when this is fixed

Examples/Python/src/Base.cpp Outdated Show resolved Hide resolved
Examples/Python/src/Json.cpp Show resolved Hide resolved
@paulgessinger
Copy link
Member

Generally I would caution against exposing types with different names and outside of their C++ scope, i.e. a nested enum/struct whatever should be exposed as a nested type in python. Otherwise I'm a bit worried this might cause confusion.

@asalzburger asalzburger merged commit 1e58c70 into acts-project:main Jun 16, 2023
48 of 50 checks passed
@paulgessinger paulgessinger modified the milestones: next, v27.0.0 Jun 20, 2023
@asalzburger asalzburger deleted the feat-detector-python-bindings branch September 19, 2023 15:31
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 - Documentation Affects the documentation Component - Examples Affects the Examples module Component - Plugins Affects one or more Plugins Seeding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants