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