From 6328369ce917f936a7be69e1c3d759d713f674d1 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Mon, 19 May 2025 18:30:29 +0200 Subject: [PATCH] added parameter conversion --- include/aare/AngleCalibration.hpp | 68 +++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/include/aare/AngleCalibration.hpp b/include/aare/AngleCalibration.hpp index a8007b1..c69e20f 100644 --- a/include/aare/AngleCalibration.hpp +++ b/include/aare/AngleCalibration.hpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -15,13 +16,15 @@ namespace aare { +using parameters = + std::tuple, std::vector, std::vector>; + // TODO: can i have a static struct, constexpr? struct MythenSpecifications { static constexpr int32_t max_modules = 48; static constexpr int32_t channels_per_module = 1280; - static constexpr double pitch = - 0.05; // what is this pitch pitch is up e.g. rotation aroung y axis + static constexpr double pitch = 0.05; // strip width [mm] ?? TODO: not sure static constexpr double ttmin = -180.0; // what is this the angle static constexpr float ttmax = 180.0; static constexpr float ttstep = @@ -41,12 +44,31 @@ class AngleCalibration { offsets.reserve(MythenSpecifications::max_modules); } + /** reads the historical Detector Group (DG) parameters from file **/ void read_initial_calibration_from_file(const std::string &filename); + /** converts DG parameters to easy EE parameters e.g.geometric parameters */ + parameters convert_to_EE_parameters(); + + /** converts DG parameters to easy BC parameters e.g. best computing + * parameters */ + parameters convert_to_BC_parameters(); + protected: - std::vector centers; - std::vector conversions; - std::vector offsets; + // TODO: Design maybe have a struct with three vectors, store all three sets + // of parameters + + // TODO: check if interpretation and units are correct + // historical DG parameters + std::vector + centers; // orthogonal projection of sample onto detector (given in + // strip number) [mm] D/pitch + std::vector + conversions; // pitch/(normal distance from sample to detector (R)) [mm] + // //used for easy conversion + std::vector + offsets; // position of strip zero relative to sample [degrees] phi - + // 180/pi*D/R TODO: expected an arcsin(D/R)? }; // read hdf5 files - > do they store the histogram? what angles do they store? @@ -94,13 +116,33 @@ void AngleCalibration::read_initial_calibration_from_file( std::cerr << "Error: " << e.what() << std::endl; // TODO: replace with log } - - // angle_sign = signbit(conversion); - // signed_angles = std::abs(conversion); - // inverse_angles = 1./signed_angles - // store [centers, signed_conversions, offsets] - // dont know what conversion and offset is - dont know what calculations one - // does there the errors are actually not needed } -} // namespace aare \ No newline at end of file +parameters AngleCalibration::convert_to_EE_parameters() { + + // normal distance between sample and detector (R) + std::vector normal_distances(centers.size()); + // distances between intersection point of sample normal and module origin + // (D) + std::vector module_center_distances(centers.size()); + // angles between undiffracted beam and orthogonal sample projection on + // detector (phi) + std::vector angles(centers.size()); + + for (size_t i = 0; i < centers.size(); ++i) { + normal_distances[i] = centers[i] * MythenSpecifications::pitch; + module_center_distances[i] = + MythenSpecifications::pitch / std::abs(conversions[i]); + angles[i] = + offsets[i] + 180.0 / M_PI * centers[i] * std::abs(conversions[i]); + } + // TODO: maybe add function rad_to_deg + + return std::make_tuple(normal_distances, module_center_distances, angles); +} +/* +parameters +AngleCalibration::convert_to_BC_parameters() {} +*/ + +} // namespace aare