40 std::vector<double>
chi2CutOff{std::numeric_limits<double>::max()};
80 template <
typename traj_t>
82 typename std::vector<typename traj_t::TrackStateProxy>::iterator,
83 typename std::vector<typename traj_t::TrackStateProxy>::iterator>>
84 select(std::vector<typename traj_t::TrackStateProxy>& candidates,
87 typename std::vector<typename traj_t::TrackStateProxy>::iterator,
88 typename std::vector<typename traj_t::TrackStateProxy>::iterator>>;
93 if (candidates.empty()) {
94 return CombinatorialKalmanFilterError::MeasurementSelectionFailed;
98 auto surface = &candidates.front().referenceSurface();
99 auto geoID =
surface->geometryId();
107 return CombinatorialKalmanFilterError::MeasurementSelectionFailed;
111 const auto& chi2CutOff =
cuts->chi2CutOff;
112 auto maxChi2Cut = *std::max_element(chi2CutOff.begin(), chi2CutOff.end());
113 double minChi2 = std::numeric_limits<double>::max();
115 auto trackStateIterEnd = candidates.end();
117 auto trackStateIter = candidates.begin();
122 assert(trackStateIter != trackStateIterEnd);
129 ->
template calibrated<
133 ->
template calibratedCovariance<
136 trackStateIter->predicted(), trackStateIter->predictedCovariance(),
137 trackStateIter->projector(), trackStateIter->calibratedSize());
139 trackStateIter->chi2() = chi2;
142 if (chi2 >= maxChi2Cut ||
143 chi2 >= VariableCut<traj_t>(*trackStateIter,
cuts, chi2CutOff,
148 if (chi2 < minChi2) {
152 minIndex =
std::distance(candidates.begin(), trackStateIterEnd);
155 if (trackStateIter == trackStateIterEnd) {
159 std::swap(*trackStateIter, *trackStateIterEnd);
166 if (trackStateIter == trackStateIterEnd) {
175 if (candidates.begin() == trackStateIterEnd) {
176 const auto bestIt =
std::next(candidates.begin(), minIndex);
178 "No measurement candidate. Return an outlier measurement chi2="
182 return Result::success(std::pair{bestIt,
std::next(bestIt, 1)});
185 std::sort(candidates.begin(), trackStateIterEnd,
186 [](
const auto& tsa,
const auto& tsb) {
187 return tsa.chi2() < tsb.chi2();
191 const auto numMeasurementsCut = VariableCut<traj_t>(
195 candidates.begin(), trackStateIterEnd)) > numMeasurementsCut &&
196 numMeasurementsCut > 0) {
197 trackStateIterEnd =
std::next(candidates.begin(), numMeasurementsCut);
202 <<
", max: " << numMeasurementsCut);
205 return std::pair{candidates.begin(), trackStateIterEnd};
209 template <
typename traj_t,
typename cut_value_t>
211 const typename traj_t::TrackStateProxy& trackState,
214 const auto& etaBins = selector->etaBins;
215 if (etaBins.empty()) {
218 const auto eta = std::atanh(std::cos(trackState.predicted()[
eBoundTheta]));
219 const auto abseta = std::abs(
eta);
221 for (
auto etaBin : etaBins) {
222 if (etaBin >= abseta) {
227 if (bin >= cuts.size()) {
228 bin = cuts.size() - 1;
235 double* fullCalibrated,
double* fullCalibratedCovariance,
237 false>::Parameters predicted,
241 false>::Projector projector,
242 unsigned int calibratedSize)
const;