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