File indexing completed on 2025-07-11 07:50:43
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Definitions/Algebra.hpp"
0010 #include "Acts/Plugins/Python/Utilities.hpp"
0011 #include "Acts/TrackFinding/TrackSelector.hpp"
0012 #include "ActsExamples/Fatras/FatrasSimulation.hpp"
0013 #include "ActsExamples/Io/Json/JsonGeometryList.hpp"
0014 #include "ActsExamples/Printers/ParticlesPrinter.hpp"
0015 #include "ActsExamples/Printers/TrackParametersPrinter.hpp"
0016 #include "ActsExamples/Utilities/Range.hpp"
0017 #include "ActsExamples/Utilities/TrackSelectorAlgorithm.hpp"
0018
0019 #include <vector>
0020
0021 #include <pybind11/pybind11.h>
0022 #include <pybind11/stl.h>
0023
0024 namespace py = pybind11;
0025
0026 using namespace ActsExamples;
0027 using namespace Acts;
0028
0029 namespace Acts::Python {
0030
0031 void addExampleAlgorithms(Context& ctx) {
0032 auto [m, mex] = ctx.get("main", "examples");
0033
0034 mex.def("readJsonGeometryList", ActsExamples::readJsonGeometryList);
0035
0036 ACTS_PYTHON_DECLARE_ALGORITHM(
0037 ActsExamples::FatrasSimulation, mex, "FatrasSimulation", inputParticles,
0038 outputParticles, outputSimHits, randomNumbers, trackingGeometry,
0039 magneticField, pMin, emScattering, emEnergyLossIonisation,
0040 emEnergyLossRadiation, emPhotonConversion, generateHitsOnSensitive,
0041 generateHitsOnMaterial, generateHitsOnPassive, averageHitsPerParticle);
0042
0043 ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::ParticlesPrinter, mex,
0044 "ParticlesPrinter", inputParticles);
0045
0046 ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::TrackParametersPrinter, mex,
0047 "TrackParametersPrinter", inputTrackParameters);
0048
0049 {
0050 using Alg = ActsExamples::TrackSelectorAlgorithm;
0051 using Config = Alg::Config;
0052
0053 auto alg = py::class_<Alg, IAlgorithm, std::shared_ptr<Alg>>(
0054 mex, "TrackSelectorAlgorithm")
0055 .def(py::init<const Alg::Config&, Acts::Logging::Level>(),
0056 py::arg("config"), py::arg("level"))
0057 .def_property_readonly("config", &Alg::config);
0058
0059 auto c = py::class_<Config>(alg, "Config").def(py::init<>());
0060
0061 ACTS_PYTHON_STRUCT(c, inputTracks, outputTracks, selectorConfig);
0062 }
0063
0064 {
0065 using EtaBinnedConfig = Acts::TrackSelector::EtaBinnedConfig;
0066 using Config = Acts::TrackSelector::Config;
0067
0068 auto tool = py::class_<Acts::TrackSelector>(m, "TrackSelector")
0069 .def(py::init<const Config&>(), py::arg("config"))
0070 .def(py::init<const EtaBinnedConfig&>(), py::arg("config"));
0071
0072 {
0073 auto mc = py::class_<Acts::TrackSelector::MeasurementCounter>(
0074 tool, "MeasurementCounter")
0075 .def(py::init<>())
0076 .def("addCounter",
0077 &Acts::TrackSelector::MeasurementCounter::addCounter);
0078 }
0079
0080 {
0081 auto c = py::class_<Config>(tool, "Config").def(py::init<>());
0082
0083 patchKwargsConstructor(c);
0084
0085 ACTS_PYTHON_STRUCT(c, loc0Min, loc0Max, loc1Min, loc1Max, timeMin,
0086 timeMax, phiMin, phiMax, etaMin, etaMax, absEtaMin,
0087 absEtaMax, ptMin, ptMax, minMeasurements, maxHoles,
0088 maxOutliers, maxHolesAndOutliers, maxSharedHits,
0089 maxChi2, measurementCounter, requireReferenceSurface);
0090
0091 pythonRangeProperty(c, "loc0", &Config::loc0Min, &Config::loc0Max);
0092 pythonRangeProperty(c, "loc1", &Config::loc1Min, &Config::loc1Max);
0093 pythonRangeProperty(c, "time", &Config::timeMin, &Config::timeMax);
0094 pythonRangeProperty(c, "phi", &Config::phiMin, &Config::phiMax);
0095 pythonRangeProperty(c, "eta", &Config::etaMin, &Config::etaMax);
0096 pythonRangeProperty(c, "absEta", &Config::absEtaMin, &Config::absEtaMax);
0097 pythonRangeProperty(c, "pt", &Config::ptMin, &Config::ptMax);
0098 }
0099
0100 {
0101 auto c = py::class_<EtaBinnedConfig>(tool, "EtaBinnedConfig")
0102 .def(py::init<>())
0103 .def(py::init<const Config&>());
0104
0105 patchKwargsConstructor(c);
0106
0107 c.def_property_readonly("nEtaBins", &EtaBinnedConfig::nEtaBins);
0108
0109 ACTS_PYTHON_STRUCT(c, cutSets, absEtaEdges);
0110 }
0111 }
0112 }
0113 }