ATLAS Offline Software
Loading...
Searching...
No Matches
GridTripletSeedingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cmath>
8#include <cstdint>
9#include <numbers>
10#include <span>
11#include <string_view>
12#include <vector>
13
14namespace ActsTrk {
15
17 const std::string& name,
18 const IInterface* parent)
19 : base_class(type, name, parent) {}
20
22 ATH_MSG_DEBUG("Initializing " << name() << "...");
23
24 ATH_MSG_DEBUG("Properties Summary:");
30
31 ATH_MSG_DEBUG(" * Used by space point grid config:");
32 ATH_MSG_DEBUG(" " << m_minPt);
35 ATH_MSG_DEBUG(" " << m_zMin);
36 ATH_MSG_DEBUG(" " << m_zMax);
44
45 ATH_MSG_DEBUG(" * Used by seed finder config:");
46 ATH_MSG_DEBUG(" " << m_minPt);
49 ATH_MSG_DEBUG(" " << m_zMin);
50 ATH_MSG_DEBUG(" " << m_zMax);
52 ATH_MSG_DEBUG(" " << m_rMax);
67 }
79 } else if (not m_rRangeMiddleSP.empty())
99 }
102 ATH_MSG_DEBUG(" " << m_phiMin);
103 ATH_MSG_DEBUG(" " << m_phiMax);
104 ATH_MSG_DEBUG(" " << m_rMin);
105 ATH_MSG_DEBUG(" " << m_zAlign);
106 ATH_MSG_DEBUG(" " << m_rAlign);
108
109 ATH_MSG_DEBUG(" * Used by seed filter config:");
133 }
140
141 // Make the logger && Propagate to ACTS routines
142 m_logger = makeActsAthenaLogger(this, "Acts");
143
144 // Both edge vectors define the bins of the corresponding grid axis, so n
145 // edges give n-1 bins. Guard against an empty vector before subtracting, the
146 // sizes are unsigned.
147 if (m_zBinEdges.size() < 2 || m_rBinEdges.size() < 2) {
148 ATH_MSG_ERROR("zBinEdges and rBinEdges must each contain at least two "
149 "edges, got "
150 << m_zBinEdges.size() << " and " << m_rBinEdges.size());
151 return StatusCode::FAILURE;
152 }
153 const std::size_t nZBins = m_zBinEdges.size() - 1;
154 const std::size_t nRBins = m_rBinEdges.size() - 1;
155
156 // The neighbour vectors hold one entry per bin and are indexed 0-based by
157 // Acts::GridBinFinder. An empty vector means "one neighbour on each side".
158 auto checkNeighbors = [this](std::string_view name,
159 std::span<const std::pair<int, int>> values,
160 std::size_t nBins) {
161 if (values.empty() || values.size() == nBins) {
162 return true;
163 }
164 ATH_MSG_ERROR("Inconsistent config " << name << ": got " << values.size()
165 << " entries but the grid has "
166 << nBins << " bins");
167 return false;
168 };
169
170 if (!checkNeighbors("zBinNeighborsTop", m_zBinNeighborsTop.value(), nZBins) ||
171 !checkNeighbors("zBinNeighborsBottom", m_zBinNeighborsBottom.value(),
172 nZBins) ||
173 !checkNeighbors("rBinNeighborsTop", m_rBinNeighborsTop.value(), nRBins) ||
174 !checkNeighbors("rBinNeighborsBottom", m_rBinNeighborsBottom.value(),
175 nRBins)) {
176 return StatusCode::FAILURE;
177 }
178
179 // The custom looping vectors are the Acts::BinnedGroup navigation and use
180 // the 1-based local bin numbering of the grid axis: valid entries run from 1
181 // to the number of bins. Bin 0 is the underflow bin, which never holds a
182 // space point, so listing it would silently drop an entry from the loop. A
183 // vector may list a subset of the bins in order to skip the remaining ones,
184 // but must not repeat a bin. An empty vector means all bins in their natural
185 // order.
186 auto checkLooping = [this](std::string_view name,
187 std::span<const std::size_t> bins,
188 std::size_t nBins) {
189 std::vector<bool> visited(nBins + 1, false);
190 for (std::size_t i : bins) {
191 if (i == 0 || i > nBins) {
192 ATH_MSG_ERROR("Inconsistent config "
193 << name << ": bin " << i
194 << " is out of range, the numbering is 1-based and the "
195 "grid has "
196 << nBins << " bins (valid entries are 1.." << nBins
197 << ")");
198 return false;
199 }
200 if (visited[i]) {
201 ATH_MSG_ERROR("Inconsistent config " << name << ": bin " << i
202 << " is listed more than once");
203 return false;
204 }
205 visited[i] = true;
206 }
207 return true;
208 };
209
210 if (!checkLooping("zBinsCustomLooping", m_zBinsCustomLooping.value(),
211 nZBins) ||
212 !checkLooping("rBinsCustomLooping", m_rBinsCustomLooping.value(),
213 nRBins)) {
214 return StatusCode::FAILURE;
215 }
216
217 // rRangeMiddleSP is indexed 0-based by z bin in retrieveRadiusRangeForMiddle,
218 // so it needs exactly one entry per z bin. It is only read when the variable
219 // middle range is disabled.
220 if (!m_useVariableMiddleSPRange && m_rRangeMiddleSP.size() != nZBins) {
221 ATH_MSG_ERROR("Inconsistent config rRangeMiddleSP: got "
222 << m_rRangeMiddleSP.size()
223 << " entries but the grid has " << nZBins << " z bins");
224 return StatusCode::FAILURE;
225 }
226
227 std::visit([&](auto& cfg) {
228 //common settings for spherical and cylindrical grids
229 cfg.minPt = m_minPt;
230 cfg.rMin = 0;
231 cfg.rMax = m_gridRMax;
232 cfg.deltaRMax = m_deltaRMax;
233 cfg.impactMax = m_impactMax;
234 cfg.phiMin = m_gridPhiMin;
235 cfg.phiMax = m_gridPhiMax;
236 cfg.phiBinDeflectionCoverage = m_phiBinDeflectionCoverage;
237 cfg.maxPhiBins = m_maxPhiBins;
238 cfg.rBinEdges = m_rBinEdges;
239 cfg.bFieldInZ = 0; // will be set later
240
241 if constexpr (std::is_same_v<std::decay_t<decltype(cfg)>, Acts::Experimental::SphericalSpacePointGrid::Config>){
242 cfg.etaMin = m_etaMin;
243 cfg.etaMax = m_etaMax;
244 cfg.etaBinEdges = m_etaBinEdges;
245 cfg.bottomBinFinder = Acts::GridBinFinder<3ul>(
246 m_numPhiNeighbors.value(), m_numEtaNeighbors.value(),
247 m_rBinNeighborsBottom.value());
248 cfg.topBinFinder = Acts::GridBinFinder<3ul>(m_numPhiNeighbors.value(),
249 m_numEtaNeighbors.value(),
250 m_rBinNeighborsTop.value());
251 } else {
252 cfg.zMin = m_zMin;
253 cfg.zMax = m_zMax;
254 cfg.cotThetaMax = m_cotThetaMax;
255 cfg.zBinEdges = m_zBinEdges;
256 cfg.bottomBinFinder = Acts::GridBinFinder<3ul>(
258 m_rBinNeighborsBottom.value());
259 cfg.topBinFinder = Acts::GridBinFinder<3ul>(m_numPhiNeighbors.value(),
260 m_zBinNeighborsTop.value(),
261 m_rBinNeighborsTop.value());
262 cfg.navigation[0ul] = {};
263 cfg.navigation[1ul] = m_zBinsCustomLooping;
264 cfg.navigation[2ul] = m_rBinsCustomLooping;
265 }
266 }, m_gridCfg
267 );
268
269 m_bottomDoubletFinderCfg.spacePointsSortedByRadius = true;
270 m_bottomDoubletFinderCfg.candidateDirection = Acts::Direction::Backward();
281 m_bottomDoubletFinderCfg.helixCutTolerance = 1.;
282 m_topDoubletFinderCfg = m_bottomDoubletFinderCfg; // copy the bottom cuts
283 m_topDoubletFinderCfg.candidateDirection = Acts::Direction::Forward();
286
288 m_tripletFinderCfg.sortedByCotTheta = true;
290 m_tripletFinderCfg.sigmaScattering = m_sigmaScattering;
291 m_tripletFinderCfg.radLengthPerSeed = m_radLengthPerSeed;
293 m_tripletFinderCfg.helixCutTolerance = 1.;
294 m_tripletFinderCfg.toleranceParam = m_toleranceParam;
296 m_filterCfg.deltaInvHelixDiameter = m_deltaInvHelixDiameter;
297 m_filterCfg.deltaRMin = m_deltaRMin;
298 m_filterCfg.compatSeedWeight = m_compatSeedWeight;
299 m_filterCfg.impactWeightFactor = m_impactWeightFactor;
300 m_filterCfg.zOriginWeightFactor = m_zOriginWeightFactor;
301 m_filterCfg.maxSeedsPerSpM = m_maxSeedsPerSpM;
302 m_filterCfg.compatSeedLimit = m_compatSeedLimit;
303 m_filterCfg.seedWeightIncrement = m_seedWeightIncrement;
304 m_filterCfg.numSeedIncrement = m_numSeedIncrement;
305 m_filterCfg.seedConfirmation = m_seedConfirmationInFilter;
306 m_filterCfg.centralSeedConfirmationRange.zMinSeedConf = m_seedConfCentralZMin;
307 m_filterCfg.centralSeedConfirmationRange.zMaxSeedConf = m_seedConfCentralZMax;
308 m_filterCfg.centralSeedConfirmationRange.rMaxSeedConf = m_seedConfCentralRMax;
309 m_filterCfg.centralSeedConfirmationRange.nTopForLargeR =
311 m_filterCfg.centralSeedConfirmationRange.nTopForSmallR =
313 m_filterCfg.centralSeedConfirmationRange.seedConfMinBottomRadius =
315 m_filterCfg.centralSeedConfirmationRange.seedConfMaxZOrigin =
317 m_filterCfg.centralSeedConfirmationRange.minImpactSeedConf =
319 m_filterCfg.forwardSeedConfirmationRange.zMinSeedConf = m_seedConfForwardZMin;
320 m_filterCfg.forwardSeedConfirmationRange.zMaxSeedConf = m_seedConfForwardZMax;
321 m_filterCfg.forwardSeedConfirmationRange.rMaxSeedConf = m_seedConfForwardRMax;
322 m_filterCfg.forwardSeedConfirmationRange.nTopForLargeR =
324 m_filterCfg.forwardSeedConfirmationRange.nTopForSmallR =
326 m_filterCfg.forwardSeedConfirmationRange.seedConfMinBottomRadius =
328 m_filterCfg.forwardSeedConfirmationRange.seedConfMaxZOrigin =
330 m_filterCfg.forwardSeedConfirmationRange.minImpactSeedConf =
332 m_filterCfg.maxSeedsPerSpMConf = m_maxSeedsPerSpMConf;
333 m_filterCfg.maxQualitySeedsPerSpMConf = m_maxQualitySeedsPerSpMConf;
334 m_filterCfg.useDeltaRinsteadOfTopRadius = m_useDeltaRorTopRadius;
335 m_filterCfg.absDeltaEtaWeightFactor = m_absDeltaEtaWeightFactor;
336 m_filterCfg.absDeltaEtaMinImpact = m_absDeltaEtaMinImpact;
337
338 m_finder = Acts::TripletSeeder(logger().cloneWithSuffix("Finder"));
339
340 m_loggerFilter = logger().cloneWithSuffix("Filter");
341
342 ATH_CHECK(detStore()->retrieve(m_pixelId, "PixelID"));
343
344 return StatusCode::SUCCESS;
345}
346
348 const xAOD::SpacePoint* sp, float r) const {
349 float zabs = std::abs(sp->z());
350 float absCotTheta = zabs / r;
351
352 // checking configuration to remove pixel space points
353 Identifier identifier = m_pixelId->wafer_id(sp->elementIdList().at(0));
354 if (m_pixelId->is_barrel(identifier)) {
355 if (zabs > 200 && r < 40)
356 return false;
357
358 return true;
359 }
360
361 // Inner layers
362 // Below 1.20 - accept all
363 static constexpr float cotThetaEta120 = 1.5095;
364 if (absCotTheta < cotThetaEta120)
365 return true;
366
367 // Below 3.40 - remove if too close to beamline
368 static constexpr float cotThetaEta340 = 14.9654;
369 if (absCotTheta < cotThetaEta340 && r < m_expCutrMin)
370 return false;
371
372 // Outer layers
373 // Above 2.20
374 static constexpr float cotThetaEta220 = 4.4571;
375 if (absCotTheta > cotThetaEta220 && r > 260.)
376 return false;
377
378 // Above 2.60
379 static constexpr float cotThetaEta260 = 6.6947;
380 if (absCotTheta > cotThetaEta260 && r > 200.)
381 return false;
382
383 // Above 3.20
384 static constexpr float cotThetaEta320 = 12.2459;
385 if (absCotTheta > cotThetaEta320 && r > 140.)
386 return false;
387
388 // Above 4.00
389 static constexpr float cotThetaEta400 = 27.2899;
390 if (absCotTheta > cotThetaEta400)
391 return false;
392
393 return true;
394}
395
397 const std::vector<float>& spPhi, const std::vector<float>& spAsinD0OverR,
398 const Acts::ConstSpacePointProxy& middle,
399 const Acts::ConstSpacePointProxy& other, float cotTheta,
400 bool isBottomCandidate) const {
401 if (m_doubletDPhiCut) {
402 // per-pair azimuthal-swing bound: the hit azimuth of a track with impact
403 // parameter d0 swings between two radii by asin(d0/rInner) -
404 // asin(d0/rOuter) on top of the curvature rotation. The grid phi-bin
405 // widening only knows the full radial span; this applies the exact
406 // per-pair bound before the doublet enters the triplet stage.
407 // NB: this container only fills the packed coordinate columns, so the
408 // packed accessor zr() must be used here.
409 const float rM = middle.zr()[1];
410 const float rO = other.zr()[1];
411 const float rInner = std::min(rM, rO);
412 const float rOuter = std::max(rM, rO);
413
414 // phi(SP) and asin(d0/r) depend only on the SP (d0 is constant from the
415 // config), so they are computed once per SP in createSeeds and looked up
416 // via copiedFromIndex, avoiding two atan2 and two asin calls per
417 // candidate. asin(d0/r) is monotone in r, so the inner-minus-outer swing
418 // equals the absolute difference of the two per-SP terms.
419 const auto iM = middle.copiedFromIndex();
420 const auto iO = other.copiedFromIndex();
421 float dPhi = spPhi[iO] - spPhi[iM];
422 const float swing = std::abs(spAsinD0OverR[iO] - spAsinD0OverR[iM]);
423 if (dPhi > std::numbers::pi_v<float>) {
424 dPhi -= 2.f * std::numbers::pi_v<float>;
425 } else if (dPhi < -std::numbers::pi_v<float>) {
426 dPhi += 2.f * std::numbers::pi_v<float>;
427 }
428 const float bound = m_doubletDPhiConst +
429 m_doubletDPhiSlope * (rOuter - rInner) +
430 std::min(m_doubletDPhiCap.value(), swing);
431
432 if (std::abs(dPhi) > bound) {
433 return false;
434 }
435 }
436
437 if (!m_useExperimentCuts) {
438 return true;
439 }
440
441 // We remove some doublets that have the middle space point in some specific
442 // areas This should eventually be moved inside ACTS and allow a veto
443 // mechanism according to the user desire. As of now we cannot really do this
444 // since we define a range of validity of the middle candidate, and if we want
445 // to veto some sub-regions inside it, we need to do it here.
446 if (std::abs(middle.zr()[0]) > 1500 and middle.zr()[1] > 100 and
447 middle.zr()[1] < 150) {
448 return false;
449 }
450
451 // We remove here some seeds, in case the bottom space point radius is
452 // too small (i.e. < fastTrackingRMin)
453
454 // This operation is done only within a specific eta window
455 // Instead of eta we use the doublet cottheta
456 static constexpr float cotThetaEta120 = 1.5095;
457 static constexpr float cotThetaEta360 = 18.2855;
458
459 float absCotTheta = std::abs(cotTheta);
460 if (isBottomCandidate && other.zr()[1] < m_expCutrMin &&
461 absCotTheta > cotThetaEta120 && absCotTheta < cotThetaEta360) {
462 return false;
463 }
464
465 return true;
466}
467
469 const Acts::ConstSpacePointProxy& spM,
470 const Acts::Range1D<float>& rMiddleSpRange) const {
472 return {rMiddleSpRange.min(), rMiddleSpRange.max()};
473 }
474 if (m_rRangeMiddleSP.empty()) {
475 throw std::runtime_error(
476 "m_rRangeMiddleSP is empty, please check the configuration.");
477 }
478
479 // get zBin position of the middle SP
480 auto pVal =
481 std::lower_bound(m_zBinEdges.begin(), m_zBinEdges.end(), spM.zr()[0]);
482 int zBin = std::distance(m_zBinEdges.begin(), pVal);
483 // protects against zM at the limit of zBinEdges
484 zBin == 0 ? zBin : --zBin;
485 return {m_rRangeMiddleSP[zBin][0], m_rRangeMiddleSP[zBin][1]};
486}
487
488template <typename Grid> struct SPGridTraits;
489
490template<typename GridType>
492 const EventContext& ctx,
493 const std::vector<const xAOD::SpacePointContainer*>& spacePointCollections,
494 const Eigen::Vector3f& beamSpotPos, float bFieldInZ,
495 ActsTrk::SeedContainer& seedContainer, GridType::Config gridCfg) const {
496 (void)ctx;
497
498 gridCfg.bFieldInZ = bFieldInZ;
499
500 GridType grid(gridCfg, logger().cloneWithSuffix("Grid"));
501
502 std::size_t totalSpacePoints = 0;
503 for (const xAOD::SpacePointContainer* spacePoints : spacePointCollections) {
504 totalSpacePoints += spacePoints->size();
505 }
506
507 std::vector<const xAOD::SpacePoint*> selectedXAODSpacePoints;
508 std::vector<float> selectedSpacePointsR;
509 selectedXAODSpacePoints.reserve(totalSpacePoints);
510 selectedSpacePointsR.reserve(totalSpacePoints);
511 // Per-SP inputs for the doublet dPhi selection (see
512 // doubletSelectionFunction); only filled when the cut is enabled.
513 std::vector<float> selectedSpacePointsPhi;
514 std::vector<float> selectedSpacePointsAsinD0OverR;
515 const float dPhiCutD0 =
516 m_doubletDPhiD0Max < 0.f ? m_impactMax.value() : m_doubletDPhiD0Max.value();
517 if (m_doubletDPhiCut) {
518 selectedSpacePointsPhi.reserve(totalSpacePoints);
519 selectedSpacePointsAsinD0OverR.reserve(totalSpacePoints);
520 }
521
522 for (const xAOD::SpacePointContainer* spacePoints : spacePointCollections) {
523 for (const xAOD::SpacePoint* sp : *spacePoints) {
524 float x = static_cast<float>(sp->x() - beamSpotPos[0]);
525 float y = static_cast<float>(sp->y() - beamSpotPos[1]);
526 float z = static_cast<float>(sp->z());
527 float r = std::hypot(x, y);
528 float phi = std::atan2(y, x);
529
531 continue;
532 }
533
534 //This takes care of using translating z -> z/r in the spherical grid insertion
535 SPGridTraits<GridType>::insert(grid, selectedXAODSpacePoints.size(), phi, z, r);
536 selectedXAODSpacePoints.push_back(sp);
537 selectedSpacePointsR.push_back(r);
538 if (m_doubletDPhiCut) {
539 selectedSpacePointsPhi.push_back(phi);
540 selectedSpacePointsAsinD0OverR.push_back(
541 std::asin(std::min(1.f, dPhiCutD0 / std::max(r, 1.f))));
542 }
543 }
544 }
545
546 for (std::size_t i = 0; i < grid.numberOfBins(); ++i) {
547 std::ranges::sort(
548 grid.at(i), [&](Acts::SpacePointIndex a, Acts::SpacePointIndex b) {
549 return selectedSpacePointsR[a] < selectedSpacePointsR[b];
550 });
551 }
552
553 Acts::SpacePointContainer selectedSpacePoints;
554 selectedSpacePoints.createColumns(
555 Acts::SpacePointColumns::CopiedFromIndex |
556 Acts::SpacePointColumns::PackedXY | Acts::SpacePointColumns::PackedZR |
557 Acts::SpacePointColumns::VarianceZ | Acts::SpacePointColumns::VarianceR);
559 selectedSpacePoints.createColumns(
560 Acts::SpacePointColumns::StripCalibrationDetails);
561 }
562 selectedSpacePoints.reserve(grid.numberOfSpacePoints());
563 std::vector<Acts::SpacePointIndexRange> gridSpacePointRanges;
564 gridSpacePointRanges.reserve(grid.numberOfBins());
565 for (std::size_t i = 0; i < grid.numberOfBins(); ++i) {
566 std::uint32_t begin = selectedSpacePoints.size();
567 for (const Acts::SpacePointIndex spIndex : grid.at(i)) {
568 const xAOD::SpacePoint* sp = selectedXAODSpacePoints[spIndex];
569
570 auto newSp = selectedSpacePoints.createSpacePoint();
571 newSp.copiedFromIndex() = spIndex;
572 newSp.xy() =
573 std::array<float, 2>{static_cast<float>(sp->x() - beamSpotPos[0]),
574 static_cast<float>(sp->y() - beamSpotPos[1])};
575 newSp.zr() = std::array<float, 2>{static_cast<float>(sp->z()),
576 selectedSpacePointsR[spIndex]};
577 newSp.varianceZ() = static_cast<float>(sp->varianceZ());
578 newSp.varianceR() = static_cast<float>(sp->varianceR());
579
581 const Eigen::Vector3f innerStripHalfVector =
582 sp->bottomHalfStripLength() * sp->bottomStripDirection();
583 const Eigen::Vector3f outerStripCenter = sp->topStripCenter();
584 const Eigen::Vector3f outerStripHalfVector =
585 sp->topHalfStripLength() * sp->topStripDirection();
586 const Eigen::Vector3f stripSeparation = sp->stripCenterDistance();
587
588 newSp.outerStripCalibrationDetails().outerCenter = std::array<float, 3>{
589 outerStripCenter.x() - beamSpotPos[0],
590 outerStripCenter.y() - beamSpotPos[1], outerStripCenter.z()};
591 newSp.outerStripCalibrationDetails().innerToOuterSeparation =
592 std::array<float, 3>{stripSeparation.x(), stripSeparation.y(),
593 stripSeparation.z()};
594 newSp.outerStripCalibrationDetails().outerHalfVector =
595 std::array<float, 3>{outerStripHalfVector.x(),
596 outerStripHalfVector.y(),
597 outerStripHalfVector.z()};
598 newSp.outerStripCalibrationDetails().innerHalfVector =
599 std::array<float, 3>{innerStripHalfVector.x(),
600 innerStripHalfVector.y(),
601 innerStripHalfVector.z()};
602 }
603 }
604 std::uint32_t end = selectedSpacePoints.size();
605 gridSpacePointRanges.emplace_back(begin, end);
606 }
607
608 // clear temporary
609 selectedSpacePointsR = {};
610
611 ACTS_VERBOSE("Number of space points after selection "
612 << selectedSpacePoints.size() << " out of " << totalSpacePoints);
613
614 // Compute radius range. We rely on the fact the grid is storing the proxies
615 // with a sorting in the radius
616 const Acts::Range1D<float> rRange = [&]() -> Acts::Range1D<float> {
617 float minRange = std::numeric_limits<float>::max();
618 float maxRange = std::numeric_limits<float>::lowest();
619 for (const Acts::SpacePointIndexRange& range : gridSpacePointRanges) {
620 if (range.first == range.second) {
621 continue;
622 }
623 auto first = selectedSpacePoints[range.first];
624 auto last = selectedSpacePoints[range.second - 1];
625 minRange = std::min(first.zr()[1], minRange);
626 maxRange = std::max(last.zr()[1], maxRange);
627 }
628 return {minRange, maxRange};
629 }();
630
631 auto bottomDoubletFinderCfg = m_bottomDoubletFinderCfg;
632 auto topDoubletFinderCfg = m_topDoubletFinderCfg;
633
634 // set up the cache for the doublet selection function, which needs to know the per-SP phi and
635 // asin(d0/r) values for the middle and other SPs. The cache is filled in
636 // createSeeds, and the selection function is connected to the doublet finders below.
637 auto doubletSelection =
638 [this, &selectedSpacePointsPhi, &selectedSpacePointsAsinD0OverR](
639 const Acts::ConstSpacePointProxy& middle,
640 const Acts::ConstSpacePointProxy& other, float cotTheta,
641 bool isBottomCandidate) {
642 return doubletSelectionFunction(selectedSpacePointsPhi,
643 selectedSpacePointsAsinD0OverR, middle,
644 other, cotTheta, isBottomCandidate);
645 };
647 bottomDoubletFinderCfg.experimentCuts.connect(doubletSelection);
648 topDoubletFinderCfg.experimentCuts.connect(doubletSelection);
649 }
650
653 ATH_CHECK(inputHoughVtx.isValid());
654
655 for(const auto* vtx: *inputHoughVtx)
656 {
657 if(vtx->vertexType() == xAOD::VxType::PriVtx)
658 {
659 bottomDoubletFinderCfg.collisionRegionMin = vtx->z() - m_hvCollisionRegionTolerance;
660 bottomDoubletFinderCfg.collisionRegionMax = vtx->z() + m_hvCollisionRegionTolerance;
661 break;
662 }
663 }
664 // in case HoughVtx is not found and inputHoughVtx is empty, keep the original collision region
665 }
666
667 auto bottomDoubletFinder =
668 Acts::DoubletSeedFinder::create(Acts::DoubletSeedFinder::DerivedConfig(
669 bottomDoubletFinderCfg, bFieldInZ));
670 auto topDoubletFinder = Acts::DoubletSeedFinder::create(
671 Acts::DoubletSeedFinder::DerivedConfig(topDoubletFinderCfg, bFieldInZ));
672 auto tripletFinder = Acts::TripletSeedFinder::create(
673 Acts::TripletSeedFinder::DerivedConfig(m_tripletFinderCfg, bFieldInZ));
674
675 // variable middle SP radial region of interest
676 const Acts::Range1D<float> rMiddleSpRange(
677 std::floor(rRange.min() / 2) * 2 + m_deltaRMiddleMinSPRange,
678 std::floor(rRange.max() / 2) * 2 - m_deltaRMiddleMaxSPRange);
679
680 Acts::BroadTripletSeedFilter::State filterState;
681 Acts::BroadTripletSeedFilter::Cache filterCache;
682 Acts::TripletSeeder::Cache cache;
683
684 Acts::BroadTripletSeedFilter filter(m_filterCfg, filterState, filterCache,
686
687 std::vector<Acts::SpacePointContainer::ConstRange> bottomSpRanges;
688 std::optional<Acts::SpacePointContainer::ConstRange> middleSpRange;
689 std::vector<Acts::SpacePointContainer::ConstRange> topSpRanges;
690
691 Acts::SeedContainer tmpSeedContainer;
692
693 for (const auto [bottom, middle, top] : grid.binnedGroup()) {
694 ACTS_VERBOSE("Process middle bin " << middle);
695 if (middle >= gridSpacePointRanges.size()) {
696 ATH_MSG_ERROR("Grid Binned Group returned an unreasonable middle bin");
697 return StatusCode::FAILURE;
698 }
699
700 bottomSpRanges.clear();
701 topSpRanges.clear();
702
703 std::ranges::transform(
704 bottom, std::back_inserter(bottomSpRanges),
705 [&](std::size_t b) -> Acts::SpacePointContainer::ConstRange {
706 return selectedSpacePoints.range(gridSpacePointRanges[b]).asConst();
707 });
708 middleSpRange =
709 selectedSpacePoints.range(gridSpacePointRanges[middle]).asConst();
710 std::ranges::transform(
711 top, std::back_inserter(topSpRanges),
712 [&](std::size_t t) -> Acts::SpacePointContainer::ConstRange {
713 return selectedSpacePoints.range(gridSpacePointRanges[t]).asConst();
714 });
715
716 // we compute this here since all middle space point candidates belong to
717 // the same z-bin
718 auto firstMiddleSp = middleSpRange->front();
719 auto radiusRangeForMiddle =
720 retrieveRadiusRangeForMiddle(firstMiddleSp, rMiddleSpRange);
721
722 ACTS_VERBOSE("Validity range (radius) for the middle space point is ["
723 << radiusRangeForMiddle.first << ", "
724 << radiusRangeForMiddle.second << "]");
725
726 m_finder->createSeedsFromGroups(
727 cache, *bottomDoubletFinder, *topDoubletFinder, *tripletFinder, filter,
728 selectedSpacePoints, bottomSpRanges, *middleSpRange, topSpRanges,
729 radiusRangeForMiddle, tmpSeedContainer);
730 }
731
732 // Selection function - temporary implementation
733 // need change from ACTS for final implementation
734 // To be used only on PPP
735 auto selectionFunction =
736 [&filterState](const Acts::MutableSeedProxy& seed) -> bool {
737 float seedQuality = seed.quality();
738 float bottomQuality =
739 filterState.bestSeedQualityMap.at(seed.spacePointIndices()[0]);
740 float middleQuality =
741 filterState.bestSeedQualityMap.at(seed.spacePointIndices()[1]);
742 float topQuality =
743 filterState.bestSeedQualityMap.at(seed.spacePointIndices()[2]);
744
745 return bottomQuality <= seedQuality || middleQuality <= seedQuality ||
746 topQuality <= seedQuality;
747 };
748
749 seedContainer.reserve(seedContainer.size() + tmpSeedContainer.size());
750
751 // Select and convert the seeds
752 for (Acts::MutableSeedProxy seed : tmpSeedContainer) {
753 if (m_seedQualitySelection && !selectionFunction(seed)) {
754 continue;
755 }
756
757 seedContainer.push_back(
758 Acts::ConstSeedProxy(seed), [&](const Acts::SpacePointIndex spIndex) {
759 const Acts::SpacePointIndex originalIndex =
760 selectedSpacePoints.at(spIndex).copiedFromIndex();
761 return selectedXAODSpacePoints[originalIndex];
762 });
763 }
764
765 return StatusCode::SUCCESS;
766}
767
768template<>
769struct SPGridTraits<Acts::CylindricalSpacePointGrid> {
770
771 static void insert(auto& grid, std::size_t index, float phi, float z, float r) {
772 grid.insert(index, phi, z, r);
773 }
774
775};
776
777template<>
778struct SPGridTraits<Acts::Experimental::SphericalSpacePointGrid> {
779
780 static void insert(auto& grid, std::size_t index, float phi, float z, float r) {
781 grid.insert(index, phi, z/r, r);
782 }
783
784};
785
786
788 const EventContext& ctx,
789 const std::vector<const xAOD::SpacePointContainer*>& spacePointCollections,
790 const Eigen::Vector3f& beamSpotPos, float bFieldInZ,
791 ActsTrk::SeedContainer& seedContainer) const {
792
793 if (m_sphericalGrid){
794 return createSeedsImpl<Acts::Experimental::SphericalSpacePointGrid>(ctx, spacePointCollections, beamSpotPos, bFieldInZ, seedContainer, std::get<Acts::Experimental::SphericalSpacePointGrid::Config>(m_gridCfg));}
795 else {
796 return createSeedsImpl<Acts::CylindricalSpacePointGrid>(ctx, spacePointCollections, beamSpotPos, bFieldInZ, seedContainer, std::get<Acts::CylindricalSpacePointGrid::Config>(m_gridCfg));
797 }
798
799}
800} // namespace ActsTrk
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
static Double_t sp
static Double_t a
static const std::vector< std::string > bins
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition Logger.cxx:64
#define y
#define x
#define z
bool spacePointSelectionFunction(const xAOD::SpacePoint *sp, float r) const
Acts::TripletSeedFinder::Config m_tripletFinderCfg
Gaudi::Property< bool > m_useDeltaRorTopRadius
Gaudi::Property< bool > m_seedQualitySelection
Gaudi::Property< float > m_seedConfForwardMinImpact
Acts::DoubletSeedFinder::Config m_bottomDoubletFinderCfg
Gaudi::Property< std::vector< std::pair< int, int > > > m_rBinNeighborsTop
Gaudi::Property< float > m_impactWeightFactor
Acts::DoubletSeedFinder::Config m_topDoubletFinderCfg
Gaudi::Property< float > m_collisionRegionMax
Gaudi::Property< float > m_seedConfCentralMinBottomRadius
std::optional< Acts::TripletSeeder > m_finder
Gaudi::Property< int > m_phiBinDeflectionCoverage
Gaudi::Property< float > m_zOriginWeightFactor
Gaudi::Property< std::size_t > m_maxSeedsPerSpMConf
Gaudi::Property< float > m_maxPtScattering
Gaudi::Property< bool > m_useVariableMiddleSPRange
Gaudi::Property< std::vector< float > > m_etaBinEdges
Gaudi::Property< float > m_toleranceParam
Gaudi::Property< float > m_maxStripDeltaCotTheta
StatusCode createSeeds(const EventContext &ctx, const std::vector< const xAOD::SpacePointContainer * > &spacePointCollections, const Eigen::Vector3f &beamSpotPos, float bFieldInZ, ActsTrk::SeedContainer &seedContainer) const override
Gaudi::Property< float > m_deltaRMaxBottomSP
Gaudi::Property< float > m_seedConfForwardMinBottomRadius
Gaudi::Property< float > m_compatSeedWeight
Gaudi::Property< std::vector< std::vector< double > > > m_rRangeMiddleSP
Gaudi::Property< float > m_deltaRMinTopSP
Gaudi::Property< float > m_seedConfForwardZMin
Gaudi::Property< float > m_doubletDPhiSlope
Gaudi::Property< bool > m_sphericalGrid
Acts::BroadTripletSeedFilter::Config m_filterCfg
Gaudi::Property< std::vector< std::pair< int, int > > > m_rBinNeighborsBottom
std::variant< Acts::CylindricalSpacePointGrid::Config, Acts::Experimental::SphericalSpacePointGrid::Config > m_gridCfg
Gaudi::Property< bool > m_useDetailedDoubleMeasurementInfo
Gaudi::Property< std::vector< std::pair< int, int > > > m_zBinNeighborsBottom
Gaudi::Property< float > m_gridPhiMin
std::pair< float, float > retrieveRadiusRangeForMiddle(const Acts::ConstSpacePointProxy &spM, const Acts::Range1D< float > &rMiddleSpRange) const
Gaudi::Property< bool > m_interactionPointCut
Gaudi::Property< size_t > m_seedConfCentralNTopSmallR
Gaudi::Property< std::vector< float > > m_rBinEdges
Gaudi::Property< float > m_seedConfForwardRMax
Gaudi::Property< float > m_doubletDPhiCap
Gaudi::Property< float > m_deltaRMiddleMaxSPRange
GridTripletSeedingTool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< bool > m_useHVCollisionRegion
Gaudi::Property< std::vector< std::pair< int, int > > > m_zBinNeighborsTop
Gaudi::Property< float > m_deltaInvHelixDiameter
Gaudi::Property< float > m_collisionRegionMin
Gaudi::Property< float > m_seedConfCentralMaxZOrigin
Gaudi::Property< float > m_seedConfCentralMinImpact
Gaudi::Property< std::size_t > m_maxQualitySeedsPerSpMConf
Gaudi::Property< std::vector< float > > m_zBinEdges
Gaudi::Property< bool > m_seedConfirmation
Gaudi::Property< float > m_seedConfForwardMaxZOrigin
Gaudi::Property< float > m_hvCollisionRegionTolerance
Gaudi::Property< float > m_doubletDPhiD0Max
Gaudi::Property< float > m_seedWeightIncrement
Gaudi::Property< float > m_radLengthPerSeed
Gaudi::Property< float > m_absDeltaEtaMinImpact
Gaudi::Property< float > m_absDeltaEtaWeightFactor
Gaudi::Property< float > m_cotThetaMax
Gaudi::Property< float > m_deltaRMinBottomSP
StatusCode createSeedsImpl(const EventContext &ctx, const std::vector< const xAOD::SpacePointContainer * > &spacePointCollections, const Eigen::Vector3f &beamSpotPos, float bFieldInZ, ActsTrk::SeedContainer &seedContainer, GridType::Config gridCfg) const
Gaudi::Property< size_t > m_seedConfCentralNTopLargeR
virtual StatusCode initialize() override
Gaudi::Property< float > m_deltaRMiddleMinSPRange
Gaudi::Property< float > m_seedConfForwardZMax
Gaudi::Property< bool > m_seedConfirmationInFilter
Gaudi::Property< std::vector< std::size_t > > m_rBinsCustomLooping
const Acts::Logger & logger() const
Private access to the logger.
Gaudi::Property< float > m_seedConfCentralRMax
std::unique_ptr< const Acts::Logger > m_logger
logging instance
Gaudi::Property< float > m_sigmaScattering
std::unique_ptr< const Acts::Logger > m_loggerFilter
Gaudi::Property< std::vector< size_t > > m_zBinsCustomLooping
Gaudi::Property< float > m_seedConfCentralZMax
bool doubletSelectionFunction(const std::vector< float > &spPhi, const std::vector< float > &spAsinD0OverR, const Acts::ConstSpacePointProxy &middle, const Acts::ConstSpacePointProxy &other, float cotTheta, bool isBottomCandidate) const
doublet selection which caches per SP phi and asin(d0/r) values for the middle and other SPs
Gaudi::Property< float > m_deltaRMaxTopSP
Gaudi::Property< std::size_t > m_compatSeedLimit
Gaudi::Property< size_t > m_seedConfForwardNTopSmallR
SG::ReadHandleKey< xAOD::VertexContainer > m_inputHoughVtxKey
Gaudi::Property< float > m_seedConfCentralZMin
Gaudi::Property< bool > m_useExperimentCuts
Gaudi::Property< float > m_numSeedIncrement
Gaudi::Property< float > m_doubletDPhiConst
Gaudi::Property< size_t > m_seedConfForwardNTopLargeR
virtual bool isValid() override final
Can the handle be successfully dereferenced?
int r
Definition globals.cxx:22
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition index.py:1
@ PriVtx
Primary vertex.
SpacePointContainer_v1 SpacePointContainer
Define the version of the space point container.
static void insert(auto &grid, std::size_t index, float phi, float z, float r)
static void insert(auto &grid, std::size_t index, float phi, float z, float r)
Seed push_back(SpacePointRange spacePoints, float quality, float vertexZ)
void reserve(std::size_t size, float averageSpacePoints=3) noexcept
std::size_t size() const noexcept