From 8eee3dc7856773172e4663f3a2e9d4dd522544df Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 23 Jun 2026 15:04:38 +0200 Subject: [PATCH] Support providing trimming energies --- broker/JFJochBrokerParser.cpp | 6 ++++++ common/DetectorSetup.cpp | 10 ++++++++++ common/DetectorSetup.h | 3 +++ detector_control/SLSDetectorWrapper.cpp | 5 +++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/broker/JFJochBrokerParser.cpp b/broker/JFJochBrokerParser.cpp index ffb3d092..0dc117cb 100644 --- a/broker/JFJochBrokerParser.cpp +++ b/broker/JFJochBrokerParser.cpp @@ -8,6 +8,7 @@ #include "../image_pusher/HDF5FilePusher.h" #include "OpenAPIConvert.h" #include "Detector_type.h" +#include "../cmake-build-release-nogpu/_deps/catch2-src/src/catch2/internal/catch_string_manip.hpp" #include "../image_pusher/NonePusher.h" #include "../image_pusher/TCPStreamPusher.h" @@ -91,10 +92,15 @@ DetectorSetup ParseDetectorSetup(const org::openapitools::server::model::Detecto DetectorSetup setup(geom, detector_type, d.getDescription(), d.getHostname()); auto calib = d.getCalibrationFile(); + auto trim_energies = d.getTrimEnergiesEV(); if (!calib.empty()) { switch (detector_type) { case DetectorType::EIGER: setup.SetTrimFiles(calib); + if (trim_energies.empty()) + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, + "Trimming energies not provided"); + setup.TrimEnergies_eV(trim_energies); break; case DetectorType::JUNGFRAU: setup.LoadGain(calib); diff --git a/common/DetectorSetup.cpp b/common/DetectorSetup.cpp index a982f693..f6b2b3cc 100644 --- a/common/DetectorSetup.cpp +++ b/common/DetectorSetup.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only #include +#include #include "DetectorSetup.h" #include "JFJochException.h" @@ -449,3 +450,12 @@ DetectorSetup &DetectorSetup::TempThreshold_degC(int64_t input) { temperature_thresold_degC = static_cast(input); return *this; } + +DetectorSetup &DetectorSetup::TrimEnergies_eV(std::vector input) { + trim_energy_eV_values = std::move(input); + return *this; +} + +std::vector DetectorSetup::GetTrimEnergies_eV() const { + return trim_energy_eV_values; +} diff --git a/common/DetectorSetup.h b/common/DetectorSetup.h index 0b082fdc..4a2472b2 100644 --- a/common/DetectorSetup.h +++ b/common/DetectorSetup.h @@ -25,6 +25,7 @@ class DetectorSetup { std::vector gain_file_names; std::vector trim_file_names; std::string trim_file_directory; + std::vector trim_energy_eV_values; std::shared_ptr gain_calibration; int64_t udp_interface_count = 2; float pixel_size_um = 75.0f; @@ -85,6 +86,7 @@ public: DetectorSetup& DECTRISROI(const std::string &input); DetectorSetup& DefaultSettings(const std::optional &input); DetectorSetup& TempThreshold_degC(int64_t input); + DetectorSetup& TrimEnergies_eV(std::vector input); [[nodiscard]] DetectorType GetDetectorType() const; [[nodiscard]] const DetectorGeometry& GetGeometry() const; @@ -116,6 +118,7 @@ public: [[nodiscard]] std::string GetDECTRISROI() const; [[nodiscard]] std::optional GetDefaultSettings() const; [[nodiscard]] int32_t GetTempThreshold_degC() const; + [[nodiscard]] std::vector GetTrimEnergies_eV() const; }; DetectorSetup DetJF4M(const std::string &description = "Detector", diff --git a/detector_control/SLSDetectorWrapper.cpp b/detector_control/SLSDetectorWrapper.cpp index 81187860..c8ad5c95 100644 --- a/detector_control/SLSDetectorWrapper.cpp +++ b/detector_control/SLSDetectorWrapper.cpp @@ -145,10 +145,11 @@ void SLSDetectorWrapper::Initialize(DiffractionExperiment& experiment, auto trim_directory = experiment.GetDetectorSetup().GetTrimFileDirectory(); if (!trim_directory.empty()) { // Hardcoded for now - need to make it nicer - std::vector trim_en = {4500, 5400, 6400, 8000, 9900, 15800}; + std::vector trim_en = experiment.GetDetectorSetup().GetTrimEnergies_eV(); + if (trim_en.empty()) + throw JFJochException(JFJochExceptionCategory::Detector, "Trimming energies not provided"); det.setTrimEnergies(trim_en); det.setSettingsPath(trim_directory); - } auto trim_files = experiment.GetDetectorSetup().GetTrimFileNames();