Files
Jungfraujoch/tests/CMakeLists.txt
T
leonarski_fandClaude Opus 5 5b5bed4f66 Powder calibration: read the rings off an azimuthal profile, not off a spot list
The ring calibration already here (AssignSpotsToRings + RingOptimizer, driven from
the viewer's powder panel) is given a SPOT LIST from a single image. A powder ring
is not a set of spots - it is a smooth arc - so a spot finder samples it wherever
its threshold happens to bite, and one image carries only the counts that image
collected. An azimuthally-binned profile summed over a run measures the same ring
directly, at every azimuth, with the whole run behind it.

RingsFromAzimuthalProfile turns such a profile into the (x, y, q_expected) triples
RingOptimizer already consumes, so nothing downstream changes: for each calibrant
ring and each azimuthal sector it fits the radial peak against a locally
interpolated background, and maps the measured (q, phi) back through the current
geometry to the pixel it came from.

What this is for is the BEAM CENTRE. A powder ring is a conic centred on the beam,
so a wrong centre makes its apparent radius oscillate once per turn and a detector
tilt twice - and neither depends on the calibrant's d-spacings or on the detector
distance. That matters, because the beam centre is otherwise the weakest parameter
we have: fitted from Bragg spots it is gauge-coupled to the crystal orientation,
which is why PostRefine has to restrain it toward the header and commit only a
sub-1 % move, and why XtalOptimizer carries a soft prior noting the beam is "only
LaB6-monitored to ~a few px". A ring does not know about the crystal.

Two things the peak fit is careful about, both of which would otherwise show up as
a spurious cos(phi) - i.e. as a beam-centre shift:

 - the sector's CENTRE is used, not its lower edge. GetBin() floors phi into the
   sector, so a bin stands for [j, j+1), and taking its edge rotates every ring
   point by half a sector.
 - a peak has to stand clear of the scatter of the background either side of it,
   or a sector with no ring in it contributes its largest noise excursion as
   though it were a measurement.

Refuses a single-azimuthal-bin profile outright: that is a plain radial profile,
the ring has been averaged over every direction, and there is nothing left to say
where its centre is.

Tested by round trip against the forward model, as the existing calibration tests
are: synthesise the profile the azimuthal integration would build with the rings
where a shifted geometry puts them but every pixel binned with the unshifted one,
then extract and fit. A 6.0 / -4.0 px beam offset is recovered as 6.13 / -4.03
from 192 ring points. Only the beam centre is exercised here; the tilt path is
covered by the existing DetGeomCalibTest round trips.

This is the extraction only - nothing calls it yet, and the run-scoped accumulator
it is meant to read (JFJochReceiverPlots::az_int_profile, already summed over a run
and written to /entry/azint/dataset) is still integrated with one azimuthal bin by
default.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 21:30:24 +02:00

109 lines
3.7 KiB
CMake

ADD_EXECUTABLE(jfjoch_test
DiffractionExperimentTest.cpp
RawToConvertedGeometryTest.cpp
../common/RawToConvertedGeometry.h
../common/DiffractionExperiment.h
CheckImageOutput.h
FPGAIntegrationTest.cpp
StrongPixelSetTest.cpp
AdaptiveThresholdTest.cpp
AdaptiveSpotFinderCPUTest.cpp
ZSTDCompressorTest.cpp
FrameTransformationTest.cpp
HDF5WritingTest.cpp PedestalCalcTest.cpp
ZMQImagePusherTest.cpp StreamWriterTest.cpp
CoordTest.cpp JFJochStateMachineTest.cpp
JFJochReceiverIntegrationTest.cpp
AcquisitionCountersTest.cpp
IndexingUnitTest.cpp
ThreadSafeFIFOSetTest.cpp
FPGANetworkTest.cpp
JFPedestalTest.cpp
JFCalibrationTest.cpp
AzimuthalIntegrationTest.cpp
StatusVectorTest.cpp
CBORTest.cpp
DetectorGeometryTest.cpp DetectorSetupTest.cpp DiffractionGeometryTest.cpp
FPGASpotFindingUnitTest.cpp
PreviewCounterTest.cpp
FPGAFrameGeneratorTest.cpp
FPGAHostWriterTest.cpp
DiffractionSpotTest.cpp
TIFFTest.cpp
JFJochReceiverProcessingTest.cpp
JPEGTest.cpp
HistogramTest.cpp
ROIMapTest.cpp
ROIIntegrationCPUTest.cpp
ROIIntegrationGPUTest.cpp
BraggIntegrationEngineGPUTest.cpp
BraggIntegrationEngineCompressedImageTest.cpp
LossyFilterTest.cpp
ImageBufferTest.cpp
PixelMaskTest.cpp
RegressionTest.cpp
FPGAHLSModulesTest.cpp
ZMQPreviewSocketTest.cpp
DetectorSettingsTest.cpp
AutoIncrVectorTest.cpp
ModuleSummationTest.cpp
ZMQMetadataSocketTest.cpp
JFJochReaderTest.cpp
RugnuxTest.cpp
RugnuxLargeTest.cpp
TestData.h
MovingAverageTest.cpp
ImageMetadataTest.cpp
JFJochReceiverLiteTest.cpp
GridScanSettingsTest.cpp
JFJochReceiverPlotsTest.cpp
GoniometerAxisTest.cpp
DetGeomCalibTest.cpp
RingsFromProfileTest.cpp
XtalOptimizerTest.cpp
CrystalLatticeTest.cpp
FPGAPTPTest.cpp
ResolutionShellsTest.cpp
ImageSpotFinderCPUTest.cpp
ImageSpotFinderGPUTest.cpp
BSLZ4DecoderGPUTest.cpp
BSLZ4DecoderGPUFuzzTest.cpp
ImagePreprocessorGPUFusedTest.cpp
AdaptiveSpotFinderGPUTest.cpp
SpotExtractorGPUParityTest.cpp
CalcBraggPredictionTest.cpp
SpotUtilsTest.cpp
LatticeSearchTest.cpp
TimeTest.cpp
RotationIndexerTest.cpp
TopPixelsTest.cpp
HKLKeyTest.cpp
TCPImagePusherTest.cpp
SearchSpaceGroupTest.cpp
SearchSpaceGroupTwinTest.cpp
SyntheticMergedReflections.h
XDSPluginTest.cpp
MergeScaleTest.cpp
RfreeFlagsTest.cpp
FrenchWilsonTest.cpp
ReindexAmbiguityTest.cpp
LoadReferenceMtzFreeFlagsTest.cpp
UnitCellTest.cpp
CCTest.cpp
MultiLatticeSearchTest.cpp
LatticeReductionTest.cpp
)
target_link_libraries(jfjoch_test Catch2WithMain JFJochBroker JFJochReceiver JFJochReader JFJochStreamWriter
Rugnux JFJochImageAnalysis JFJochCommon JFJochHLSSimulation JFJochPreview
jfjoch_xds_plugin)
target_include_directories(jfjoch_test PRIVATE .)
find_package(Threads REQUIRED)
add_library(enospc_shim MODULE enospc_shim.c)
target_link_libraries(enospc_shim PRIVATE Threads::Threads dl)
set_target_properties(enospc_shim PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE ON) # remove "lib"
ADD_EXECUTABLE(jfjoch_hdf5_enospc_test jfjoch_hdf5_enospc_test.cpp)
target_link_libraries(jfjoch_hdf5_enospc_test Catch2WithMain JFJochWriter)