Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:37

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/Geometry/GeometryContext.hpp"
0010 #include "Acts/Material/BinnedSurfaceMaterialAccumulater.hpp"
0011 #include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
0012 #include "Acts/Material/IMaterialDecorator.hpp"
0013 #include "Acts/Material/ISurfaceMaterial.hpp"
0014 #include "Acts/Material/IVolumeMaterial.hpp"
0015 #include "Acts/Material/IntersectionMaterialAssigner.hpp"
0016 #include "Acts/Material/MaterialMapper.hpp"
0017 #include "Acts/Material/MaterialValidater.hpp"
0018 #include "Acts/Material/PropagatorMaterialAssigner.hpp"
0019 #include "Acts/Material/ProtoSurfaceMaterial.hpp"
0020 #include "Acts/Material/SurfaceMaterialMapper.hpp"
0021 #include "Acts/Material/VolumeMaterialMapper.hpp"
0022 #include "Acts/Utilities/Logger.hpp"
0023 #include "ActsPython/Utilities/Helpers.hpp"
0024 #include "ActsPython/Utilities/Macros.hpp"
0025 
0026 #include <array>
0027 #include <map>
0028 #include <memory>
0029 #include <tuple>
0030 #include <utility>
0031 #include <vector>
0032 
0033 #include <pybind11/pybind11.h>
0034 #include <pybind11/stl.h>
0035 
0036 namespace Acts {
0037 class TrackingGeometry;
0038 }  // namespace Acts
0039 
0040 namespace py = pybind11;
0041 using namespace pybind11::literals;
0042 
0043 using namespace Acts;
0044 
0045 namespace ActsPython {
0046 
0047 /// @brief Add the material bindings to a module.
0048 /// @param m the module to add the bindings to
0049 void addMaterial(py::module_& m) {
0050   {
0051     py::class_<ISurfaceMaterial, std::shared_ptr<ISurfaceMaterial>>(
0052         m, "ISurfaceMaterial")
0053         .def("toString", &ISurfaceMaterial::toString);
0054 
0055     py::class_<ProtoGridSurfaceMaterial, ISurfaceMaterial,
0056                std::shared_ptr<ProtoGridSurfaceMaterial>>(
0057         m, "ProtoGridSurfaceMaterial");
0058 
0059     py::class_<ProtoSurfaceMaterial, ISurfaceMaterial,
0060                std::shared_ptr<ProtoSurfaceMaterial>>(m,
0061                                                       "ProtoSurfaceMaterial");
0062 
0063     py::class_<HomogeneousSurfaceMaterial, ISurfaceMaterial,
0064                std::shared_ptr<HomogeneousSurfaceMaterial>>(
0065         m, "HomogeneousSurfaceMaterial");
0066 
0067     py::class_<IVolumeMaterial, std::shared_ptr<IVolumeMaterial>>(
0068         m, "IVolumeMaterial");
0069   }
0070 
0071   {
0072     py::class_<IMaterialDecorator, std::shared_ptr<IMaterialDecorator>>(
0073         m, "IMaterialDecorator")
0074         .def("decorate", py::overload_cast<Surface&>(
0075                              &IMaterialDecorator::decorate, py::const_));
0076   }
0077 
0078   {
0079     auto cls =
0080         py::class_<SurfaceMaterialMapper,
0081                    std::shared_ptr<SurfaceMaterialMapper>>(
0082             m, "SurfaceMaterialMapper")
0083             .def(py::init([](const SurfaceMaterialMapper::Config& config,
0084                              SurfaceMaterialMapper::StraightLinePropagator prop,
0085                              Logging::Level level) {
0086                    return std::make_shared<SurfaceMaterialMapper>(
0087                        config, std::move(prop),
0088                        getDefaultLogger("SurfaceMaterialMapper", level));
0089                  }),
0090                  py::arg("config"), py::arg("propagator"), py::arg("level"));
0091 
0092     auto c = py::class_<SurfaceMaterialMapper::Config>(cls, "Config")
0093                  .def(py::init<>());
0094     ACTS_PYTHON_STRUCT(c, etaRange, emptyBinCorrection, mapperDebugOutput,
0095                        computeVariance);
0096   }
0097 
0098   {
0099     auto cls =
0100         py::class_<VolumeMaterialMapper, std::shared_ptr<VolumeMaterialMapper>>(
0101             m, "VolumeMaterialMapper")
0102             .def(py::init([](const VolumeMaterialMapper::Config& config,
0103                              VolumeMaterialMapper::StraightLinePropagator prop,
0104                              Logging::Level level) {
0105                    return std::make_shared<VolumeMaterialMapper>(
0106                        config, std::move(prop),
0107                        getDefaultLogger("VolumeMaterialMapper", level));
0108                  }),
0109                  py::arg("config"), py::arg("propagator"), py::arg("level"));
0110 
0111     auto c = py::class_<VolumeMaterialMapper::Config>(cls, "Config")
0112                  .def(py::init<>());
0113     ACTS_PYTHON_STRUCT(c, mappingStep);
0114   }
0115 
0116   {
0117     py::class_<IAssignmentFinder, std::shared_ptr<IAssignmentFinder>>(
0118         m, "IAssignmentFinder");
0119   }
0120 
0121   {
0122     auto isma =
0123         py::class_<IntersectionMaterialAssigner, IAssignmentFinder,
0124                    std::shared_ptr<IntersectionMaterialAssigner>>(
0125             m, "IntersectionMaterialAssigner")
0126             .def(py::init([](const IntersectionMaterialAssigner::Config& config,
0127                              Logging::Level level) {
0128                    return std::make_shared<IntersectionMaterialAssigner>(
0129                        config,
0130                        getDefaultLogger("IntersectionMaterialAssigner", level));
0131                  }),
0132                  py::arg("config"), py::arg("level"))
0133             .def("assignmentCandidates",
0134                  &IntersectionMaterialAssigner::assignmentCandidates);
0135 
0136     auto c = py::class_<IntersectionMaterialAssigner::Config>(isma, "Config")
0137                  .def(py::init<>());
0138     ACTS_PYTHON_STRUCT(c, surfaces, trackingVolumes);
0139   }
0140 
0141   {
0142     py::class_<ISurfaceMaterialAccumulater,
0143                std::shared_ptr<ISurfaceMaterialAccumulater>>(
0144         m, "ISurfaceMaterialAccumulater");
0145   }
0146 
0147   {
0148     auto bsma =
0149         py::class_<BinnedSurfaceMaterialAccumulater,
0150                    ISurfaceMaterialAccumulater,
0151                    std::shared_ptr<BinnedSurfaceMaterialAccumulater>>(
0152             m, "BinnedSurfaceMaterialAccumulater")
0153             .def(
0154                 py::init(
0155                     [](const BinnedSurfaceMaterialAccumulater::Config& config,
0156                        Logging::Level level) {
0157                       return std::make_shared<BinnedSurfaceMaterialAccumulater>(
0158                           config,
0159                           getDefaultLogger("BinnedSurfaceMaterialAccumulater",
0160                                            level));
0161                     }),
0162                 py::arg("config"), py::arg("level"))
0163             .def("createState", &BinnedSurfaceMaterialAccumulater::createState)
0164             .def("accumulate", &BinnedSurfaceMaterialAccumulater::accumulate)
0165             .def("finalizeMaterial",
0166                  &BinnedSurfaceMaterialAccumulater::finalizeMaterial);
0167 
0168     auto c =
0169         py::class_<BinnedSurfaceMaterialAccumulater::Config>(bsma, "Config")
0170             .def(py::init<>());
0171     ACTS_PYTHON_STRUCT(c, emptyBinCorrection, materialSurfaces);
0172   }
0173 
0174   {
0175     auto mm = py::class_<MaterialMapper, std::shared_ptr<MaterialMapper>>(
0176                   m, "MaterialMapper")
0177                   .def(py::init([](const MaterialMapper::Config& config,
0178                                    Logging::Level level) {
0179                          return std::make_shared<MaterialMapper>(
0180                              config, getDefaultLogger("MaterialMapper", level));
0181                        }),
0182                        py::arg("config"), py::arg("level"));
0183 
0184     auto c = py::class_<MaterialMapper::Config>(mm, "Config").def(py::init<>());
0185     ACTS_PYTHON_STRUCT(c, assignmentFinder, surfaceMaterialAccumulater);
0186   }
0187 
0188   {
0189     auto mvc =
0190         py::class_<MaterialValidater, std::shared_ptr<MaterialValidater>>(
0191             m, "MaterialValidater")
0192             .def(py::init([](const MaterialValidater::Config& config,
0193                              Logging::Level level) {
0194                    return std::make_shared<MaterialValidater>(
0195                        config, getDefaultLogger("MaterialValidater", level));
0196                  }),
0197                  py::arg("config"), py::arg("level"))
0198             .def("recordMaterial", &MaterialValidater::recordMaterial);
0199 
0200     auto c =
0201         py::class_<MaterialValidater::Config>(mvc, "Config").def(py::init<>());
0202     ACTS_PYTHON_STRUCT(c, materialAssigner);
0203   }
0204 }
0205 
0206 }  // namespace ActsPython