DetectorSetup: Added class that describes detector (geometry, calibration, hostname, etc.) => in the future this should be abstract class

This commit is contained in:
2023-04-13 12:55:20 +02:00
parent 90af364f68
commit 89703baa45
10 changed files with 280 additions and 164 deletions
+52
View File
@@ -0,0 +1,52 @@
// Copyright (2019-2022) Paul Scherrer Institute
// SPDX-License-Identifier: GPL-3.0-or-later
#include <catch2/catch.hpp>
#include "../common/DetectorSetup.h"
TEST_CASE("DetectorSetup_MismatchInSize") {
REQUIRE_THROWS(DetectorSetup(DetectorGeometry(8), "JF", {"mx1","mx2","mx3","mx4"}));
REQUIRE_THROWS(DetectorSetup(DetectorGeometry(2), "JF", {"mx1","mx2","mx3","mx4"}));
REQUIRE_NOTHROW(DetectorSetup(DetectorGeometry(4), "JF", {"mx1","mx2","mx3","mx4"}));
}
TEST_CASE("DetectorSetup_ProtoBuf") {
DetectorSetup setup(DetectorGeometry(4), "JF", {"mx1","mx2","mx3","mx4"});
JFJochProtoBuf::Detector detector = setup;
REQUIRE(detector.type() == JFJochProtoBuf::JUNGFRAU);
REQUIRE(detector.description() == "JF");
REQUIRE(detector.module_hostname_size() == 4);
REQUIRE(detector.module_hostname(3) == "mx4");
REQUIRE(detector.pixel_size_mm() == Approx(0.075));
REQUIRE(detector.nmodules() == 4);
REQUIRE(detector.geometry().module_geometry_size() == 4);
}
TEST_CASE("DetectorSetup_LoadGainFile") {
DetectorSetup setup(DetectorGeometry(4), "JF", {"mx1","mx2","mx3","mx4"});
REQUIRE_THROWS(setup.LoadGain({}));
REQUIRE(setup.GetGainCalibration().empty());
REQUIRE_THROWS(setup.LoadGain({
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin"
}));
REQUIRE_THROWS(setup.LoadGain({
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin"
}));
REQUIRE_NOTHROW(setup.LoadGain({
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin",
"../../tests/test_data/gainMaps_M049.bin"
}));
REQUIRE(setup.GetGainCalibration().size() == 4);
}