File indexing completed on 2025-09-15 08:14:44
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Plugins/Python/Utilities.hpp"
0010 #include "Acts/Utilities/Logger.hpp"
0011 #include "ActsExamples/TruthTracking/HitSelector.hpp"
0012 #include "ActsExamples/TruthTracking/ParticleSelector.hpp"
0013 #include "ActsExamples/TruthTracking/ParticleTrackParamExtractor.hpp"
0014 #include "ActsExamples/TruthTracking/TrackModifier.hpp"
0015 #include "ActsExamples/TruthTracking/TrackParameterSelector.hpp"
0016 #include "ActsExamples/TruthTracking/TrackParameterSmearing.hpp"
0017 #include "ActsExamples/TruthTracking/TrackTruthMatcher.hpp"
0018 #include "ActsExamples/TruthTracking/TruthSeedingAlgorithm.hpp"
0019 #include "ActsExamples/TruthTracking/TruthTrackFinder.hpp"
0020 #include "ActsExamples/TruthTracking/TruthVertexFinder.hpp"
0021
0022 #include <memory>
0023
0024 #include <pybind11/pybind11.h>
0025 #include <pybind11/stl.h>
0026
0027 namespace ActsExamples {
0028 class IAlgorithm;
0029 }
0030
0031 namespace py = pybind11;
0032
0033 using namespace ActsExamples;
0034 using namespace Acts;
0035
0036 namespace Acts::Python {
0037
0038 void addTruthTracking(Context& ctx) {
0039 auto mex = ctx.get("examples");
0040
0041 ACTS_PYTHON_DECLARE_ALGORITHM(
0042 ActsExamples::TruthTrackFinder, mex, "TruthTrackFinder", inputParticles,
0043 inputParticleMeasurementsMap, inputMeasurements, inputSimHits,
0044 inputMeasurementSimHitsMap, outputProtoTracks);
0045
0046 ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::ParticleTrackParamExtractor, mex,
0047 "ParticleTrackParamExtractor", inputParticles,
0048 outputTrackParameters);
0049
0050 ACTS_PYTHON_DECLARE_ALGORITHM(
0051 ActsExamples::TrackParameterSmearing, mex, "TrackParameterSmearing",
0052 inputTrackParameters, outputTrackParameters, sigmaLoc0, sigmaLoc0PtA,
0053 sigmaLoc0PtB, sigmaLoc1, sigmaLoc1PtA, sigmaLoc1PtB, sigmaTime, sigmaPhi,
0054 sigmaTheta, sigmaPtRel, initialSigmas, initialSigmaQoverPt,
0055 initialSigmaPtRel, initialVarInflation, particleHypothesis,
0056 randomNumbers);
0057
0058 {
0059 using Alg = ActsExamples::ParticleSelector;
0060 using Config = Alg::Config;
0061
0062 auto alg = py::class_<Alg, IAlgorithm, std::shared_ptr<Alg>>(
0063 mex, "ParticleSelector")
0064 .def(py::init<const Alg::Config&, Acts::Logging::Level>(),
0065 py::arg("config"), py::arg("level"))
0066 .def_property_readonly("config", &Alg::config);
0067
0068 {
0069 auto mc = py::class_<Alg::MeasurementCounter>(alg, "MeasurementCounter")
0070 .def(py::init<>())
0071 .def("addCounter", &Alg::MeasurementCounter::addCounter);
0072 }
0073
0074 auto c = py::class_<Config>(alg, "Config").def(py::init<>());
0075
0076 ACTS_PYTHON_STRUCT(
0077 c, inputParticles, inputParticleMeasurementsMap, inputMeasurements,
0078 outputParticles, rhoMin, rhoMax, absZMin, absZMax, timeMin, timeMax,
0079 phiMin, phiMax, etaMin, etaMax, absEtaMin, absEtaMax, mMin, mMax, ptMin,
0080 ptMax, hitsMin, hitsMax, measurementsMin, measurementsMax,
0081 removeCharged, removeNeutral, removeSecondaries, excludeAbsPdgs,
0082 minPrimaryVertexId, maxPrimaryVertexId, measurementCounter);
0083
0084 pythonRangeProperty(c, "rho", &Config::rhoMin, &Config::rhoMax);
0085 pythonRangeProperty(c, "absZ", &Config::absZMin, &Config::absZMax);
0086 pythonRangeProperty(c, "time", &Config::timeMin, &Config::timeMax);
0087 pythonRangeProperty(c, "phi", &Config::phiMin, &Config::phiMax);
0088 pythonRangeProperty(c, "eta", &Config::etaMin, &Config::etaMax);
0089 pythonRangeProperty(c, "absEta", &Config::absEtaMin, &Config::absEtaMax);
0090 pythonRangeProperty(c, "m", &Config::mMin, &Config::mMax);
0091 pythonRangeProperty(c, "pt", &Config::ptMin, &Config::ptMax);
0092 pythonRangeProperty(c, "measurements", &Config::measurementsMin,
0093 &Config::measurementsMax);
0094 pythonRangeProperty(c, "hits", &Config::hitsMin, &Config::hitsMax);
0095 pythonRangeProperty(c, "primaryVertexId", &Config::minPrimaryVertexId,
0096 &Config::maxPrimaryVertexId);
0097 }
0098
0099 {
0100 using Alg = ActsExamples::TrackParameterSelector;
0101 using Config = Alg::Config;
0102
0103 auto alg = py::class_<Alg, IAlgorithm, std::shared_ptr<Alg>>(
0104 mex, "TrackParameterSelector")
0105 .def(py::init<const Alg::Config&, Acts::Logging::Level>(),
0106 py::arg("config"), py::arg("level"))
0107 .def_property_readonly("config", &Alg::config);
0108
0109 auto c = py::class_<Config>(alg, "Config").def(py::init<>());
0110
0111 ACTS_PYTHON_STRUCT(c, inputTrackParameters, outputTrackParameters, loc0Min,
0112 loc0Max, loc1Min, loc1Max, timeMin, timeMax, phiMin,
0113 phiMax, etaMin, etaMax, absEtaMin, absEtaMax, ptMin,
0114 ptMax);
0115
0116 pythonRangeProperty(c, "loc0", &Config::loc0Min, &Config::loc0Max);
0117 pythonRangeProperty(c, "loc1", &Config::loc1Min, &Config::loc1Max);
0118 pythonRangeProperty(c, "time", &Config::timeMin, &Config::timeMax);
0119 pythonRangeProperty(c, "phi", &Config::phiMin, &Config::phiMax);
0120 pythonRangeProperty(c, "eta", &Config::etaMin, &Config::etaMax);
0121 pythonRangeProperty(c, "absEta", &Config::absEtaMin, &Config::absEtaMax);
0122 pythonRangeProperty(c, "pt", &Config::ptMin, &Config::ptMax);
0123 }
0124
0125 ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::TruthVertexFinder, mex,
0126 "TruthVertexFinder", inputTracks,
0127 inputTrackParticleMatching, outputProtoVertices,
0128 excludeSecondaries, separateSecondaries);
0129
0130 ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::TrackModifier, mex,
0131 "TrackModifier", inputTracks, outputTracks,
0132 dropCovariance, covScale, killTime);
0133
0134 ACTS_PYTHON_DECLARE_ALGORITHM(
0135 ActsExamples::TruthSeedingAlgorithm, mex, "TruthSeedingAlgorithm",
0136 inputParticles, inputParticleMeasurementsMap, inputSimHits,
0137 inputMeasurementSimHitsMap, inputSpacePoints, outputParticles,
0138 outputSeeds, outputProtoTracks, deltaRMin, deltaRMax);
0139
0140 ACTS_PYTHON_DECLARE_ALGORITHM(ActsExamples::HitSelector, mex, "HitSelector",
0141 inputHits, inputParticlesSelected, outputHits,
0142 minX, maxX, minY, maxY, minZ, maxZ, minR, maxR,
0143 minTime, maxTime, minEnergyLoss, maxEnergyLoss,
0144 minPrimaryVertexId, maxPrimaryVertexId);
0145
0146 ACTS_PYTHON_DECLARE_ALGORITHM(
0147 ActsExamples::TrackTruthMatcher, mex, "TrackTruthMatcher", inputTracks,
0148 inputParticles, inputMeasurementParticlesMap, outputTrackParticleMatching,
0149 outputParticleTrackMatching, matchingRatio, doubleMatching);
0150 }
0151
0152 }