Files
Jungfraujoch/tests/DetectorSettingsTest.cpp
2025-07-15 09:55:19 +02:00

35 lines
1.4 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/DetectorSettings.h"
TEST_CASE("DetectorSettings_CountTime") {
DetectorSettings d;
REQUIRE_NOTHROW(d.FrameTime(std::chrono::microseconds(1000)));
REQUIRE(d.GetFrameTime() == std::chrono::milliseconds(1));
REQUIRE(!d.GetCountTime());
REQUIRE_NOTHROW(d.FrameTime(std::chrono::microseconds(1000), std::chrono::microseconds(500)));
REQUIRE(d.GetFrameTime() == std::chrono::milliseconds(1));
REQUIRE(d.GetCountTime());
REQUIRE(d.GetCountTime().value().count() == 500);
}
TEST_CASE("DetectorSettings_NeedsJUNGFRAURecalibration") {
DetectorSettings d1;
d1.EigerThreshold_keV(12.4).FixGainG1(true).PedestalG1Frames(1234);
DetectorSettings d2 = d1;
REQUIRE(!d1.NeedsJUNGFRAURecalibration(d1));
REQUIRE(!d1.NeedsJUNGFRAURecalibration(d2));
d1.DetectorDelay(std::chrono::microseconds(500)).EigerThreshold_keV(10.0).EigerBitDepth(32).InternalGeneratorImages(12);
REQUIRE(!d2.NeedsJUNGFRAURecalibration(d1));
REQUIRE(!d1.NeedsJUNGFRAURecalibration(d2));
d1.FrameTime(std::chrono::microseconds(1000), std::chrono::microseconds(10));
REQUIRE(d1.NeedsJUNGFRAURecalibration(d2));
REQUIRE(d2.NeedsJUNGFRAURecalibration(d1));
REQUIRE(d1.NeedsJUNGFRAURecalibration(DetectorSettings()));
}