From 591c8cbc4b5b2f2947d2b11a216bdabf5d41a819 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Sat, 12 Sep 2026 23:16:44 +0200 Subject: [PATCH] beam centre: the depth question is asked at both centres The ladder inside the beam-centre check ran only at the MEASURED centre, and its count was then set against the whole spot list at the file's. Two things differ between those two numbers - where the beam is and how much of each frame the pass reads - so the count cannot say which of them the gain came from, and the run attributed all of it to the centre. Measured on one crystal: at the measured centre, 15 px and 2.8 sigma from the file's, the ladder reached 40/60 on a cell five times the deposited primitive volume; at the file's own centre it reaches 49/60 on the deposited cell. The run moved the centre, post-refined the supercell, and - standing at 40/60 - skipped the beam-centre walk that finds the crystal's own centre six pixels the other way. It shipped a C-centred monoclinic cell of the right volume in the wrong lattice, on 43 per cent of the unique reflections. The ladder now runs at both centres and the centre moves only when it is the centre that pays. An exact tie keeps the file's centre. Where the file's centre wins, the run takes that rung and says the depth, not the centre, was the problem. No arbiter can be asked instead here: at the measured centre the true cell is not among the rungs, so no rung-versus-rung comparison contains the right answer, and the standing pass the winner would be judged against is itself a wrong 18 thousand cubic Angstrom cell 32 times smaller. --- rugnux/Rugnux.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/rugnux/Rugnux.cpp b/rugnux/Rugnux.cpp index 17ac8a819..f5a5a3ef1 100644 --- a/rugnux/Rugnux.cpp +++ b/rugnux/Rugnux.cpp @@ -3334,10 +3334,42 @@ ProcessResult Rugnux::RunPipeline(RugnuxObserver *observer, bool write_output, b // the run died; with the ladder's lean seed the measured centre indexes 60/60, and // the run then indexes every frame of the sweep and merges to the deposited // resolution. So ask the ladder here too, before giving the centre up. + // + // The depth is asked at BOTH centres, and the centre moves only if it is the + // centre that paid. A lean rung at the measured centre scored against the whole + // spot list at the file's changes two things at once, and the count cannot say + // which of them the gain came from - the same reason a trial centre is scored on + // its own spots at all. Measured on one crystal: the measured centre's ladder + // reached 40/60 on a FIVE-fold axis harmonic while the file's own centre reached + // 49/60 on the deposited cell, and the run moved the centre, shipped the + // supercell, and skipped the beam-centre walk that would have found the crystal's + // own. An exact tie keeps the file's centre: nothing then says the centre is wrong. bool lean = false; + bool deeper_at_home = false; if (!measured_indexes) { - if (auto l = first_pass_ladder(alt.score, 1, majority + 1)) { - alt = *l; + const FirstPassState before = committed; + restore_beam_center(header_x, header_y); + const auto home = first_pass_ladder(best.score, 1, majority + 1); + const FirstPassState home_state = committed; + committed = before; + apply_state(committed); + try_beam_center(measured_x, measured_y); + const auto away = first_pass_ladder(alt.score, 1, majority + 1); + if (home && (!away || home->score >= away->score)) { + committed = home_state; + restore_beam_center(header_x, header_y); + apply_state(committed); + best = *home; + deeper_at_home = true; + logger.Warning("Beam centre check: reading less of each frame takes the " + "file's centre to {}/{} validation frames against {}/{} at " + "the measured centre {:.2f} px away - it is how deep this " + "run was reading and not the centre, so the centre stays", + home->score, static_cast(validation.size()), + away ? away->score : 0, + static_cast(validation.size()), moved); + } else if (away) { + alt = *away; measured_indexes = true; lean = true; } @@ -3361,7 +3393,7 @@ ProcessResult Rugnux::RunPipeline(RugnuxObserver *observer, bool write_output, b static_cast(validation.size()), measured_x, measured_y, alt.score, static_cast(validation.size())); best = alt; - } else { + } else if (!deeper_at_home) { // Nothing worked. Put the file's centre back, so the ladder below searches // around the value the run started with rather than around a fit that has just // been tested and found no better - and so a run that fails for some other