Improve plotting
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
// Copyright (2019-2024) Paul Scherrer Institute
|
||||
|
||||
#include "MXAnalyzer.h"
|
||||
#include "CPUSpotFinder.h"
|
||||
|
||||
MXAnalyzer::MXAnalyzer(const DiffractionExperiment &in_experiment)
|
||||
: experiment(in_experiment) {
|
||||
auto uc = experiment.GetUnitCell();
|
||||
if (uc) {
|
||||
do_indexing = true;
|
||||
indexer.Setup(uc.value());
|
||||
}
|
||||
if (experiment.IsSpotFindingEnabled())
|
||||
find_spots = true;
|
||||
|
||||
}
|
||||
|
||||
void MXAnalyzer::ReadFromFPGA(const DeviceOutput *output, const SpotFindingSettings &settings, size_t module_number) {
|
||||
if (!find_spots)
|
||||
return;
|
||||
StrongPixelSet strong_pixel_set;
|
||||
strong_pixel_set.ReadFPGAOutput(*output);
|
||||
strong_pixel_set.FindSpots(experiment, settings, spots, module_number);
|
||||
}
|
||||
|
||||
void MXAnalyzer::ReadFromCPU(const int16_t *image, const SpotFindingSettings &settings, size_t module_number) {
|
||||
if (!find_spots)
|
||||
return;
|
||||
StrongPixelSet strong_pixel_set;
|
||||
FindSpots(strong_pixel_set, settings, image);
|
||||
strong_pixel_set.FindSpots(experiment, settings, spots, module_number);
|
||||
}
|
||||
|
||||
bool MXAnalyzer::Process(DataMessage &message) {
|
||||
message.indexing_result = 0;
|
||||
if (!find_spots)
|
||||
return false;
|
||||
|
||||
bool indexed = false;
|
||||
|
||||
std::vector<DiffractionSpot> spots_out;
|
||||
FilterSpotsByCount(experiment, spots, spots_out);
|
||||
|
||||
for (const auto &spot: spots_out)
|
||||
message.spots.push_back(spot);
|
||||
|
||||
if (do_indexing) {
|
||||
std::vector<Coord> recip;
|
||||
for (const auto &i: spots_out)
|
||||
recip.push_back(i.ReciprocalCoord(experiment));
|
||||
|
||||
auto indexer_result = indexer.Run(recip);
|
||||
|
||||
if (!indexer_result.empty()) {
|
||||
message.indexing_result = 1;
|
||||
for (int i = 0; i < recip.size(); i++)
|
||||
message.spots[i].indexed = indexer_result[0].indexed_spots[i];
|
||||
indexer_result[0].l.Save(message.indexing_lattice);
|
||||
message.indexing_unit_cell = indexer_result[0].l.GetUnitCell();
|
||||
indexed = true;
|
||||
}
|
||||
}
|
||||
spots.clear();
|
||||
return indexed;
|
||||
}
|
||||
Reference in New Issue
Block a user