44 #include <pybind11/pybind11.h>
45 #include <pybind11/stl.h>
47 namespace py = pybind11;
48 using namespace pybind11::literals;
58 .cast<Acts::GeometryIdentifier>();
63 namespace Acts::Python {
65 auto m = ctx.
get(
"main");
68 py::class_<Acts::GeometryIdentifier>(
m,
"GeometryIdentifier")
70 .def(py::init<Acts::GeometryIdentifier::Value>())
86 py::class_<Acts::Surface, std::shared_ptr<Acts::Surface>>(
m,
"Surface")
93 .def(
"type", [](
Acts::Surface&
self) {
return self.type(); });
97 py::enum_<Acts::Surface::SurfaceType>(
m,
"SurfaceType")
98 .
value(
"Cone", Acts::Surface::SurfaceType::Cone)
99 .value(
"Cylinder", Acts::Surface::SurfaceType::Cylinder)
100 .value(
"Disc", Acts::Surface::SurfaceType::Disc)
101 .value(
"Perigee", Acts::Surface::SurfaceType::Perigee)
102 .value(
"Plane", Acts::Surface::SurfaceType::Plane)
103 .value(
"Straw", Acts::Surface::SurfaceType::Straw)
104 .value(
"Curvilinear", Acts::Surface::SurfaceType::Curvilinear)
105 .value(
"Other", Acts::Surface::SurfaceType::Other);
109 py::enum_<Acts::VolumeBounds::BoundsType>(
m,
"VolumeBoundsType")
110 .
value(
"Cone", Acts::VolumeBounds::BoundsType::eCone)
111 .value(
"Cuboid", Acts::VolumeBounds::BoundsType::eCuboid)
112 .value(
"CutoutCylinder",
113 Acts::VolumeBounds::BoundsType::eCutoutCylinder)
114 .value(
"Cylinder", Acts::VolumeBounds::BoundsType::eCylinder)
115 .value(
"GenericCuboid", Acts::VolumeBounds::BoundsType::eGenericCuboid)
116 .value(
"Trapezoid", Acts::VolumeBounds::BoundsType::eTrapezoid)
117 .value(
"Other", Acts::VolumeBounds::BoundsType::eOther);
121 py::class_<Acts::TrackingGeometry, std::shared_ptr<Acts::TrackingGeometry>>(
122 m,
"TrackingGeometry")
123 .def(
"visitSurfaces",
125 self.visitSurfaces(func);
127 .def_property_readonly(
133 py::class_<Acts::Volume, std::shared_ptr<Acts::Volume>>(
m,
"Volume")
135 "makeCylinderVolume",
136 [](
double r,
double halfZ) {
138 std::make_shared<Acts::CylinderVolumeBounds>(0,
r, halfZ);
139 return std::make_shared<Acts::Volume>(Transform3::Identity(),
147 std::shared_ptr<Acts::TrackingVolume>>(
m,
"TrackingVolume");
152 std::shared_ptr<Acts::GeometryIdentifierHook>>(
153 m,
"GeometryIdentifierHook")
154 .def(
py::init([](py::object callable) {
155 auto hook = std::make_shared<GeometryIdentifierHookBinding>();
156 hook->callable = callable;
162 py::class_<Acts::Extent>(
m,
"Extent")
165 std::array<Acts::ActsScalar, 2u>>>&
168 for (
const auto& [bval, frange] : franges) {
169 extent.
set(bval, frange[0], frange[1]);
174 return std::array<Acts::ActsScalar, 2u>{
self.min(bval),
181 auto [
m, mex] = ctx.
get(
"main",
"examples");
183 using namespace Acts::Experimental;
186 py::class_<Detector, std::shared_ptr<Detector>>(
m,
"Detector");
189 py::class_<DetectorVolume, std::shared_ptr<DetectorVolume>>(
m,
194 using SurfaceHierarchyMap =
197 py::class_<SurfaceHierarchyMap, std::shared_ptr<SurfaceHierarchyMap>>(
198 m,
"SurfaceHierarchyMap");
201 mex.def(
"extractVolumeLayerSurfaces", [](
const SurfaceHierarchyMap& smap,
202 bool sensitiveOnly) {
203 std::map<
unsigned int,
204 std::map<unsigned int, std::vector<std::shared_ptr<Surface>>>>
205 surfaceVolumeLayerMap;
206 for (
const auto&
surface : smap) {
209 if (sensitiveOnly and
gid.sensitive() == 0) {
212 surfaceVolumeLayerMap[
gid.volume()][
gid.layer()].push_back(
surface);
215 return surfaceVolumeLayerMap;
221 py::class_<ProtoBinning>(
m,
"ProtoBinning")
223 const std::vector<Acts::ActsScalar>&, std::size_t>())
232 std::shared_ptr<Acts::Experimental::IInternalStructureBuilder>>(
233 m,
"IInternalStructureBuilder");
237 Acts::Experimental::IInternalStructureBuilder,
238 std::shared_ptr<LayerStructureBuilder>>(
239 m,
"LayerStructureBuilder")
243 return std::make_shared<LayerStructureBuilder>(
248 py::class_<LayerStructureBuilder::Config>(lsBuilder,
"Config")
261 std::shared_ptr<Acts::Experimental::ISurfacesProvider>>(
262 m,
"ISurfacesProvider");
265 Acts::Experimental::ISurfacesProvider,
266 std::shared_ptr<LayerStructureBuilder::SurfacesHolder>>(
267 lsBuilder,
"SurfacesHolder")
268 .def(
py::init<std::vector<std::shared_ptr<Surface>>>());
274 using KdtSurfacesProvider2D =
277 py::class_<Range2D>(
m,
"Range2D")
278 .def(
py::init([](
const std::array<Acts::ActsScalar, 2u>& range0,
279 const std::array<Acts::ActsScalar, 2u>& range1) {
281 range[0].shrink(range0[0], range0[1]);
282 range[1].shrink(range1[0], range1[1]);
286 py::class_<KdtSurfaces2D, std::shared_ptr<KdtSurfaces2D>>(
m,
289 const std::vector<std::shared_ptr<Acts::Surface>>&,
290 const std::array<Acts::BinningValue, 2u>&>())
291 .def(
"surfaces", [](KdtSurfaces2D&
self,
const Range2D& range) {
292 return self.surfaces(range);
296 std::shared_ptr<KdtSurfacesProvider2D>>(
m,
297 "KdtSurfacesProvider2D")
299 [](std::shared_ptr<KdtSurfaces2D> kdt,
const Extent& extent) {
300 return std::make_shared<KdtSurfacesProvider2D>(kdt, extent);
307 std::shared_ptr<Acts::Experimental::IExternalStructureBuilder>>(
308 m,
"IExternalStructureBuilder");
312 Acts::Experimental::IExternalStructureBuilder,
313 std::shared_ptr<VolumeStructureBuilder>>(
314 m,
"VolumeStructureBuilder")
318 return std::make_shared<VolumeStructureBuilder>(
323 py::class_<VolumeStructureBuilder::Config>(vsBuilder,
"Config")
336 std::shared_ptr<Acts::Experimental::IGeometryIdGenerator>>(
337 m,
"IGeometryIdGenerator");
341 Acts::Experimental::IGeometryIdGenerator,
342 std::shared_ptr<Acts::Experimental::GeometryIdGenerator>>(
343 m,
"GeometryIdGenerator")
348 return std::make_shared<Acts::Experimental::GeometryIdGenerator>(
352 auto geoIdGenConfig =
353 py::class_<Acts::Experimental::GeometryIdGenerator::Config>(geoIdGen,
369 std::shared_ptr<Acts::Experimental::IDetectorComponentBuilder>>(
370 m,
"IDetectorComponentBuilder");
374 Acts::Experimental::IDetectorComponentBuilder,
375 std::shared_ptr<DetectorVolumeBuilder>>(
376 m,
"DetectorVolumeBuilder")
380 return std::make_shared<DetectorVolumeBuilder>(
383 .def(
"construct", &DetectorVolumeBuilder::construct);
386 py::class_<DetectorVolumeBuilder::Config>(dvBuilder,
"Config")
401 std::shared_ptr<Acts::Experimental::IRootVolumeFinderBuilder>>(
402 m,
"IRootVolumeFinderBuilder");
406 Acts::Experimental::IRootVolumeFinderBuilder,
408 Acts::Experimental::IndexedRootVolumeFinderBuilder>>(
409 m,
"IndexedRootVolumeFinderBuilder")
410 .def(
py::init<std::vector<Acts::BinningValue>>());
418 std::shared_ptr<CylindricalContainerBuilder>>(
419 m,
"CylindricalContainerBuilder")
423 return std::make_shared<CylindricalContainerBuilder>(
426 .def(
"construct", &CylindricalContainerBuilder::construct);
429 py::class_<CylindricalContainerBuilder::Config>(ccBuilder,
"Config")
445 py::class_<DetectorBuilder, std::shared_ptr<DetectorBuilder>>(
446 m,
"DetectorBuilder")
450 return std::make_shared<DetectorBuilder>(
453 .def(
"construct", &DetectorBuilder::construct);
455 auto dConfig = py::class_<DetectorBuilder::Config>(dBuilder,
"Config")