// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #include #include #include "Calibrants.h" #include "AssignSpotsToRings.h" // CalculateXtalRings #include "../../common/Definitions.h" #include "../../common/JFJochMath.h" namespace { std::string lower_case(const std::string &s) { std::string out = s; std::transform(out.begin(), out.end(), out.begin(), [](unsigned char c) { return static_cast(std::tolower(c)); }); return out; } } const std::vector &Calibrants() { static const std::vector table = { {"LaB6", UnitCell(LAB6_CELL_A, LAB6_CELL_A, LAB6_CELL_A, 90, 90, 90)}, // Silver behenate. T. C. Huang, H. Toraya, T. N. Blanton, Y. Wu, J. Appl. Cryst. 26 (1993), 180-184. {"AgBh", UnitCell(5.1769, 4.7218, 58.380, 89.440, 89.634, 75.854)}, // CeO2, cubic fluorite, NIST SRM 674b. {"CeO2", UnitCell(5.4115, 5.4115, 5.4115, 90, 90, 90)}, // Silicon, cubic, NIST SRM 640. {"Si", UnitCell(5.43102, 5.43102, 5.43102, 90, 90, 90)}, // Hexagonal ice: measured ring positions, not a cell (see the header). {"ice", std::nullopt} }; return table; } std::vector CalibrantRings(const std::string &name) { const std::string key = lower_case(name); for (const auto &c : Calibrants()) { if (lower_case(c.name) != key) continue; if (c.cell) return CalculateXtalRings(*c.cell); std::vector q; for (const float d : ICE_RING_RES_A) q.push_back(static_cast(2.0 * PI) / d); std::sort(q.begin(), q.end()); return q; } return {}; } std::string CalibrantNameList() { std::string out; for (const auto &c : Calibrants()) { if (!out.empty()) out += ", "; out += lower_case(c.name); } return out; }