Commit f6908942 authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #22420 clang-format

parent a0f6aacb
......@@ -2,9 +2,9 @@
#define MANTID_CRYSTAL_INDEX_PEAKS_WITH_SATELLITES_H_
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Peak.h"
#include "MantidKernel/System.h"
#include "MantidKernel/V3D.h"
#include "MantidDataObjects/Peak.h"
namespace Mantid {
namespace Crystal {
......@@ -63,14 +63,15 @@ private:
/// Run the algorithm
void exec() override;
void predictOffsets(
DataObjects::Peak &peak, int &sate_indexed,
double &satetolerance, double &satellite_error,
Kernel::V3D offsets, int &maxOrder, Kernel::V3D &hkl);
void predictOffsetsWithCrossTerms(
DataObjects::Peak &peak, int &sate_indexed,
double &satetolerance, double &satellite_error,
Kernel::V3D offsets1, Kernel::V3D offsets2, Kernel::V3D offsets3, int &maxOrder, Kernel::V3D &hkl);
void predictOffsets(DataObjects::Peak &peak, int &sate_indexed,
double &satetolerance, double &satellite_error,
Kernel::V3D offsets, int &maxOrder, Kernel::V3D &hkl);
void predictOffsetsWithCrossTerms(DataObjects::Peak &peak, int &sate_indexed,
double &satetolerance,
double &satellite_error,
Kernel::V3D offsets1, Kernel::V3D offsets2,
Kernel::V3D offsets3, int &maxOrder,
Kernel::V3D &hkl);
Kernel::V3D getOffsetVector(const std::string &label);
};
......
......@@ -246,11 +246,16 @@ void IndexPeakswithSatellites::exec() {
l_error = fabs(round(hkl[2]) - hkl[2]);
main_error += h_error + k_error + l_error;
} else if (!crossTerms) {
predictOffsets(peak, sate_indexed, satetolerance, satellite_error, offsets1, maxOrder, hkl);
predictOffsets(peak, sate_indexed, satetolerance, satellite_error, offsets2, maxOrder, hkl);
predictOffsets(peak, sate_indexed, satetolerance, satellite_error, offsets3, maxOrder, hkl);
predictOffsets(peak, sate_indexed, satetolerance, satellite_error,
offsets1, maxOrder, hkl);
predictOffsets(peak, sate_indexed, satetolerance, satellite_error,
offsets2, maxOrder, hkl);
predictOffsets(peak, sate_indexed, satetolerance, satellite_error,
offsets3, maxOrder, hkl);
} else {
predictOffsetsWithCrossTerms(peak, sate_indexed, satetolerance, satellite_error, offsets1, offsets2, offsets3, maxOrder, hkl);
predictOffsetsWithCrossTerms(peak, sate_indexed, satetolerance,
satellite_error, offsets1, offsets2,
offsets3, maxOrder, hkl);
}
}
}
......@@ -289,64 +294,67 @@ void IndexPeakswithSatellites::exec() {
setProperty("MainError", main_error);
setProperty("SatelliteError", satellite_error);
}
void IndexPeakswithSatellites::predictOffsets(
Peak &peak, int &sate_indexed,
double &satetolerance, double &satellite_error,
V3D offsets, int &maxOrder, V3D &hkl) {
if (offsets != V3D(0,0,0)) {
for (int order = -maxOrder; order <= maxOrder; order++) {
if (order == 0)
continue; // exclude order 0
V3D hkl1(hkl);
hkl1[0] -= order * offsets[0];
hkl1[1] -= order * offsets[1];
hkl1[2] -= order * offsets[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(order, 0, 0));
sate_indexed++;
double h_error = fabs(round(hkl1[0]) - hkl1[0]);
double k_error = fabs(round(hkl1[1]) - hkl1[1]);
double l_error = fabs(round(hkl1[2]) - hkl1[2]);
satellite_error += h_error + k_error + l_error;
}
}
}
void IndexPeakswithSatellites::predictOffsets(Peak &peak, int &sate_indexed,
double &satetolerance,
double &satellite_error,
V3D offsets, int &maxOrder,
V3D &hkl) {
if (offsets != V3D(0, 0, 0)) {
for (int order = -maxOrder; order <= maxOrder; order++) {
if (order == 0)
continue; // exclude order 0
V3D hkl1(hkl);
hkl1[0] -= order * offsets[0];
hkl1[1] -= order * offsets[1];
hkl1[2] -= order * offsets[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(order, 0, 0));
sate_indexed++;
double h_error = fabs(round(hkl1[0]) - hkl1[0]);
double k_error = fabs(round(hkl1[1]) - hkl1[1]);
double l_error = fabs(round(hkl1[2]) - hkl1[2]);
satellite_error += h_error + k_error + l_error;
}
}
}
}
void IndexPeakswithSatellites::predictOffsetsWithCrossTerms(
Peak &peak, int &sate_indexed,
double &satetolerance, double &satellite_error,
V3D offsets1, V3D offsets2, V3D offsets3, int &maxOrder, V3D &hkl) {
DblMatrix offsetsMat(3, 3);
offsetsMat.setColumn(0, offsets1);
offsetsMat.setColumn(1, offsets2);
offsetsMat.setColumn(2, offsets3);
int maxOrder1 = maxOrder;
if (offsets1 == V3D(0, 0, 0)) maxOrder1 = 0;
int maxOrder2 = maxOrder;
if (offsets2 == V3D(0, 0, 0)) maxOrder2 = 0;
int maxOrder3 = maxOrder;
if (offsets3 == V3D(0, 0, 0)) maxOrder3 = 0;
for (int m = -maxOrder1; m <= maxOrder1; m++)
for (int n = -maxOrder2; n <= maxOrder2; n++)
for (int p = -maxOrder3; p <= maxOrder3; p++) {
if (m == 0 && n == 0 && p == 0)
continue; // exclude 0,0,0
V3D hkl1(hkl);
V3D mnp = V3D(m, n, p);
hkl1 -= offsetsMat * mnp;
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(m, n, p));
sate_indexed++;
V3D intHkl = hkl1;
intHkl.round();
hkl1 = intHkl - hkl1;
satellite_error +=
fabs(hkl1[0]) + fabs(hkl1[1]) + fabs(hkl1[2]);
}
}
Peak &peak, int &sate_indexed, double &satetolerance,
double &satellite_error, V3D offsets1, V3D offsets2, V3D offsets3,
int &maxOrder, V3D &hkl) {
DblMatrix offsetsMat(3, 3);
offsetsMat.setColumn(0, offsets1);
offsetsMat.setColumn(1, offsets2);
offsetsMat.setColumn(2, offsets3);
int maxOrder1 = maxOrder;
if (offsets1 == V3D(0, 0, 0))
maxOrder1 = 0;
int maxOrder2 = maxOrder;
if (offsets2 == V3D(0, 0, 0))
maxOrder2 = 0;
int maxOrder3 = maxOrder;
if (offsets3 == V3D(0, 0, 0))
maxOrder3 = 0;
for (int m = -maxOrder1; m <= maxOrder1; m++)
for (int n = -maxOrder2; n <= maxOrder2; n++)
for (int p = -maxOrder3; p <= maxOrder3; p++) {
if (m == 0 && n == 0 && p == 0)
continue; // exclude 0,0,0
V3D hkl1(hkl);
V3D mnp = V3D(m, n, p);
hkl1 -= offsetsMat * mnp;
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(m, n, p));
sate_indexed++;
V3D intHkl = hkl1;
intHkl.round();
hkl1 = intHkl - hkl1;
satellite_error += fabs(hkl1[0]) + fabs(hkl1[1]) + fabs(hkl1[2]);
}
}
}
V3D IndexPeakswithSatellites::getOffsetVector(const std::string &label) {
vector<double> offsets = getProperty(label);
......
......@@ -344,11 +344,14 @@ void PredictSatellitePeaks::predictOffsetsWithCrossTerms(
offsetsMat.setColumn(1, offsets2);
offsetsMat.setColumn(2, offsets3);
int maxOrder1 = maxOrder;
if (offsets1 == V3D(0, 0, 0)) maxOrder1 = 0;
if (offsets1 == V3D(0, 0, 0))
maxOrder1 = 0;
int maxOrder2 = maxOrder;
if (offsets2 == V3D(0, 0, 0)) maxOrder2 = 0;
if (offsets2 == V3D(0, 0, 0))
maxOrder2 = 0;
int maxOrder3 = maxOrder;
if (offsets3 == V3D(0, 0, 0)) maxOrder3 = 0;
if (offsets3 == V3D(0, 0, 0))
maxOrder3 = 0;
for (int m = -maxOrder1; m <= maxOrder1; m++)
for (int n = -maxOrder2; n <= maxOrder2; n++)
for (int p = -maxOrder3; p <= maxOrder3; p++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment