DiffractionExperiment: Move internal variables to a C++ structure

This commit is contained in:
2023-11-14 11:54:51 +01:00
parent e85988dfa2
commit f778a35e6f
19 changed files with 490 additions and 511 deletions

View File

@@ -6,63 +6,59 @@
TEST_CASE("DetectorGeometry_Regular", "[DetectorGeometry]") {
DetectorGeometry geometry(18, 3, 8, 36, false);
const JFJochProtoBuf::DetectorGeometry pbuf = geometry;
REQUIRE(pbuf.module_geometry_size() == 18);
REQUIRE(geometry.GetModulesNum() == 18);
REQUIRE(pbuf.width_pxl() == 3 * 1030 + 2 * 8);
REQUIRE(pbuf.height_pxl() == 6 * 514 + 5 * 36);
REQUIRE(pbuf.module_geometry(0).pixel0() == 0);
REQUIRE(pbuf.module_geometry(2).pixel0() == 2 * 1030 + 2 * 8);
REQUIRE(geometry.GetWidth() == 3 * 1030 + 2 * 8);
REQUIRE(geometry.GetHeight() == 6 * 514 + 5 * 36);
REQUIRE(geometry.GetPixel0(0) == 0);
REQUIRE(geometry.GetPixel0(2) == 2 * 1030 + 2 * 8);
REQUIRE(pbuf.module_geometry(15).pixel0() == pbuf.width_pxl() * (514 * 5 + 36 * 5));
REQUIRE(pbuf.module_geometry(15).fast_direction_step() == 1);
REQUIRE(pbuf.module_geometry(15).slow_direction_step() == pbuf.width_pxl());
REQUIRE(geometry.GetPixel0(15) == geometry.GetWidth() * (514 * 5 + 36 * 5));
REQUIRE(geometry.GetFastDirectionStep(15) == 1);
REQUIRE(geometry.GetSlowDirectionStep(15) == geometry.GetWidth());
}
TEST_CASE("DetectorGeometry_Regular_1Module", "[DetectorGeometry]") {
DetectorGeometry geometry(1, 3, 8, 36, false);
const JFJochProtoBuf::DetectorGeometry pbuf = geometry;
REQUIRE(pbuf.module_geometry_size() == 1);
REQUIRE(geometry.GetModulesNum() == 1);
REQUIRE(pbuf.width_pxl() == CONVERTED_MODULE_COLS);
REQUIRE(pbuf.height_pxl() == CONVERTED_MODULE_LINES);
REQUIRE(pbuf.module_geometry(0).pixel0() == 0);
REQUIRE(geometry.GetWidth() == CONVERTED_MODULE_COLS);
REQUIRE(geometry.GetHeight() == CONVERTED_MODULE_LINES);
REQUIRE(geometry.GetPixel0(0) == 0);
REQUIRE(pbuf.module_geometry(0).fast_direction_step() == 1);
REQUIRE(pbuf.module_geometry(0).slow_direction_step() == CONVERTED_MODULE_COLS);
REQUIRE(geometry.GetFastDirectionStep(0) == 1);
REQUIRE(geometry.GetSlowDirectionStep(0) == CONVERTED_MODULE_COLS);
}
TEST_CASE("DetectorGeometry_Regular_2Module", "[DetectorGeometry]") {
DetectorGeometry geometry(2, 2, 8, 36, false);
const JFJochProtoBuf::DetectorGeometry pbuf = geometry;
REQUIRE(pbuf.module_geometry_size() == 2);
REQUIRE(geometry.GetModulesNum() == 2);
REQUIRE(pbuf.width_pxl() == CONVERTED_MODULE_COLS * 2 + 8);
REQUIRE(pbuf.height_pxl() == CONVERTED_MODULE_LINES);
REQUIRE(pbuf.module_geometry(0).pixel0() == 0);
REQUIRE(pbuf.module_geometry(1).pixel0() == CONVERTED_MODULE_COLS + 8);
REQUIRE(geometry.GetWidth() == CONVERTED_MODULE_COLS * 2 + 8);
REQUIRE(geometry.GetHeight() == CONVERTED_MODULE_LINES);
REQUIRE(geometry.GetPixel0(0) == 0);
REQUIRE(geometry.GetPixel0(1) == CONVERTED_MODULE_COLS + 8);
REQUIRE(pbuf.module_geometry(0).fast_direction_step() == 1);
REQUIRE(pbuf.module_geometry(0).slow_direction_step() == CONVERTED_MODULE_COLS * 2 + 8);
REQUIRE(geometry.GetFastDirectionStep(0) == 1);
REQUIRE(geometry.GetSlowDirectionStep(0) == CONVERTED_MODULE_COLS * 2 + 8);
}
TEST_CASE("DetectorGeometry_RegularMirror", "[DetectorGeometry]") {
DetectorGeometry geometry(18, 3, 8, 36, true);
const JFJochProtoBuf::DetectorGeometry pbuf = geometry;
REQUIRE(pbuf.module_geometry_size() == 18);
REQUIRE(geometry.GetModulesNum() == 18);
REQUIRE(pbuf.width_pxl() == 3 * 1030 + 2 * 8);
REQUIRE(pbuf.height_pxl() == 6 * 514 + 5 * 36);
REQUIRE(pbuf.module_geometry(0).pixel0() == pbuf.width_pxl() * (pbuf.height_pxl() - 1));
REQUIRE(pbuf.module_geometry(2).pixel0() == pbuf.width_pxl() * (pbuf.height_pxl() - 1) + 2 * 1030 + 2 * 8);
REQUIRE(geometry.GetWidth() == 3 * 1030 + 2 * 8);
REQUIRE(geometry.GetHeight() == 6 * 514 + 5 * 36);
REQUIRE(geometry.GetPixel0(0) == geometry.GetWidth() * (geometry.GetHeight() - 1));
REQUIRE(geometry.GetPixel0(2) == geometry.GetWidth() * (geometry.GetHeight() - 1) + 2 * 1030 + 2 * 8);
CHECK(pbuf.module_geometry(15).pixel0() == pbuf.width_pxl() * 513);
CHECK(pbuf.module_geometry(17).pixel0() == pbuf.width_pxl() * (513) + 2 * 1030 + 2 * 8);
REQUIRE(pbuf.module_geometry(15).fast_direction_step() == 1);
REQUIRE(pbuf.module_geometry(15).slow_direction_step() == -pbuf.width_pxl());
CHECK(geometry.GetPixel0(15) == geometry.GetWidth() * 513);
CHECK(geometry.GetPixel0(17) == geometry.GetWidth() * (513) + 2 * 1030 + 2 * 8);
REQUIRE(geometry.GetFastDirectionStep(15) == 1);
REQUIRE(geometry.GetSlowDirectionStep(15) == -geometry.GetWidth());
}
TEST_CASE("DetectorModuleGeometry_SameAxis", "[DetectorGeometry]") {
@@ -171,19 +167,19 @@ TEST_CASE("DetectorGeometry_Custom", "[DetectorGeometry]") {
DetectorGeometry geometry(module_geom);
REQUIRE(geometry.GetModulesNum() == 3);
JFJochProtoBuf::DetectorGeometry pbuf_geom = geometry;
CHECK(pbuf_geom.height_pxl() == 2999+1);
CHECK(pbuf_geom.width_pxl() == 5513+1);
CHECK(pbuf_geom.module_geometry(0).pixel0() == 2999 * pbuf_geom.width_pxl() + 2999);
CHECK(pbuf_geom.module_geometry(1).pixel0() == 0);
CHECK(pbuf_geom.module_geometry(2).pixel0() == 5000);
CHECK(pbuf_geom.module_geometry(0).fast_direction_step() == -1);
CHECK(pbuf_geom.module_geometry(1).fast_direction_step() == pbuf_geom.width_pxl());
CHECK(pbuf_geom.module_geometry(2).fast_direction_step() == pbuf_geom.width_pxl());
CHECK(geometry.GetHeight() == 2999+1);
CHECK(geometry.GetWidth() == 5513+1);
CHECK(geometry.GetPixel0(0) == 2999 * geometry.GetWidth() + 2999);
CHECK(geometry.GetPixel0(1) == 0);
CHECK(geometry.GetPixel0(2) == 5000);
CHECK(pbuf_geom.module_geometry(0).slow_direction_step() == -pbuf_geom.width_pxl());
CHECK(pbuf_geom.module_geometry(1).slow_direction_step() == 1);
CHECK(pbuf_geom.module_geometry(2).slow_direction_step() == 1);
CHECK(geometry.GetFastDirectionStep(0) == -1);
CHECK(geometry.GetFastDirectionStep(1) == geometry.GetWidth());
CHECK(geometry.GetFastDirectionStep(2) == geometry.GetWidth());
CHECK(geometry.GetSlowDirectionStep(0) == -geometry.GetWidth());
CHECK(geometry.GetSlowDirectionStep(1) == 1);
CHECK(geometry.GetSlowDirectionStep(2) == 1);
}