All checks were successful
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 7m51s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 7m19s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 7m46s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 8m32s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m6s
Build Packages / build:rpm (rocky8) (push) Successful in 8m7s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m37s
Build Packages / Generate python client (push) Successful in 17s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 32s
Build Packages / build:rpm (rocky9) (push) Successful in 9m6s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m53s
Build Packages / Unit tests (push) Successful in 1h9m39s
This is an UNSTABLE release. * jfjoch_viewer: Minor improvements to the viewer * jfjoch_broker: Change behavior for modular detectors: coordinates of 0-th pixel can be now arbitrary and detector will be cropped to the smallest rectangle limited by module coordinates Reviewed-on: #8 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
88 lines
2.9 KiB
C++
88 lines
2.9 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 "../receiver/ImageMetadata.h"
|
|
|
|
TEST_CASE("ImageMetadata_ROI") {
|
|
DetectorGeometryModular geom(8,2,8,36, true);
|
|
DiffractionExperiment experiment(DetJF(geom));
|
|
|
|
experiment.ROI().SetROI(ROIDefinition{.boxes = {ROIBox("roi1",1,5,2,8)}});
|
|
|
|
int64_t sum = 100;
|
|
|
|
ImageMetadata metadata(experiment);
|
|
DeviceOutput output{};
|
|
output.module_statistics.module_number = 5;
|
|
output.module_statistics.frame_number = 0;
|
|
output.roi_counts[0].sum = sum;
|
|
output.roi_counts[0].sum_x_weighted = 50 * sum;
|
|
output.roi_counts[0].sum_y_weighted = 23 * sum;
|
|
|
|
metadata.Process(&output);
|
|
|
|
DataMessage message;
|
|
|
|
REQUIRE_NOTHROW(metadata.Export(message, 123));
|
|
|
|
REQUIRE(message.roi.size() == 1);
|
|
REQUIRE(message.roi.contains("roi1"));
|
|
REQUIRE(message.roi["roi1"].sum == sum);
|
|
REQUIRE(message.roi["roi1"].x_weighted == sum * (geom.GetX0(5) + 50));
|
|
REQUIRE(message.roi["roi1"].y_weighted == sum * (geom.GetY0(5) - 23));
|
|
}
|
|
|
|
TEST_CASE("ImageMetadata_ROI_flipped_module") {
|
|
DetectorGeometryModular geom({DetectorModuleGeometry(45,1811,
|
|
DetectorModuleGeometry::Direction::Yneg,
|
|
DetectorModuleGeometry::Direction::Xpos)});
|
|
DiffractionExperiment experiment(DetJF(geom));
|
|
|
|
experiment.ROI().SetROI(ROIDefinition{.boxes = {ROIBox("roi1",1,5,2,8)}});
|
|
|
|
int64_t sum = 100;
|
|
|
|
ImageMetadata metadata(experiment);
|
|
DeviceOutput output{};
|
|
output.module_statistics.module_number = 0;
|
|
output.module_statistics.frame_number = 0;
|
|
output.roi_counts[0].sum = sum;
|
|
output.roi_counts[0].sum_x_weighted = 50 * sum;
|
|
output.roi_counts[0].sum_y_weighted = 23 * sum;
|
|
|
|
metadata.Process(&output);
|
|
|
|
DataMessage message;
|
|
|
|
REQUIRE_NOTHROW(metadata.Export(message, 123));
|
|
|
|
REQUIRE(message.roi.size() == 1);
|
|
REQUIRE(message.roi.contains("roi1"));
|
|
REQUIRE(message.roi["roi1"].sum == sum);
|
|
CHECK(message.roi["roi1"].x_weighted / sum == 23 );
|
|
CHECK(message.roi["roi1"].y_weighted / sum == 1029 - 50);
|
|
}
|
|
|
|
TEST_CASE("ImageMetadata_PulseID_mismatch") {
|
|
DiffractionExperiment experiment(DetJF4M());
|
|
experiment.PulsedSource(true);
|
|
|
|
ImageMetadata metadata(experiment);
|
|
DeviceOutput output{};
|
|
output.module_statistics.module_number = 0;
|
|
output.module_statistics.frame_number = 0;
|
|
output.module_statistics.pulse_id = 123.0;
|
|
metadata.Process(&output);
|
|
|
|
output.module_statistics.module_number = 1;
|
|
output.module_statistics.frame_number = 0;
|
|
output.module_statistics.pulse_id = 124.0;
|
|
metadata.Process(&output);
|
|
|
|
DataMessage message;
|
|
|
|
REQUIRE_NOTHROW(metadata.Export(message, 123));
|
|
REQUIRE(message.xfel_pulse_id == UINT64_MAX);
|
|
} |