Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-19 07:58:24

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