Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-12 09:16:32

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 
0042 namespace ActsPython {
0043 
0044 void addGeoModel(Context& ctx) {
0045   auto& mex = ctx.get("examples");
0046 
0047   auto gm = mex.def_submodule("geomodel");
0048 
0049   {
0050     auto f =
0051         py::class_<GeoModelDetector, Detector,
0052                    std::shared_ptr<GeoModelDetector>>(gm, "GeoModelDetector")
0053             .def(py::init<const GeoModelDetector::Config&>())
0054             .def("buildTrackingGeometry",
0055                  &GeoModelDetector::buildTrackingGeometry);
0056 
0057     auto c =
0058         py::class_<GeoModelDetector::Config>(f, "Config").def(py::init<>());
0059     ACTS_PYTHON_STRUCT(c, geoModelTree, logLevel, path);
0060 
0061     // patch the constructor
0062     patchKwargsConstructor(c);
0063   }
0064   {
0065     // GeomodelMuonMockupBuilder
0066     py::class_<ITrackingGeometryBuilder,
0067                std::shared_ptr<ITrackingGeometryBuilder>>(
0068         gm, "ITrackingGeometryBuilder");
0069     auto gmMuonBuilder =
0070         py::class_<GeoModelMuonMockupBuilder, ITrackingGeometryBuilder,
0071                    std::shared_ptr<GeoModelMuonMockupBuilder>>(
0072             gm, "GeoModelMuonMockupBuilder")
0073             .def(py::init([](const GeoModelMuonMockupBuilder::Config& config,
0074                              const std::string& name, Logging::Level level) {
0075               return std::make_shared<GeoModelMuonMockupBuilder>(
0076                   config, getDefaultLogger(name, level));
0077             }))
0078             .def("trackingGeometry",
0079                  &GeoModelMuonMockupBuilder::trackingGeometry);
0080     auto gmMuonConfig =
0081         py::class_<GeoModelMuonMockupBuilder::Config>(gmMuonBuilder, "Config")
0082             .def(py::init<>());
0083     ACTS_PYTHON_STRUCT(gmMuonConfig, volumeBoxFPVs, stationNames,
0084                        volumeBoundFactory);
0085   }
0086 
0087   {
0088     // GeoMuonMockupExperiment
0089     auto f =
0090         py::class_<GeoMuonMockupExperiment,
0091                    std::shared_ptr<GeoMuonMockupExperiment>>(
0092             gm, "GeoMuonMockupExperiment")
0093             .def(py::init([](const GeoMuonMockupExperiment::Config& config,
0094                              const std::string& name, Logging::Level level) {
0095               return std::make_shared<GeoMuonMockupExperiment>(
0096                   config, getDefaultLogger(name, level));
0097             }))
0098             .def("constructMS", &GeoMuonMockupExperiment::constructMS);
0099     auto c = py::class_<GeoMuonMockupExperiment::Config>(f, "Config")
0100                  .def(py::init<>());
0101     ACTS_PYTHON_STRUCT(c,
0102                        /// General properties
0103                        dumpTree, dbName,
0104                        /// Mdt properties
0105                        innerTubeRadius, tubeWallThickness, nTubeLayers, nTubes,
0106                        mdtFoamThickness, multiLayerSeparation,
0107                        /// Rpc properties
0108                        nRpcGasGaps, nRpcAlongZ, nRpcAlongPhi,
0109                        /// Station properties
0110                        barrelRadii, nSectors, nEtaStations, stationDistInZ,
0111                        stationDistInR, endCapWheelLowR, bigWheelDistZ,
0112                        buildEndcaps, nInnerMultiplets, nInnerGasGapsPerMl);
0113   }
0114 
0115   /// Module splitting
0116   {
0117     gm.def(
0118         "splitBarrelModule",
0119         [](const GeometryContext& gctx,
0120            std::shared_ptr<const GeoModelDetectorElement> detElement,
0121            unsigned nSegments, Logging::Level logLevel) {
0122           auto logger = getDefaultLogger("ITkSlitBarrel", logLevel);
0123           auto name = detElement->databaseEntryName();
0124 
0125           auto factory = [&](const auto& trafo, const auto& bounds) {
0126             return GeoModelDetectorElement::createDetectorElement<
0127                 PlaneSurface, RectangleBounds>(detElement->physicalVolume(),
0128                                                bounds, trafo,
0129                                                detElement->thickness());
0130           };
0131 
0132           return ITk::splitBarrelModule(gctx, detElement, nSegments, factory,
0133                                         name, *logger);
0134         },
0135         "gxtx"_a, "detElement"_a, "nSegments"_a, "logLevel"_a = Logging::INFO);
0136 
0137     gm.def(
0138         "splitDiscModule",
0139         [](const GeometryContext& gctx,
0140            std::shared_ptr<const GeoModelDetectorElement> detElement,
0141            const std::vector<std::pair<double, double>>& patterns,
0142            Logging::Level logLevel) {
0143           auto logger = getDefaultLogger("ITkSlitBarrel", logLevel);
0144           auto name = detElement->databaseEntryName();
0145 
0146           auto factory = [&](const auto& trafo, const auto& bounds) {
0147             return GeoModelDetectorElement::createDetectorElement<
0148                 DiscSurface, AnnulusBounds>(detElement->physicalVolume(),
0149                                             bounds, trafo,
0150                                             detElement->thickness());
0151           };
0152 
0153           return ITk::splitDiscModule(gctx, detElement, patterns, factory, name,
0154                                       *logger);
0155         },
0156         "gxtx"_a, "detElement"_a, "splitRanges"_a,
0157         "logLevel"_a = Logging::INFO);
0158   }
0159 }
0160 
0161 }  // namespace ActsPython