Modifications in preparation to MAX IV experiment

This commit is contained in:
2024-01-27 21:23:56 +01:00
parent 2446643489
commit f5f86d9ab6
250 changed files with 9363 additions and 3022 deletions

View File

@@ -0,0 +1,45 @@
// Copyright (2019-2023) Paul Scherrer Institute
#include "ImageMetadata.h"
void ImageMetadata::Process(const DeviceOutput *output) {
if (!first_module_loaded) {
xfel_bunch_id = output->module_statistics.bunchid;
jf_info = output->module_statistics.debug;
storage_cell = (jf_info >> 8) & 0xF;
xfel_event_code = (jf_info >> 16) & UINT8_MAX;
timestamp = output->module_statistics.timestamp;
exptime = output->module_statistics.exptime;
first_module_loaded = true;
} else {
if (output->module_statistics.bunchid != xfel_bunch_id)
metadata_consistent = false;
}
saturated_pixels += output->module_statistics.saturated_pixels;
error_pixels += output->module_statistics.err_pixels;
strong_pixels += output->spot_finding_result.strong_pixel_count;
packets_collected += output->module_statistics.packet_count;
}
bool ImageMetadata::IsBunchIDConsistent() const {
return metadata_consistent;
}
void ImageMetadata::Export(DataMessage &message, uint64_t packets_expected_per_image) const {
message.xfel_bunch_id = xfel_event_code;
message.xfel_event_code = xfel_event_code;
message.jf_info = jf_info;
message.storage_cell = storage_cell;
message.timestamp = timestamp;
message.timestamp_base = 10*1000*1000;
message.exptime = exptime;
message.exptime_base = 10*1000*1000;
message.saturated_pixel_count = saturated_pixels;
message.error_pixel_count = error_pixels;
message.strong_pixel_count = strong_pixels;
if ((packets_collected > 0) && (packets_expected_per_image > 0))
message.image_collection_efficiency = static_cast<double>(packets_collected)
/ static_cast<double>(packets_expected_per_image);
else
message.image_collection_efficiency = 0.0f;
}