File indexing completed on 2025-01-18 09:12:02
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_BEGIN(c, Config);
0062 ACTS_PYTHON_MEMBER(inputTracks);
0063 ACTS_PYTHON_MEMBER(outputTracks);
0064 ACTS_PYTHON_MEMBER(selectorConfig);
0065 ACTS_PYTHON_STRUCT_END();
0066 }
0067
0068 {
0069 using EtaBinnedConfig = Acts::TrackSelector::EtaBinnedConfig;
0070 using Config = Acts::TrackSelector::Config;
0071
0072 auto tool = py::class_<Acts::TrackSelector>(m, "TrackSelector")
0073 .def(py::init<const Config&>(), py::arg("config"))
0074 .def(py::init<const EtaBinnedConfig&>(), py::arg("config"));
0075
0076 {
0077 auto mc = py::class_<Acts::TrackSelector::MeasurementCounter>(
0078 tool, "MeasurementCounter")
0079 .def(py::init<>())
0080 .def("addCounter",
0081 &Acts::TrackSelector::MeasurementCounter::addCounter);
0082 }
0083
0084 {
0085 auto c = py::class_<Config>(tool, "Config").def(py::init<>());
0086
0087 patchKwargsConstructor(c);
0088
0089 ACTS_PYTHON_STRUCT_BEGIN(c, Config);
0090 ACTS_PYTHON_MEMBER(loc0Min);
0091 ACTS_PYTHON_MEMBER(loc0Max);
0092 ACTS_PYTHON_MEMBER(loc1Min);
0093 ACTS_PYTHON_MEMBER(loc1Max);
0094 ACTS_PYTHON_MEMBER(timeMin);
0095 ACTS_PYTHON_MEMBER(timeMax);
0096 ACTS_PYTHON_MEMBER(phiMin);
0097 ACTS_PYTHON_MEMBER(phiMax);
0098 ACTS_PYTHON_MEMBER(etaMin);
0099 ACTS_PYTHON_MEMBER(etaMax);
0100 ACTS_PYTHON_MEMBER(absEtaMin);
0101 ACTS_PYTHON_MEMBER(absEtaMax);
0102 ACTS_PYTHON_MEMBER(ptMin);
0103 ACTS_PYTHON_MEMBER(ptMax);
0104 ACTS_PYTHON_MEMBER(minMeasurements);
0105 ACTS_PYTHON_MEMBER(maxHoles);
0106 ACTS_PYTHON_MEMBER(maxOutliers);
0107 ACTS_PYTHON_MEMBER(maxHolesAndOutliers);
0108 ACTS_PYTHON_MEMBER(maxSharedHits);
0109 ACTS_PYTHON_MEMBER(maxChi2);
0110 ACTS_PYTHON_MEMBER(measurementCounter);
0111 ACTS_PYTHON_MEMBER(requireReferenceSurface);
0112 ACTS_PYTHON_STRUCT_END();
0113
0114 pythonRangeProperty(c, "loc0", &Config::loc0Min, &Config::loc0Max);
0115 pythonRangeProperty(c, "loc1", &Config::loc1Min, &Config::loc1Max);
0116 pythonRangeProperty(c, "time", &Config::timeMin, &Config::timeMax);
0117 pythonRangeProperty(c, "phi", &Config::phiMin, &Config::phiMax);
0118 pythonRangeProperty(c, "eta", &Config::etaMin, &Config::etaMax);
0119 pythonRangeProperty(c, "absEta", &Config::absEtaMin, &Config::absEtaMax);
0120 pythonRangeProperty(c, "pt", &Config::ptMin, &Config::ptMax);
0121 }
0122
0123 {
0124 auto c = py::class_<EtaBinnedConfig>(tool, "EtaBinnedConfig")
0125 .def(py::init<>())
0126 .def(py::init<const Config&>());
0127
0128 patchKwargsConstructor(c);
0129
0130 c.def_property_readonly("nEtaBins", &EtaBinnedConfig::nEtaBins);
0131
0132 ACTS_PYTHON_STRUCT_BEGIN(c, EtaBinnedConfig);
0133 ACTS_PYTHON_MEMBER(cutSets);
0134 ACTS_PYTHON_MEMBER(absEtaEdges);
0135 ACTS_PYTHON_STRUCT_END();
0136 }
0137 }
0138 }
0139 }