File indexing completed on 2025-07-02 07:51:40
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Detector/Detector.hpp"
0010 #include "Acts/Plugins/Detray/DetrayConversionUtils.hpp"
0011 #include "Acts/Plugins/Detray/DetrayConverter.hpp"
0012 #include "Acts/Plugins/Python/Utilities.hpp"
0013
0014 #include <memory>
0015 #include <string>
0016
0017 #include <detray/builders/detector_builder.hpp>
0018 #include <pybind11/pybind11.h>
0019 #include <vecmem/memory/host_memory_resource.hpp>
0020 #include <vecmem/memory/memory_resource.hpp>
0021
0022 namespace py = pybind11;
0023 using namespace pybind11::literals;
0024
0025 using namespace Acts;
0026 using namespace detray;
0027 using namespace detray::io::detail;
0028
0029 namespace Acts::Python {
0030
0031 void addDetray(Context& ctx) {
0032 auto [m, mex] = ctx.get("main", "examples");
0033
0034 auto detray = m.def_submodule("detray");
0035 {
0036 py::class_<DetrayHostDetector, std::shared_ptr<DetrayHostDetector>>(
0037 detray, "detray_detector");
0038 }
0039
0040 {
0041
0042
0043
0044
0045 detray.def("writeToJson", [](const GeometryContext& gctx,
0046 const Experimental::Detector& detector) {
0047 auto memoryResource = vecmem::host_memory_resource();
0048
0049 DetrayConverter::Options options;
0050 options.writeToJson = true;
0051 options.convertMaterial = false;
0052 options.convertSurfaceGrids = true;
0053 auto DetrayHostDetector =
0054 DetrayConverter().convert<>(gctx, detector, memoryResource, options);
0055 });
0056 }
0057
0058 {
0059 auto converter = py::class_<DetrayConverter>(detray, "DetrayConverter");
0060
0061 auto options = py::class_<DetrayConverter::Options>(converter, "Options")
0062 .def(py::init<>());
0063
0064 ACTS_PYTHON_STRUCT(options, convertMaterial, convertSurfaceGrids,
0065 writeToJson);
0066 }
0067 }
0068 }