Files
Jungfraujoch/image_analysis/geom_refinement/BeamCenterFromBackground.h
T
leonarski_f 77bc0cfe52
Build Packages / build:viewer-tgz:cpu (push) Successful in 11m35s
Build Packages / build:windows:nocuda (push) Successful in 16m52s
Build Packages / build:windows:cuda (push) Successful in 20m24s
Build Packages / build:rugnux-tgz (x86_64) (push) Successful in 18m38s
Build Packages / build:rugnux:windows (push) Successful in 10m38s
Build Packages / build:rugnux:aarch64 (cross) (push) Successful in 9m4s
Build Packages / build:viewer-tgz:cuda (push) Successful in 14m44s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 20m46s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 21m24s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 24m13s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 26m2s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 18m34s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 23m55s
Build Packages / build:rpm (rocky9) (push) Successful in 21m9s
Build Packages / XDS test (durin plugin) (push) Successful in 12m8s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 20m6s
Build Packages / build:rpm (rocky8) (push) Successful in 25m46s
Build Packages / Generate python client (push) Successful in 38s
Build Packages / Create release (push) Skipped
Build Packages / Build documentation (push) Successful in 58s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 24m36s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 8m44s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m17s
Build Packages / DIALS test (push) Successful in 19m45s
Build Packages / Unit tests (push) Successful in 1h26m13s
v1.0.0-rc.168 (#78)
* rugnux is substantially faster - a corpus of 145 rotation datasets processes in about two thirds of the time - with identical results.
* A crystal whose lattice looks more symmetric than it is because the beam centre is off is no longer processed on the wrong cell.
* rugnux prints at startup, and writes at the foot of every results report, a short acknowledgement of the X-ray research community whose methods it implements and of the open-source projects it builds on; `ACKNOWLEDGEMENT.md` now ships in every package beside `LICENSE` and `THIRD_PARTY_NOTICES.md`.

Reviewed-on: #78
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-09-10 13:51:16 +02:00

40 lines
2.1 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <optional>
#include <vector>
#include "../../common/DiffractionExperiment.h"
#include "../../common/PixelMask.h"
struct BeamCenterEstimate {
float beam_x_pxl = 0.0f;
float beam_y_pxl = 0.0f;
float sigma_pxl = 0.0f; // 1 sigma on the fitted shift, the larger of the two axes
};
// Beam centre from the isotropy of the scattered background, before anything is indexed.
//
// The solvent and air scatter is isotropic in 2-theta about the beam, so a centre that is off
// shifts each azimuthal sector's radial profile by a different amount. Sector k's profile is
// m_k * g(2theta + d_k), with the shift d_k = Jx_k*dx + Jy_k*dy and m_k an amplitude that
// absorbs anything multiplicative and azimuthal - a holder arm, a cryostream shadow, a
// flat-field gradient. Fitting the amplitude alongside the shift is what makes this usable:
// a 50% shadow over one sextant otherwise reads as several tens of pixels of centre error.
//
// The leverage comes from the CURVATURE of the radial profile - the water ring - because for a
// pure exponential decay g' is proportional to g and shift and amplitude are indistinguishable.
// The sigma measures that leverage, so it grows as the curvature weakens, and the caller's gate on
// it is what keeps an ill-determined centre out. It is a precision and not an accuracy: on a
// background with NO curvature at all there is nothing to separate the two parameters, the fit
// follows the noise in g' instead, and it does so confidently.
//
// `mean` is a per-pixel projection over a few tens of frames, NAN where no frame contributed.
// nthreads = 0 asks for all hardware threads. The pixels are split into a fixed number of row
// blocks whatever that count is, so the answer does not depend on it.
std::optional<BeamCenterEstimate>
FindBeamCenterFromBackground(const DiffractionExperiment &experiment, const PixelMask &mask,
const std::vector<float> &mean, size_t nthreads = 0);