diff --git a/include/aare/RawMasterFile.hpp b/include/aare/RawMasterFile.hpp index a6c04e6..16eb1ca 100644 --- a/include/aare/RawMasterFile.hpp +++ b/include/aare/RawMasterFile.hpp @@ -103,6 +103,7 @@ class RawMasterFile { std::optional m_digital_samples; std::optional m_transceiver_samples; std::optional m_number_of_rows; + std::optional m_counter_mask; std::optional m_roi; @@ -133,6 +134,7 @@ class RawMasterFile { std::optional digital_samples() const; std::optional transceiver_samples() const; std::optional number_of_rows() const; + std::optional counter_mask() const; std::optional roi() const; diff --git a/src/RawFile.test.cpp b/src/RawFile.test.cpp index c96a393..90daef4 100644 --- a/src/RawFile.test.cpp +++ b/src/RawFile.test.cpp @@ -320,4 +320,14 @@ TEST_CASE("Read file with unordered frames", "[.with-data]") { REQUIRE(std::filesystem::exists(fpath)); File f(fpath); REQUIRE_THROWS((f.read_frame())); +} + +TEST_CASE("Read Mythenframe", "[.with-data]") { + auto fpath = test_data_path() / "raw/newmythen03/run_2_master_1.json"; + REQUIRE(std::filesystem::exists(fpath)); + RawFile f(fpath); + REQUIRE(f.master().roi().value().width() == 2560); + REQUIRE(f.master().roi().value().height() == 1); + auto frame = f.read_frame(); + REQUIRE(frame.cols() == 2560); } \ No newline at end of file diff --git a/src/RawMasterFile.cpp b/src/RawMasterFile.cpp index d54a14d..243fd9b 100644 --- a/src/RawMasterFile.cpp +++ b/src/RawMasterFile.cpp @@ -143,6 +143,10 @@ std::optional RawMasterFile::number_of_rows() const { return m_number_of_rows; } +std::optional RawMasterFile::counter_mask() const { + return m_counter_mask; +} + xy RawMasterFile::geometry() const { return m_geometry; } size_t RawMasterFile::n_modules() const { @@ -313,15 +317,26 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) { } // if any of the values are set update the roi + // TODO: doesnt it write garbage if one of them is not set if (tmp_roi.xmin != 4294967295 || tmp_roi.xmax != 4294967295 || tmp_roi.ymin != 4294967295 || tmp_roi.ymax != 4294967295) { tmp_roi.xmax++; + // Handle Mythen + if (tmp_roi.ymin == -1 && tmp_roi.ymax == -1) { + tmp_roi.ymin = 0; + tmp_roi.ymax = 0; + } tmp_roi.ymax++; m_roi = tmp_roi; } } catch (const json::out_of_range &e) { - LOG(TLogLevel::logERROR) << e.what() << std::endl; + // leave the optional empty + } + try { + // TODO: what is the best format to handle + m_counter_mask = j.at("Counter Mask"); + } catch (const json::out_of_range &e) { // leave the optional empty }