added parameter conversion

This commit is contained in:
mazzol_a 2025-05-19 18:30:29 +02:00
parent 67b94eefb0
commit 6328369ce9

View File

@ -1,3 +1,4 @@
#include <algorithm>
#include <cstdint>
#include <fstream>
#include <iostream>
@ -15,13 +16,15 @@
namespace aare {
using parameters =
std::tuple<std::vector<double>, std::vector<double>, std::vector<double>>;
// 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<double> centers;
std::vector<double> conversions;
std::vector<double> 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<double>
centers; // orthogonal projection of sample onto detector (given in
// strip number) [mm] D/pitch
std::vector<double>
conversions; // pitch/(normal distance from sample to detector (R)) [mm]
// //used for easy conversion
std::vector<double>
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
parameters AngleCalibration::convert_to_EE_parameters() {
// normal distance between sample and detector (R)
std::vector<double> normal_distances(centers.size());
// distances between intersection point of sample normal and module origin
// (D)
std::vector<double> module_center_distances(centers.size());
// angles between undiffracted beam and orthogonal sample projection on
// detector (phi)
std::vector<double> 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