v1.0.0-rc.72

This commit is contained in:
2025-09-08 20:28:59 +02:00
parent 6c88c6902e
commit c67337cfe1
275 changed files with 7525 additions and 1039 deletions

View File

@@ -99,33 +99,13 @@ TEST_CASE("DetGeomCalib_AnalyzeClusters") {
}
TEST_CASE("DetGeomCalib_build_u") {
auto ret = CalculateCubicXtalRings();
REQUIRE(ret[0] == Catch::Approx(1.0));
REQUIRE(ret[1] == Catch::Approx(sqrtf(2.0)));
REQUIRE(ret[2] == Catch::Approx(sqrtf(3.0)));
REQUIRE(ret[3] == Catch::Approx(2.0));
auto ret = CalculateCubicXtalRings(2.0);
CHECK(ret[0] == Catch::Approx(2.0 * M_PI * 1.0 / 2.0));
CHECK(ret[1] == Catch::Approx(2.0 * M_PI * sqrt( 2.0 )/ 2.0));
CHECK(ret[2] == Catch::Approx(2.0 * M_PI * sqrt( 3.0 )/ 2.0));
CHECK(ret[3] == Catch::Approx(2.0 * M_PI * 2.0/ 2.0));
// 7 cannot be obtained by h^2 + k^2 + l^2, while 8 can
REQUIRE(ret[6] == Catch::Approx(sqrtf(8.0)));
}
TEST_CASE("DetGeomCalib_AssignRings") {
std::vector<RingClusters> obs_sorted;
float S_val = 100.0f;
obs_sorted.push_back(RingClusters{{}, S_val * 1.0f,-1 });
obs_sorted.push_back(RingClusters{{}, S_val * 1.2f,-1 });
obs_sorted.push_back(RingClusters{{}, S_val * sqrtf(3.0f),-1 });
obs_sorted.push_back(RingClusters{{}, S_val * sqrtf(5.0f),-1 });
obs_sorted.push_back(RingClusters{{}, S_val * 3.100f,-1 });
auto res = AssignRings(obs_sorted);
CHECK(res.S == S_val);
CHECK(res.num_rings == 3);
REQUIRE(obs_sorted[0].ring_idx == 0);
REQUIRE(obs_sorted[2].ring_idx == 2);
REQUIRE(obs_sorted[3].ring_idx == 4);
CHECK(ret[6] == Catch::Approx(2.0 * M_PI * sqrt( 8.0 )/ 2.0));
}
TEST_CASE("DetGeomCalib_GuessDetectorDistance") {
@@ -217,15 +197,20 @@ TEST_CASE("DetGeomCalib_RingOptimizer") {
for (int i = 0; i < 30; i++) {
auto [x, y] = geom.ResPhiToPxl(lab6_a, i * M_PI * 2.0 / 30.0);
spots.push_back(RingOptimizerInput{.x = x, .y = y, .d_expected = lab6_a});
spots.push_back(RingOptimizerInput{
.x = x, .y = y,
.q_expected = M_PI * 2.0 / lab6_a
});
}
for (int i = 0; i < 30; i++) {
auto [x, y] = geom.ResPhiToPxl(lab6_a / sqrt(2), i * M_PI * 2.0 / 30.0);
spots.push_back(RingOptimizerInput{.x = x, .y = y, .d_expected = lab6_a / sqrtf(2.0f)});
spots.push_back(RingOptimizerInput{
.x = x, .y = y,
.q_expected = sqrtf(2.0f) * M_PI * 2.0 / lab6_a
});
}
DiffractionGeometry geom_i;
geom_i.Wavelength_A(1.0).BeamX_pxl(105).BeamY_pxl(195).DetectorDistance_mm(110);
@@ -239,3 +224,33 @@ TEST_CASE("DetGeomCalib_RingOptimizer") {
CHECK(fabs(geom_o.GetPoniRot1_rad() - geom.GetPoniRot1_rad()) < 0.001f);
CHECK(fabs(geom_o.GetPoniRot2_rad() - geom.GetPoniRot2_rad()) < 0.001f);
}
TEST_CASE("DetGeomCalib_OptimizeGeometry") {
DiffractionGeometry geom;
geom.Wavelength_A(1.0).BeamX_pxl(1000.0).BeamY_pxl(1275.0)
.DetectorDistance_mm(100).PoniRot1_rad(0.1).PoniRot2_rad(0.05);
float lab6_a = LAB6_CELL_A;
std::vector<SpotToSave> spots;
for (int d = 1; d < 7; d++) {
for (int i = 0; i < 30; i++) {
auto [x, y] = geom.ResPhiToPxl(lab6_a / sqrt(d), i * M_PI * 2.0 / 30.0);
spots.push_back(SpotToSave{.x = x, .y = y});
}
}
DiffractionGeometry geom_i;
geom_i.Wavelength_A(1.0).BeamX_pxl(995.0).BeamY_pxl(1277.0)
.DetectorDistance_mm(98).PoniRot1_rad(0.0975).PoniRot2_rad(0.055);
OptimizeGeometry(geom_i, spots, lab6_a);
CHECK(geom_i.GetBeamX_pxl() == Catch::Approx(geom.GetBeamX_pxl()));
CHECK(geom_i.GetBeamY_pxl() == Catch::Approx(geom.GetBeamY_pxl()));
CHECK(geom_i.GetDetectorDistance_mm() == Catch::Approx(geom.GetDetectorDistance_mm()));
CHECK(geom_i.GetPoniRot1_rad() == Catch::Approx(geom.GetPoniRot1_rad()));
CHECK(geom_i.GetPoniRot2_rad() == Catch::Approx(geom.GetPoniRot2_rad()));
}