diff --git a/docs/CPU_DATA_ANALYSIS_INDEXING.md b/docs/CPU_DATA_ANALYSIS_INDEXING.md index eca6c6648..8c6a0dac1 100644 --- a/docs/CPU_DATA_ANALYSIS_INDEXING.md +++ b/docs/CPU_DATA_ANALYSIS_INDEXING.md @@ -325,6 +325,8 @@ The refinement above (§7.2) runs per image against that image's spots. For rota The **distance and the cell lengths are bounded one step at a time, not as a whole**. One per cent was once a cap on the entire move, and as a cap it was the opposite of its job — a header is most worth correcting when it is most wrong, and a geometry genuinely several per cent out could never be reached (measured: a refused fit of 310.000 → 305.692 mm whose cell landed within 0.06 % of the deposited one). It is a **trust region** instead. The first solve is asked in the wide box around nominal exactly as before, so a fit that settles within one step commits unchanged; a fit that wants more is re-fitted as a *walk* of one-per-cent steps, each seeded where the last arrived and each required to lower the held-out residual, stopping where a step stops paying. A walk that uses every step it is allowed has not settled — it stopped because it ran out of steps, not because it arrived — and is refused, which is the runaway the cap stood in for, tested where it can be seen. A move of more than one step is additionally **ratified by re-indexing at where it arrived**: that is what separates the failure the cap was really aimed at (a second lattice, whose spots bias every cross-validation fold identically) from a wrong header, since a second lattice does not index better at the new geometry and a real distance error does. The geometry the run commits is re-fitted on all the reflections once the held-out half has approved it — a walk from where it arrived, one step wide; everything else from nominal in the wide box — and the bounds are asked again of that fit rather than only of the half that earned it. A move outside them leaves the geometry at nominal, as every other refusal does, and the refusal says so in the report (`POSTREFINE_REFUSED`, with what the fit wanted) rather than passing silently. Detector tilt is held fixed, being gauge-coupled to the crystal orientation on a single crystal. + + **Whether the data determine the distance at all is asked, not assumed.** At a detector far enough away that no reflection reaches more than a few degrees of $2\theta$, a longer distance and a larger cell move every spot the same way to first order — the difference is of order $\sin^2\theta$ of the spot's own position, about 0.4 px rms per per cent of distance over a 2M detector at 820 mm against 2–3 px at the distances a crystal is usually collected at — and the rocking angles pin the cell scale only through the same $\sin\theta$. The joint fit then finds a distance/cell pair that fits its own observations a little better than the header, commits it, and the pass re-integrated there finds the next pair: a walk along the degenerate direction that the realised residual never ratifies (measured on such a sweep: a header at 820 mm walked to 846 mm with the cell 3.3 % too large, the realised held-out residual flat at every round). So the same fit is asked once more with the distance **held at the header**, every other block as free as before — the nested hypothesis "the header distance is right". Where the free distance lowers the held-out residual below the held fit's by more than that residual's own standard error, it has paid decisively and is committed exactly as before, which is every sweep whose $2\theta$ reaches tens of degrees and whose header is wrong. Where it has not, the fit cannot say — its own gain is not what decides, because a re-integration at the new distance need not realise it — so **both hypotheses are carried**: the canonical pass runs at the free geometry as before and once more at the header distance, and the run keeps the one whose *re-integrated* held-out residual is lower, the header's on a tie (the report says so: `POSTREFINE_DISTANCE_HELD`, and the pass decision names both residuals). Nothing is tuned here: the only inputs are the standard errors of the residuals themselves, the same noise the geometry walk's rounds have to beat. The wavelength is never refined on a single crystal for the same reason in its exact form: it scales the spot positions and the rocking angles identically to the cell, so no sweep can tell the two apart at any $2\theta$. 3. **Pass 2** re-indexes de novo and re-integrates at the committed geometry. Only the **detector distance and beam centre** carry over: the refined cell, orientation and axis are what make the distance identifiable, but pass 2 re-indexes from scratch, so they are not propagated. Where that re-index indexes too few frames the run falls back to pass 1's lattice and integrates it at the refined geometry — and the cell is then **scaled to the distance it will be used at**, since a real-space cell is measured against the distance its spots were seen at, and carrying it across a distance change otherwise scales the whole cell by the ratio of the two. The orientation is untouched. The space group is determined **after** pass 2, on the geometry the run refined, and pass 1 does not search at all: a decision taken on the worse of the two passes and then carried forward is a constraint on the better one, and would have to be reconciled with what pass 2 later found. The guard that chooses which pass is written compares each pass's **first** merge — $P1$ on both sides, full resolution range, before the correction surfaces — which both passes produce anyway, so it never compares statistics computed in two different space groups. What it compares there is the **signal each pass measured**: the count of unique reflections merged at $I/\sigma \ge 2$. Self-consistency cannot do this job — against an external arbiter the signal count named the more accurate geometry on 23 of 27 arm-dataset pairs where $R_\mathrm{meas}$, $CC_{1/2}$ and ISa managed 13, a coin flip — and that merge's own $CC_{1/2}$ least of all, being pooled over the whole range, uncut and uncorrected, so the shells with no signal in them dominate it and they are exactly the shells a geometry move disturbs (it reads 0.13 on a crystal whose data merge at 0.995). The refined pass is sent back only where it merges more unique reflections than its cell can hold, where it measured decisively less signal (10 %, and only where it holds no more reflections either — a wider integration disk pulls weak reflections in and dilutes the strong fraction without measuring less), or where it lost the axial rows the systematic absences are read off. One index-time veto remains and is keyed to pass 1's **lattice** rather than its group: a centred pass-1 lattice against a primitive pass-2 one. diff --git a/image_analysis/geom_refinement/PostRefine.cpp b/image_analysis/geom_refinement/PostRefine.cpp index 65a6e905c..fee879231 100644 --- a/image_analysis/geom_refinement/PostRefine.cpp +++ b/image_analysis/geom_refinement/PostRefine.cpp @@ -542,8 +542,14 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, // nominal for the first step of the walk below, the last step's answer after that. The // detector tilt is declared and held constant so that a non-zero rot1/rot2 still acts on // the observed side. - auto solve_joint = [&](Subset s, bool wide, double bm[2], double ds[1], double rv[3], - double q0[3], double q1[3], double q2[3]) { + // fix_distance holds the distance block at its seed, which makes the solve the nested + // hypothesis "the header distance is right" of the free one. distance_corr, where given + // (four values), receives the free fit's own formal picture of the distance: sd(distance) + // over the distance, and its correlation with each cell length, from the covariance of + // the solution. + auto solve_joint = [&](Subset s, bool wide, bool fix_distance, double bm[2], double ds[1], + double rv[3], double q0[3], double q1[3], double q2[3], + double *distance_corr = nullptr) { const double ds_seed = ds[0]; const double q1_seed[3] = {q1[0], q1[1], q1[2]}; ceres::Problem p; @@ -565,6 +571,7 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, } if (p.NumResidualBlocks() == 0) return false; p.SetParameterBlockConstant(det_rot); + if (fix_distance) p.SetParameterBlockConstant(ds); if (!p2_free) p.SetParameterBlockConstant(q2); // Two boxes on the distance and the cell lengths. WIDE is the one this fit has always // had, around nominal: it is what the first solve is asked in, so a fit that settles @@ -599,6 +606,26 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, ceres::Solver::Options o; o.linear_solver_type = ceres::DENSE_QR; o.max_num_iterations = 60; o.num_threads = std::max(1, settings.num_threads); o.logging_type = ceres::LoggingType::SILENT; ceres::Solver::Summary sum; ceres::Solve(o, &p, &sum); + if (distance_corr && !fix_distance && sum.IsSolutionUsable()) { + std::fill(distance_corr, distance_corr + 4, std::numeric_limits::quiet_NaN()); + ceres::Covariance::Options co; + co.algorithm_type = ceres::DENSE_SVD; + co.null_space_rank = -1; // a symmetry-constrained cell leaves unused length components + ceres::Covariance cov(co); + if (cov.Compute({{ds, ds}, {ds, q1}, {q1, q1}}, &p)) { + double cdd[1], cdq[3], cqq[9]; + cov.GetCovarianceBlock(ds, ds, cdd); + cov.GetCovarianceBlock(ds, q1, cdq); + cov.GetCovarianceBlock(q1, q1, cqq); + // Ceres' covariance is (J^T J)^-1 for unit-variance residuals; the residuals' + // own variance, from the fit's cost, puts it in real units. + const double sigma2 = 2.0 * sum.final_cost + / std::max(1, sum.num_residuals_reduced - sum.num_effective_parameters_reduced); + distance_corr[0] = std::sqrt(std::max(0.0, cdd[0]) * sigma2) / ds[0]; + for (int j = 0; j < 3; ++j) + distance_corr[1 + j] = cdq[j] / std::sqrt(std::max(1e-300, cdd[0] * cqq[4 * j])); + } + } return sum.IsSolutionUsable(); }; @@ -631,12 +658,59 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, for (int j = 0; j < 3; ++j) { rv_f[j] = ax0[j]; q0_f[j] = p0_0[j]; q1_f[j] = p1_0[j]; q2_f[j] = p2_0[j]; } - bool convJ = solve_joint(FIT, /*wide=*/true, bm_f, ds_f, rv_f, q0_f, q1_f, q2_f); + double distance_corr[4]; + bool convJ = solve_joint(FIT, /*wide=*/true, /*fix_distance=*/false, bm_f, ds_f, rv_f, + q0_f, q1_f, q2_f, distance_corr); + double cv_ref_se = NAN; double cv_ref = convJ ? joint_cost(VAL, bm_f, ds_f, rv_f, q0_f, q1_f, q2_f, - pos_ref, exc_ref) + pos_ref, exc_ref, &cv_ref_se) : cv_nom; int steps = 1; + // Do these data determine the distance at all? At a detector far enough away that + // no reflection reaches more than a few degrees of 2theta, a longer distance and a + // larger cell move every spot the same way to first order (the difference is of + // order sin^2 theta of the spot's own position), and the rocking angles pin the + // cell scale only through the same sin theta. The joint fit then finds a + // distance/cell pair that fits its own observations a little better than the + // header, commits it, and the pass re-integrated there finds the next pair - a + // walk along the degenerate direction that the realised residual never ratifies. + // So the same fit is asked once more with the distance HELD at the header, every + // other block as free as before - the nested hypothesis "the header distance is + // right". Where the free distance lowers the held-out residual below the held fit's + // by more than the standard error of that residual - the same noise a round of the + // geometry walk has to beat (HeldOutResidualFell) - it has paid decisively and is + // committed exactly as before. Where it has not, this fit cannot say: its own gain is + // not what decides, because the pass re-integrated at the new distance need not + // realise it (measured: a 0.6 % in-fit gain at nearly three times its paired scatter, + // none of it realised) while a sweep at a short distance realises a gain of that size + // several times over. So both hypotheses are carried - the free fit committed as + // before, the held fit's beam beside it - and RunAllPasses runs the canonical pass at + // each and keeps the one whose RE-INTEGRATED held-out residual is lower, the header's + // on a tie. + double bm_h[2] = {beam_x0, beam_y0}, ds_h[1] = {dist0}; + double rv_h[3], q0_h[3], q1_h[3], q2_h[3]; + for (int j = 0; j < 3; ++j) { + rv_h[j] = ax0[j]; q0_h[j] = p0_0[j]; q1_h[j] = p1_0[j]; q2_h[j] = p2_0[j]; + } + const bool convH = convJ && solve_joint(FIT, /*wide=*/true, /*fix_distance=*/true, + bm_h, ds_h, rv_h, q0_h, q1_h, q2_h); + double pos_h = 0.0, exc_h = 0.0, cv_h = cv_nom, cv_h_se = NAN; + if (convH) + cv_h = joint_cost(VAL, bm_h, ds_h, rv_h, q0_h, q1_h, q2_h, pos_h, exc_h, &cv_h_se); + const double noise = std::hypot(cv_ref_se, cv_h_se); + const bool distance_pays = convH && std::isfinite(noise) && cv_ref < cv_h - noise; + const bool distance_undecided = convH && !distance_pays; + logger.Info("Post-refine GEOM distance: free {:.3f} mm gives held-out {:.3e} +- {:.1e}; held " + "at the header {:.3f} mm gives {:.3e} +- {:.1e} (positional {:.3e}, excitation " + "{:.3e}); free minus held {:+.3e} against the noise {:.1e} => {}; the free fit's " + "formal sd(distance) {:.4f} %, corr(distance, cell a/b/c) {:.4f} {:.4f} {:.4f}", + ds_f[0], cv_ref, cv_ref_se, dist0, cv_h, cv_h_se, pos_h, exc_h, cv_ref - cv_h, + noise, + distance_undecided ? "this fit cannot tell, both are carried to the canonical pass" + : "the free distance pays", + 100.0 * distance_corr[0], distance_corr[1], distance_corr[2], distance_corr[3]); + // A larger move is no longer refused for its size - but it is not taken as one solve // asserted it either. It is re-fitted as a WALK: each step seeded where the last one // arrived, each bounded by the trust region, and each required to lower the held-out @@ -656,7 +730,8 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, for (int j = 0; j < 3; ++j) { rv_s[j] = rv_f[j]; q0_s[j] = q0_f[j]; q1_s[j] = q1_f[j]; q2_s[j] = q2_f[j]; } - if (!solve_joint(FIT, /*wide=*/false, bm_s, ds_s, rv_s, q0_s, q1_s, q2_s)) + if (!solve_joint(FIT, /*wide=*/false, /*fix_distance=*/false, bm_s, ds_s, rv_s, + q0_s, q1_s, q2_s)) break; double pos_s = 0.0, exc_s = 0.0; const double cv_s = joint_cost(VAL, bm_s, ds_s, rv_s, q0_s, q1_s, q2_s, @@ -732,7 +807,7 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, axv[j] = rv_f[j]; p0[j] = q0_f[j]; p1[j] = q1_f[j]; p2[j] = q2_f[j]; } } - solve_joint(ALL, !walked, beam, dist, axv, p0, p1, p2); // commit: re-fit on all data + solve_joint(ALL, !walked, /*fix_distance=*/false, beam, dist, axv, p0, p1, p2); // commit: re-fit on all data ds_log[0] = dist[0]; bm_log[0] = beam[0]; bm_log[1] = beam[1]; for (int j = 0; j < 3; ++j) { q1_log[j] = p1[j]; q2_log[j] = p2[j]; } refused = out_of_bounds(beam, p2); @@ -741,6 +816,13 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, for (int j = 0; j < 3; ++j) { axv[j] = ax0[j]; p0[j] = p0_0[j]; p1[j] = p1_0[j]; p2[j] = p2_0[j]; } + } else if (distance_undecided) { + // The other arm, re-fitted on all the data the same way: its beam at the + // header distance is what the canonical pass at that distance runs with. + if (solve_joint(ALL, /*wide=*/true, /*fix_distance=*/true, bm_h, ds_h, rv_h, q0_h, + q1_h, q2_h) + && out_of_bounds(bm_h, q2_h) == nullptr) + result.held_arm_beam_px = std::array{bm_h[0], bm_h[1]}; } } commit = (refused == nullptr); @@ -750,8 +832,11 @@ PostRefineResult PostRefineRotationGeometry(PostRefineObservations observations, // large for the bound - which is the one case where the number worth reading is the one // that was thrown away. The report carries the same sentence, so a refusal is visible // without the log. - const std::string verdict = commit ? fmt::format("COMMIT ({} step{})", steps, - steps == 1 ? "" : "s") + const std::string verdict = commit ? fmt::format("COMMIT ({} step{}{})", steps, + steps == 1 ? "" : "s", + result.held_arm_beam_px + ? ", the header distance carried as the other arm" + : "") : "reject (" + std::string(refused) + ")"; // The cell the log names is the EFFECTIVE one - what the residual's B matrix builds // from the blocks - not the blocks themselves, whose unused components a high-symmetry diff --git a/image_analysis/geom_refinement/PostRefine.h b/image_analysis/geom_refinement/PostRefine.h index b6f20833c..5abfe9ce7 100644 --- a/image_analysis/geom_refinement/PostRefine.h +++ b/image_analysis/geom_refinement/PostRefine.h @@ -49,6 +49,15 @@ struct PostRefineResult { // from. Such a move is not refused for its size - it is RATIFIED by re-integrating and re-indexing // at it, which a second lattice does not survive and a wrong header does (see RunAllPasses). bool large_move = false; + // The same fit with the distance HELD at the header, where the free distance did not lower the + // held-out residual below it by more than the noise of that residual: the beam centre that fit + // committed, at the header distance. The free fit is what `geom`, `cell` and the *_after fields + // carry, exactly as before; this is the other hypothesis, carried so that the canonical stage + // can run at both and keep the one whose RE-INTEGRATED residual is lower (see RunAllPasses). + // Absent where the free distance paid decisively, or where nothing was committed. + std::optional> held_arm_beam_px; + // Set by RunAllPasses where that comparison kept the header distance: the report names it. + bool distance_held = false; // The held-out residual at the geometry the fit STARTED from - what the integration this fit was // handed actually realises there, before the fit moves anything - and its standard error over the // held-out values. Two passes at two geometries are compared on this, not on the fit's own diff --git a/rugnux/ResultReport.cpp b/rugnux/ResultReport.cpp index 0a976d95d..59eb2452c 100644 --- a/rugnux/ResultReport.cpp +++ b/rugnux/ResultReport.cpp @@ -519,6 +519,9 @@ ReportDocument BuildReportDocument(const std::string &output_prefix, Add(s, KeyBool("POSTREFINE_DETECTOR_COMMITTED", pr.detector_refined)); Add(s, KeyText("POSTREFINE_DISTANCE", fmt::format("{:.3f} -> {:.3f}", pr.distance_before_mm, pr.distance_after_mm))); + // TRUE where the fit left the distance at the header because freeing it did not lower the + // held-out residual beyond the noise of that comparison - the data do not determine it. + Add(s, KeyBool("POSTREFINE_DISTANCE_HELD", pr.distance_held)); Add(s, KeyText("POSTREFINE_BEAM_CENTRE", fmt::format("{:.2f} {:.2f} -> {:.2f} {:.2f}", pr.beam_x_before_px, pr.beam_y_before_px, pr.beam_x_after_px, pr.beam_y_after_px))); diff --git a/rugnux/Rugnux.cpp b/rugnux/Rugnux.cpp index 557c79afe..e4ce27285 100644 --- a/rugnux/Rugnux.cpp +++ b/rugnux/Rugnux.cpp @@ -2031,6 +2031,78 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { experiment_.BeamX_pxl(g[0]).BeamY_pxl(g[1]).DetectorDistance_mm(g[2]) .PoniRot1_rad(g[3]).PoniRot2_rad(g[4]); }; + + // Where the pre-pass could not tell whether its distance move paid (held_arm_beam_px: the + // free distance lowered the fit's own held-out residual by less than that residual's noise), + // the other hypothesis - the header distance, with the beam the same fit found there - is run + // as a canonical pass of its own, and the two are judged on what they REALISE: the held-out + // residual each re-integrated pass measures at its own geometry, the comparison the walk + // below makes between its rounds. The free arm ran first and wrote the canonical files, so + // where it wins nothing is re-run; where the header's wins, or the two cannot be told apart, + // the header's is re-run to write them - it is the hypothesis that asserts nothing, so a tie + // is its, and the distance walk below is not entered: the data have just said they cannot + // place the distance. Measured on a sweep at 820 mm reaching 2theta ~ 9 deg, where the fit's + // own gain never realises: the free arm's re-integrated residual sat within 0.6 % of the + // header's at a noise of 8 %, and the cell it carried was 1 % too large. On a sweep at 110 mm + // reaching 57 deg, a 0.14 % distance move the pre-pass could not decide realised 3.7 % + // against a noise of 1.5 %, and the cell it carried matched the reference to 0.04 %. + std::string distance_arm; // the arm decision, for the pass decision text + bool distance_arm_kept_header = false; + int arm_passes = 0; + if (!cancelled_ && prepass_detector_geometry_ && pass1.post_refine + && pass1.post_refine->held_arm_beam_px && pass2.post_refine) { + const std::array free_geometry = current_geometry(); + std::array held_geometry = free_geometry; + held_geometry[0] = static_cast((*pass1.post_refine->held_arm_beam_px)[0]); + held_geometry[1] = static_cast((*pass1.post_refine->held_arm_beam_px)[1]); + held_geometry[2] = header_geometry[2]; + logger.Info("Two-pass: the pre-pass could not tell whether moving the distance {:.3f} -> {:.3f} mm " + "paid, so the canonical pass runs at the header distance as well and the two are " + "judged on the held-out residual each realises", header_geometry[2], + free_geometry[2]); + // The pass at the header distance measures its own post-refinement and integration, and + // neither may replace the free pass's where the free pass is the one kept. + const auto free_wish = prepass_detector_geometry_; + const auto free_starved = bkg_starved_fraction_; + set_geometry(held_geometry); + auto held = RunPipeline(observer, /*write_output=*/false, /*geometry_prepass=*/false); + ++arm_passes; + const double realised_free = pass2.post_refine->held_out_before; + const double realised_held = held.post_refine ? held.post_refine->held_out_before : NAN; + const double se_free = pass2.post_refine->held_out_before_se; + const double se_held = held.post_refine ? held.post_refine->held_out_before_se : NAN; + if (!cancelled_ && held.post_refine && HeldOutResidualFell(*held.post_refine, *pass2.post_refine)) { + logger.Info("Two-pass: re-integrated at the post-refined distance {:.3f} mm the held-out " + "residual is {:.3e} against {:.3e} at the header's {:.3f} mm (standard errors " + "{:.1e} and {:.1e}) - the move is realised and stands", free_geometry[2], + realised_free, realised_held, held_geometry[2], se_free, se_held); + set_geometry(free_geometry); + prepass_detector_geometry_ = free_wish; + bkg_starved_fraction_ = free_starved; + distance_arm = fmt::format( + "the header distance {:.3f} mm was run as well and realised a held-out residual of " + "{:.3e} against {:.3e} at the post-refined {:.3f} mm, so the post-refined distance " + "stands", held_geometry[2], realised_held, realised_free, free_geometry[2]); + } else if (!cancelled_) { + logger.Info("Two-pass: re-integrated at the header distance {:.3f} mm the held-out residual " + "is {:.3e}, which the post-refined {:.3f} mm does not beat ({:.3e}; standard " + "errors {:.1e} and {:.1e}) - these data do not determine the distance, and the " + "header's stands", held_geometry[2], realised_held, free_geometry[2], + realised_free, se_held, se_free); + pass2 = RunPipeline(observer, /*write_output=*/true, /*geometry_prepass=*/false); + ++arm_passes; + distance_arm_kept_header = true; + pass1.post_refine->distance_held = true; + pass1.post_refine->beam_x_after_px = held_geometry[0]; + pass1.post_refine->beam_y_after_px = held_geometry[1]; + pass1.post_refine->distance_after_mm = held_geometry[2]; + distance_arm = fmt::format( + "the header distance {:.3f} mm kept: re-integrated there the held-out residual is " + "{:.3e}, which the post-refined {:.3f} mm does not beat ({:.3e}), so these data do " + "not determine the distance", held_geometry[2], realised_held, free_geometry[2], + realised_free); + } + } int geometry_rounds = 0; // passes run at a geometry the walk moved to int walk_passes = 0; // every pass the walk ran, the return to its best round included int best_round = 0; @@ -2044,7 +2116,7 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { best_fit = *pass2.post_refine; walk_rounds = fmt::format("{:.3f} mm / {:.3e}", best_geometry[2], best_fit.held_out_before); } - while (!cancelled_ && prepass_detector_geometry_ + while (!cancelled_ && prepass_detector_geometry_ && !distance_arm_kept_header && pass2.post_refine && pass2.post_refine->detector_refined && (pass2.post_refine->large_move || geometry_rounds > 0)) { if (geometry_rounds == MAX_GEOMETRY_ROUNDS) { @@ -2112,8 +2184,8 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { pass1.post_refine->distance_after_mm = best_geometry[2]; } pass2.post_refine = pass1.post_refine; - pass2.pass_number = 2 + walk_passes; - pass2.pass_count = 2 + walk_passes; + pass2.pass_number = 2 + arm_passes + walk_passes; + pass2.pass_count = 2 + arm_passes + walk_passes; if (geometry_rounds > 0) pass2.pass_decision = fmt::format( "post-refined geometry walked {} round{} and kept round {}, detector distance {:.3f} mm " @@ -2248,6 +2320,8 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { pass2.pass_decision = (prepass_detector_geometry_ || prepass_rotation_scale_) ? "post-refined geometry adopted" : "the post-refinement committed no geometry change, so this pass reproduces the first"; + if (!distance_arm.empty()) + pass2.pass_decision = distance_arm + "; " + pass2.pass_decision; pass2.geometry_not_converged = geometry_not_converged; return pass2; }