Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:17:43

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(Context& ctx) {
0047   auto& mex = ctx.get("examples");
0048 
0049   {
0050     using Alg = MaterialMapping;
0051 
0052     auto alg = py::class_<Alg, IAlgorithm, std::shared_ptr<Alg>>(
0053                    mex, "MaterialMapping")
0054                    .def(py::init<const Alg::Config&, Logging::Level>(),
0055                         py::arg("config"), py::arg("level"))
0056                    .def("scoringParameters", &Alg::scoringParameters)
0057                    .def_property_readonly("config", &Alg::config);
0058 
0059     auto c = py::class_<Alg::Config>(alg, "Config")
0060                  .def(py::init<const GeometryContext&,
0061                                const MagneticFieldContext&>());
0062 
0063     ACTS_PYTHON_STRUCT(c, inputMaterialTracks, mappingMaterialCollection,
0064                        materialSurfaceMapper, materialVolumeMapper,
0065                        materialWriters, trackingGeometry, geoContext,
0066                        magFieldContext);
0067   }
0068 
0069   {
0070     py::class_<MappingMaterialDecorator, IMaterialDecorator,
0071                std::shared_ptr<MappingMaterialDecorator>>(
0072         mex, "MappingMaterialDecorator")
0073         .def(py::init<const TrackingGeometry&, Logging::Level, bool, bool>(),
0074              py::arg("tGeometry"), py::arg("level"),
0075              py::arg("clearSurfaceMaterial") = true,
0076              py::arg("clearVolumeMaterial") = true)
0077         .def("binningMap", &MappingMaterialDecorator::binningMap)
0078         .def("setBinningMap", &MappingMaterialDecorator::setBinningMap);
0079   }
0080 
0081   {
0082     auto mmca =
0083         py::class_<CoreMaterialMapping, IAlgorithm,
0084                    std::shared_ptr<CoreMaterialMapping>>(mex,
0085                                                          "CoreMaterialMapping")
0086             .def(py::init<const CoreMaterialMapping::Config&, Logging::Level>(),
0087                  py::arg("config"), py::arg("level"));
0088 
0089     auto c = py::class_<CoreMaterialMapping::Config>(mmca, "Config")
0090                  .def(py::init<>());
0091     ACTS_PYTHON_STRUCT(c, inputMaterialTracks, mappedMaterialTracks,
0092                        unmappedMaterialTracks, materialMapper,
0093                        materiaMaplWriters);
0094   }
0095 
0096   {
0097     auto mv =
0098         py::class_<MaterialValidation, IAlgorithm,
0099                    std::shared_ptr<MaterialValidation>>(mex,
0100                                                         "MaterialValidation")
0101             .def(py::init<const MaterialValidation::Config&, Logging::Level>(),
0102                  py::arg("config"), py::arg("level"))
0103             .def("execute", &MaterialValidation::execute)
0104             .def_property_readonly("config", &MaterialValidation::config);
0105 
0106     auto c =
0107         py::class_<MaterialValidation::Config>(mv, "Config").def(py::init<>());
0108     ACTS_PYTHON_STRUCT(c, ntracks, startPosition, phiRange, etaRange,
0109                        randomNumberSvc, materialValidater,
0110                        outputMaterialTracks);
0111   }
0112 }
0113 
0114 }  // namespace ActsPython