RotationIndexer: More information in output

This commit is contained in:
2025-11-29 18:46:30 +01:00
parent 1b64f45fdc
commit a6745e7a1a
2 changed files with 26 additions and 11 deletions
+13 -9
View File
@@ -12,8 +12,8 @@ RotationIndexer::RotationIndexer(const DiffractionExperiment &x, IndexerThreadPo
index_ice_rings(x.GetIndexingSettings().GetIndexIceRings()),
axis_(x.GetGoniometer()),
geom_(x.GetDiffractionGeometry()),
updated_geom_(geom_),
indexer_(indexer) {
if (axis_) {
float angle_norm_deg = std::fabs(axis_->GetIncrement_deg());
if (angle_norm_deg < 1e-6) {
@@ -40,8 +40,6 @@ void RotationIndexer::SetLattice(const CrystalLattice &lattice) {
indexed_lattice = lattice;
}
#include <iostream>
void RotationIndexer::TryIndex() {
// Index
std::vector<SpotToSave> v_sel;
@@ -80,14 +78,14 @@ void RotationIndexer::TryIndex() {
auto indexer_result = indexer_.Run(experiment, coords_sel).get();
if (!indexer_result.lattice.empty()) {
// Find lattice type
auto sym_result = LatticeSearch(indexer_result.lattice[0]);
search_result_ = LatticeSearch(indexer_result.lattice[0]);
// Run refinement
DiffractionExperiment experiment_copy(experiment);
XtalOptimizerData data{
.geom = experiment_copy.GetDiffractionGeometry(),
.latt = sym_result.conventional,
.crystal_system = sym_result.system,
.latt = search_result_.conventional,
.crystal_system = search_result_.system,
.min_spots = experiment.GetIndexingSettings().GetViableCellMinSpots(),
.refine_beam_center = true,
.refine_distance_mm = true,
@@ -97,12 +95,14 @@ void RotationIndexer::TryIndex() {
if (data.crystal_system == gemmi::CrystalSystem::Trigonal)
data.crystal_system = gemmi::CrystalSystem::Hexagonal;
if (XtalOptimizer(data, v_sel))
if (XtalOptimizer(data, v_sel)) {
indexed_lattice = data.latt;
updated_geom_ = data.geom;
}
}
}
std::optional<CrystalLattice> RotationIndexer::ProcessImage(int64_t image, const std::vector<SpotToSave> &spots) {
std::optional<RotatinIndexerImageResult> RotationIndexer::ProcessImage(int64_t image, const std::vector<SpotToSave> &spots) {
std::unique_lock ul(m);
// For non-rotation just ignore the whole procedure
@@ -130,7 +130,11 @@ std::optional<CrystalLattice> RotationIndexer::ProcessImage(int64_t image, const
}
if (indexed_lattice)
return indexed_lattice->Multiply(rot.transpose());
return RotatinIndexerImageResult{
.lattice = indexed_lattice->Multiply(rot.transpose()),
.search_result = search_result_,
.geom = updated_geom_
};
return {};
}
+13 -2
View File
@@ -10,6 +10,7 @@
#include "../common/DiffractionSpot.h"
#include "../common/DiffractionExperiment.h"
#include "indexing/IndexerThreadPool.h"
#include "lattice_search/LatticeSearch.h"
// RotationIndexer works as following:
// 1. First accumulates spot results from rotation images (only images within a certain stride are included)
@@ -17,12 +18,18 @@
// 3. If indexing is successful - lattice is provided that is used by subsequent images
// 4. If indexing is not-successful - accumulation procedure is continued
struct RotatinIndexerImageResult {
CrystalLattice lattice;
LatticeSearchResult search_result;
DiffractionGeometry geom;
};
class RotationIndexer {
mutable std::mutex m;
const DiffractionExperiment& experiment;
constexpr static int64_t max_spots = 32768;
constexpr static float min_accum_angle_deg = 20.0;
constexpr static float min_accum_angle_deg = 10.0;
constexpr static float stride_angle_deg = 0.5;
constexpr static int64_t min_images_for_indexing = 10;
@@ -32,6 +39,8 @@ class RotationIndexer {
std::vector<Coord> coords_;
std::optional<GoniometerAxis> axis_;
const DiffractionGeometry geom_;
DiffractionGeometry updated_geom_;
LatticeSearchResult search_result_;
IndexerThreadPool &indexer_;
@@ -42,11 +51,13 @@ class RotationIndexer {
int64_t first_image_to_try_indexing;
std::optional<CrystalLattice> indexed_lattice;
void TryIndex();
public:
RotationIndexer(const DiffractionExperiment& x, IndexerThreadPool& indexer);
void SetLattice(const CrystalLattice &lattice);
std::optional<CrystalLattice> ProcessImage(int64_t image, const std::vector<SpotToSave>& spots);
std::optional<RotatinIndexerImageResult> ProcessImage(int64_t image, const std::vector<SpotToSave>& spots);
std::optional<CrystalLattice> Finalize(bool retry);
};