Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:18:28

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/TrackFinding/MeasurementSelector.hpp"
0010 #include "Acts/TrackFinding/TrackSelector.hpp"
0011 #include "ActsPython/Utilities/Helpers.hpp"
0012 #include "ActsPython/Utilities/Macros.hpp"
0013 
0014 #include <pybind11/pybind11.h>
0015 #include <pybind11/stl.h>
0016 
0017 namespace py = pybind11;
0018 
0019 using namespace Acts;
0020 
0021 namespace ActsPython {
0022 
0023 /// Add the track finding related bindings to the module
0024 /// @param m The module to add the bindings to
0025 void addTrackFinding(py::module_& m) {
0026   {
0027     auto constructor =
0028         [](const std::vector<std::pair<
0029                Acts::GeometryIdentifier,
0030                std::tuple<std::vector<double>, std::vector<double>,
0031                           std::vector<double>, std::vector<std::size_t>>>>&
0032                input) {
0033           std::vector<std::pair<Acts::GeometryIdentifier,
0034                                 Acts::MeasurementSelectorCuts>>
0035               converted;
0036           converted.reserve(input.size());
0037           for (const auto& [id, cuts] : input) {
0038             const auto& [bins, chi2Measurement, chi2Outlier, num] = cuts;
0039             converted.emplace_back(
0040                 id, Acts::MeasurementSelectorCuts{bins, chi2Measurement, num,
0041                                                   chi2Outlier});
0042           }
0043           return std::make_unique<Acts::MeasurementSelector::Config>(converted);
0044         };
0045 
0046     py::class_<Acts::MeasurementSelectorCuts>(m, "MeasurementSelectorCuts")
0047         .def(py::init<>())
0048         .def(py::init<std::vector<double>, std::vector<double>,
0049                       std::vector<std::size_t>, std::vector<double>>())
0050         .def_readwrite("etaBins", &Acts::MeasurementSelectorCuts::etaBins)
0051         .def_readwrite("chi2CutOffMeasurement",
0052                        &Acts::MeasurementSelectorCuts::chi2CutOff)
0053         .def_readwrite("chi2CutOffOutlier",
0054                        &Acts::MeasurementSelectorCuts::chi2CutOffOutlier)
0055         .def_readwrite("numMeasurementsCutOff",
0056                        &Acts::MeasurementSelectorCuts::numMeasurementsCutOff);
0057 
0058     auto ms = py::class_<Acts::MeasurementSelector>(m, "MeasurementSelector");
0059     auto c = py::class_<Acts::MeasurementSelector::Config>(ms, "Config")
0060                  .def(py::init<
0061                       std::vector<std::pair<Acts::GeometryIdentifier,
0062                                             Acts::MeasurementSelectorCuts>>>())
0063                  .def(py::init(constructor));
0064   }
0065   {
0066     using EtaBinnedConfig = TrackSelector::EtaBinnedConfig;
0067     using Config = TrackSelector::Config;
0068 
0069     auto tool = py::class_<TrackSelector>(m, "TrackSelector")
0070                     .def(py::init<const Config&>(), py::arg("config"))
0071                     .def(py::init<const EtaBinnedConfig&>(), py::arg("config"));
0072 
0073     {
0074       auto mc = py::class_<TrackSelector::MeasurementCounter>(
0075                     tool, "MeasurementCounter")
0076                     .def(py::init<>())
0077                     .def("addCounter",
0078                          &TrackSelector::MeasurementCounter::addCounter);
0079     }
0080 
0081     {
0082       auto c = py::class_<Config>(tool, "Config").def(py::init<>());
0083 
0084       patchKwargsConstructor(c);
0085 
0086       ACTS_PYTHON_STRUCT(c, loc0Min, loc0Max, loc1Min, loc1Max, timeMin,
0087                          timeMax, phiMin, phiMax, etaMin, etaMax, absEtaMin,
0088                          absEtaMax, ptMin, ptMax, minMeasurements, maxHoles,
0089                          maxOutliers, maxHolesAndOutliers, maxSharedHits,
0090                          maxChi2, measurementCounter, requireReferenceSurface);
0091 
0092       pythonRangeProperty(c, "loc0", &Config::loc0Min, &Config::loc0Max);
0093       pythonRangeProperty(c, "loc1", &Config::loc1Min, &Config::loc1Max);
0094       pythonRangeProperty(c, "time", &Config::timeMin, &Config::timeMax);
0095       pythonRangeProperty(c, "phi", &Config::phiMin, &Config::phiMax);
0096       pythonRangeProperty(c, "eta", &Config::etaMin, &Config::etaMax);
0097       pythonRangeProperty(c, "absEta", &Config::absEtaMin, &Config::absEtaMax);
0098       pythonRangeProperty(c, "pt", &Config::ptMin, &Config::ptMax);
0099     }
0100 
0101     {
0102       auto c = py::class_<EtaBinnedConfig>(tool, "EtaBinnedConfig")
0103                    .def(py::init<>())
0104                    .def(py::init<const Config&>());
0105 
0106       patchKwargsConstructor(c);
0107 
0108       c.def_property_readonly("nEtaBins", &EtaBinnedConfig::nEtaBins);
0109 
0110       ACTS_PYTHON_STRUCT(c, cutSets, absEtaEdges);
0111     }
0112   }
0113 }
0114 }  // namespace ActsPython