From f5ea01d238512fd4f3a9049d215c0db17eb84ec5 Mon Sep 17 00:00:00 2001 From: Alice Date: Tue, 3 Feb 2026 17:16:15 +0100 Subject: [PATCH] changed RoMode to be consistent with slsdet --- include/aare/RawMasterFile.hpp | 2 +- include/aare/defs.hpp | 14 +++++++------- python/aare/__init__.py | 2 +- python/aare/transform.py | 8 ++++---- python/src/raw_master_file.hpp | 14 +++++++------- python/tests/test_RawMasterFile.py | 4 ++-- src/RawMasterFile.cpp | 16 ++++++++-------- src/RawMasterFile.test.cpp | 6 +++--- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/include/aare/RawMasterFile.hpp b/include/aare/RawMasterFile.hpp index 0c07bf3..b433eb3 100644 --- a/include/aare/RawMasterFile.hpp +++ b/include/aare/RawMasterFile.hpp @@ -135,7 +135,7 @@ class RawMasterFile { size_t n_modules() const; uint8_t quad() const; - ReadingMode get_reading_mode() const; + ReadoutMode get_reading_mode() const; std::optional analog_samples() const; std::optional digital_samples() const; diff --git a/include/aare/defs.hpp b/include/aare/defs.hpp index 1264bce..5fc4257 100644 --- a/include/aare/defs.hpp +++ b/include/aare/defs.hpp @@ -188,13 +188,13 @@ struct ROI { } }; -enum ReadingMode : uint8_t { - Analog = 0, - Digital = 1, - AnalogAndDigital = 2, - Transceiver = 3, - DigitalAndTransceiver = 4, - Unknown = 5 +enum ReadoutMode : uint8_t { + ANALOG_ONLY = 0, + DIGITAL_ONLY = 1, + ANALOG_AND_DIGITAL = 2, + TRANSCEIVER_ONLY = 3, + DIGITAL_AND_TRANSCEIVER = 4, + UNKNOWN = 5 }; using dynamic_shape = std::vector; diff --git a/python/aare/__init__.py b/python/aare/__init__.py index e687489..ab3cd76 100644 --- a/python/aare/__init__.py +++ b/python/aare/__init__.py @@ -5,7 +5,7 @@ from . import _aare from ._aare import File, RawMasterFile, RawSubFile, JungfrauDataFile from ._aare import Pedestal_d, Pedestal_f, ClusterFinder_Cluster3x3i, VarClusterFinder -from ._aare import DetectorType, ReadingMode +from ._aare import DetectorType, ReadoutMode from ._aare import hitmap from ._aare import ROI from ._aare import corner diff --git a/python/aare/transform.py b/python/aare/transform.py index a0098a3..b94840f 100644 --- a/python/aare/transform.py +++ b/python/aare/transform.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MPL-2.0 import numpy as np from . import _aare -from aare import ReadingMode +from aare import ReadoutMode class AdcSar04Transform64to16: def __call__(self, data): @@ -71,15 +71,15 @@ class Matterhorn10Transform: self.dynamic_range = dynamic_range self.num_counters = num_counters - def compatibility(self, readingmode : ReadingMode): + def compatibility(self, readingmode : ReadoutMode): """ checks if Matterhorn10Transform is compatible with given parameters :param readingmode: Reading mode set - :type readingmode: ReadingMode + :type readingmode: ReadoutMode :raises ValueError: if not compatible """ - if(readingmode != ReadingMode.Transceiver): + if(readingmode != ReadoutMode.TRANSCEIVER_ONLY): raise ValueError(f"Incompatible Transformation. Matterhorn10Transform only requires transceiver samples. However reading mode is {readingmode}.") pass diff --git a/python/src/raw_master_file.hpp b/python/src/raw_master_file.hpp index 5322494..b67720b 100644 --- a/python/src/raw_master_file.hpp +++ b/python/src/raw_master_file.hpp @@ -24,13 +24,13 @@ using namespace ::aare; void define_raw_master_file_bindings(py::module &m) { - py::enum_(m, "ReadingMode") - .value("Analog", ReadingMode::Analog) - .value("Digital", ReadingMode::Digital) - .value("AnalogAndDigital", ReadingMode::AnalogAndDigital) - .value("Transceiver", ReadingMode::Transceiver) - .value("DigitalAndTransceiver", ReadingMode::DigitalAndTransceiver) - .value("Unknown", ReadingMode::Unknown) + py::enum_(m, "ReadoutMode") + .value("ANALOG_ONLY", ReadoutMode::ANALOG_ONLY) + .value("DIGITAL_ONLY", ReadoutMode::DIGITAL_ONLY) + .value("ANALOG_AND_DIGITAL", ReadoutMode::ANALOG_AND_DIGITAL) + .value("TRANSCEIVER_ONLY", ReadoutMode::TRANSCEIVER_ONLY) + .value("DIGITAL_AND_TRANSCEIVER", ReadoutMode::DIGITAL_AND_TRANSCEIVER) + .value("UNKNOWN", ReadoutMode::UNKNOWN) .export_values(); py::class_(m, "RawMasterFile") diff --git a/python/tests/test_RawMasterFile.py b/python/tests/test_RawMasterFile.py index c9eb821..6ea9ff7 100644 --- a/python/tests/test_RawMasterFile.py +++ b/python/tests/test_RawMasterFile.py @@ -1,7 +1,7 @@ import pytest -from aare import RawMasterFile, ReadingMode, DetectorType +from aare import RawMasterFile, ReadoutMode, DetectorType @pytest.mark.withdata @@ -10,5 +10,5 @@ def test_read_rawfile_quad_eiger_and_compare_to_numpy(test_data_path): file_name = test_data_path/'raw/jungfrau/jungfrau_single_master_0.json' f = RawMasterFile(file_name) - assert(f.reading_mode == ReadingMode.Unknown) + assert(f.reading_mode == ReadoutMode.UNKNOWN) assert(f.detector_type == DetectorType.Jungfrau) \ No newline at end of file diff --git a/src/RawMasterFile.cpp b/src/RawMasterFile.cpp index faff25e..f9b093f 100644 --- a/src/RawMasterFile.cpp +++ b/src/RawMasterFile.cpp @@ -195,27 +195,27 @@ ScanParameters RawMasterFile::scan_parameters() const { std::optional RawMasterFile::roi() const { return m_roi; } -ReadingMode RawMasterFile::get_reading_mode() const { +ReadoutMode RawMasterFile::get_reading_mode() const { if (m_type != DetectorType::ChipTestBoard && m_type != DetectorType::Xilinx_ChipTestBoard) { LOG(TLogLevel::logINFO) << "reading mode is only available for CTB detectors."; - return ReadingMode::Unknown; + return ReadoutMode::UNKNOWN; } if (m_analog_flag && m_digital_flag) { - return ReadingMode::AnalogAndDigital; + return ReadoutMode::ANALOG_AND_DIGITAL; } else if (m_analog_flag) { - return ReadingMode::Analog; + return ReadoutMode::ANALOG_ONLY; } else if (m_digital_flag && m_transceiver_flag) { - return ReadingMode::DigitalAndTransceiver; + return ReadoutMode::DIGITAL_AND_TRANSCEIVER; } else if (m_digital_flag) { - return ReadingMode::Digital; + return ReadoutMode::DIGITAL_ONLY; } else if (m_transceiver_flag) { - return ReadingMode::Transceiver; + return ReadoutMode::TRANSCEIVER_ONLY; } else { - return ReadingMode::Unknown; + return ReadoutMode::UNKNOWN; } } diff --git a/src/RawMasterFile.test.cpp b/src/RawMasterFile.test.cpp index 2957ebd..5d077ce 100644 --- a/src/RawMasterFile.test.cpp +++ b/src/RawMasterFile.test.cpp @@ -147,7 +147,7 @@ TEST_CASE("Parse a master file in .json format", "[.integration]") { REQUIRE_FALSE(f.analog_samples()); REQUIRE_FALSE(f.digital_samples()); - REQUIRE(f.get_reading_mode() == ReadingMode::Unknown); + REQUIRE(f.get_reading_mode() == ReadoutMode::UNKNOWN); } TEST_CASE("Parse a master file in old .raw format", @@ -213,7 +213,7 @@ TEST_CASE("Parse a master file in .raw format", "[.integration]") { // Frames in File : 100 REQUIRE(f.frames_in_file() == 100); - REQUIRE(f.get_reading_mode() == ReadingMode::Unknown); + REQUIRE(f.get_reading_mode() == ReadoutMode::ANALOG_AND_DIGITAL); // #Frame Header // Frame Number : 8 bytes @@ -564,7 +564,7 @@ TEST_CASE("Parse a CTB file from stream") { REQUIRE(f.digital_samples() == std::nullopt); // Digital Flag is 0 REQUIRE(f.transceiver_samples() == 1152); REQUIRE(f.frames_in_file() == 40); - REQUIRE(f.get_reading_mode() == ReadingMode::Transceiver); + REQUIRE(f.get_reading_mode() == ReadoutMode::TRANSCEIVER_ONLY); } TEST_CASE("Parse v8.0 MYTHEN3 from stream") {