File indexing completed on 2025-07-14 08:10:41
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/SourceLink.hpp"
0012 #include "Acts/EventData/TrackParameters.hpp"
0013 #include "Acts/Seeding/detail/UtilityFunctions.hpp"
0014 #include "Acts/Utilities/Delegate.hpp"
0015 #include "Acts/Utilities/GridIterator.hpp"
0016
0017 namespace Acts {
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 class PathSeeder {
0045 public:
0046 using PathSeed = std::pair<BoundTrackParameters, std::vector<SourceLink>>;
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 using TrackEstimator =
0057 Delegate<std::pair<BoundTrackParameters, BoundTrackParameters>(
0058 const GeometryContext&, const SourceLink&)>;
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 using IntersectionLookup =
0069 Delegate<std::vector<std::pair<GeometryIdentifier, Vector2>>(
0070 const GeometryContext&, const BoundTrackParameters&)>;
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082 using PathWidthLookup = Delegate<std::pair<double, double>(
0083 const GeometryContext&, const GeometryIdentifier&)>;
0084
0085
0086 struct Config {
0087
0088 TrackEstimator trackEstimator;
0089
0090 IntersectionLookup intersectionFinder;
0091
0092 PathWidthLookup pathWidthProvider;
0093
0094 std::vector<GeometryIdentifier> refLayerIds;
0095 };
0096
0097
0098 explicit PathSeeder(const Config& config) : m_cfg(config) {};
0099
0100
0101 ~PathSeeder() = default;
0102
0103
0104
0105
0106
0107
0108
0109 template <Acts::detail::SourceLinkGrid grid_t, typename container_t>
0110 void findSeeds(const GeometryContext& gctx,
0111 const std::unordered_map<GeometryIdentifier, grid_t>&
0112 sourceLinkGridLookup,
0113 container_t& seedCollection) const {
0114
0115 for (auto& refGeoId : m_cfg.refLayerIds) {
0116 auto refGrid = sourceLinkGridLookup.at(refGeoId);
0117
0118 for (auto it = refGrid.begin(); it != refGrid.end(); it++) {
0119 std::vector<SourceLink> pivotSourceLinks = *it;
0120
0121 for (const auto& pivot : pivotSourceLinks) {
0122
0123 auto [ipParameters, refLayerParameters] =
0124 m_cfg.trackEstimator(gctx, pivot);
0125
0126
0127 std::vector<std::pair<GeometryIdentifier, Vector2>> intersections =
0128 m_cfg.intersectionFinder(gctx, refLayerParameters);
0129
0130
0131 if (intersections.empty()) {
0132 continue;
0133 }
0134
0135
0136
0137
0138 std::vector<SourceLink> seedSourceLinks;
0139 for (auto& [geoId, refPoint] : intersections) {
0140
0141 auto [pathWidth0, pathWidth1] =
0142 m_cfg.pathWidthProvider(gctx, geoId);
0143
0144
0145 double top0 = refPoint[0] + pathWidth0;
0146 double bot0 = refPoint[0] - pathWidth0;
0147 double top1 = refPoint[1] + pathWidth1;
0148 double bot1 = refPoint[1] - pathWidth1;
0149
0150
0151 auto grid = sourceLinkGridLookup.at(geoId);
0152
0153
0154 auto botLeftBin = grid.localBinsFromPosition(Vector2(bot0, bot1));
0155 auto topRightBin = grid.localBinsFromPosition(Vector2(top0, top1));
0156
0157
0158
0159 auto currentBin = botLeftBin;
0160 while (currentBin.at(1) <= topRightBin.at(1)) {
0161 while (currentBin.at(0) <= topRightBin.at(0)) {
0162 auto sourceLinksToAdd = grid.atLocalBins(currentBin);
0163
0164 seedSourceLinks.insert(seedSourceLinks.end(),
0165 sourceLinksToAdd.begin(),
0166 sourceLinksToAdd.end());
0167
0168 currentBin.at(0)++;
0169 }
0170 currentBin.at(1)++;
0171 currentBin.at(0) = botLeftBin.at(0);
0172 }
0173 }
0174 PathSeed seed = {ipParameters, seedSourceLinks};
0175
0176
0177 Acts::detail::pushBackOrInsertAtEnd(seedCollection, seed);
0178 }
0179 }
0180 }
0181 }
0182
0183 private:
0184 Config m_cfg;
0185 };
0186
0187 }