60 lines
2.6 KiB
C++
60 lines
2.6 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#ifndef JUNGFRAUJOCH_PREDICTSPOTSONDETECTOR_H
|
|
#define JUNGFRAUJOCH_PREDICTSPOTSONDETECTOR_H
|
|
|
|
#include <vector>
|
|
#include "../common/DiffractionGeometry.h"
|
|
#include "../common/ROIFilter.h"
|
|
#include "CrystalLattice.h"
|
|
|
|
std::vector<std::pair<float, float>> PredictSpotsOnDetector(const DiffractionExperiment& experiment,
|
|
const CrystalLattice& lattice,
|
|
int32_t max_hkl = 30,
|
|
float epsilon = 4e-4) {
|
|
CrystalLattice recip_l = lattice.ReciprocalLattice();
|
|
std::vector<std::pair<float, float>> ret;
|
|
for (int h = -max_hkl; h < max_hkl; h++) {
|
|
for (int k = -max_hkl; k < max_hkl; k++) {
|
|
for (int l = -max_hkl; l < max_hkl; l++) {
|
|
Coord recip = static_cast<float>(h) * recip_l.Vec0()
|
|
+ static_cast<float>(k) * recip_l.Vec1()
|
|
+ static_cast<float>(l) * recip_l.Vec2();
|
|
|
|
if (DistFromEwaldSphere(experiment, recip) < epsilon)
|
|
ret.push_back(RecipToDector(experiment, recip));
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
void PredictSpotsOnDetector(ROIFilter &filter,
|
|
const DiffractionExperiment& experiment,
|
|
const CrystalLattice& lattice,
|
|
int32_t max_hkl = 30,
|
|
float epsilon = 4e-4,
|
|
uint16_t box_size = 7) {
|
|
CrystalLattice recip_l = lattice.ReciprocalLattice();
|
|
std::vector<std::pair<float, float>> ret;
|
|
for (int h = -max_hkl; h < max_hkl; h++) {
|
|
for (int k = -max_hkl; k < max_hkl; k++) {
|
|
for (int l = -max_hkl; l < max_hkl; l++) {
|
|
Coord recip = static_cast<float>(h) * recip_l.Vec0()
|
|
+ static_cast<float>(k) * recip_l.Vec1()
|
|
+ static_cast<float>(l) * recip_l.Vec2();
|
|
|
|
if (DistFromEwaldSphere(experiment, recip) < epsilon) {
|
|
auto [x,y] = RecipToDector(experiment, recip);
|
|
auto x0 = static_cast<int32_t>(std::lroundf(x - static_cast<float>(box_size)));
|
|
auto y0 = static_cast<int32_t>(std::lroundf(y - static_cast<float>(box_size)));
|
|
filter.SetRectangle(x0, y0, 2 * box_size + 1, 2 * box_size + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif //JUNGFRAUJOCH_PREDICTSPOTSONDETECTOR_H
|