// This file is part of the ACTS project. // // Copyright (C) 2016 CERN for the benefit of the ACTS project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. // Must be on top to avoid some conflict between forward declare and typedef // Needed until https://gitlab.cern.ch/GeoModelDev/GeoModel/-/merge_requests/351 // is deployed // clang-format off #include // clang-format on #include "Acts/Geometry/ITrackingGeometryBuilder.hpp" #include "Acts/Surfaces/AnnulusBounds.hpp" #include "Acts/Surfaces/DiscSurface.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "ActsPlugins/GeoModel/GeoModelConverters.hpp" #include "ActsPlugins/GeoModel/GeoModelDetectorElement.hpp" #include "ActsPlugins/GeoModel/GeoModelDetectorElementITk.hpp" #include "ActsPlugins/GeoModel/GeoModelDetectorObjectFactory.hpp" #include "ActsPlugins/GeoModel/GeoModelReader.hpp" #include "ActsPlugins/GeoModel/GeoModelTree.hpp" #include "ActsPlugins/GeoModel/IGeoShapeConverter.hpp" #include "ActsPython/Utilities/Helpers.hpp" #include "ActsPython/Utilities/Macros.hpp" #include #include #include #include #include namespace py = pybind11; using namespace pybind11::literals; PYBIND11_MODULE(ActsPluginsPythonBindingsGeoModel, gm) { using namespace Acts; using namespace ActsPython; using namespace ActsPlugins; // Basic bindings { py::class_(gm, "GeoModelTree::FpvConstLink") .def(py::init<>()) .def("get", &GeoModelTree::FpvConstLink::get, py::return_value_policy::reference); py::class_(gm, "GeoModelTree").def(py::init<>()); gm.def("readFromDb", &GeoModelReader::readFromDb); py::class_>( gm, "GeoModelDetectorElement") .def("logVolName", &GeoModelDetectorElement::logVolName) .def("databaseEntryName", &GeoModelDetectorElement::databaseEntryName) .def("surface", [](GeoModelDetectorElement self) { return self.surface().getSharedPtr(); }); py::class_>( gm, "GeoModelDetectorElementITk") .def("surface", [](GeoModelDetectorElementITk& self) { return self.surface().getSharedPtr(); }); gm.def("convertToItk", &GeoModelDetectorElementITk::convertFromGeomodel); } // Shape converters { py::class_>( gm, "IGeoShapeConverter"); py::class_>(gm, "GeoBoxConverter") .def(py::init<>()) .def("toSensitiveSurface", &GeoBoxConverter::toSensitiveSurface) .def("toPassiveSurface", &GeoBoxConverter::toPassiveSurface); py::class_>(gm, "GeoTrdConverter") .def(py::init<>()) .def("toSensitiveSurface", &GeoTrdConverter::toSensitiveSurface) .def("toPassiveSurface", &GeoTrdConverter::toPassiveSurface); py::class_>(gm, "GeoTubeConverter") .def(py::init<>()) .def("toSensitiveSurface", &GeoTubeConverter::toSensitiveSurface) .def("toPassiveSurface", &GeoTubeConverter::toPassiveSurface); py::class_>( gm, "GeoUnionDoubleTrdConverter") .def(py::init<>()) .def("toSensitiveSurface", &GeoUnionDoubleTrdConverter::toSensitiveSurface) .def("toPassiveSurface", &GeoUnionDoubleTrdConverter::toPassiveSurface); py::class_>( gm, "GeoIntersectionAnnulusConverter") .def(py::init<>()) .def("toSensitiveSurface", &GeoIntersectionAnnulusConverter::toSensitiveSurface) .def("toPassiveSurface", &GeoIntersectionAnnulusConverter::toPassiveSurface); py::class_>(gm, "GeoShiftConverter") .def(py::init<>()) .def("toSensitiveSurface", &GeoShiftConverter::toSensitiveSurface) .def("toPassiveSurface", &GeoShiftConverter::toPassiveSurface); } // Volume factory { auto a = py::class_>( gm, "GeoModelDetectorObjectFactory") .def(py::init([](const GeoModelDetectorObjectFactory::Config& cfg, Logging::Level level) { return std::make_shared( cfg, getDefaultLogger("GeoModelDetectorObjectFactory", level)); })) .def("construct", &GeoModelDetectorObjectFactory::construct); py::class_(a, "Config") .def(py::init<>()) .def_readwrite( "convertSubVolumes", &GeoModelDetectorObjectFactory::Config::convertSubVolumes) .def_readwrite("nameList", &GeoModelDetectorObjectFactory::Config::nameList) .def_readwrite("convertBox", &GeoModelDetectorObjectFactory::Config::convertBox) .def_readwrite("materialList", &GeoModelDetectorObjectFactory::Config::materialList); auto convVol = py::class_( a, "ConvertedGeoVol"); ACTS_PYTHON_STRUCT(convVol, volume, fullPhysVol, name, surfaces); py::class_(a, "Cache") .def(py::init<>()) .def_readwrite("sensitiveSurfaces", &GeoModelDetectorObjectFactory::Cache::sensitiveSurfaces) .def_readwrite("boundingBoxes", &GeoModelDetectorObjectFactory::Cache::volumeBoxFPVs); py::class_(a, "Options") .def(py::init<>()) .def_readwrite("queries", &GeoModelDetectorObjectFactory::Options::queries); } }