ATLAS Offline Software
Loading...
Searching...
No Matches
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
5namespace 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::variant<std::unique_ptr<Acts::BoundTrackParameters>, TrackFindingBaseAlg::EStat> 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_WARNING("Could not identify the target surface for fitting the provided seed");
44 return kNSeedRefitFailure;
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_VERBOSE("KF fit failure");
51 return kNSeedRefitFailure;
52 }
53 if (fittedSeedCollection->size() != 1) {
54 ATH_MSG_WARNING("KF produced " << fittedSeedCollection->size() << " tracks but should produce 1!");
55 return kNSeedRefitFailure;
56 }
57 const auto fittedSeed = fittedSeedCollection->getTrack(0);
58
59 // get the track state at the beginning of the track, where we started
60 std::optional<typename decltype(fittedSeed)::ConstTrackStateProxy> trackState {std::nullopt};
61 if (paramsAtOutermostSurface) {
62 trackState = fittedSeed.outermostTrackState();
63 } else {
64 trackState = fittedSeed.innermostTrackState();
65 if (!trackState) {
66 // if the track is not forward linked (fixed by #5666), then we need to search back to the innermost track state
67 for (auto st : fittedSeed.trackStatesReversed()) {
68 trackState = st;
69 }
70 }
71 }
72
73 if (!trackState) {
74 ATH_MSG_VERBOSE("Missing "
75 << (paramsAtOutermostSurface ? "outermost" : "innermost")
76 << " track state");
77 return kNSeedRefitFailure;
78 }
79 const auto boundParameters = fittedSeed.createParametersFromState(trackState.value());
80
81 // Check pTmin requirement
82 const double etaSeed = -std::log(std::tan(0.5 * boundParameters.parameters()[Acts::eBoundTheta]));
83 const auto &cutSet = getCuts(etaSeed);
84 if (boundParameters.transverseMomentum() < cutSet.ptMin * m_seedRefitPtMinFactor) {
85 ATH_MSG_VERBOSE("min pt requirement not satisfied after param refinement: pt min is " << cutSet.ptMin << " but Refined params have pt of " << boundParameters.transverseMomentum());
86 return kNRejectedRefinedSeeds;
87 }
88
89 // Return updated parameters
90 return std::make_unique<Acts::BoundTrackParameters>(boundParameters);
91 };
92} // namespace ActsTrk