// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include "../common/DetectorModules.h" #include "../common/DetectorOrientation.h" #include "../writer/HDF5Objects.h" // Metres per one `units`, a length unit as NXmx states it ("m", "mm", "um", "microns", ...). No unit means // metres - what every DECTRIS master and everything this system writes means by one. A unit not recognised is // refused rather than guessed at: read as metres, a length in millimetres is a silent factor of a thousand. double NXmxLengthUnit_m(const std::string &units, const std::string &name); // The geometry the file's first NXdetector_module states, square to the beam: where the beam (+z from the // sample) meets the module plane, in pixels of the image (the module's data_origin added), the distance from // the sample to that plane, and the pixel size along the fast direction. NXmx makes beam_center_x/y, distance // and x_pixel_size optional, the module geometry being what places the detector; a file that leaves them out // is read from here. Rotations in the chain are not taken, as ReadDetectorRotationChain in // HDF5MetadataSource.cpp reads them separately. Throws when the file has no module. struct NXmxModuleGeometry { float beam_x_pxl; float beam_y_pxl; float distance_m; float pixel_size_m; }; NXmxModuleGeometry ReadNXmxModuleGeometry(HDF5Object &file); // The group of module n, "/entry/instrument/detector/module_/" with n padded as the file pads it // (module_3 or module_03), or empty when the file has no such module. std::string NXmxModuleGroup(HDF5Object &file, size_t n); // The modules an NXmx file states, as WriteNXmxModules (writer/NXmxModules.h) writes them: groups // /entry/instrument/detector/module_0, module_1, ... (or module_00, module_01, ...). Their offsets are taken // relative to the image's pixel (0, 0) and in the detector plane; a module standing out of that plane (an // offset or pixel direction with a component along the detector normal) is refused. Fewer than two such groups: none. DetectorModules ReadNXmxModules(HDF5Object &file, double pixel_size_m, const DetectorOrientation &orientation);