File indexing completed on 2025-01-18 09:11:01
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/Surfaces/Surface.hpp"
0015 #include "Acts/Utilities/Delegate.hpp"
0016 #include "Acts/Utilities/GridIterator.hpp"
0017
0018 namespace Acts {
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
0045 class PathSeeder {
0046 public:
0047 using PathSeed =
0048 std::pair<CurvilinearTrackParameters, std::vector<SourceLink>>;
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 using TrackEstimator = Delegate<
0059 std::pair<CurvilinearTrackParameters, CurvilinearTrackParameters>(
0060 const GeometryContext&, const SourceLink&)>;
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 using IntersectionLookup =
0071 Delegate<std::vector<std::pair<GeometryIdentifier, Vector2>>(
0072 const GeometryContext&, const CurvilinearTrackParameters&)>;
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 using PathWidthLookup = Delegate<std::pair<double, double>(
0085 const GeometryContext&, const GeometryIdentifier&)>;
0086
0087
0088 struct Config {
0089
0090 TrackEstimator trackEstimator;
0091
0092 IntersectionLookup intersectionFinder;
0093
0094 PathWidthLookup pathWidthProvider;
0095
0096 std::vector<GeometryIdentifier> refLayerIds;
0097 };
0098
0099
0100 PathSeeder(const Config& config) : m_cfg(config) {};
0101
0102
0103 ~PathSeeder() = default;
0104
0105
0106
0107
0108
0109
0110
0111 template <Acts::detail::SourceLinkGrid grid_t, typename container_t>
0112 void findSeeds(const GeometryContext& gctx,
0113 const std::unordered_map<GeometryIdentifier, grid_t>&
0114 sourceLinkGridLookup,
0115 container_t& seedCollection) const {
0116
0117 for (auto& refGeoId : m_cfg.refLayerIds) {
0118 auto refGrid = sourceLinkGridLookup.at(refGeoId);
0119
0120 for (auto it = refGrid.begin(); it != refGrid.end(); it++) {
0121 std::vector<SourceLink> pivotSourceLinks = *it;
0122
0123 for (const auto& pivot : pivotSourceLinks) {
0124
0125 auto [ipParameters, refLayerParameters] =
0126 m_cfg.trackEstimator(gctx, pivot);
0127
0128
0129 std::vector<std::pair<GeometryIdentifier, Vector2>> intersections =
0130 m_cfg.intersectionFinder(gctx, refLayerParameters);
0131
0132
0133 if (intersections.empty()) {
0134 continue;
0135 }
0136
0137
0138
0139
0140 std::vector<SourceLink> seedSourceLinks;
0141 for (auto& [geoId, refPoint] : intersections) {
0142
0143 auto [pathWidth0, pathWidth1] =
0144 m_cfg.pathWidthProvider(gctx, geoId);
0145
0146
0147 double top0 = refPoint[0] + pathWidth0;
0148 double bot0 = refPoint[0] - pathWidth0;
0149 double top1 = refPoint[1] + pathWidth1;
0150 double bot1 = refPoint[1] - pathWidth1;
0151
0152
0153 auto grid = sourceLinkGridLookup.at(geoId);
0154
0155
0156 auto botLeftBin = grid.localBinsFromPosition(Vector2(bot0, bot1));
0157 auto topRightBin = grid.localBinsFromPosition(Vector2(top0, top1));
0158
0159
0160
0161 auto currentBin = botLeftBin;
0162 while (currentBin.at(1) <= topRightBin.at(1)) {
0163 while (currentBin.at(0) <= topRightBin.at(0)) {
0164 auto sourceLinksToAdd = grid.atLocalBins(currentBin);
0165
0166 seedSourceLinks.insert(seedSourceLinks.end(),
0167 sourceLinksToAdd.begin(),
0168 sourceLinksToAdd.end());
0169
0170 currentBin.at(0)++;
0171 }
0172 currentBin.at(1)++;
0173 currentBin.at(0) = botLeftBin.at(0);
0174 }
0175 }
0176 PathSeed seed = {ipParameters, seedSourceLinks};
0177
0178
0179 Acts::detail::pushBackOrInsertAtEnd(seedCollection, seed);
0180 }
0181 }
0182 }
0183 }
0184
0185 private:
0186 Config m_cfg;
0187 };
0188
0189 }