File indexing completed on 2025-06-05 08:29:38
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/EventData/SourceLink.hpp"
0012 #include "Acts/Surfaces/Surface.hpp"
0013 #include "Acts/Utilities/Delegate.hpp"
0014
0015 namespace Acts::Experimental {
0016
0017
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 template <typename grid_t>
0044 class PathSeeder {
0045 public:
0046 using GridType = grid_t;
0047
0048
0049
0050
0051
0052
0053 struct Seed {
0054
0055 ActsScalar ipP;
0056
0057
0058 Vector3 ipDir;
0059
0060
0061 Vector3 ipVertex;
0062
0063
0064 std::vector<SourceLink> sourceLinks;
0065
0066 Seed() = delete;
0067 Seed(ActsScalar ipPmag, Vector3 ipPdir, Vector3 ipPos,
0068 std::vector<SourceLink> sls)
0069 : ipP(ipPmag),
0070 ipDir(std::move(ipPdir)),
0071 ipVertex(std::move(ipPos)),
0072 sourceLinks(std::move(sls)) {};
0073 };
0074
0075
0076
0077
0078
0079
0080
0081
0082 using SourceLinkGridLookup = Delegate<GridType(const GeometryIdentifier&)>;
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093 using TrackEstimator =
0094 Delegate<std::tuple<ActsScalar, ActsScalar, Vector3, Vector3, Vector3>(
0095 const GeometryContext&, const Vector3&)>;
0096
0097
0098
0099
0100
0101
0102
0103
0104 using SourceLinkCalibrator =
0105 Delegate<Vector3(const GeometryContext&, const SourceLink&)>;
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116 using IntersectionLookup =
0117 Delegate<std::vector<std::pair<GeometryIdentifier, Vector3>>(
0118 const GeometryContext&, const Vector3&, const Vector3&,
0119 const ActsScalar&, const ActsScalar&)>;
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 using PathWidthLookup = Delegate<std::pair<ActsScalar, ActsScalar>(
0132 const GeometryContext&, const GeometryIdentifier&)>;
0133
0134
0135 struct Config {
0136
0137 SourceLinkGridLookup sourceLinkGridLookup;
0138
0139 TrackEstimator trackEstimator;
0140
0141 SourceLinkCalibrator sourceLinkCalibrator;
0142
0143 IntersectionLookup intersectionFinder;
0144
0145 PathWidthLookup pathWidthProvider;
0146
0147 Extent firstLayerExtent;
0148
0149 BinningValue orientation = BinningValue::binX;
0150 };
0151
0152
0153 PathSeeder(const Config& config) : m_cfg(std::move(config)) {};
0154
0155
0156 ~PathSeeder() = default;
0157
0158
0159
0160
0161
0162
0163
0164
0165 std::vector<Seed> getSeeds(const GeometryContext& gctx,
0166 const std::vector<SourceLink>& sourceLinks) const {
0167
0168
0169 int bin0 = static_cast<int>(BinningValue::binX);
0170 int bin1 = static_cast<int>(BinningValue::binY);
0171 if (m_cfg.orientation == BinningValue::binX) {
0172 bin0 = static_cast<int>(BinningValue::binY);
0173 bin1 = static_cast<int>(BinningValue::binZ);
0174 } else if (m_cfg.orientation == BinningValue::binY) {
0175 bin0 = static_cast<int>(BinningValue::binX);
0176 bin1 = static_cast<int>(BinningValue::binZ);
0177 }
0178
0179
0180 std::vector<Seed> seeds;
0181 for (const auto& sl : sourceLinks) {
0182 Vector3 globalPos = m_cfg.sourceLinkCalibrator(gctx, sl);
0183
0184
0185
0186 if (!m_cfg.firstLayerExtent.contains(globalPos)) {
0187 continue;
0188 }
0189
0190
0191 auto [q, ipP, ipVertex, ipDir, flDir] =
0192 m_cfg.trackEstimator(gctx, globalPos);
0193
0194
0195 std::vector<std::pair<GeometryIdentifier, Vector3>> intersections =
0196 m_cfg.intersectionFinder(gctx, globalPos, flDir, ipP, q);
0197
0198
0199 if (intersections.empty()) {
0200 continue;
0201 }
0202
0203 std::vector<SourceLink> seedSourceLinks;
0204
0205
0206 seedSourceLinks.push_back(sl);
0207
0208
0209
0210
0211 for (auto& [geoId, refPoint] : intersections) {
0212
0213 auto [pathWidth0, pathWidth1] = m_cfg.pathWidthProvider(gctx, geoId);
0214
0215
0216 ActsScalar top0 = refPoint[bin0] + pathWidth0;
0217 ActsScalar bot0 = refPoint[bin0] - pathWidth0;
0218 ActsScalar top1 = refPoint[bin1] + pathWidth1;
0219 ActsScalar bot1 = refPoint[bin1] - pathWidth1;
0220
0221
0222 auto grid = m_cfg.sourceLinkGridLookup(geoId);
0223
0224
0225 auto botLeftBin = grid.localBinsFromPosition(Vector2(bot0, bot1));
0226 auto topRightBin = grid.localBinsFromPosition(Vector2(top0, top1));
0227
0228
0229
0230 auto currentBin = botLeftBin;
0231 while (currentBin.at(1) <= topRightBin.at(1)) {
0232 while (currentBin.at(0) <= topRightBin.at(0)) {
0233 auto sourceLinksToAdd = grid.atLocalBins(currentBin);
0234
0235 seedSourceLinks.insert(seedSourceLinks.end(),
0236 sourceLinksToAdd.begin(),
0237 sourceLinksToAdd.end());
0238 currentBin.at(0)++;
0239 }
0240 currentBin.at(1)++;
0241 currentBin.at(0) = botLeftBin.at(0);
0242 }
0243 }
0244
0245
0246
0247 Seed seed{ipP, ipDir, ipVertex, seedSourceLinks};
0248
0249
0250 seeds.push_back(seed);
0251 }
0252 return seeds;
0253 };
0254
0255 private:
0256 Config m_cfg;
0257 };
0258
0259 }