File indexing completed on 2025-11-29 09:18:29
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Detector/Detector.hpp"
0010
0011 #include "Acts/Geometry/DetectorElementBase.hpp"
0012 #include "Acts/Geometry/TrackingGeometry.hpp"
0013 #include "Acts/Material/IMaterialDecorator.hpp"
0014 #include "Acts/Utilities/BinningType.hpp"
0015 #include "ActsExamples/DetectorCommons/Detector.hpp"
0016 #include "ActsExamples/DetectorCommons/StructureSelector.hpp"
0017 #include "ActsExamples/Framework/IContextDecorator.hpp"
0018 #include "ActsExamples/GenericDetector/AlignedGenericDetector.hpp"
0019 #include "ActsExamples/GenericDetector/GenericDetector.hpp"
0020 #include "ActsExamples/TelescopeDetector/TelescopeDetector.hpp"
0021 #include "ActsExamples/Utilities/Options.hpp"
0022 #include "ActsPython/Utilities/Helpers.hpp"
0023 #include "ActsPython/Utilities/Macros.hpp"
0024
0025 #include <memory>
0026 #include <optional>
0027 #include <string>
0028 #include <utility>
0029 #include <vector>
0030
0031 #include <pybind11/pybind11.h>
0032 #include <pybind11/stl.h>
0033 #include <pybind11/stl/filesystem.h>
0034
0035 namespace py = pybind11;
0036
0037 using namespace Acts;
0038 using namespace ActsExamples;
0039
0040 namespace ActsPython {
0041
0042 void addDetector(Context& ctx) {
0043 auto& mex = ctx.get("examples");
0044
0045 {
0046 py::class_<Detector, std::shared_ptr<Detector>>(mex, "DetectorBase")
0047 .def("nominalGeometryContext", &Detector::nominalGeometryContext)
0048 .def("trackingGeometry", &Detector::trackingGeometry)
0049 .def("gen2Geometry", &Detector::gen2Geometry)
0050 .def("contextDecorators", &Detector::contextDecorators)
0051 .def("__enter__",
0052 [](const std::shared_ptr<Detector>& self) { return self; })
0053 .def("__exit__",
0054 [](std::shared_ptr<Detector>& self,
0055 const std::optional<py::object>&,
0056 const std::optional<py::object>&,
0057 const std::optional<py::object>&) { self.reset(); });
0058 }
0059
0060 {
0061 py::class_<StructureSelector, std::shared_ptr<StructureSelector>>(
0062 mex, "StructureSelector")
0063 .def(py::init<std::shared_ptr<const TrackingGeometry>>())
0064 .def("selectSurfaces", &StructureSelector::selectSurfaces)
0065 .def("selectedTransforms", &StructureSelector::selectedTransforms);
0066 }
0067
0068 {
0069 auto d =
0070 py::class_<GenericDetector, Detector, std::shared_ptr<GenericDetector>>(
0071 mex, "GenericDetector")
0072 .def(py::init<const GenericDetector::Config&>());
0073
0074 auto c = py::class_<GenericDetector::Config>(d, "Config").def(py::init<>());
0075 ACTS_PYTHON_STRUCT(c, buildLevel, logLevel, surfaceLogLevel, layerLogLevel,
0076 volumeLogLevel, buildProto, materialDecorator, gen3,
0077 graphvizFile);
0078 }
0079
0080 {
0081 auto ad = py::class_<AlignedGenericDetector, GenericDetector,
0082 std::shared_ptr<AlignedGenericDetector>>(
0083 mex, "AlignedGenericDetector")
0084 .def(py::init<const GenericDetector::Config&>());
0085 }
0086
0087 {
0088 auto d =
0089 py::class_<TelescopeDetector, Detector,
0090 std::shared_ptr<TelescopeDetector>>(mex, "TelescopeDetector")
0091 .def(py::init<const TelescopeDetector::Config&>());
0092
0093 auto c =
0094 py::class_<TelescopeDetector::Config>(d, "Config").def(py::init<>());
0095 ACTS_PYTHON_STRUCT(c, positions, stereos, offsets, bounds, thickness,
0096 surfaceType, binValue, materialDecorator, logLevel);
0097 }
0098
0099 {
0100 py::class_<DetectorElementBase, std::shared_ptr<DetectorElementBase>>(
0101 mex, "DetectorElementBase");
0102 }
0103 }
0104
0105 }