Files
Jungfraujoch/image_analysis/IndexerWrapper.cpp

41 lines
1.0 KiB
C++

// Copyright (2019-2022) Paul Scherrer Institute
// SPDX-License-Identifier: GPL-3.0-or-later
#include "IndexerWrapper.h"
void IndexerWrapper::Setup(const UnitCell &cell) {
#ifdef JFJOCH_USE_CUDA
indexer.iCellM() = CrystalLattice(cell).GetEigenMatrix();
#endif
}
std::vector<CrystalLattice> IndexerWrapper::Run(const std::vector<Coord> &coord) {
#ifdef JFJOCH_USE_CUDA
std::vector<CrystalLattice> ret;
if (coord.size() < MIN_SPOTS_TO_INDEX)
return ret;
size_t nspots = std::min<size_t>(MAX_SPOTS_TO_INDEX, coord.size());
for (int i = 0; i < nspots; i++) {
indexer.spotX(i) = coord[i].x;
indexer.spotY(i) = coord[i].y;
indexer.spotZ(i) = coord[i].z;
}
// Index
indexer.index(1, nspots);
// Get best cell
auto id = fast_feedback::refine::best_cell(indexer.oScoreV());
// Check if is viable
if (fast_feedback::refine::is_viable_cell(indexer.oCell(id), indexer.Spots(), 0.05f, 9u))
ret.emplace_back(indexer.oCell(id));
return ret;
#else
return {};
#endif
}