All checks were successful
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 7m51s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 7m19s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 7m46s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 8m32s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 8m6s
Build Packages / build:rpm (rocky8) (push) Successful in 8m7s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 7m37s
Build Packages / Generate python client (push) Successful in 17s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 32s
Build Packages / build:rpm (rocky9) (push) Successful in 9m6s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 6m53s
Build Packages / Unit tests (push) Successful in 1h9m39s
This is an UNSTABLE release. * jfjoch_viewer: Minor improvements to the viewer * jfjoch_broker: Change behavior for modular detectors: coordinates of 0-th pixel can be now arbitrary and detector will be cropped to the smallest rectangle limited by module coordinates Reviewed-on: #8 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch> Co-committed-by: Filip Leonarski <filip.leonarski@psi.ch>
286 lines
13 KiB
C++
286 lines
13 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include <catch2/catch_all.hpp>
|
|
#include "../common/DetectorGeometryFixed.h"
|
|
#include "../common/DetectorGeometryModular.h"
|
|
|
|
TEST_CASE("DetectorGeometryFixed", "[DetectorGeometry]") {
|
|
DetectorGeometryFixed geometry(1024,1068);
|
|
|
|
REQUIRE(geometry.GetWidth(true) == 1024);
|
|
REQUIRE(geometry.GetWidth(false) == 1024);
|
|
REQUIRE(geometry.GetHeight(true) == 1068);
|
|
REQUIRE(geometry.GetHeight(false) == 1068);
|
|
REQUIRE(geometry.GetModulesNum() == 1);
|
|
REQUIRE(geometry.GetPixel0(0, true) == 0);
|
|
REQUIRE(geometry.GetFastDirection(0) == Coord(1,0,0));
|
|
REQUIRE(geometry.GetSlowDirection(0) == Coord(0,1,0));
|
|
REQUIRE(geometry.GetFastDirectionStep(0) == 1);
|
|
REQUIRE(geometry.GetSlowDirectionStep(0) == 1024);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_Regular", "[DetectorGeometry]") {
|
|
DetectorGeometryModular geometry(18, 3, 8, 36, false);
|
|
|
|
REQUIRE(geometry.GetModulesNum() == 18);
|
|
|
|
REQUIRE(geometry.GetWidth(true) == 3 * 1030 + 2 * 8);
|
|
REQUIRE(geometry.GetHeight(true) == 6 * 514 + 5 * 36);
|
|
REQUIRE(geometry.GetPixel0(0, true) == 0);
|
|
REQUIRE(geometry.GetPixel0(2, true) == 2 * 1030 + 2 * 8);
|
|
|
|
REQUIRE(geometry.GetPixel0(15, true) == geometry.GetWidth(true) * (514 * 5 + 36 * 5));
|
|
REQUIRE(geometry.GetFastDirectionStep(15) == 1);
|
|
REQUIRE(geometry.GetFastDirection(15).x == 1);
|
|
REQUIRE(geometry.GetFastDirection(15).y == 0);
|
|
REQUIRE(geometry.GetFastDirection(15).z == 0);
|
|
REQUIRE(geometry.GetSlowDirectionStep(15) == geometry.GetWidth(true));
|
|
|
|
REQUIRE(geometry.GetSlowDirection(15).x == 0);
|
|
REQUIRE(geometry.GetSlowDirection(15).y == 1);
|
|
REQUIRE(geometry.GetSlowDirection(15).z == 0);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_Regular_NoTransformation", "[DetectorGeometry]") {
|
|
DetectorGeometryModular geometry(18, 3, 8, 36, false);
|
|
REQUIRE(geometry.GetWidth(false) == RAW_MODULE_COLS);
|
|
REQUIRE(geometry.GetHeight(false) == 18 * RAW_MODULE_LINES);
|
|
REQUIRE(geometry.GetPixel0(16, false) == 16 * RAW_MODULE_SIZE);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_Regular_1Module", "[DetectorGeometry]") {
|
|
DetectorGeometryModular geometry(1, 3, 8, 36, false);
|
|
|
|
REQUIRE(geometry.GetModulesNum() == 1);
|
|
|
|
REQUIRE(geometry.GetWidth(true) == CONVERTED_MODULE_COLS);
|
|
REQUIRE(geometry.GetHeight(true) == CONVERTED_MODULE_LINES);
|
|
REQUIRE(geometry.GetPixel0(0, true) == 0);
|
|
|
|
REQUIRE(geometry.GetFastDirectionStep(0) == 1);
|
|
REQUIRE(geometry.GetSlowDirectionStep(0) == CONVERTED_MODULE_COLS);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_Regular_2Module", "[DetectorGeometry]") {
|
|
DetectorGeometryModular geometry(2, 2, 8, 36, false);
|
|
|
|
REQUIRE(geometry.GetModulesNum() == 2);
|
|
|
|
REQUIRE(geometry.GetWidth(true) == CONVERTED_MODULE_COLS * 2 + 8);
|
|
REQUIRE(geometry.GetHeight(true) == CONVERTED_MODULE_LINES);
|
|
REQUIRE(geometry.GetPixel0(0, true) == 0);
|
|
REQUIRE(geometry.GetPixel0(1, true) == CONVERTED_MODULE_COLS + 8);
|
|
|
|
REQUIRE(geometry.GetFastDirectionStep(0) == 1);
|
|
REQUIRE(geometry.GetSlowDirectionStep(0) == CONVERTED_MODULE_COLS * 2 + 8);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_RegularMirror", "[DetectorGeometry]") {
|
|
DetectorGeometryModular geometry(18, 3, 8, 36, true);
|
|
|
|
REQUIRE(geometry.GetModulesNum() == 18);
|
|
|
|
REQUIRE(geometry.GetWidth(true) == 3 * 1030 + 2 * 8);
|
|
REQUIRE(geometry.GetHeight(true) == 6 * 514 + 5 * 36);
|
|
REQUIRE(geometry.GetPixel0(0, true) == geometry.GetWidth(true) * (geometry.GetHeight(true) - 1));
|
|
REQUIRE(geometry.GetPixel0(2, true) == geometry.GetWidth(true) * (geometry.GetHeight(true) - 1) + 2 * 1030 + 2 * 8);
|
|
|
|
CHECK(geometry.GetPixel0(15, true) == geometry.GetWidth(true) * 513);
|
|
CHECK(geometry.GetPixel0(17, true) == geometry.GetWidth(true) * (513) + 2 * 1030 + 2 * 8);
|
|
REQUIRE(geometry.GetFastDirectionStep(15) == 1);
|
|
REQUIRE(geometry.GetSlowDirectionStep(15) == -geometry.GetWidth(true));
|
|
}
|
|
|
|
TEST_CASE("DetectorModuleGeometry_SameAxis", "[DetectorGeometry]") {
|
|
std::unique_ptr<DetectorModuleGeometry> geometry;
|
|
|
|
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
|
DetectorModuleGeometry::Direction::Xpos,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
|
|
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
|
DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Ypos));
|
|
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(2000,2000,
|
|
DetectorModuleGeometry::Direction::Yneg,
|
|
DetectorModuleGeometry::Direction::Ypos));
|
|
|
|
REQUIRE_THROWS(geometry = std::make_unique<DetectorModuleGeometry>(2000,2000,
|
|
DetectorModuleGeometry::Direction::Xpos,
|
|
DetectorModuleGeometry::Direction::Xneg));
|
|
|
|
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2000,2000,
|
|
DetectorModuleGeometry::Direction::Xneg,
|
|
DetectorModuleGeometry::Direction::Ypos));
|
|
|
|
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
|
DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
}
|
|
|
|
TEST_CASE("DetectorModuleGeometry_GetMaxX_GetMaxY", "[DetectorGeometry]") {
|
|
std::unique_ptr<DetectorModuleGeometry> geometry;
|
|
|
|
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(0,0,
|
|
DetectorModuleGeometry::Direction::Xpos,
|
|
DetectorModuleGeometry::Direction::Ypos));
|
|
CHECK(geometry->GetMinX() == 0);
|
|
CHECK(geometry->GetMaxX() == 1029);
|
|
|
|
CHECK(geometry->GetMinY() == 0);
|
|
CHECK(geometry->GetMaxY() == 513);
|
|
|
|
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
|
DetectorModuleGeometry::Direction::Xneg,
|
|
DetectorModuleGeometry::Direction::Yneg));
|
|
CHECK(geometry->GetMinX() == 2029 - 1029);
|
|
CHECK(geometry->GetMaxX() == 2029);
|
|
|
|
CHECK(geometry->GetMinY() == 1513 - 513);
|
|
CHECK(geometry->GetMaxY() == 1513);
|
|
|
|
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
|
DetectorModuleGeometry::Direction::Yneg,
|
|
DetectorModuleGeometry::Direction::Xneg));
|
|
CHECK(geometry->GetMinX() == 2029 - 513);
|
|
CHECK(geometry->GetMaxX() == 2029);
|
|
|
|
CHECK(geometry->GetMinY() == 1513 - 1029);
|
|
CHECK(geometry->GetMaxY() == 1513);
|
|
|
|
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
|
DetectorModuleGeometry::Direction::Yneg,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
CHECK(geometry->GetMinX() == 2029);
|
|
CHECK(geometry->GetMaxX() == 2029 + 513);
|
|
|
|
CHECK(geometry->GetMinY() == 1513 - 1029);
|
|
CHECK(geometry->GetMaxY() == 1513);
|
|
|
|
REQUIRE_NOTHROW(geometry = std::make_unique<DetectorModuleGeometry>(2029,1513,
|
|
DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Xneg));
|
|
CHECK(geometry->GetMinX() == 2029 - 513);
|
|
CHECK(geometry->GetMaxX() == 2029);
|
|
|
|
CHECK(geometry->GetMinY() == 1513);
|
|
CHECK(geometry->GetMaxY() == 1513 + 1029);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_Custom", "[DetectorGeometry]") {
|
|
std::vector<DetectorModuleGeometry> module_geom;
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(2999, 2999, DetectorModuleGeometry::Direction::Xneg,
|
|
DetectorModuleGeometry::Direction::Yneg));
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(0, 0, DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(5000, 0, DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
|
|
DetectorGeometryModular geometry(module_geom);
|
|
|
|
REQUIRE(geometry.GetModulesNum() == 3);
|
|
|
|
CHECK(geometry.GetHeight(true) == 2999+1);
|
|
CHECK(geometry.GetWidth(true) == 5513+1);
|
|
CHECK(geometry.GetPixel0(0, true) == 2999 * geometry.GetWidth(true) + 2999);
|
|
CHECK(geometry.GetPixel0(1, true) == 0);
|
|
CHECK(geometry.GetPixel0(2, true) == 5000);
|
|
|
|
CHECK(geometry.GetFastDirectionStep(0) == -1);
|
|
|
|
REQUIRE(geometry.GetFastDirection(0).x == -1);
|
|
REQUIRE(geometry.GetFastDirection(0).y == 0);
|
|
REQUIRE(geometry.GetFastDirection(0).z == 0);
|
|
|
|
CHECK(geometry.GetFastDirectionStep(1) == geometry.GetWidth(true));
|
|
REQUIRE(geometry.GetFastDirection(1).x == 0);
|
|
REQUIRE(geometry.GetFastDirection(1).y == 1);
|
|
REQUIRE(geometry.GetFastDirection(1).z == 0);
|
|
|
|
CHECK(geometry.GetFastDirectionStep(2) == geometry.GetWidth(true));
|
|
|
|
CHECK(geometry.GetSlowDirectionStep(0) == -geometry.GetWidth(true));
|
|
|
|
REQUIRE(geometry.GetSlowDirection(0).x == 0);
|
|
REQUIRE(geometry.GetSlowDirection(0).y == -1);
|
|
REQUIRE(geometry.GetSlowDirection(0).z == 0);
|
|
|
|
CHECK(geometry.GetSlowDirectionStep(1) == 1);
|
|
|
|
REQUIRE(geometry.GetSlowDirection(1).x == 1);
|
|
REQUIRE(geometry.GetSlowDirection(1).y == 0);
|
|
REQUIRE(geometry.GetSlowDirection(1).z == 0);
|
|
|
|
CHECK(geometry.GetSlowDirectionStep(2) == 1);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_Limit", "[DetectorGeometry]") {
|
|
std::vector<DetectorModuleGeometry> module_geom;
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(-100, 2999, DetectorModuleGeometry::Direction::Xneg,
|
|
DetectorModuleGeometry::Direction::Yneg));
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(5000, 500, DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
|
|
DetectorGeometryModular geometry(module_geom);
|
|
|
|
REQUIRE(geometry.GetModulesNum() == 2);
|
|
CHECK(geometry.GetWidth(true) == 5000 + 514 - (-100 - 1030) - 1);
|
|
CHECK(geometry.GetHeight(true) == 2999 - 500 + 1);
|
|
}
|
|
|
|
TEST_CASE("DetectorGeometryModular_Custom_Mirror", "[DetectorGeometry]") {
|
|
std::vector<DetectorModuleGeometry> module_geom;
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(2999, 2999, DetectorModuleGeometry::Direction::Xneg,
|
|
DetectorModuleGeometry::Direction::Yneg));
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(0, 0, DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
|
|
REQUIRE_NOTHROW(module_geom.emplace_back(5000, 0, DetectorModuleGeometry::Direction::Ypos,
|
|
DetectorModuleGeometry::Direction::Xpos));
|
|
|
|
DetectorGeometryModular geometry(module_geom, true);
|
|
|
|
REQUIRE(geometry.GetModulesNum() == 3);
|
|
|
|
CHECK(geometry.GetHeight(true) == 2999+1);
|
|
CHECK(geometry.GetWidth(true) == 5513+1);
|
|
CHECK(geometry.GetPixel0(0, true) == 2999);
|
|
CHECK(geometry.GetPixel0(1, true) == 2999 * geometry.GetWidth(true));
|
|
CHECK(geometry.GetPixel0(2, true) == 2999 * geometry.GetWidth(true) + 5000 );
|
|
|
|
CHECK(geometry.GetFastDirectionStep(0) == -1);
|
|
|
|
REQUIRE(geometry.GetFastDirection(0).x == -1);
|
|
REQUIRE(geometry.GetFastDirection(0).y == 0);
|
|
REQUIRE(geometry.GetFastDirection(0).z == 0);
|
|
|
|
CHECK(geometry.GetFastDirectionStep(1) == -geometry.GetWidth(true));
|
|
REQUIRE(geometry.GetFastDirection(1).x == 0);
|
|
REQUIRE(geometry.GetFastDirection(1).y == -1);
|
|
REQUIRE(geometry.GetFastDirection(1).z == 0);
|
|
|
|
CHECK(geometry.GetFastDirectionStep(2) == -geometry.GetWidth(true));
|
|
|
|
CHECK(geometry.GetSlowDirectionStep(0) == geometry.GetWidth(true));
|
|
|
|
REQUIRE(geometry.GetSlowDirection(0).x == 0);
|
|
REQUIRE(geometry.GetSlowDirection(0).y == 1);
|
|
REQUIRE(geometry.GetSlowDirection(0).z == 0);
|
|
|
|
CHECK(geometry.GetSlowDirectionStep(1) == 1);
|
|
|
|
REQUIRE(geometry.GetSlowDirection(1).x == 1);
|
|
REQUIRE(geometry.GetSlowDirection(1).y == 0);
|
|
REQUIRE(geometry.GetSlowDirection(1).z == 0);
|
|
|
|
CHECK(geometry.GetSlowDirectionStep(2) == 1);
|
|
}
|