Files
Jungfraujoch/broker/ModulePlacementConvert.cpp
leonarski_fandClaude Opus 5.5 532f795348
Build Packages / build:portable:windows-x86_64:cuda (push) Failing after 24m10s
Build Packages / build:portable:linux-x86_64:cuda (push) Failing after 12m10s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 26m58s
Build Packages / Create release (push) Successful in 7s
Build Packages / build:portable:macos-arm64:nocuda (push) Failing after 2m53s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 24m49s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 30m24s
Build Packages / Build documentation (push) Successful in 44s
Build Packages / build:portable:linux-x86_64:nocuda (push) Failing after 9m10s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 10m45s
Build Packages / build:portable:windows-x86_64:nocuda (push) Failing after 22m23s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 29m4s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 30m18s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 33m38s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 28m38s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 30m36s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 32m54s
Build Packages / Generate python client (push) Successful in 13s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 32m18s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 35m18s
Build Packages / Unit tests (push) Successful in 2h25m46s
Build Packages / Validation Battery (push) Successful in 1h10m47s
module_placement in custom_geometry's words: x0/y0/fast_axis/slow_axis after mirror_y
dataset_settings.module_placement (detector_module_placement) now names a module as custom_geometry's
detector_module does - x0, y0 (image position of the readout pixel 0) and fast_axis, slow_axis
(detector_module_direction) - but in the stored image, after mirror_y; x0_plane, y0_plane and
fast_step, slow_step give where pixel 0 lies on the plane and the plane step per readout pixel. Both
schema descriptions state the frame and the mirror (y0 = H - 1 - y0, Yp <-> Yn).

DetectorModule carries the readout axes in the image (pixel 0 follows from the box): from the
detector geometry after mirror_y (ModulesAsImaged), from how the XFEL reader turns a panel, and
Xp/Yp for a panel read along its own array. They travel in the CBOR detector_modules
(fast_axis/slow_axis) and in the NXmx module_NN groups (readout_fast_axis/readout_slow_axis, beside
the NXmx fields), so a stored file names its modules as the broker does. ModulesPlaced matches the
four keys exactly; a module not of the detector, placed twice or left out is an error (400 at /start).
The rugnux log names modules the same way.

New test ModulePlacement_TurnedMirroredModules (Yp/Xn module, mirror_y on) and PanelLayout_Placement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqXYdJKPUFLoeAchjzv3x4
2026-11-03 11:39:36 +01:00

88 lines
3.2 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "ModulePlacementConvert.h"
namespace model = org::openapitools::server::model;
namespace {
DetectorModuleGeometry::Direction Convert(const model::Detector_module_direction &input) {
switch (input.getValue()) {
case model::Detector_module_direction::eDetector_module_direction::XN:
return DetectorModuleGeometry::Direction::Xneg;
case model::Detector_module_direction::eDetector_module_direction::YP:
return DetectorModuleGeometry::Direction::Ypos;
case model::Detector_module_direction::eDetector_module_direction::YN:
return DetectorModuleGeometry::Direction::Yneg;
default:
return DetectorModuleGeometry::Direction::Xpos;
}
}
model::Detector_module_direction Convert(DetectorModuleGeometry::Direction input) {
model::Detector_module_direction d;
switch (input) {
case DetectorModuleGeometry::Direction::Xneg:
d.setValue(model::Detector_module_direction::eDetector_module_direction::XN);
break;
case DetectorModuleGeometry::Direction::Ypos:
d.setValue(model::Detector_module_direction::eDetector_module_direction::YP);
break;
case DetectorModuleGeometry::Direction::Yneg:
d.setValue(model::Detector_module_direction::eDetector_module_direction::YN);
break;
default:
d.setValue(model::Detector_module_direction::eDetector_module_direction::XP);
break;
}
return d;
}
} // namespace
ModulePlacement Convert(const model::Detector_module_placement &input) {
ModulePlacement p;
p.x0 = input.getX0();
p.y0 = input.getY0();
p.fast = Convert(input.getFastAxis());
p.slow = Convert(input.getSlowAxis());
p.x0_plane = input.getX0Plane();
p.y0_plane = input.getY0Plane();
const auto f = input.getFastStep(), s = input.getSlowStep();
p.fast_step = {f.at(0), f.at(1)};
p.slow_step = {s.at(0), s.at(1)};
return p;
}
model::Detector_module_placement ConvertPlacement(const ModulePlacement &input) {
model::Detector_module_placement m;
m.setX0(input.x0);
m.setY0(input.y0);
m.setFastAxis(Convert(input.fast));
m.setSlowAxis(Convert(input.slow));
m.setX0Plane(input.x0_plane);
m.setY0Plane(input.y0_plane);
m.setFastStep({input.fast_step[0], input.fast_step[1]});
m.setSlowStep({input.slow_step[0], input.slow_step[1]});
return m;
}
std::vector<ModulePlacement> ParseModulePlacement(const std::string &json_text) {
const auto list = nlohmann::json::parse(json_text).at("module_placement")
.get<std::vector<model::Detector_module_placement>>();
std::vector<ModulePlacement> out;
for (const auto &e: list) {
e.validate();
out.push_back(Convert(e));
}
return out;
}
std::string ModulePlacementJson(const DetectorModules &modules) {
std::vector<model::Detector_module_placement> list;
for (const auto &m: modules.Get())
list.push_back(ConvertPlacement(PlacementOf(m)));
return nlohmann::json{{"module_placement", list}}.dump(2) + "\n";
}