ATLAS Offline Software
TrackFindingBaseAlg.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 namespace ActsTrk {
6  template <class HandleArrayKeyType, class ContainerType>
7  StatusCode TrackFindingBaseAlg::getContainersFromKeys(
8  const EventContext &ctx,
9  HandleArrayKeyType &handleKeyArray,
10  std::vector<const ContainerType *> &outputContainers,
11  std::size_t &sum) const {
12  outputContainers.reserve(handleKeyArray.size());
13  for (const auto &handleKey : handleKeyArray) {
14  ATH_MSG_DEBUG("Reading input collection with key " << handleKey.key());
15  auto handle = SG::makeHandle(handleKey, ctx);
16  ATH_CHECK(handle.isValid());
17  outputContainers.push_back(handle.cptr());
18  ATH_MSG_DEBUG("Retrieved " << outputContainers.back()->size()
19  << " input elements from key " << handle.key());
20  sum += outputContainers.back()->size();
21  }
22 
23  return StatusCode::SUCCESS;
24  }
25 
26  template <class MeasurementSource>
27  std::unique_ptr<Acts::BoundTrackParameters> TrackFindingBaseAlg::doRefit(
28  const MeasurementSource &measurement,
29  const Acts::BoundTrackParameters &initialParameters,
30  const DetectorContextHolder &detContext,
31  const bool paramsAtOutermostSurface) const {
32  // Perform KF before CKF
33  const Acts::Surface* targetSurface = nullptr;
34  // get the proper surface
35  if (not paramsAtOutermostSurface) {
36  // inner-most surface
37  targetSurface = m_unalibMeasSurfAcc.get(measurement.sp().front()->measurements().front());
38  } else {
39  // outer-most surface
40  targetSurface = m_unalibMeasSurfAcc.get(measurement.sp().back()->measurements().back());
41  }
42  if (not targetSurface) {
43  ATH_MSG_VERBOSE("Could not identify the target surface for fitting the provided seed");
44  return nullptr;
45  }
46  const auto fittedSeedCollection = m_fitterTool->fit(measurement, initialParameters,
47  detContext.geometry, detContext.magField, detContext.calib,
48  *targetSurface);
49  if (not fittedSeedCollection) {
50  ATH_MSG_WARNING("KF Fitted Track is nullptr");
51  }
52  else if (fittedSeedCollection->size() != 1) {
53  ATH_MSG_WARNING("KF produced " << fittedSeedCollection->size() << " tracks but should produce 1!");
54  }
55  else
56  {
57  const auto fittedSeed = fittedSeedCollection->getTrack(0);
58  const auto trackState = paramsAtOutermostSurface ? fittedSeed.outermostTrackState()
59  : fittedSeed.innermostTrackState().value();
60  const auto boundParameters = fittedSeed.createParametersFromState(trackState);
61 
62  // Check pTmin requirement
63  const double etaSeed = -std::log(std::tan(0.5 * boundParameters.parameters()[Acts::eBoundTheta]));
64  const auto &cutSet = getCuts(etaSeed);
65  if (boundParameters.transverseMomentum() < cutSet.ptMin) {
66  ATH_MSG_VERBOSE("min pt requirement not satisfied after param refinement: pt min is " << cutSet.ptMin << " but Refined params have pt of " << boundParameters.transverseMomentum());
67  return nullptr;
68  }
69 
70  // Return updated parameters
71  return std::make_unique<Acts::BoundTrackParameters>(boundParameters);
72  }
73 
74  // When skipping return unchanged parameters
75  return std::make_unique<Acts::BoundTrackParameters>(initialParameters);
76  };
77 } // namespace ActsTrk