When a reference cell is supplied, PostIndexingRefinement::Refine() vetted candidates on sorted edge lengths only; a cell with the right edges but a wrong angle (a pseudo-symmetric near-metric, e.g. a monoclinic beta refined to the wrong value) passed. Add a sorted-angle check against the reference, folding each angle to its acute complement min(x,180-x) so the obtuse/acute setting choice is irrelevant (tolerance 10 deg). Reference-cell path only (no effect de novo, where reference_unit_cell is null): the /data/rotation_test battery is byte-identical (22/25), and NmHR with the correct C2 cell is unchanged (9.1%, beta~131.7). A latent guard against wrong-angle cells slipping through on -C / reference-MTZ runs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
#include <optional>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <cstdint>
|
|
#include <Eigen/Dense>
|
|
|
|
#include "../common/CrystalLattice.h"
|
|
|
|
constexpr float REFINE_CANDIDATE_SPOT_COUNT_RATIO_THRESHOLD = 0.9f;
|
|
constexpr float REFINE_CANDIDATE_VOLUME_RATIO_THRESHOLD = 1.05f;
|
|
constexpr float REFINE_CANDIDATE_OVERLAP_RATIO_THRESHOLD = 0.4f;
|
|
constexpr float REFINE_MIN_VOLUME_EPSILON = 1e-12f;
|
|
constexpr float REFINE_MIN_REFERENCE_LENGTH_EPSILON = 1e-6f;
|
|
// Max deviation (deg) of a candidate cell angle from the reference cell angle, compared after
|
|
// folding both to the acute complement (min(x,180-x)) so the obtuse/acute setting is irrelevant.
|
|
constexpr float REFINE_ANGLE_TOLERANCE_VS_REFERENCE_DEG = 10.0f;
|
|
|
|
struct RefineParameters {
|
|
int64_t viable_cell_min_spots;
|
|
float dist_tolerance_vs_reference;
|
|
std::optional<UnitCell> reference_unit_cell;
|
|
float min_length_A;
|
|
float max_length_A;
|
|
float min_angle_deg;
|
|
float max_angle_deg;
|
|
float indexing_tolerance;
|
|
};
|
|
|
|
std::vector<CrystalLattice> Refine(const std::vector<Coord> &in_spots,
|
|
size_t nspots,
|
|
Eigen::MatrixX3<float> &oCell,
|
|
Eigen::VectorX<float> &scores,
|
|
RefineParameters &p); |