Commit 7ee58c5e authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #22420 clang-format

parent 1d8a5421
......@@ -8,9 +8,9 @@
#define MANTID_CRYSTAL_FIND_UB_USING_INDEXED_PEAKS_H_
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Peak.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidKernel/System.h"
#include "MantidDataObjects/Peak.h"
namespace Mantid {
namespace Crystal {
......
......@@ -8,8 +8,8 @@
#define MANTID_CRYSTAL_LOADISAWUB_H_
#include "MantidAPI/Algorithm.h"
#include "MantidKernel/System.h"
#include "MantidKernel/Matrix.h"
#include "MantidKernel/System.h"
namespace Mantid {
namespace Crystal {
......
......@@ -70,8 +70,7 @@ private:
void exec() override;
void exec_peaks();
Kernel::V3D getOffsetVector(const std::string &label);
void predictOffsets(
int iVector, Kernel::V3D offsets, int &maxOrder,
void predictOffsets(int iVector, Kernel::V3D offsets, int &maxOrder,
Kernel::V3D &hkl,
Geometry::HKLFilterWavelength &lambdaFilter,
bool &includePeaksInRange, bool &includeOrderZero,
......
......@@ -82,8 +82,7 @@ void FindUBUsingIndexedPeaks::exec() {
if (mnp[0] * mnp[1] != 0 || mnp[1] * mnp[2] != 0 || mnp[2] * mnp[0] != 0)
CrossTerm = true;
if (isPeakIndexed(peak))
{
if (isPeakIndexed(peak)) {
q_vectors.push_back(peak.getQSampleFrame());
hkl_vectors.push_back(hkl);
mnp_vectors.push_back(mnp);
......@@ -91,7 +90,7 @@ void FindUBUsingIndexedPeaks::exec() {
}
}
//too few indexed peaks to work with
// too few indexed peaks to work with
if (indexed_count < MIN_INDEXED_PEAKS) {
throw std::runtime_error(
"At least three linearly independent indexed peaks are needed.");
......@@ -114,7 +113,7 @@ void FindUBUsingIndexedPeaks::exec() {
{ // from the full list of peaks, and
q_vectors.clear(); // save the UB in the sample
q_vectors.reserve(n_peaks);
for (auto & peak : peaks) {
for (auto &peak : peaks) {
q_vectors.push_back(peak.getQSampleFrame());
}
......@@ -170,14 +169,14 @@ void FindUBUsingIndexedPeaks::exec() {
rsigabc[4], rsigabc[5]);
g_log.notice() << run_lattice << "\n";
double average_error = 0.;
IndexingUtils::CalculateMillerIndices(
UB, run_q_vectors, 1.0, run_fhkl_vectors, average_error);
for (size_t i = 0; i < run_indexed; i++) {
if (IndexingUtils::ValidIndex(run_fhkl_vectors[i], tolerance))
continue;
double average_error = 0.;
IndexingUtils::CalculateMillerIndices(UB, run_q_vectors, 1.0,
run_fhkl_vectors, average_error);
for (size_t i = 0; i < run_indexed; i++) {
if (IndexingUtils::ValidIndex(run_fhkl_vectors[i], tolerance))
continue;
V3D fhkl(run_fhkl_vectors[i]);
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) * run_mnp_vectors[i][j];
......@@ -185,9 +184,10 @@ void FindUBUsingIndexedPeaks::exec() {
sate_indexed++;
V3D errhkl = fhkl - run_hkl_vectors[i];
errhkl = errhkl.absoluteValue();
for (int k = 0; k < 3; k++) errorHKL[k][j] += errhkl[k];
for (int k = 0; k < 3; k++)
errorHKL[k][j] += errhkl[k];
}
}
}
}
}
}
......@@ -224,17 +224,17 @@ void FindUBUsingIndexedPeaks::logLattice(OrientedLattice &o_lattice,
g_log.notice() << o_lattice << "\n";
g_log.notice() << "Modulation Dimension is: " << ModDim << "\n";
for (int i = 0; i < ModDim; i++) {
g_log.notice() << "Modulation Vector " << i+1 << ": "
g_log.notice() << "Modulation Vector " << i + 1 << ": "
<< o_lattice.getModVec(i) << "\n";
g_log.notice() << "Modulation Vector " << i+1
g_log.notice() << "Modulation Vector " << i + 1
<< " error: " << o_lattice.getVecErr(i) << "\n";
}
}
bool FindUBUsingIndexedPeaks::isPeakIndexed(Peak &peak) {
V3D hkl(peak.getIntHKL()); // ##### KEEP
V3D mnp(peak.getIntMNP());
return (IndexingUtils::ValidIndex(hkl, 1.0) ||
IndexingUtils::ValidIndex(mnp, 1.0));
V3D hkl(peak.getIntHKL()); // ##### KEEP
V3D mnp(peak.getIntMNP());
return (IndexingUtils::ValidIndex(hkl, 1.0) ||
IndexingUtils::ValidIndex(mnp, 1.0));
}
} // namespace Crystal
} // namespace Mantid
......@@ -112,7 +112,7 @@ void IndexPeaks::exec() {
std::vector<V3D> q_vectors;
q_vectors.reserve(n_peaks);
for (auto& peak : peaks) {
for (auto &peak : peaks) {
q_vectors.push_back(peak.getQSampleFrame());
}
......@@ -132,7 +132,7 @@ void IndexPeaks::exec() {
// get list of run numbers in this peaks workspace
std::vector<int> run_numbers;
for (auto& peak : peaks) {
for (auto &peak : peaks) {
int run = peak.getRunNumber();
bool found = false;
size_t k = 0;
......@@ -154,7 +154,7 @@ void IndexPeaks::exec() {
std::vector<V3D> q_vectors;
int run = run_numbers[run_index];
for (auto& peak : peaks) {
for (auto &peak : peaks) {
if (peak.getRunNumber() == run)
q_vectors.push_back(peak.getQSampleFrame());
}
......@@ -228,7 +228,7 @@ void IndexPeaks::exec() {
}
size_t miller_index_counter = 0;
for (auto& peak : peaks) {
for (auto &peak : peaks) {
if (peak.getRunNumber() == run) {
peak.setHKL(miller_indices[miller_index_counter]);
peak.setIntHKL(miller_indices[miller_index_counter]);
......@@ -262,7 +262,7 @@ void IndexPeaks::exec() {
// Index satellite peaks
size_t miller_index_counter = 0;
for (auto& peak : peaks) {
for (auto &peak : peaks) {
if (peak.getRunNumber() == run) {
peak.setHKL(miller_indices[miller_index_counter]);
miller_index_counter++;
......@@ -297,7 +297,7 @@ void IndexPeaks::exec() {
if (order == 0)
continue; // exclude order 0
V3D hkl1(hkl);
hkl1 -= offsets2* order;
hkl1 -= offsets2 * order;
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(0, order, 0));
......@@ -328,7 +328,7 @@ void IndexPeaks::exec() {
if (order == 0)
continue; // exclude order 0
V3D hkl1(hkl);
hkl1 -= offsets1 * order;
hkl1 -= offsets1 * order;
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(order, 0, 0));
......@@ -344,7 +344,7 @@ void IndexPeaks::exec() {
if (m == 0 && n == 0)
continue; // exclude 0,0
V3D hkl1(hkl);
hkl1 -= offsets1 * m + offsets2 * n;
hkl1 -= offsets1 * m + offsets2 * n;
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(m, n, 0));
......@@ -361,8 +361,7 @@ void IndexPeaks::exec() {
if (m == 0 && n == 0 && p == 0)
continue; // exclude 0,0,0
V3D hkl1(hkl);
hkl1 -=
offsets1 * m + offsets2 * n + offsets3 * p;
hkl1 -= offsets1 * m + offsets2 * n + offsets3 * p;
if (IndexingUtils::ValidIndex(hkl1, satetolerance)) {
peak.setIntHKL(hkl1);
peak.setIntMNP(V3D(m, n, p));
......
......@@ -178,8 +178,9 @@ void IndexPeaksWithSatellites::exec() {
// get list of run numbers in this peaks workspace
std::unordered_set<int> run_numbers;
transform(peaks.begin(), peaks.end(), std::inserter(run_numbers, run_numbers.begin()),
[] (const auto& peak) { return peak.getRunNumber(); });
transform(peaks.begin(), peaks.end(),
std::inserter(run_numbers, run_numbers.begin()),
[](const auto &peak) { return peak.getRunNumber(); });
// index the peaks for each run separately, using a UB matrix optimized for
// that run
......
......@@ -212,10 +212,9 @@ void PredictSatellitePeaks::exec() {
for (auto it = possibleHKLs.begin(); it != possibleHKLs.end(); ++it) {
V3D hkl = *it;
if (crossTerms) {
predictOffsetsWithCrossTerms(offsets1, offsets2,
offsets3, maxOrder, hkl, lambdaFilter,
includePeaksInRange, includeOrderZero,
AlreadyDonePeaks);
predictOffsetsWithCrossTerms(offsets1, offsets2, offsets3, maxOrder, hkl,
lambdaFilter, includePeaksInRange,
includeOrderZero, AlreadyDonePeaks);
} else {
predictOffsets(0, offsets1, maxOrder, hkl, lambdaFilter,
includePeaksInRange, includeOrderZero, AlreadyDonePeaks);
......@@ -291,10 +290,9 @@ void PredictSatellitePeaks::exec_peaks() {
auto peak = *it;
V3D hkl = peak.getHKL();
if (crossTerms) {
predictOffsetsWithCrossTerms(offsets1, offsets2,
offsets3, maxOrder, hkl, lambdaFilter,
includePeaksInRange, includeOrderZero,
AlreadyDonePeaks);
predictOffsetsWithCrossTerms(offsets1, offsets2, offsets3, maxOrder, hkl,
lambdaFilter, includePeaksInRange,
includeOrderZero, AlreadyDonePeaks);
} else {
predictOffsets(0, offsets1, maxOrder, hkl, lambdaFilter,
includePeaksInRange, includeOrderZero, AlreadyDonePeaks);
......@@ -322,10 +320,9 @@ void PredictSatellitePeaks::exec_peaks() {
}
void PredictSatellitePeaks::predictOffsets(
int indexModulatedVector,
V3D offsets, int &maxOrder, V3D &hkl, HKLFilterWavelength &lambdaFilter,
bool &includePeaksInRange, bool &includeOrderZero,
vector<vector<int>> &AlreadyDonePeaks) {
int indexModulatedVector, V3D offsets, int &maxOrder, V3D &hkl,
HKLFilterWavelength &lambdaFilter, bool &includePeaksInRange,
bool &includeOrderZero, vector<vector<int>> &AlreadyDonePeaks) {
if (offsets == V3D(0, 0, 0))
return;
const Kernel::DblMatrix &UB = Peaks->sample().getOrientedLattice().getUB();
......@@ -379,8 +376,7 @@ void PredictSatellitePeaks::predictOffsets(
}
void PredictSatellitePeaks::predictOffsetsWithCrossTerms(
V3D offsets1,
V3D offsets2, V3D offsets3, int &maxOrder, V3D &hkl,
V3D offsets1, V3D offsets2, V3D offsets3, int &maxOrder, V3D &hkl,
HKLFilterWavelength &lambdaFilter, bool &includePeaksInRange,
bool &includeOrderZero, vector<vector<int>> &AlreadyDonePeaks) {
if (offsets1 == V3D(0, 0, 0) && offsets2 == V3D(0, 0, 0) &&
......
......@@ -14,11 +14,11 @@
#include <cxxtest/TestSuite.h>
#include "MantidCrystal/FindUBUsingIndexedPeaks.h"
#include "MantidCrystal/LoadIsawPeaks.h"
#include "MantidCrystal/LoadIsawUB.h"
#include "MantidDataHandling/LoadNexusProcessed.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidCrystal/LoadIsawPeaks.h"
using namespace Mantid::Crystal;
using Mantid::Geometry::OrientedLattice;
......@@ -102,7 +102,8 @@ public:
const V3D mnp = peak.getIntMNP();
V3D mnpNew = mnp;
srand(0);
if(std::abs(mnp[0]) == 1) mnpNew[1] = rand() % 2;
if (std::abs(mnp[0]) == 1)
mnpNew[1] = rand() % 2;
peak.setIntMNP(mnpNew);
}
FindUBUsingIndexedPeaks alg2;
......@@ -123,8 +124,8 @@ public:
// Check that the UB matrix is the same as in TOPAZ_3007.mat
OrientedLattice latt = ws->mutableSample().getOrientedLattice();
double correct_err1[] = {0.003723,0.002231,0.002820};
double correct_err2[] = {0.000796,0.002043,0.002671};
double correct_err1[] = {0.003723, 0.002231, 0.002820};
double correct_err2[] = {0.000796, 0.002043, 0.002671};
std::vector<double> err_calculated1 = latt.getVecErr(0);
std::vector<double> err_calculated2 = latt.getVecErr(1);
......
......@@ -574,29 +574,28 @@ V3D V3D::directionAngles(bool inDegrees) const {
*/
int V3D::maxCoeff() {
int MaxOrder = 0;
if (abs(static_cast<int>(x)) > MaxOrder)
MaxOrder = abs(static_cast<int>(x));
if (abs(static_cast<int>(y)) > MaxOrder)
MaxOrder = abs(static_cast<int>(y));
if (abs(static_cast<int>(z)) > MaxOrder)
MaxOrder = abs(static_cast<int>(z));
return MaxOrder;
if (abs(static_cast<int>(x)) > MaxOrder)
MaxOrder = abs(static_cast<int>(x));
if (abs(static_cast<int>(y)) > MaxOrder)
MaxOrder = abs(static_cast<int>(y));
if (abs(static_cast<int>(z)) > MaxOrder)
MaxOrder = abs(static_cast<int>(z));
return MaxOrder;
}
/**
Calculates the absolute value.
Calculates the absolute value.
@return The absolute value
*/
V3D V3D::absoluteValue() const {
return V3D(fabs(x), fabs(y), fabs(z));
}
V3D V3D::absoluteValue() const { return V3D(fabs(x), fabs(y), fabs(z)); }
/**
Calculates the error of the HKL to compare with tolerance
@return The error
*/
double V3D::hklError() const {
return fabs(x - std::round(x)) + fabs(y - std::round(y)) + fabs(z - std::round(z));
return fabs(x - std::round(x)) + fabs(y - std::round(y)) +
fabs(z - std::round(z));
}
} // Namespace Kernel
......
......@@ -151,17 +151,15 @@ public:
UBinv.setRow(1, V3D(0, .2, 0));
UBinv.setRow(2, V3D(0, 0, .25));
std::vector<V3D> hkl_list{
UBinv * peak_1, UBinv * peak_2, UBinv * peak_3};
std::vector<V3D> hkl_list{UBinv * peak_1, UBinv * peak_2, UBinv * peak_3};
// synthesize a ModHKL
DblMatrix ModHKL(3, 3, false); // Q to h,k,l
ModHKL.setRow(0, V3D(0.4, 0, 0));
ModHKL.setRow(1, V3D(0, 0, 0));
ModHKL.setRow(2, V3D(0, 0, 0));
std::vector<V3D> mnp_list{
V3D(-1, 0, 0), V3D(0, 0, 0), V3D(0, 0, 0)};
std::vector<V3D> mnp_list{V3D(-1, 0, 0), V3D(0, 0, 0), V3D(0, 0, 0)};
// synthesize events around the
// peaks. All events with in one
......@@ -209,7 +207,8 @@ public:
double radius_s = 0.1;
int maxOrder = 1;
bool crossTerm = false;
Integrate3DEvents integrator(peak_q_list, hkl_list, mnp_list, UBinv, ModHKL, radius, radius_s, maxOrder, crossTerm);
Integrate3DEvents integrator(peak_q_list, hkl_list, mnp_list, UBinv, ModHKL,
radius, radius_s, maxOrder, crossTerm);
integrator.addEvents(event_Qs, false);
......
......@@ -28,9 +28,9 @@ using Mantid::Types::Event::TofEvent;
namespace {
// Add A Fake 'Peak' to both the event data and to the peaks workspace
void addFakeEllipsoid(const V3D &peakHKL, const V3D &peakMNP, const int &totalNPixels,
const int &nEvents, const double tofGap,
EventWorkspace_sptr &eventWS,
void addFakeEllipsoid(const V3D &peakHKL, const V3D &peakMNP,
const int &totalNPixels, const int &nEvents,
const double tofGap, EventWorkspace_sptr &eventWS,
PeaksWorkspace_sptr &peaksWS) {
// Create the peak and add it to the peaks ws
Peak *peak = peaksWS->createPeakHKL(peakHKL);
......@@ -358,7 +358,8 @@ public:
TSM_ASSERT_DELTA("Wrong intensity for peak 0",
integratedPeaksWS->getPeak(0).getIntensity(), 6, 0.01);
TSM_ASSERT_DELTA("Wrong intensity for peak 1",
integratedPeaksWS->getPeak(1).getIntensity(), 10.8964, 0.01);
integratedPeaksWS->getPeak(1).getIntensity(), 10.8964,
0.01);
TSM_ASSERT_DELTA("Wrong intensity for peak 2",
integratedPeaksWS->getPeak(2).getIntensity(), 9, 0.01);
TSM_ASSERT_DELTA("Wrong intensity for peak 3",
......@@ -366,7 +367,8 @@ public:
TSM_ASSERT_DELTA("Wrong intensity for peak 4",
integratedPeaksWS->getPeak(4).getIntensity(), 0, 0.01);
TSM_ASSERT_DELTA("Wrong intensity for peak 5",
integratedPeaksWS->getPeak(5).getIntensity(), 20.9410, 0.01);
integratedPeaksWS->getPeak(5).getIntensity(), 20.9410,
0.01);
}
void test_execution_histograms_adaptive() {
......
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