Integrate a pass-1 lattice fallback at the pass's own detector geometry

The second (refined-geometry) pass falls back to pass 1's lattice where
its re-index finds less. Two defects made that fallback undo the
post-refined geometry:

- The fallback adopts pass 1's whole indexing result (ForceResult), its
  detector geometry included, so the pass integrated at pass 1's
  distance and beam while the cell had already been scaled to the
  post-refined distance - a cell and a detector that do not belong
  together. The fallback now carries the pass's own distance and beam.

- A sparse crystal that indexes fewer validation frames than the 1/6
  floor fell back on every pass, even where the re-index found pass 1's
  lattice again with as many frames. Pass 1 had no more evidence for it
  than the re-index has, and the re-index is the one refined at the
  geometry the pass integrates at, so it is kept.

On a small-molecule sweep from a detector swung out on a 2theta arm,
whose sparse lattice indexes 5 of 60 validation frames, every move of
the distance the post-refinement asked for was undone by the fallback;
with both fixed, a moved distance reaches the integration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVeDQpv3w9JdZswRqKUW2H
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-22 11:45:48 +01:00
1 parent d95627d2cb
commit f7fbbb4cc0
1 file changed
+10 -1
+10 -1
View File
@@ -1196,6 +1196,11 @@ auto Rugnux::FirstPassRun::Pass1Fallback(FirstPass best) -> FirstPass {
const auto &l = pass1_lattice.lattice;
pass1_lattice.lattice = CrystalLattice(l.Vec0() * f, l.Vec1() * f, l.Vec2() * f);
}
// And the detector it is integrated at is this pass's, not pass 1's: the result is adopted whole
// (ForceResult), geometry included, so carrying pass 1's would integrate a cell scaled to the
// post-refined distance at the distance and beam the post-refinement has just moved off.
pass1_lattice.geom.BeamX_pxl(rx.experiment_.GetBeamX_pxl()).BeamY_pxl(rx.experiment_.GetBeamY_pxl())
.DetectorDistance_mm(d_use);
const CrystalLattice pass1_primitive = pass1_lattice.lattice
.ToPrimitive(pass1_lattice.search_result.centering).NiggliReduce();
const double pass1_vol = std::abs(pass1_primitive.CalcVolume());
@@ -1231,7 +1236,11 @@ auto Rugnux::FirstPassRun::Pass1Fallback(FirstPass best) -> FirstPass {
late_validation.size(), pass1_late, late_validation.size()),
early, pass1_more);
}
if (best.score < floor || pass1_more) {
// The floor is a question about the lattice, not about this geometry: where the re-index found pass
// 1's lattice again and indexes as many frames with it, pass 1 had no more evidence for it than this
// pass has, and the re-index is the one refined at the geometry the pass integrates at.
const bool same_and_as_good = same_lattice && best.score >= pass1_score;
if ((best.score < floor && !same_and_as_good) || pass1_more) {
const auto &pc = pass1_lattice.search_result.conventional.GetUnitCell();
const auto &bc = best.result->search_result.conventional.GetUnitCell();
logger.Warning("Two-pass: the refined-geometry re-index indexes {}/{} validation frames "