Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Python/Plugins/src/GeoModel.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 // Must be on top to avoid some conflict between forward declare and typedef
0010 // Needed until https://gitlab.cern.ch/GeoModelDev/GeoModel/-/merge_requests/351
0011 // is deployed
0012 // clang-format off
0013 #include <GeoModelRead/ReadGeoModel.h>
0014 // clang-format on
0015 
0016 #include "Acts/Detector/CylindricalContainerBuilder.hpp"
0017 #include "Acts/Geometry/ITrackingGeometryBuilder.hpp"
0018 #include "Acts/Surfaces/AnnulusBounds.hpp"
0019 #include "Acts/Surfaces/DiscSurface.hpp"
0020 #include "Acts/Surfaces/PlaneSurface.hpp"
0021 #include "Acts/Surfaces/RectangleBounds.hpp"
0022 #include "ActsPlugins/GeoModel/GeoModelBlueprintCreater.hpp"
0023 #include "ActsPlugins/GeoModel/GeoModelConverters.hpp"
0024 #include "ActsPlugins/GeoModel/GeoModelDetectorElement.hpp"
0025 #include "ActsPlugins/GeoModel/GeoModelDetectorElementITk.hpp"
0026 #include "ActsPlugins/GeoModel/GeoModelDetectorObjectFactory.hpp"
0027 #include "ActsPlugins/GeoModel/GeoModelReader.hpp"
0028 #include "ActsPlugins/GeoModel/GeoModelTree.hpp"
0029 #include "ActsPlugins/GeoModel/IGeoShapeConverter.hpp"
0030 #include "ActsPython/Utilities/Helpers.hpp"
0031 #include "ActsPython/Utilities/Macros.hpp"
0032 
0033 #include <string>
0034 
0035 #include <GeoModelKernel/GeoFullPhysVol.h>
0036 #include <GeoModelKernel/GeoVPhysVol.h>
0037 #include <pybind11/pybind11.h>
0038 #include <pybind11/stl.h>
0039 
0040 namespace py = pybind11;
0041 using namespace pybind11::literals;
0042 
0043 PYBIND11_MODULE(ActsPluginsPythonBindingsGeoModel, gm) {
0044   using namespace Acts;
0045   using namespace ActsPython;
0046   using namespace ActsPlugins;
0047 
0048   // Basic bindings
0049   {
0050     py::class_<GeoModelTree::FpvConstLink>(gm, "GeoModelTree::FpvConstLink")
0051         .def(py::init<>())
0052         .def("get", &GeoModelTree::FpvConstLink::get,
0053              py::return_value_policy::reference);
0054 
0055     py::class_<GeoModelTree>(gm, "GeoModelTree").def(py::init<>());
0056 
0057     gm.def("readFromDb", &GeoModelReader::readFromDb);
0058 
0059     py::class_<GeoModelDetectorElement,
0060                std::shared_ptr<GeoModelDetectorElement>>(
0061         gm, "GeoModelDetectorElement")
0062         .def("logVolName", &GeoModelDetectorElement::logVolName)
0063         .def("databaseEntryName", &GeoModelDetectorElement::databaseEntryName)
0064         .def("surface", [](GeoModelDetectorElement self) {
0065           return self.surface().getSharedPtr();
0066         });
0067 
0068     py::class_<GeoModelDetectorElementITk,
0069                std::shared_ptr<GeoModelDetectorElementITk>>(
0070         gm, "GeoModelDetectorElementITk")
0071         .def("surface", [](GeoModelDetectorElementITk& self) {
0072           return self.surface().getSharedPtr();
0073         });
0074     gm.def("convertToItk", &GeoModelDetectorElementITk::convertFromGeomodel);
0075   }
0076 
0077   // Shape converters
0078   {
0079     py::class_<IGeoShapeConverter, std::shared_ptr<IGeoShapeConverter>>(
0080         gm, "IGeoShapeConverter");
0081 
0082     py::class_<GeoBoxConverter, IGeoShapeConverter,
0083                std::shared_ptr<GeoBoxConverter>>(gm, "GeoBoxConverter")
0084         .def(py::init<>())
0085         .def("toSensitiveSurface", &GeoBoxConverter::toSensitiveSurface)
0086         .def("toPassiveSurface", &GeoBoxConverter::toPassiveSurface);
0087 
0088     py::class_<GeoTrdConverter, IGeoShapeConverter,
0089                std::shared_ptr<GeoTrdConverter>>(gm, "GeoTrdConverter")
0090         .def(py::init<>())
0091         .def("toSensitiveSurface", &GeoTrdConverter::toSensitiveSurface)
0092         .def("toPassiveSurface", &GeoTrdConverter::toPassiveSurface);
0093 
0094     py::class_<GeoTubeConverter, IGeoShapeConverter,
0095                std::shared_ptr<GeoTubeConverter>>(gm, "GeoTubeConverter")
0096         .def(py::init<>())
0097         .def("toSensitiveSurface", &GeoTubeConverter::toSensitiveSurface)
0098         .def("toPassiveSurface", &GeoTubeConverter::toPassiveSurface);
0099 
0100     py::class_<GeoUnionDoubleTrdConverter, IGeoShapeConverter,
0101                std::shared_ptr<GeoUnionDoubleTrdConverter>>(
0102         gm, "GeoUnionDoubleTrdConverter")
0103         .def(py::init<>())
0104         .def("toSensitiveSurface",
0105              &GeoUnionDoubleTrdConverter::toSensitiveSurface)
0106         .def("toPassiveSurface", &GeoUnionDoubleTrdConverter::toPassiveSurface);
0107 
0108     py::class_<GeoIntersectionAnnulusConverter, IGeoShapeConverter,
0109                std::shared_ptr<GeoIntersectionAnnulusConverter>>(
0110         gm, "GeoIntersectionAnnulusConverter")
0111         .def(py::init<>())
0112         .def("toSensitiveSurface",
0113              &GeoIntersectionAnnulusConverter::toSensitiveSurface)
0114         .def("toPassiveSurface",
0115              &GeoIntersectionAnnulusConverter::toPassiveSurface);
0116 
0117     py::class_<GeoShiftConverter, IGeoShapeConverter,
0118                std::shared_ptr<GeoShiftConverter>>(gm, "GeoShiftConverter")
0119         .def(py::init<>())
0120         .def("toSensitiveSurface", &GeoShiftConverter::toSensitiveSurface)
0121         .def("toPassiveSurface", &GeoShiftConverter::toPassiveSurface);
0122   }
0123 
0124   // Volume factory
0125   {
0126     auto a =
0127         py::class_<GeoModelDetectorObjectFactory,
0128                    std::shared_ptr<GeoModelDetectorObjectFactory>>(
0129             gm, "GeoModelDetectorObjectFactory")
0130             .def(py::init([](const GeoModelDetectorObjectFactory::Config& cfg,
0131                              Logging::Level level) {
0132               return std::make_shared<GeoModelDetectorObjectFactory>(
0133                   cfg,
0134                   getDefaultLogger("GeoModelDetectorObjectFactory", level));
0135             }))
0136             .def("construct", &GeoModelDetectorObjectFactory::construct);
0137 
0138     py::class_<GeoModelDetectorObjectFactory::Config>(a, "Config")
0139         .def(py::init<>())
0140         .def_readwrite(
0141             "convertSubVolumes",
0142             &GeoModelDetectorObjectFactory::Config::convertSubVolumes)
0143         .def_readwrite("nameList",
0144                        &GeoModelDetectorObjectFactory::Config::nameList)
0145         .def_readwrite("convertBox",
0146                        &GeoModelDetectorObjectFactory::Config::convertBox)
0147         .def_readwrite("materialList",
0148                        &GeoModelDetectorObjectFactory::Config::materialList);
0149 
0150     auto convVol = py::class_<GeoModelDetectorObjectFactory::ConvertedGeoVol>(
0151         a, "ConvertedGeoVol");
0152 
0153     ACTS_PYTHON_STRUCT(convVol, volume, gen2Volume, fullPhysVol, name,
0154                        surfaces);
0155     py::class_<GeoModelDetectorObjectFactory::Cache>(a, "Cache")
0156         .def(py::init<>())
0157         .def_readwrite("sensitiveSurfaces",
0158                        &GeoModelDetectorObjectFactory::Cache::sensitiveSurfaces)
0159         .def_readwrite("boundingBoxes",
0160                        &GeoModelDetectorObjectFactory::Cache::volumeBoxFPVs);
0161 
0162     py::class_<GeoModelDetectorObjectFactory::Options>(a, "Options")
0163         .def(py::init<>())
0164         .def_readwrite("queries",
0165                        &GeoModelDetectorObjectFactory::Options::queries);
0166   }
0167 
0168   {
0169     py::class_<GeoModelBlueprintCreater::Blueprint,
0170                std::shared_ptr<GeoModelBlueprintCreater::Blueprint>>(
0171         gm, "Blueprint")
0172         .def("convertToBuilder", [](GeoModelBlueprintCreater::Blueprint& self,
0173                                     Logging::Level level) {
0174           // It's a container builder
0175           return std::make_shared<Experimental::CylindricalContainerBuilder>(
0176               self.node(), level);
0177         });
0178 
0179     auto bpc =
0180         py::class_<GeoModelBlueprintCreater,
0181                    std::shared_ptr<GeoModelBlueprintCreater>>(
0182             gm, "GeoModelBlueprintCreater")
0183             .def(py::init([](const GeoModelBlueprintCreater::Config& cfg,
0184                              Logging::Level level) {
0185               return std::make_shared<GeoModelBlueprintCreater>(
0186                   cfg, getDefaultLogger("GeoModelBlueprintCreater", level));
0187             }))
0188             .def("create", &GeoModelBlueprintCreater::create);
0189 
0190     py::class_<GeoModelBlueprintCreater::Config>(bpc, "Config")
0191         .def(py::init<>())
0192         .def_readwrite("detectorSurfaces",
0193                        &GeoModelBlueprintCreater::Config::detectorSurfaces)
0194         .def_readwrite("kdtBinning",
0195                        &GeoModelBlueprintCreater::Config::kdtBinning);
0196 
0197     py::class_<GeoModelBlueprintCreater::Options>(bpc, "Options")
0198         .def(py::init<>())
0199         .def_readwrite("topEntry", &GeoModelBlueprintCreater::Options::topEntry)
0200         .def_readwrite("topBoundsOverride",
0201                        &GeoModelBlueprintCreater::Options::topBoundsOverride)
0202         .def_readwrite("table", &GeoModelBlueprintCreater::Options::table)
0203         .def_readwrite("dotGraph",
0204                        &GeoModelBlueprintCreater::Options::dotGraph);
0205   }
0206 }