* Enhancements for EIGER * Writer is more flexible and capable of handling DECTRIS data
111 lines
4.2 KiB
C++
111 lines
4.2 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#include "JFJochReceiverPlots.h"
|
|
|
|
JFJochReceiverPlots::JFJochReceiverPlots(const DiffractionExperiment &experiment,
|
|
const AzimuthalIntegrationMapping &mapping)
|
|
: indexing_solution_per_file(experiment.GetDataFileCount()),
|
|
default_binning(experiment.GetSpotFindingBin()),
|
|
rad_int_profile(mapping), resolution_estimation(50, 1.0, 5.0) {
|
|
for (int i = 0; i < experiment.GetDataFileCount(); i++)
|
|
rad_int_profile_per_file.emplace_back(mapping);
|
|
}
|
|
|
|
void JFJochReceiverPlots::Add(const DataMessage &msg, uint64_t file_number, const AzimuthalIntegrationProfile &profile) {
|
|
bkg_estimate.AddElement(msg.number, msg.bkg_estimate);
|
|
spot_count.AddElement(msg.number, msg.spots.size());
|
|
saturated_pixels.AddElement(msg.number, msg.saturated_pixel_count);
|
|
error_pixels.AddElement(msg.number, msg.error_pixel_count);
|
|
strong_pixels.AddElement(msg.number, msg.strong_pixel_count);
|
|
|
|
image_collection_efficiency.AddElement(msg.number, msg.image_collection_efficiency);
|
|
receiver_delay.AddElement(msg.number, msg.receiver_aq_dev_delay.value());
|
|
|
|
indexing_solution.AddElement(msg.number, msg.indexing_result);
|
|
indexing_solution_per_file.Add(file_number, msg.indexing_result);
|
|
|
|
if (msg.roi_sum)
|
|
roi_sum.AddElement(file_number, msg.roi_sum.value());
|
|
if (msg.resolution_estimation)
|
|
resolution_estimation.Add(msg.resolution_estimation.value());
|
|
|
|
rad_int_profile += profile;
|
|
rad_int_profile_per_file.at(file_number) += profile;
|
|
}
|
|
|
|
void JFJochReceiverPlots::AddEmptyImage(const DataMessage &msg) {
|
|
image_collection_efficiency.AddElement(msg.number, msg.image_collection_efficiency);
|
|
}
|
|
|
|
Plot JFJochReceiverPlots::GetPlots(const PlotRequest &request) {
|
|
Plot ret;
|
|
auto nbins = default_binning;
|
|
if (request.binning > 0)
|
|
nbins = request.binning;
|
|
|
|
switch (request.type) {
|
|
case PlotType::RadInt:
|
|
return rad_int_profile.GetPlot();
|
|
case PlotType::SpotCount:
|
|
return spot_count.GetPlot(nbins);
|
|
case PlotType::IndexingRate:
|
|
return indexing_solution.GetPlot(nbins);
|
|
case PlotType::BkgEstimate:
|
|
return bkg_estimate.GetPlot(nbins);
|
|
case PlotType::IndexingRatePerFile:
|
|
return indexing_solution_per_file.GetPlot();
|
|
case PlotType::SaturatedPixels:
|
|
return saturated_pixels.GetPlot(nbins);
|
|
case PlotType::ErrorPixels:
|
|
return error_pixels.GetPlot(nbins);
|
|
case PlotType::ImageCollectionEfficiency:
|
|
return image_collection_efficiency.GetPlot(nbins);
|
|
case PlotType::ReceiverDelay:
|
|
return receiver_delay.GetPlot(nbins);
|
|
case PlotType::StrongPixels:
|
|
return strong_pixels.GetPlot(nbins);
|
|
case PlotType::ROISum:
|
|
return roi_sum.GetPlot(nbins);
|
|
case PlotType::ResEstimation:
|
|
return resolution_estimation.GetPlot();
|
|
default:
|
|
// Do nothing
|
|
break;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
RadialIntegrationProfiles JFJochReceiverPlots::GetRadialIntegrationProfiles() {
|
|
RadialIntegrationProfiles ret;
|
|
|
|
ret.profiles.emplace_back(RadialIntegrationProfileStruct{
|
|
.title = "dataset" ,
|
|
.plot = rad_int_profile.GetPlot()});
|
|
|
|
for (int i = 0; i < rad_int_profile_per_file.size(); i++) {
|
|
ret.profiles.emplace_back(RadialIntegrationProfileStruct{
|
|
.title = "file" + std::to_string(i),
|
|
.plot = rad_int_profile_per_file[i].GetPlot()});
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
float JFJochReceiverPlots::GetIndexingRate() const {
|
|
return indexing_solution.Mean();
|
|
}
|
|
|
|
float JFJochReceiverPlots::GetBkgEstimate() const {
|
|
return bkg_estimate.Mean();
|
|
}
|
|
|
|
std::vector<float> JFJochReceiverPlots::GetRadialPlot() const {
|
|
return rad_int_profile.GetResult();
|
|
}
|
|
|
|
std::vector<float> JFJochReceiverPlots::GetRadialPlotPerFile(uint64_t file_number) {
|
|
if (file_number < rad_int_profile_per_file.size())
|
|
return rad_int_profile_per_file.at(file_number).GetResult();
|
|
else
|
|
throw JFJochException(JFJochExceptionCategory::ArrayOutOfBounds, "JFJochReceiverPlots::GetRadialPlotPerFile out of bounds");
|
|
}
|