DetectorSetup: Save gain calibration in shared pointer to avoid copying it when copying DiffractionExperiment

This commit is contained in:
2026-04-30 19:59:26 +02:00
parent 87fde1b32e
commit 58df84a324
4 changed files with 29 additions and 12 deletions
+12 -11
View File
@@ -40,14 +40,16 @@ DetectorSetup::DetectorSetup(const DetectorGeometryModular &geom, DetectorType d
DetectorSetup::DetectorSetup(std::shared_ptr<DetectorGeometry> in_geometry,
DetectorType in_detector_type,
const std::string &in_description,
const std::vector<std::string> &in_det_modules_hostname) :
geometry(std::move(in_geometry)),
description(in_description),
det_modules_hostname(in_det_modules_hostname),
detector_type(in_detector_type),
read_out_time(0),
min_frame_time(std::chrono::milliseconds(1)),
min_count_time(MIN_COUNT_TIME) {
const std::vector<std::string> &
in_det_modules_hostname)
: description(in_description),
geometry(std::move(in_geometry)),
det_modules_hostname(in_det_modules_hostname),
gain_calibration(std::make_shared<JFGainCalibration>()),
detector_type(in_detector_type),
read_out_time(0),
min_count_time(MIN_COUNT_TIME),
min_frame_time(std::chrono::milliseconds(1)) {
if (description.empty())
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
@@ -124,8 +126,7 @@ void DetectorSetup::LoadGain(const std::vector<std::string> &filenames) {
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"Mismatch in number of gain calibration files");
gain_file_names = filenames;
for (const auto& i: filenames)
gain_calibration.emplace_back(i);
gain_calibration->LoadGain(filenames);
}
DetectorSetup &DetectorSetup::UDPInterfaceCount(int64_t input) {
@@ -137,7 +138,7 @@ DetectorSetup &DetectorSetup::UDPInterfaceCount(int64_t input) {
}
const std::vector<JFModuleGainCalibration> &DetectorSetup::GetGainCalibration() const {
return gain_calibration;
return gain_calibration->GetCalibration();
}
int64_t DetectorSetup::GetUDPInterfaceCount() const {
+1 -1
View File
@@ -26,7 +26,7 @@ class DetectorSetup {
std::vector<std::string> gain_file_names;
std::vector<std::string> trim_file_names;
std::string trim_file_directory;
std::vector<JFModuleGainCalibration> gain_calibration;
std::shared_ptr<JFGainCalibration> gain_calibration;
int64_t udp_interface_count = 2;
float pixel_size_um = 75.0f;
std::string sensor_material = "Si";
+9
View File
@@ -113,3 +113,12 @@ double JFModuleGainCalibration::GetG2StdDev() const {
double JFModuleGainCalibration::GetHG0StdDev() const {
return GetStdDev(offset_hg0);
}
JFGainCalibration::JFGainCalibration(const std::vector<std::string>& filenames) {
for (const auto& filename : filenames)
c.emplace_back(filename);
}
const std::vector<JFModuleGainCalibration>& JFGainCalibration::GetCalibration() const {
return c;
}
+7
View File
@@ -47,4 +47,11 @@ inline JFModuleGainCalibration GainCalibrationFromTestFile() {
return JFModuleGainCalibration("../../tests/test_data/gainMaps_M049.bin");
}
class JFGainCalibration {
std::vector<JFModuleGainCalibration> c;
public:
void LoadGain(const std::vector<std::string>& filenames);
const std::vector<JFModuleGainCalibration>& GetCalibration() const;
};
#endif //JUNGFRAUJOCH_JFMODULEGAINCALIBRATION_H