considered num_udp_interafces for jungfrau and quad structure for eiger

This commit is contained in:
2025-06-10 11:35:15 +02:00
parent 87d8682b1e
commit ad7525cd02
6 changed files with 90 additions and 60 deletions

View File

@@ -149,19 +149,27 @@ RawMasterFile RawFile::master() const { return m_master; }
void RawFile::find_geometry() {
for (size_t col = 0; col < m_master.geometry().col;
col += m_master.num_udp_interfaces_per_module())
for (size_t row = 0; row < m_master.geometry().row; ++row) {
for (size_t port = 0;
port < m_master.num_udp_interfaces_per_module(); ++port) {
ModuleGeometry g;
g.origin_x = (col + port) * m_master.pixels_x();
g.origin_y = row * m_master.pixels_y();
g.row_index = row;
g.col_index = col + port;
g.width = m_master.pixels_x();
g.height = m_master.pixels_y();
m_geometry.module_pixel_0.push_back(g);
}
col += m_master.udp_interfaces_per_module().col)
for (size_t row = 0; row < m_master.geometry().row;
row += m_master.udp_interfaces_per_module().row) {
for (size_t port_row = 0;
port_row < m_master.udp_interfaces_per_module().row;
++port_row)
for (size_t port_col = 0;
port_col < m_master.udp_interfaces_per_module().col;
++port_col) {
ModuleGeometry g;
g.origin_x = (col + port_col) * m_master.pixels_x();
g.origin_y = (row + port_row) *
m_master.pixels_y(); // TODO: quad doesnt seem
// to have an effect
g.row_index = m_master.quad() ? (row + port_row + 1) % 2
: (row + port_row);
g.col_index = col + port_col;
g.width = m_master.pixels_x();
g.height = m_master.pixels_y();
m_geometry.module_pixel_0.push_back(g);
}
}
m_geometry.pixels_y = (m_master.geometry().row * m_master.pixels_y());

View File

@@ -200,9 +200,27 @@ TEST_CASE("check find_geometry", "[.integration][.files][.rawfile]") {
ModuleGeometry{0, 0, 256, 512, 0, 0},
ModuleGeometry{512, 0, 256, 512, 0, 1},
ModuleGeometry{0, 256, 256, 512, 1, 0},
ModuleGeometry{512, 256, 256, 512, 1, 1}}}});
ModuleGeometry{512, 256, 256, 512, 1, 1}}}},
TestParameters{
"raw/jungfrau_2modules_2interfaces/run_master_0.json", 4,
DetectorGeometry{1, 4, 1024, 1024, 0, 0,
std::vector<ModuleGeometry>{
ModuleGeometry{0, 0, 256, 1024, 0, 0},
ModuleGeometry{0, 256, 256, 1024, 1, 0},
ModuleGeometry{0, 512, 256, 1024, 2, 0},
ModuleGeometry{0, 768, 256, 1024, 3, 0}}}},
TestParameters{
"raw/W13_230320/"
"W13_vthreshscan_m21C_300V_800eV_vrpre3400_master_0.json",
2,
DetectorGeometry{1, 2, 512, 512, 0, 0,
std::vector<ModuleGeometry>{
ModuleGeometry{0, 0, 256, 512, 0, 0},
ModuleGeometry{0, 256, 256, 512, 1, 0}}}});
auto fpath = test_data_path() / test_parameters.master_filename;
REQUIRE(std::filesystem::exists(fpath));
RawFileTestWrapper f(fpath, "r");
@@ -242,7 +260,7 @@ TEST_CASE("check find_geometry", "[.integration][.files][.rawfile]") {
TEST_CASE("Open multi module file with ROI",
"[.integration][.files][.rawfile]") {
auto fpath = test_data_path() / "SingleChipROI/Data_master_0.json";
auto fpath = test_data_path() / "raw/SingleChipROI/Data_master_0.json";
REQUIRE(std::filesystem::exists(fpath));
RawFile f(fpath, "r");

View File

@@ -139,11 +139,11 @@ size_t RawMasterFile::n_modules() const {
return m_geometry.row * m_geometry.col;
}
size_t RawMasterFile::num_udp_interfaces_per_module() const {
return m_num_udp_interfaces_per_module;
xy RawMasterFile::udp_interfaces_per_module() const {
return m_udp_interfaces_per_module;
}
std::optional<uint8_t> RawMasterFile::quad() const { return m_quad; }
uint8_t RawMasterFile::quad() const { return m_quad; }
// optional values, these may or may not be present in the master file
// and are therefore modeled as std::optional
@@ -267,10 +267,13 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) {
// not a scan
}
try {
m_num_udp_interfaces_per_module = j.at("Number of UDP Interfaces");
m_udp_interfaces_per_module = {j.at("Number of UDP Interfaces"), 1};
} catch (const json::out_of_range &e) {
if (m_type == DetectorType::Eiger)
m_num_udp_interfaces_per_module = 2;
if (m_type == DetectorType::Eiger && m_quad == 1)
m_udp_interfaces_per_module = {2, 1};
else if (m_type == DetectorType::Eiger) {
m_udp_interfaces_per_module = {1, 2};
}
}
try {
@@ -347,9 +350,6 @@ void RawMasterFile::parse_raw(const std::filesystem::path &fpath) {
if (m_type == DetectorType::Moench) {
m_type = DetectorType::Moench03_old;
}
if (m_type == DetectorType::Eiger) {
m_num_udp_interfaces_per_module = 2;
}
} else if (key == "Timing Mode") {
m_timing_mode = StringTo<TimingMode>(value);
} else if (key == "Image Size") {
@@ -407,10 +407,18 @@ void RawMasterFile::parse_raw(const std::filesystem::path &fpath) {
static_cast<uint32_t>(std::stoi(value.substr(1, pos))),
static_cast<uint32_t>(std::stoi(value.substr(pos + 1)))};
} else if (key == "Number of UDP Interfaces") {
m_num_udp_interfaces_per_module = std::stoi(value);
m_udp_interfaces_per_module = {
static_cast<uint32_t>(std::stoi(value)), 1};
}
}
}
if (m_type == DetectorType::Eiger && m_quad == 1) {
m_udp_interfaces_per_module = {2, 1};
} else if (m_type == DetectorType::Eiger) {
m_udp_interfaces_per_module = {1, 2};
}
if (m_pixels_x == 400 && m_pixels_y == 400) {
m_type = DetectorType::Moench03_old;
}

View File

@@ -153,7 +153,7 @@ TEST_CASE("Parse a master file in old .raw format",
REQUIRE(std::filesystem::exists(fpath));
RawMasterFile f(fpath);
CHECK(f.num_udp_interfaces_per_module() == 1);
CHECK(f.udp_interfaces_per_module() == xy{1, 1});
CHECK(f.n_modules() == 2);
CHECK(f.geometry().row == 2);
CHECK(f.geometry().col == 1);