Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 09:26:46

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/Geometry/GeometryContext.hpp"
0017 #include "Acts/Surfaces/AnnulusBounds.hpp"
0018 #include "Acts/Surfaces/DiscSurface.hpp"
0019 #include "Acts/Surfaces/PlaneSurface.hpp"
0020 #include "Acts/Surfaces/RectangleBounds.hpp"
0021 #include "ActsExamples/GeoModelDetector/GeoModelDetector.hpp"
0022 #include "ActsExamples/GeoModelDetector/GeoModelMuonMockupBuilder.hpp"
0023 #include "ActsExamples/ITkModuleSplitting/ITkModuleSplitting.hpp"
0024 #include "ActsExamples/MuonSpectrometerMockupDetector/GeoMuonMockupExperiment.hpp"
0025 #include "ActsPython/Utilities/Helpers.hpp"
0026 #include "ActsPython/Utilities/Macros.hpp"
0027 
0028 #include <string>
0029 
0030 #include <GeoModelKernel/GeoFullPhysVol.h>
0031 #include <GeoModelKernel/GeoVPhysVol.h>
0032 #include <pybind11/pybind11.h>
0033 #include <pybind11/stl.h>
0034 
0035 namespace py = pybind11;
0036 using namespace pybind11::literals;
0037 
0038 using namespace Acts;
0039 using namespace ActsPlugins;
0040 using namespace ActsExamples;
0041 using namespace ActsPython;
0042 
0043 PYBIND11_MODULE(ActsExamplesPythonBindingsGeoModel, gm) {
0044   {
0045     auto f =
0046         py::class_<GeoModelDetector, Detector,
0047                    std::shared_ptr<GeoModelDetector>>(gm, "GeoModelDetector")
0048             .def(py::init<const GeoModelDetector::Config&>())
0049             .def("buildTrackingGeometry",
0050                  &GeoModelDetector::buildTrackingGeometry);
0051 
0052     auto c =
0053         py::class_<GeoModelDetector::Config>(f, "Config").def(py::init<>());
0054     ACTS_PYTHON_STRUCT(c, geoModelTree, logLevel, path);
0055 
0056     // patch the constructor
0057     patchKwargsConstructor(c);
0058   }
0059   {
0060     // GeomodelMuonMockupBuilder
0061     py::class_<ITrackingGeometryBuilder,
0062                std::shared_ptr<ITrackingGeometryBuilder>>(
0063         gm, "ITrackingGeometryBuilder");
0064     auto gmMuonBuilder =
0065         py::class_<GeoModelMuonMockupBuilder, ITrackingGeometryBuilder,
0066                    std::shared_ptr<GeoModelMuonMockupBuilder>>(
0067             gm, "GeoModelMuonMockupBuilder")
0068             .def(py::init([](const GeoModelMuonMockupBuilder::Config& config,
0069                              const std::string& name, Logging::Level level) {
0070               return std::make_shared<GeoModelMuonMockupBuilder>(
0071                   config, getDefaultLogger(name, level));
0072             }))
0073             .def("trackingGeometry",
0074                  &GeoModelMuonMockupBuilder::trackingGeometry);
0075     auto gmMuonConfig =
0076         py::class_<GeoModelMuonMockupBuilder::Config>(gmMuonBuilder, "Config")
0077             .def(py::init<>());
0078     ACTS_PYTHON_STRUCT(gmMuonConfig, volumeBoxFPVs, stationNames,
0079                        volumeBoundFactory);
0080   }
0081 
0082   {
0083     // GeoMuonMockupExperiment
0084     auto f =
0085         py::class_<GeoMuonMockupExperiment,
0086                    std::shared_ptr<GeoMuonMockupExperiment>>(
0087             gm, "GeoMuonMockupExperiment")
0088             .def(py::init([](const GeoMuonMockupExperiment::Config& config,
0089                              const std::string& name, Logging::Level level) {
0090               return std::make_shared<GeoMuonMockupExperiment>(
0091                   config, getDefaultLogger(name, level));
0092             }))
0093             .def("constructMS", &GeoMuonMockupExperiment::constructMS);
0094     auto c = py::class_<GeoMuonMockupExperiment::Config>(f, "Config")
0095                  .def(py::init<>());
0096     ACTS_PYTHON_STRUCT(c,
0097                        /// General properties
0098                        dumpTree, dbName,
0099                        /// Mdt properties
0100                        innerTubeRadius, tubeWallThickness, nTubeLayers, nTubes,
0101                        mdtFoamThickness, multiLayerSeparation,
0102                        /// Rpc properties
0103                        nRpcGasGaps, nRpcAlongZ, nRpcAlongPhi,
0104                        /// Station properties
0105                        barrelRadii, nSectors, nEtaStations, stationDistInZ,
0106                        stationDistInR, endCapWheelLowR, bigWheelDistZ,
0107                        buildEndcaps, nInnerMultiplets, nInnerGasGapsPerMl);
0108   }
0109 
0110   /// Module splitting
0111   {
0112     gm.def(
0113         "splitBarrelModule",
0114         [](const GeometryContext& gctx,
0115            std::shared_ptr<const GeoModelDetectorElement> detElement,
0116            unsigned nSegments, Logging::Level logLevel) {
0117           auto logger = getDefaultLogger("ITkSlitBarrel", logLevel);
0118           auto name = detElement->databaseEntryName();
0119 
0120           auto factory = [&](const auto& trafo, const auto& bounds) {
0121             return GeoModelDetectorElement::createDetectorElement<
0122                 PlaneSurface, RectangleBounds>(detElement->physicalVolume(),
0123                                                bounds, trafo,
0124                                                detElement->thickness());
0125           };
0126 
0127           return ITk::splitBarrelModule(gctx, detElement, nSegments, factory,
0128                                         name, *logger);
0129         },
0130         "gxtx"_a, "detElement"_a, "nSegments"_a, "logLevel"_a = Logging::INFO);
0131 
0132     gm.def(
0133         "splitDiscModule",
0134         [](const GeometryContext& gctx,
0135            std::shared_ptr<const GeoModelDetectorElement> detElement,
0136            const std::vector<std::pair<double, double>>& patterns,
0137            Logging::Level logLevel) {
0138           auto logger = getDefaultLogger("ITkSlitBarrel", logLevel);
0139           auto name = detElement->databaseEntryName();
0140 
0141           auto factory = [&](const auto& trafo, const auto& bounds) {
0142             return GeoModelDetectorElement::createDetectorElement<
0143                 DiscSurface, AnnulusBounds>(detElement->physicalVolume(),
0144                                             bounds, trafo,
0145                                             detElement->thickness());
0146           };
0147 
0148           return ITk::splitDiscModule(gctx, detElement, patterns, factory, name,
0149                                       *logger);
0150         },
0151         "gxtx"_a, "detElement"_a, "splitRanges"_a,
0152         "logLevel"_a = Logging::INFO);
0153   }
0154 }