Files
Jungfraujoch/tests/DiffractionSpotTest.cpp
leonarski_fandClaude Opus 5 5f30f0d1ac
Build Packages / build:viewer-tgz:cpu (push) Successful in 6m40s
Build Packages / build:viewer-tgz:cuda (push) Successful in 7m28s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 10m51s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m20s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 11m38s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 12m35s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 11m39s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 12m10s
Build Packages / build:rpm (rocky8) (push) Successful in 11m55s
Build Packages / build:windows:nocuda (push) Successful in 19m48s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 12m4s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 12m42s
Build Packages / Generate python client (push) Successful in 20s
Build Packages / build:rpm (rocky9) (push) Successful in 13m33s
Build Packages / Create release (push) Skipped
Build Packages / Build documentation (push) Successful in 1m8s
Build Packages / XDS test (durin plugin) (push) Successful in 8m51s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 7m17s
Build Packages / DIALS test (push) Successful in 13m39s
Build Packages / XDS test (neggia plugin) (push) Successful in 7m5s
Build Packages / build:windows:cuda (push) Successful in 21m16s
Build Packages / Unit tests (push) Successful in 1h47m1s
tests: hold the integer coordinate conversion to the module map
ConvertToImageCoordinates now transforms the photon-weighted sums instead of
the centroid, which is only equivalent because a module's raw -> image map is
a signed axis swap plus an integer translation. Check that against the map
itself on every module of a detector whose modules do not share an
orientation, and either side of the 256-column multipixel gaps where the
translation changes. A wrong sign or a dropped gap term on any single module
would otherwise only show up as mispositioned spots on that module.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-02 19:14:32 +02:00

51 lines
2.5 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include <catch2/catch_all.hpp>
#include "../common/DiffractionSpot.h"
#include "../common/RawToConvertedGeometry.h"
TEST_CASE("DiffractionSpot_ConvertToImageCoordinates", "[LinearAlgebra][Coord]") {
DiffractionExperiment experiment(DetJF(4, 2, 8, 36, true));
DiffractionSpot spot_1(800, 300, 12);
spot_1 += DiffractionSpot(800, 301, 4);
spot_1 += DiffractionSpot(801, 300, 12);
spot_1 += DiffractionSpot(801, 301, 4);
REQUIRE(spot_1.RawCoord().x == 800.5);
REQUIRE(spot_1.RawCoord().y == 300.25);
REQUIRE(spot_1.Count() == 12 * 2 + 4 * 2);
spot_1.ConvertToImageCoordinates(experiment, 1);
REQUIRE(spot_1.RawCoord().x == Catch::Approx(CONVERTED_MODULE_COLS + 8 + 800.5 + 6));
REQUIRE(spot_1.RawCoord().y == Catch::Approx(CONVERTED_MODULE_LINES * 2 + 36 - 1 - 300.25 - 2));
REQUIRE(spot_1.Count() == 12 * 2 + 4 * 2);
}
// ConvertToImageCoordinates transforms the photon-weighted SUMS in integers rather than converting
// the centroid, which is only equivalent because the module map is a signed axis swap plus an
// integer translation. Hold it to the map it is standing in for, on every module of a detector
// whose modules do not all share an orientation, and either side of the 256-column multipixel gaps
// where the translation changes.
TEST_CASE("DiffractionSpot_ConvertMatchesModuleMap", "[LinearAlgebra][Coord]") {
DiffractionExperiment experiment(DetJF(8, 2, 8, 36, true));
for (uint16_t module = 0; module < experiment.GetModulesNum(); module++) {
for (const auto [col, line] : {std::pair<uint32_t, uint32_t>{3, 5},
{255, 255}, {256, 256}, {700, 300}, {1020, 505}}) {
INFO("module " << module << " pixel " << col << "," << line);
// Two pixels of unequal weight, so the centroid is a genuine fraction rather than a
// pixel centre - a whole-pixel centroid would not notice a lost fractional part.
DiffractionSpot spot(col, line, 7);
spot += DiffractionSpot(col, line + 1, 3);
const Coord raw = spot.RawCoord();
spot.ConvertToImageCoordinates(experiment, module);
const Coord expected = RawToConvertedCoordinate(experiment, module, raw);
REQUIRE(spot.RawCoord().x == Catch::Approx(expected.x));
REQUIRE(spot.RawCoord().y == Catch::Approx(expected.y));
REQUIRE(spot.Count() == 10);
}
}
}