BraggPrediction: Add SystematicAbsence header
This commit is contained in:
@@ -2,10 +2,7 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#include "BraggPrediction.h"
|
||||
|
||||
inline bool odd(const int val) {
|
||||
return (val & 1) != 0;
|
||||
}
|
||||
#include "SystematicAbsence.h"
|
||||
|
||||
BraggPrediction::BraggPrediction(int max_reflections)
|
||||
: max_reflections(max_reflections), reflections(max_reflections) {}
|
||||
@@ -55,52 +52,7 @@ int BraggPrediction::Calc(const DiffractionExperiment &experiment, const Crystal
|
||||
const float AhBk_z = Ah_z + Bstar.z * k;
|
||||
|
||||
for (int l = -settings.max_hkl; l < settings.max_hkl; l++) {
|
||||
bool absent = false;
|
||||
// (000) is not too interesting
|
||||
if (h == 0 && k == 0 && l == 0)
|
||||
absent = true;
|
||||
|
||||
switch (settings.centering) {
|
||||
case 'I':
|
||||
// Body-centered: h + k + l must be even
|
||||
if (odd(h + k + l))
|
||||
absent = true;
|
||||
break;
|
||||
case 'A':
|
||||
// A-centered: k + l must be even
|
||||
if (odd(k + l))
|
||||
absent = true;
|
||||
break;
|
||||
case 'B':
|
||||
// B-centered: h + l must be even
|
||||
if (odd(h + l))
|
||||
absent = true;
|
||||
break;
|
||||
case 'C':
|
||||
// C-centered: h + k must be even
|
||||
if (odd(h + k))
|
||||
absent = true;
|
||||
break;
|
||||
case 'F': { // Face-centered: h, k, l all even or all odd
|
||||
if (odd(h+k) || odd(h+l) || odd(k+l))
|
||||
absent = true;
|
||||
break;
|
||||
}
|
||||
case 'R': {
|
||||
// Rhombohedral in hexagonal setting (hR, a_h=b_h, γ=120°):
|
||||
// Reflection condition: -h + k + l = 3n (equivalently h - k + l = 3n)
|
||||
int mod = (-h + k + l) % 3;
|
||||
if (mod < 0) mod += 3;
|
||||
if (mod != 0)
|
||||
absent = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// P or unspecified: no systematic absences
|
||||
break;
|
||||
}
|
||||
|
||||
if (absent)
|
||||
if (systematic_absence(h, k, l, settings.centering))
|
||||
continue;
|
||||
|
||||
if (i >= max_reflections)
|
||||
|
||||
@@ -8,6 +8,7 @@ ADD_LIBRARY(JFJochBraggIntegration STATIC
|
||||
CalcISigma.h
|
||||
BraggPredictionFactory.cpp
|
||||
BraggPredictionFactory.h
|
||||
SystematicAbsence.h
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES(JFJochBraggIntegration JFJochCommon)
|
||||
|
||||
26
image_analysis/bragg_integration/SystematicAbsence.h
Normal file
26
image_analysis/bragg_integration/SystematicAbsence.h
Normal file
@@ -0,0 +1,26 @@
|
||||
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
#ifndef JFJOCH_SYSTEMATICABSENCE_H
|
||||
#define JFJOCH_SYSTEMATICABSENCE_H
|
||||
|
||||
static inline bool odd_int(int v) { return (v & 1) != 0; }
|
||||
|
||||
static inline bool systematic_absence(int h, int k, int l, char centering) {
|
||||
if (h == 0 && k == 0 && l == 0) return true;
|
||||
switch (centering) {
|
||||
case 'I': return odd_int(h + k + l);
|
||||
case 'A': return odd_int(k + l);
|
||||
case 'B': return odd_int(h + l);
|
||||
case 'C': return odd_int(h + k);
|
||||
case 'F': return (odd_int(h + k) || odd_int(h + l) || odd_int(k + l));
|
||||
case 'R': {
|
||||
int mod = (-h + k + l) % 3;
|
||||
if (mod < 0) mod += 3;
|
||||
return mod != 0;
|
||||
}
|
||||
default: return false; // P
|
||||
}
|
||||
}
|
||||
|
||||
#endif //JFJOCH_SYSTEMATICABSENCE_H
|
||||
Reference in New Issue
Block a user