From 3096454e7d42e206036c15e3fa38fc5f230714aa Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 4 Nov 2025 17:01:11 +0100 Subject: [PATCH] DiffractionExperiment: Add DarkMask setting to DetectorMode enum --- common/DiffractionExperiment.cpp | 23 +++++++++++++++++++++++ common/DiffractionExperiment.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/common/DiffractionExperiment.cpp b/common/DiffractionExperiment.cpp index 21d45974..1cc58a69 100644 --- a/common/DiffractionExperiment.cpp +++ b/common/DiffractionExperiment.cpp @@ -39,6 +39,10 @@ DiffractionExperiment::DiffractionExperiment(const DetectorSetup& det_setup) // setter functions DiffractionExperiment &DiffractionExperiment::Detector(const DetectorSetup &input) { detector = input; + + // Conversion is always default mode after switching detectors + mode = DetectorMode::Conversion; + auto settings = detector.GetDefaultSettings(); if (settings) detector_settings = *settings; @@ -47,6 +51,25 @@ DiffractionExperiment &DiffractionExperiment::Detector(const DetectorSetup &inpu DiffractionExperiment &DiffractionExperiment::Mode(DetectorMode input) { mode = input; + + // Handle allowed mode settings + switch (GetDetectorType()) { + case DetectorType::JUNGFRAU: + if (input == DetectorMode::DarkMask) + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Dark mask is not supported for PSI JUNGFRAU detector"); + break; + case DetectorType::DECTRIS: + if ((input == DetectorMode::PedestalG0) || (input == DetectorMode::PedestalG1) || (input == DetectorMode::PedestalG2)) + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Pedestal data collection is not supported for DECTRIS detector"); + if (input == DetectorMode::Raw) + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Raw data collection is not supported for DECTRIS detector"); + break; + case DetectorType::EIGER: + if ((input == DetectorMode::PedestalG0) || (input == DetectorMode::PedestalG1) || (input == DetectorMode::PedestalG2) || (input == DetectorMode::DarkMask)) + throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Pedestal or dark mask data collection is not supported for PSI EIGER detector"); + break; + } + if (input == DetectorMode::Conversion) Conversion(); if (input == DetectorMode::Raw) diff --git a/common/DiffractionExperiment.h b/common/DiffractionExperiment.h index a9407219..73fcf781 100644 --- a/common/DiffractionExperiment.h +++ b/common/DiffractionExperiment.h @@ -31,7 +31,7 @@ #include "../symmetry/gemmi/symmetry.hpp" enum class DetectorMode { - Conversion, Raw, PedestalG0, PedestalG1, PedestalG2 + Conversion, Raw, PedestalG0, PedestalG1, PedestalG2, DarkMask }; struct AcquisitionDeviceNetConfig {