34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "Indexer.h"
|
|
|
|
void Indexer::Setup(const DiffractionExperiment& experiment) {
|
|
geom = experiment.GetDiffractionGeometry();
|
|
indexing_tolerance = experiment.GetIndexingSettings().GetTolerance();
|
|
dist_tolerance_vs_reference = experiment.GetIndexingSettings().GetUnitCellDistTolerance();
|
|
viable_cell_min_spots = experiment.GetIndexingSettings().GetViableCellMinSpots();
|
|
SetupUnitCell(experiment.GetUnitCell());
|
|
}
|
|
|
|
std::optional<CrystalLattice> Indexer::Run(DataMessage &message) {
|
|
auto start = std::chrono::high_resolution_clock::now();
|
|
|
|
std::vector<Coord> recip;
|
|
recip.reserve(message.spots.size());
|
|
|
|
for (const auto &i: message.spots)
|
|
recip.push_back(i.ReciprocalCoord(geom));
|
|
|
|
auto ret = Run(recip, message.spots.size());
|
|
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
std::chrono::duration<float> duration = end - start;
|
|
message.indexing_time_s = duration.count();
|
|
|
|
if (ret.empty())
|
|
return {};
|
|
|
|
return ret[0];
|
|
}
|