Files
Jungfraujoch/viewer/widgets/PowderCalibrationWidget.h
T
leonarski_fandClaude Opus 5 03456dcddd calibration: an option to hold the detector tilt fixed
--mode calibration fits five parameters - beam centre, distance and the two
PONI tilts - and a program that cannot express a tilted detector has nowhere to
put the last two. Dropping them after the fact is worse than never fitting
them: the centre and the distance of a tilted fit have already absorbed the
tilt, so the flattened geometry is right nowhere.

rugnux --no-refine-tilt, the "Refine detector tilt" tick box on the viewer's
Calib page and RingOptimizer's refine_tilt argument hold rot1/rot2 at the value
the geometry came in with and fit the remaining three. That is the best
flat-detector answer, and the one such a program would refine to itself.

Measured on a five-distance calibrant series. At short distance the tilt is
real and reproducible - three independent fits agreeing to 0.01 deg, radial rms
1.4 -> 0.4 px - and its direct beam agrees with the background beam-centre
estimator to 0.05 px, so the tilted model is the physically right one. The
pinned fit then displaces the centre 2.6 px to absorb the tilt and lands within
0.03 px of the same place at every distance.

Past ~300 mm, where only two rings reach the detector, the tilt is instead
under-determined: it comes out with the opposite sign to every short-distance
fit and drags the PONI 28 px while the rms does not move (0.960 against 0.962).
The existing degeneracy guard only fires on a strictly single ring, so it does
not catch that; declining a tilt that does not pay for itself in rms is left
for a separate change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MxrrPcxodNiXzhNiECCVp5
2026-08-30 20:44:12 +02:00

49 lines
1.9 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <QWidget>
#include <QCheckBox>
#include <QComboBox>
#include <QVector>
#include "../../common/UnitCell.h"
#include "../../reader/JFJochReaderImage.h"
#include "../../rugnux/RugnuxCalibration.h" // CalibrationMethod
// What a whole-dataset calibration run is set to. The analysis library takes the calibrant as a ring
// list rather than a name (ice has no cell to enumerate rings from), so the name is resolved here.
struct CalibrationSelection {
QString name;
std::vector<float> ring_q; // q = 2*pi/d [1/A], ascending
CalibrationMethod method = CalibrationMethod::Rings;
bool refine_tilt = true; // false pins rot1/rot2 where they are (a calibration meant for XDS)
};
// Detector geometry from a powder standard: the calibrant, and how its rings are measured. The two
// buttons fit the image currently on screen; "Analyze dataset" reads Selection() and fits the whole
// dataset the same way rugnux --mode calibration does.
class PowderCalibrationWidget : public QWidget {
Q_OBJECT
std::optional<UnitCell> sample_cell;
QComboBox* calibrantCombo{nullptr}; // stores current calibrant selection
QComboBox* methodCombo{nullptr}; // rings / spots, for the whole-dataset run
QCheckBox* refineTiltCheck{nullptr};// fit the detector tilt, or hold it where it is
std::vector<float> GetCalibrantRings() const;
void updateCalibrantList();
signals:
void ringsFromCalibration(QVector<float> v);
void findBeamCenter(QVector<float> ring_q, bool guess, bool refine_tilt);
public:
PowderCalibrationWidget(QWidget* parent);
CalibrationSelection Selection() const;
public slots:
void loadImage(std::shared_ptr<const JFJochReaderImage> image);
private slots:
void findBeamCenterClicked();
void optimizeBeamCenterClicked();
};