Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 09:26:48

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