Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-16 08:49:38

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 "ActsPlugins/Mille/MillePedeResultReader.hpp"
0010 #include "ActsPlugins/Mille/MillePedeSolver.hpp"
0011 #include "ActsPlugins/Mille/MillePedeSteering.hpp"
0012 #include "ActsPython/Utilities/Helpers.hpp"
0013 #include "ActsPython/Utilities/Macros.hpp"
0014 
0015 #include <pybind11/pybind11.h>
0016 #include <pybind11/stl.h>
0017 #include <pybind11/stl/filesystem.h>
0018 
0019 namespace py = pybind11;
0020 using namespace pybind11::literals;
0021 
0022 using ActsPlugins::MillePedeExitStatus;
0023 using ActsPlugins::MillePedeSolverConfig;
0024 using ActsPlugins::MillePedeSolverResult;
0025 
0026 PYBIND11_MODULE(ActsPluginsPythonBindingsMille, mille) {
0027   {
0028     using enum ActsPlugins::MillePedeExitStatus;
0029     auto es = py::enum_<ActsPlugins::MillePedeExitStatus>(mille,
0030                                                           "MillePedeExitStatus")
0031                   .value("NotFinishedOrCrashed", NotFinishedOrCrashed)
0032                   .value("NominalExit", NominalExit)
0033                   .value("TolerableWarnings", TolerableWarnings)
0034                   .value("SeriousWarnings", SeriousWarnings)
0035                   .value("NoSolution", NoSolution)
0036                   .value("Aborted", Aborted);
0037 
0038     auto mr = py::class_<MillePedeSolverResult>(mille, "MillePedeSolverResult")
0039                   .def(py::init<>());
0040     ACTS_PYTHON_STRUCT(mr, exitCode, exitStatus, exitMessage, resultsFile,
0041                        logFile, histoFile, evFile);
0042 
0043     auto sc = py::class_<MillePedeSolverConfig>(mille, "MillePedeSolverConfig")
0044                   .def(py::init<>());
0045     ACTS_PYTHON_STRUCT(sc, steeringFile, workDir, extraOpts, resFileName,
0046                        redirectStdout, logFileName, histoFileName, evFileName);
0047     // unwrap Acts::Result - will throw in case of an error-result
0048     mille.def("runMilleSolver",
0049               [](const MillePedeSolverConfig& cfg, const Acts::Logger& logger) {
0050                 return ActsPlugins::runMillePedeSolver(cfg, logger).value();
0051               });
0052   }
0053 
0054   {
0055     // unwrap Acts::Result - will throw in case of an error-result
0056     mille.def("readMillePedeResult", [](const std::filesystem::path& mpFile,
0057                                         const Acts::Logger& logger) {
0058       return ActsPlugins::readMillePedeResult(mpFile, logger).value();
0059     });
0060 
0061     auto c = py::class_<ActsPlugins::MillePedeParameterResult>(
0062                  mille, "MillePedeParameterResult")
0063                  .def(py::init<>());
0064 
0065     ACTS_PYTHON_STRUCT(c, label, val, start, delta, sigma, nRecords);
0066   }
0067   {
0068     using enum ActsPlugins::MillePedeSolutionStrategy;
0069     mille.def("generateMillePedeSteeringFile",
0070               &ActsPlugins::generateMillePedeSteeringFile);
0071 
0072     auto e = py::class_<ActsPlugins::MillePedeEqualityConstraint>(
0073                  mille, "MillePedeEqualityConstraint")
0074                  .def(py::init<>());
0075     ACTS_PYTHON_STRUCT(e, labelsAndWeights, constraint);
0076 
0077     auto s = py::enum_<ActsPlugins::MillePedeSolutionStrategy>(
0078                  mille, "MillePedeSolutionStrategy")
0079                  .value("Inversion", Inversion)
0080                  .value("Diagonalization", Diagonalization)
0081                  .value("Decomposition", Decomposition)
0082                  .value("FullMinRes", FullMinRes)
0083                  .value("SparseMinRes", SparseMinRes)
0084                  .value("FullMinResQlp", FullMinResQlp)
0085                  .value("SparseMinResQlp", SparseMinResQlp)
0086                  .value("FullLapack", FullLapack)
0087                  .value("UnpackedLapack", UnpackedLapack)
0088                  .value("SparsePardiso", SparsePardiso);
0089 
0090     auto c = py::class_<ActsPlugins::MillePedeSteeringConfig>(
0091                  mille, "MillePedeSteeringConfig")
0092                  .def(py::init<>());
0093     ACTS_PYTHON_STRUCT(c, strategy, minIterations, convergenceLimit, entriesCut,
0094                        outlierDownweighting, downweightFractionCut, nOMPthreads,
0095                        nIOthreads, matIter, printCounts, chi2Cut,
0096                        monitorResiduals, monitorPulls, skipEmptyCons,
0097                        countRecords, extraLines, constraints, inputFiles);
0098   }
0099 }