DetectorModuleGeometry: More flexibility for modular geometry, allowing for non-zero top left corner

This commit is contained in:
2025-11-18 13:52:42 +01:00
parent a041b94a91
commit accbb6bd21
2 changed files with 31 additions and 2 deletions

View File

@@ -12,11 +12,24 @@ DetectorGeometryModular::DetectorGeometryModular(const std::vector<DetectorModul
width = 0;
height = 0;
int64_t min_x = modules[0].GetMinX();
int64_t max_x = modules[0].GetMaxX();
int64_t min_y = modules[0].GetMinY();
int64_t max_y = modules[0].GetMaxY();
for (auto &m: modules) {
width = std::max<int64_t>(width, m.GetMaxX()+1);
height = std::max<int64_t>(height, m.GetMaxY()+1);
min_x = std::min<int64_t>(min_x, m.GetMinX());
max_x = std::max<int64_t>(max_x, m.GetMaxX());
min_y = std::min<int64_t>(min_y, m.GetMinY());
max_y = std::max<int64_t>(max_y, m.GetMaxY());
}
width = max_x - min_x + 1;
height = max_y - min_y + 1;
for (auto &m: modules)
m.Translate(-min_x, -min_y);
if (vertical_flip)
VerticalFlip();
}

View File

@@ -218,6 +218,22 @@ TEST_CASE("DetectorGeometryModular_Custom", "[DetectorGeometry]") {
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 + 513 - (-100 - 1029));
CHECK(geometry.GetHeight(true) == 2999 + 513 - 500);
}
TEST_CASE("DetectorGeometryModular_Custom_Mirror", "[DetectorGeometry]") {
std::vector<DetectorModuleGeometry> module_geom;