Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Python/Plugins/src/Detray.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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 PYBIND11_MODULE(ActsPluginsPythonBindingsDetray, detray) {
0027   using namespace Acts;
0028   using namespace Acts::Experimental;
0029   using namespace ActsPlugins;
0030   using namespace ActsPython;
0031 
0032   {
0033     py::class_<DetrayHostDetector, std::shared_ptr<DetrayHostDetector>>(
0034         detray, "detray_detector");
0035   }
0036 
0037   {
0038     // This test function will convert an ACTS detector into a detray detector
0039     // and write it to the corresponding json files.
0040     //
0041     // The memory resource and the detector are destroyed after the function
0042     detray.def("writeToJson",
0043                [](const GeometryContext& gctx, const Detector& detector) {
0044                  auto memoryResource = vecmem::host_memory_resource();
0045 
0046                  DetrayConverter::Options options;
0047                  options.writeToJson = true;
0048                  options.convertMaterial = false;
0049                  options.convertSurfaceGrids = true;
0050                  auto DetrayHostDetector = DetrayConverter().convert<>(
0051                      gctx, detector, memoryResource, options);
0052                });
0053   }
0054 
0055   {
0056     auto converter = py::class_<DetrayConverter>(detray, "DetrayConverter");
0057 
0058     auto options = py::class_<DetrayConverter::Options>(converter, "Options")
0059                        .def(py::init<>());
0060 
0061     ACTS_PYTHON_STRUCT(options, convertMaterial, convertSurfaceGrids,
0062                        writeToJson);
0063   }
0064 }