Commit 67db74e2 authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #22420 use 0 based indexing

parent 7b52a8a3
......@@ -56,9 +56,8 @@ void FindUBUsingIndexedPeaks::exec() {
int ModDim = 0;
int MaxOrder = 0;
bool CrossTerm = false;
std::vector<V3D> errorHKL;
DblMatrix errorHKL(3, 3);
errorHKL.reserve(3);
q_vectors.reserve(n_peaks);
hkl_vectors.reserve(n_peaks);
mnp_vectors.reserve(n_peaks);
......@@ -181,12 +180,12 @@ void FindUBUsingIndexedPeaks::exec() {
V3D fhkl(run_fhkl_vectors[i]);
for (int j = 0; j < 3; j++) {
if (run_mnp_vectors[i][j] != 0) {
fhkl -= run_lattice.getModVec(j+1) * run_mnp_vectors[i][j];
fhkl -= run_lattice.getModVec(j) * run_mnp_vectors[i][j];
if (IndexingUtils::ValidIndex(fhkl, satetolerance)) {
sate_indexed++;
V3D errhkl = fhkl - run_hkl_vectors[i];
errhkl = errhkl.absoluteValue();
errorHKL[j] += errhkl;
for (int k = 0; k < 3; k++) errorHKL[k][j] += errhkl[k];
}
}
}
......@@ -207,12 +206,8 @@ void FindUBUsingIndexedPeaks::exec() {
o_lattice.setError(sigabc[0], sigabc[1], sigabc[2], sigabc[3], sigabc[4],
sigabc[5]);
double ind_count_inv = 1. / static_cast<double>(indexed_count);
o_lattice.setErrorModHKL(
errorHKL[0][0] * ind_count_inv, errorHKL[1][0] * ind_count_inv,
errorHKL[2][0] * ind_count_inv, errorHKL[0][1] * ind_count_inv,
errorHKL[1][1] * ind_count_inv, errorHKL[2][1] * ind_count_inv,
errorHKL[0][2] * ind_count_inv, errorHKL[1][2] * ind_count_inv,
errorHKL[2][2] * ind_count_inv);
errorHKL *= ind_count_inv;
o_lattice.setErrorModHKL(errorHKL);
o_lattice.setMaxOrder(MaxOrder);
o_lattice.setCrossTerm(CrossTerm);
......@@ -228,7 +223,7 @@ void FindUBUsingIndexedPeaks::logLattice(OrientedLattice &o_lattice,
// Show the modified lattice parameters
g_log.notice() << o_lattice << "\n";
g_log.notice() << "Modulation Dimension is: " << ModDim << "\n";
for (int i = 1; i < ModDim + 1; i++) {
for (int i = 0; i < ModDim; i++) {
g_log.notice() << "Modulation Vector " << i << ": "
<< o_lattice.getModVec(i) << "\n";
g_log.notice() << "Modulation Vector " << i
......
......@@ -112,8 +112,8 @@ void IndexPeaks::exec() {
std::vector<V3D> q_vectors;
q_vectors.reserve(n_peaks);
for (size_t i = 0; i < n_peaks; i++) {
q_vectors.push_back(peaks[i].getQSampleFrame());
for (auto& peak : peaks) {
q_vectors.push_back(peak.getQSampleFrame());
}
total_indexed = IndexingUtils::CalculateMillerIndices(
......@@ -121,9 +121,7 @@ void IndexPeaks::exec() {
for (size_t i = 0; i < n_peaks; i++) {
peaks[i].setHKL(miller_indices[i]);
peaks[i].setIntHKL(V3D(round(miller_indices[i][0]),
round(miller_indices[i][1]),
round(miller_indices[i][2])));
peaks[i].setIntHKL(miller_indices[i]);
peaks[i].setIntMNP(V3D(0, 0, 0));
}
} else {
......@@ -134,8 +132,8 @@ void IndexPeaks::exec() {
// get list of run numbers in this peaks workspace
std::vector<int> run_numbers;
for (size_t i = 0; i < n_peaks; i++) {
int run = peaks[i].getRunNumber();
for (auto& peak : peaks) {
int run = peak.getRunNumber();
bool found = false;
size_t k = 0;
while (k < run_numbers.size() && !found) {
......@@ -156,9 +154,9 @@ void IndexPeaks::exec() {
std::vector<V3D> q_vectors;
int run = run_numbers[run_index];
for (size_t i = 0; i < n_peaks; i++) {
if (peaks[i].getRunNumber() == run)
q_vectors.push_back(peaks[i].getQSampleFrame());
for (auto& peak : peaks) {
if (peak.getRunNumber() == run)
q_vectors.push_back(peak.getQSampleFrame());
}
Matrix<double> tempUB(UB);
......@@ -230,14 +228,11 @@ void IndexPeaks::exec() {
}
size_t miller_index_counter = 0;
for (size_t i = 0; i < n_peaks; i++) {
if (peaks[i].getRunNumber() == run) {
peaks[i].setHKL(miller_indices[miller_index_counter]);
peaks[i].setIntHKL(
V3D(round(miller_indices[miller_index_counter][0]),
round(miller_indices[miller_index_counter][1]),
round(miller_indices[miller_index_counter][2])));
peaks[i].setIntMNP(V3D(0, 0, 0));
for (auto& peak : peaks) {
if (peak.getRunNumber() == run) {
peak.setHKL(miller_indices[miller_index_counter]);
peak.setIntHKL(miller_indices[miller_index_counter]);
peak.setIntMNP(V3D(0, 0, 0));
miller_index_counter++;
}
}
......@@ -248,10 +243,10 @@ void IndexPeaks::exec() {
double main_error = 0;
double sate_error = 0;
int maxOrder = o_lattice.getMaxOrder();
bool CT = o_lattice.getCrossTerm();
V3D offsets1 = o_lattice.getModVec(1);
V3D offsets2 = o_lattice.getModVec(2);
V3D offsets3 = o_lattice.getModVec(3);
bool crossTerm = o_lattice.getCrossTerm();
V3D offsets1 = o_lattice.getModVec(0);
V3D offsets2 = o_lattice.getModVec(1);
V3D offsets3 = o_lattice.getModVec(2);
if (offsets1 == V3D(0, 0, 0))
throw std::runtime_error("Invalid Modulation Vector");
......@@ -267,30 +262,27 @@ void IndexPeaks::exec() {
// Index satellite peaks
size_t miller_index_counter = 0;
for (size_t i = 0; i < n_peaks; i++) {
if (peaks[i].getRunNumber() == run) {
peaks[i].setHKL(miller_indices[miller_index_counter]);
for (auto& peak : peaks) {
if (peak.getRunNumber() == run) {
peak.setHKL(miller_indices[miller_index_counter]);
miller_index_counter++;
V3D hkl;
hkl[0] = peaks[i].getH();
hkl[1] = peaks[i].getK();
hkl[2] = peaks[i].getL();
auto hkl = peak.getHKL();
double h_error;
double k_error;
double l_error;
bool suc_indexed = false;
if (IndexingUtils::ValidIndex(hkl, tolerance)) {
peaks[i].setIntHKL(hkl);
peaks[i].setIntMNP(V3D(0, 0, 0));
peak.setIntHKL(hkl);
peak.setIntMNP(V3D(0, 0, 0));
suc_indexed = true;
main_indexed++;
h_error = fabs(round(hkl[0]) - hkl[0]);
k_error = fabs(round(hkl[1]) - hkl[1]);
l_error = fabs(round(hkl[2]) - hkl[2]);
main_error += h_error + k_error + l_error;
} else if (!CT) {
} else if (!crossTerm) {
if (ModDim > 0) {
for (int order = -maxOrder; order <= maxOrder; order++) {
if (order == 0)
......@@ -300,8 +292,8 @@ void IndexPeaks::exec() {
hkl1[1] -= order * offsets1[1];
hkl1[2] -= order * offsets1[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peaks[i].setIntHKL(hkl1);
peaks[i].setIntMNP(V3D(order, 0, 0));
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(order, 0, 0));
suc_indexed = true;
sate_indexed++;
h_error = fabs(round(hkl1[0]) - hkl1[0]);
......@@ -320,8 +312,8 @@ void IndexPeaks::exec() {
hkl1[1] -= order * offsets2[1];
hkl1[2] -= order * offsets2[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peaks[i].setIntHKL(hkl1);
peaks[i].setIntMNP(V3D(0, order, 0));
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(0, order, 0));
suc_indexed = true;
sate_indexed++;
h_error = fabs(round(hkl1[0]) - hkl1[0]);
......@@ -340,8 +332,8 @@ void IndexPeaks::exec() {
hkl1[1] -= order * offsets3[1];
hkl1[2] -= order * offsets3[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peaks[i].setIntHKL(hkl1);
peaks[i].setIntMNP(V3D(0, 0, order));
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(0, 0, order));
suc_indexed = true;
sate_indexed++;
h_error = fabs(round(hkl1[0]) - hkl1[0]);
......@@ -361,8 +353,8 @@ void IndexPeaks::exec() {
hkl1[1] -= order * offsets1[1];
hkl1[2] -= order * offsets1[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peaks[i].setIntHKL(hkl1);
peaks[i].setIntMNP(V3D(order, 0, 0));
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(order, 0, 0));
suc_indexed = true;
sate_indexed++;
h_error = fabs(round(hkl1[0]) - hkl1[0]);
......@@ -382,8 +374,8 @@ void IndexPeaks::exec() {
hkl1[1] -= m * offsets1[1] + n * offsets2[1];
hkl1[2] -= m * offsets1[2] + n * offsets2[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peaks[i].setIntHKL(hkl1);
peaks[i].setIntMNP(V3D(m, n, 0));
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(m, n, 0));
suc_indexed = true;
sate_indexed++;
h_error = fabs(round(hkl1[0]) - hkl1[0]);
......@@ -407,8 +399,8 @@ void IndexPeaks::exec() {
hkl1[2] -=
m * offsets1[2] + n * offsets2[2] + p * offsets3[2];
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peaks[i].setIntHKL(hkl1);
peaks[i].setIntMNP(V3D(m, n, p));
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(m, n, p));
suc_indexed = true;
sate_indexed++;
h_error = fabs(round(hkl1[0]) - hkl1[0]);
......@@ -420,8 +412,8 @@ void IndexPeaks::exec() {
}
}
if (!suc_indexed) {
peaks[i].setIntHKL(V3D(0, 0, 0));
peaks[i].setIntMNP(V3D(0, 0, 0));
peak.setIntHKL(V3D(0, 0, 0));
peak.setIntMNP(V3D(0, 0, 0));
}
}
}
......
......@@ -125,9 +125,9 @@ void IndexPeaksWithSatellites::exec() {
OrientedLattice o_lattice = sample.getOrientedLattice();
if (getProperty("GetModVectorsFromUB")) {
offsets1 = o_lattice.getModVec(1);
offsets2 = o_lattice.getModVec(2);
offsets3 = o_lattice.getModVec(3);
offsets1 = o_lattice.getModVec(0);
offsets2 = o_lattice.getModVec(1);
offsets3 = o_lattice.getModVec(2);
if (maxOrder == 0)
maxOrder = o_lattice.getMaxOrder();
CT = o_lattice.getCrossTerm();
......
......@@ -154,9 +154,9 @@ void PredictSatellitePeaks::exec() {
OrientedLattice lattice = sample.getOrientedLattice();
if (getProperty("GetModVectorsFromUB")) {
offsets1 = lattice.getModVec(1);
offsets2 = lattice.getModVec(2);
offsets3 = lattice.getModVec(3);
offsets1 = lattice.getModVec(0);
offsets2 = lattice.getModVec(1);
offsets3 = lattice.getModVec(2);
if (maxOrder == 0)
maxOrder = lattice.getMaxOrder();
}
......@@ -258,9 +258,9 @@ void PredictSatellitePeaks::exec_peaks() {
OrientedLattice lattice = sample.getOrientedLattice();
if (getProperty("GetModVectorsFromUB")) {
offsets1 = lattice.getModVec(1);
offsets2 = lattice.getModVec(2);
offsets3 = lattice.getModVec(3);
offsets1 = lattice.getModVec(0);
offsets2 = lattice.getModVec(1);
offsets3 = lattice.getModVec(2);
if (maxOrder == 0)
maxOrder = lattice.getMaxOrder();
}
......
......@@ -126,7 +126,7 @@ void SaveIsawUB::exec() {
int ModDim = 0;
for (int i = 0; i < 3; i++) {
if (lattice.getModVec(i + 1) == V3D(0, 0, 0))
if (lattice.getModVec(i) == V3D(0, 0, 0))
continue;
else
ModDim++;
......
......@@ -2888,9 +2888,9 @@ int IndexingUtils::GetModulationVectors(const DblMatrix &UB,
o_lattice.setUB(UB);
o_lattice.setModUB(ModUB);
ModVec1 = o_lattice.getModVec(1);
ModVec2 = o_lattice.getModVec(2);
ModVec3 = o_lattice.getModVec(3);
ModVec1 = o_lattice.getModVec(0);
ModVec2 = o_lattice.getModVec(1);
ModVec3 = o_lattice.getModVec(2);
int ModDim = 0;
if (o_lattice.getdh(1) != 0.0 || o_lattice.getdk(1) != 0.0 ||
......
......@@ -572,42 +572,42 @@ const Kernel::DblMatrix &UnitCell::getModHKL() const { return ModHKL; }
@return dh :: dh of modulation vector
*/
double UnitCell::getdh(int j) const { return ModHKL[0][j - 1]; }
double UnitCell::getdh(int j) const { return ModHKL[0][j]; }
/** Get modulation vectors for satellites
@param j index of vector to get
@return ModVec :: modulation vector
*/
double UnitCell::getdk(int j) const { return ModHKL[1][j - 1]; }
double UnitCell::getdk(int j) const { return ModHKL[1][j]; }
/** Get modulation vectors for satellites
@param j index of vector to get
@return ModVec :: modulation vector
*/
double UnitCell::getdl(int j) const { return ModHKL[2][j - 1]; }
double UnitCell::getdl(int j) const { return ModHKL[2][j]; }
/** Get error of modulation vectors for satellites
@param j index of vector to get
@return ModVecErr :: error of modulation vector
*/
double UnitCell::getdherr(int j) const { return errorModHKL[0][j - 1]; }
double UnitCell::getdherr(int j) const { return errorModHKL[0][j]; }
/** Get error of modulation vectors for satellites
@param j index of vector to get
@return ModVecErr :: error of modulation vector
*/
double UnitCell::getdkerr(int j) const { return errorModHKL[1][j - 1]; }
double UnitCell::getdkerr(int j) const { return errorModHKL[1][j]; }
/** Get error of modulation vectors for satellites
@param j index of vector to get
@return ModVecErr :: error of modulation vector
*/
double UnitCell::getdlerr(int j) const { return errorModHKL[2][j - 1]; }
double UnitCell::getdlerr(int j) const { return errorModHKL[2][j]; }
/** Get max order
@return MaxOrder :: maximum order
......
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