// Copyright (2019-2023) Paul Scherrer Institute #ifndef JUNGFRAUJOCH_PREDICTSPOTSONDETECTOR_H #define JUNGFRAUJOCH_PREDICTSPOTSONDETECTOR_H #include #include "../common/DiffractionGeometry.h" #include "../common/ROIFilter.h" #include "CrystalLattice.h" std::vector> PredictSpotsOnDetector(const DiffractionExperiment& experiment, const CrystalLattice& lattice, int32_t max_hkl = 30, float epsilon = 4e-4) { CrystalLattice recip_l = lattice.ReciprocalLattice(); std::vector> 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(h) * recip_l.Vec0() + static_cast(k) * recip_l.Vec1() + static_cast(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> 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(h) * recip_l.Vec0() + static_cast(k) * recip_l.Vec1() + static_cast(l) * recip_l.Vec2(); if (DistFromEwaldSphere(experiment, recip) < epsilon) { auto [x,y] = RecipToDector(experiment, recip); auto x0 = static_cast(std::lroundf(x - static_cast(box_size))); auto y0 = static_cast(std::lroundf(y - static_cast(box_size))); filter.SetRectangle(x0, y0, 2 * box_size + 1, 2 * box_size + 1); } } } } } #endif //JUNGFRAUJOCH_PREDICTSPOTSONDETECTOR_H