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