19 {
20 const DataVector<const Trk::TrackParameters>* pars =
track.trackParameters();
21 if (!pars || pars->
empty()) {
return nullptr; }
22
23 bool firstOk = onlyUseMeasured ? pars->
front()->covariance() != nullptr :
true;
24 bool lastOk = onlyUseMeasured ? pars->
back()->covariance() != nullptr :
true;
25
27 if (distFront > 0. && firstOk) {
return pars->
front()->uniqueClone(); }
28
30 if (distBack < 0. && lastOk) {
return pars->
back()->uniqueClone(); }
31
32 bool startFront = std::abs(distFront) < distBack;
33
35 if (startFront) {
36 double prevDist = distFront - 1.;
37
40 for (;
it != it_end; ++
it) {
41 if (onlyUseMeasured && !(*it)->covariance()) continue;
42
44
45 if (dist > 0.) {
46 if (std::abs(dist) < std::abs(prevDist))
48 else if (it == pars->
begin())
50 else
52 break;
53 }
54 prevDist = dist;
56 }
57 } else {
58 double prevDist = distBack + 1.;
59
62 for (;
it != it_end; ++
it) {
63 if (onlyUseMeasured && !(*it)->covariance()) continue;
64
65 const double dist =
distance(**it, pos);
66
67 if (dist < 0.) {
68 if (std::abs(dist) < std::abs(prevDist))
70 else if (it == pars->
rbegin())
72 else
74 break;
75 }
76 prevDist = dist;
78 }
79 }
80
82 }
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const T * back() const
Access the last element in the collection as an rvalue.
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
std::reverse_iterator< const_iterator > const_reverse_iterator
Standard const_reverse_iterator.
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
static double distance(const Trk::TrackParameters &pars, const Amg::Vector3D &pos)
ParametersBase< TrackParametersDim, Charged > TrackParameters