Back to home page

EIC code displayed by LXR

 
 

    


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

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 "ActsExamples/MaterialMapping/MaterialMapping.hpp"
0010 
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Utilities/Logger.hpp"
0013 #include "ActsExamples/Framework/ProcessCode.hpp"
0014 #include "ActsExamples/MaterialMapping/CoreMaterialMapping.hpp"
0015 #include "ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp"
0016 #include "ActsExamples/MaterialMapping/MaterialValidation.hpp"
0017 #include "ActsPlugins/Json/ActsJson.hpp"
0018 #include "ActsPlugins/Json/MaterialMapJsonConverter.hpp"
0019 #include "ActsPython/Utilities/Helpers.hpp"
0020 #include "ActsPython/Utilities/Macros.hpp"
0021 
0022 #include <array>
0023 #include <map>
0024 #include <memory>
0025 #include <tuple>
0026 #include <utility>
0027 #include <vector>
0028 
0029 #include <pybind11/pybind11.h>
0030 #include <pybind11/stl.h>
0031 
0032 namespace Acts {
0033 class TrackingGeometry;
0034 }  // namespace Acts
0035 namespace ActsExamples {
0036 class IAlgorithm;
0037 }  // namespace ActsExamples
0038 
0039 namespace py = pybind11;
0040 using namespace pybind11::literals;
0041 
0042 using namespace Acts;
0043 using namespace ActsExamples;
0044 
0045 namespace ActsPython {
0046 void addMaterialMapping(py::module& mex) {
0047   {
0048     using Alg = MaterialMapping;
0049 
0050     auto alg = py::class_<Alg, IAlgorithm, std::shared_ptr<Alg>>(
0051                    mex, "MaterialMapping")
0052                    .def(py::init<const Alg::Config&, Logging::Level>(),
0053                         py::arg("config"), py::arg("level"))
0054                    .def("scoringParameters", &Alg::scoringParameters)
0055                    .def_property_readonly("config", &Alg::config);
0056 
0057     auto c = py::class_<Alg::Config>(alg, "Config")
0058                  .def(py::init<const GeometryContext&,
0059                                const MagneticFieldContext&>());
0060 
0061     ACTS_PYTHON_STRUCT(c, inputMaterialTracks, mappingMaterialCollection,
0062                        materialSurfaceMapper, materialVolumeMapper,
0063                        materialWriters, trackingGeometry, geoContext,
0064                        magFieldContext);
0065   }
0066 
0067   {
0068     py::class_<MappingMaterialDecorator, IMaterialDecorator,
0069                std::shared_ptr<MappingMaterialDecorator>>(
0070         mex, "MappingMaterialDecorator")
0071         .def(py::init<const TrackingGeometry&, Logging::Level, bool, bool>(),
0072              py::arg("tGeometry"), py::arg("level"),
0073              py::arg("clearSurfaceMaterial") = true,
0074              py::arg("clearVolumeMaterial") = true)
0075         .def("binningMap", &MappingMaterialDecorator::binningMap)
0076         .def("setBinningMap", &MappingMaterialDecorator::setBinningMap);
0077   }
0078 
0079   {
0080     auto mmca =
0081         py::class_<CoreMaterialMapping, IAlgorithm,
0082                    std::shared_ptr<CoreMaterialMapping>>(mex,
0083                                                          "CoreMaterialMapping")
0084             .def(py::init<const CoreMaterialMapping::Config&, Logging::Level>(),
0085                  py::arg("config"), py::arg("level"));
0086 
0087     auto c = py::class_<CoreMaterialMapping::Config>(mmca, "Config")
0088                  .def(py::init<>());
0089     ACTS_PYTHON_STRUCT(c, inputMaterialTracks, mappedMaterialTracks,
0090                        unmappedMaterialTracks, materialMapper,
0091                        materiaMaplWriters);
0092   }
0093 
0094   {
0095     auto mv =
0096         py::class_<MaterialValidation, IAlgorithm,
0097                    std::shared_ptr<MaterialValidation>>(mex,
0098                                                         "MaterialValidation")
0099             .def(py::init<const MaterialValidation::Config&, Logging::Level>(),
0100                  py::arg("config"), py::arg("level"))
0101             .def("execute", &MaterialValidation::execute)
0102             .def_property_readonly("config", &MaterialValidation::config);
0103 
0104     auto c =
0105         py::class_<MaterialValidation::Config>(mv, "Config").def(py::init<>());
0106     ACTS_PYTHON_STRUCT(c, ntracks, startPosition, phiRange, etaRange,
0107                        randomNumberSvc, materialValidater,
0108                        outputMaterialTracks);
0109   }
0110 }
0111 
0112 }  // namespace ActsPython