PostIndexingRefinement: Fix a bug in spot indexing cutoffs

This commit is contained in:
2026-03-13 19:18:19 +01:00
parent 4f79e12b92
commit e6b905a832
3 changed files with 433 additions and 12 deletions
@@ -35,18 +35,22 @@ namespace {
}
static inline std::vector<uint8_t> ComputeIndexedMask(
const Eigen::Ref<const Eigen::MatrixX3<float>> &spots,
const Eigen::Matrix3f &cell,
float indexing_tolerance,
int64_t &indexed_spot_count) {
const Eigen::Ref<const Eigen::MatrixX3<float>> &spots,
const Eigen::Matrix3f &cell,
float indexing_tolerance,
int64_t &indexed_spot_count) {
const float indexing_tolerance_sq = indexing_tolerance * indexing_tolerance;
const Eigen::MatrixX3<float> resid = CalculateResiduals(spots, cell);
// Compute fractional Miller indices
Eigen::MatrixX3<float> miller_frac = spots * cell;
Eigen::MatrixX3<float> miller_int = miller_frac.array().round().matrix();
Eigen::MatrixX3<float> frac_resid = miller_frac - miller_int;
std::vector<uint8_t> mask(spots.rows(), 0);
indexed_spot_count = 0;
for (int i = 0; i < spots.rows(); ++i) {
if (resid.row(i).squaredNorm() < indexing_tolerance_sq) {
if (frac_resid.row(i).squaredNorm() < indexing_tolerance_sq) {
mask[i] = 1;
indexed_spot_count++;
}