File indexing completed on 2025-01-18 09:27:32
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Units.hpp"
0012 #include "Acts/EventData/TrackContainer.hpp"
0013 #include "Acts/Utilities/Delegate.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015
0016 #include <cstddef>
0017 #include <map>
0018 #include <memory>
0019 #include <string>
0020 #include <tuple>
0021 #include <vector>
0022
0023 #include <boost/container/flat_map.hpp>
0024 #include <boost/container/flat_set.hpp>
0025
0026 namespace Acts {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class ScoreBasedAmbiguityResolution {
0038 public:
0039
0040
0041
0042
0043 struct DetectorConfig {
0044 int hitsScoreWeight = 0;
0045 int holesScoreWeight = 0;
0046 int outliersScoreWeight = 0;
0047 int otherScoreWeight = 0;
0048
0049 std::size_t minHits = 0;
0050 std::size_t maxHits = 0;
0051 std::size_t maxHoles = 0;
0052 std::size_t maxOutliers = 0;
0053 std::size_t maxSharedHits = 0;
0054
0055
0056 bool sharedHitsFlag = false;
0057
0058 std::size_t detectorId = 0;
0059
0060
0061
0062
0063 std::vector<double> factorHits = {1.0};
0064
0065
0066
0067
0068 std::vector<double> factorHoles = {1.0};
0069 };
0070
0071
0072
0073
0074 struct TrackFeatures {
0075 std::size_t nHits = 0;
0076 std::size_t nHoles = 0;
0077 std::size_t nOutliers = 0;
0078 std::size_t nSharedHits = 0;
0079 };
0080
0081
0082 struct MeasurementInfo {
0083 std::size_t iMeasurement = 0;
0084 std::size_t detectorId = 0;
0085 bool isOutlier = false;
0086 };
0087
0088
0089 struct Config {
0090 std::map<std::size_t, std::size_t> volumeMap = {{0, 0}};
0091 std::vector<DetectorConfig> detectorConfigs;
0092
0093 double minScore = 0;
0094
0095 double minScoreSharedTracks = 0;
0096
0097 std::size_t maxSharedTracksPerMeasurement = 10;
0098
0099 std::size_t maxShared = 5;
0100
0101 double pTMin = 0 * UnitConstants::GeV;
0102 double pTMax = 1e5 * UnitConstants::GeV;
0103
0104 double phiMin = -M_PI * UnitConstants::rad;
0105 double phiMax = M_PI * UnitConstants::rad;
0106
0107 double etaMin = -5;
0108 double etaMax = 5;
0109
0110
0111 bool useAmbiguityFunction = false;
0112 };
0113
0114
0115
0116
0117
0118
0119 template <typename track_container_t, typename traj_t,
0120 template <typename> class holder_t, bool ReadOnly>
0121 struct OptionalCuts {
0122 using OptionalFilter =
0123 std::function<bool(const Acts::TrackProxy<track_container_t, traj_t,
0124 holder_t, ReadOnly>&)>;
0125
0126 using OptionalScoreModifier = std::function<void(
0127 const Acts::TrackProxy<track_container_t, traj_t, holder_t, ReadOnly>&,
0128 double&)>;
0129 std::vector<OptionalFilter> cuts = {};
0130 std::vector<OptionalScoreModifier> weights = {};
0131
0132
0133 std::vector<OptionalScoreModifier> scores = {};
0134 };
0135
0136 ScoreBasedAmbiguityResolution(
0137 const Config& cfg,
0138 std::unique_ptr<const Logger> logger =
0139 getDefaultLogger("ScoreBasedAmbiguityResolution", Logging::INFO))
0140 : m_cfg{cfg}, m_logger{std::move(logger)} {}
0141
0142
0143
0144
0145
0146
0147
0148
0149 template <typename track_container_t, typename traj_t,
0150 template <typename> class holder_t, typename source_link_hash_t,
0151 typename source_link_equality_t>
0152 std::vector<std::vector<MeasurementInfo>> computeInitialState(
0153 const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
0154 source_link_hash_t sourceLinkHash,
0155 source_link_equality_t sourceLinkEquality,
0156 std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors) const;
0157
0158
0159
0160
0161
0162
0163
0164 template <typename track_container_t, typename traj_t,
0165 template <typename> class holder_t, bool ReadOnly>
0166 std::vector<double> simpleScore(
0167 const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
0168 const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
0169 const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
0170 optionalCuts = {}) const;
0171
0172
0173
0174
0175
0176
0177
0178 template <typename track_container_t, typename traj_t,
0179 template <typename> class holder_t, bool ReadOnly>
0180 std::vector<double> ambiguityScore(
0181 const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
0182 const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
0183 const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
0184 optionalCuts = {}) const;
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194 std::vector<bool> getCleanedOutTracks(
0195 const std::vector<double>& trackScore,
0196 const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
0197 const std::vector<std::vector<MeasurementInfo>>& measurementsPerTrack)
0198 const;
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208 template <typename track_container_t, typename traj_t,
0209 template <typename> class holder_t, bool ReadOnly>
0210 std::vector<int> solveAmbiguity(
0211 const TrackContainer<track_container_t, traj_t, holder_t>& tracks,
0212 const std::vector<std::vector<MeasurementInfo>>& measurementsPerTrack,
0213 const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
0214 const OptionalCuts<track_container_t, traj_t, holder_t, ReadOnly>&
0215 optionalCuts = {}) const;
0216
0217 private:
0218 Config m_cfg;
0219
0220
0221 std::unique_ptr<const Logger> m_logger = nullptr;
0222
0223
0224 const Logger& logger() const;
0225 };
0226
0227 }
0228
0229 #include "Acts/AmbiguityResolution/ScoreBasedAmbiguityResolution.ipp"