From 7ee58c5e8fde8a223d686a18ef6d3947caaa9c53 Mon Sep 17 00:00:00 2001 From: Vickie Lynch <lynchve@ornl.gov> Date: Wed, 5 Dec 2018 09:15:01 -0500 Subject: [PATCH] Refs #22420 clang-format --- .../MantidCrystal/FindUBUsingIndexedPeaks.h | 2 +- .../Crystal/inc/MantidCrystal/LoadIsawUB.h | 2 +- .../inc/MantidCrystal/PredictSatellitePeaks.h | 3 +- .../Crystal/src/FindUBUsingIndexedPeaks.cpp | 38 +++++++++---------- Framework/Crystal/src/IndexPeaks.cpp | 19 +++++----- .../Crystal/src/IndexPeaksWithSatellites.cpp | 5 ++- .../Crystal/src/PredictSatellitePeaks.cpp | 24 +++++------- .../test/FindUBUsingIndexedPeaksTest.h | 9 +++-- Framework/Kernel/src/V3D.cpp | 23 ++++++----- .../MDAlgorithms/test/Integrate3DEventsTest.h | 11 +++--- .../IntegrateEllipsoidsWithSatellitesTest.h | 12 +++--- 11 files changed, 72 insertions(+), 76 deletions(-) diff --git a/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h b/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h index 37a34ee5e5e..6aaa4bfd9c0 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h @@ -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 { diff --git a/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h b/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h index 7dd04d8e65b..8a3433288f7 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h @@ -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 { diff --git a/Framework/Crystal/inc/MantidCrystal/PredictSatellitePeaks.h b/Framework/Crystal/inc/MantidCrystal/PredictSatellitePeaks.h index b0c14e2b0ea..9275dfaefa6 100644 --- a/Framework/Crystal/inc/MantidCrystal/PredictSatellitePeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/PredictSatellitePeaks.h @@ -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, diff --git a/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp b/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp index d1c9492a800..03bb761d0a2 100644 --- a/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp +++ b/Framework/Crystal/src/FindUBUsingIndexedPeaks.cpp @@ -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 diff --git a/Framework/Crystal/src/IndexPeaks.cpp b/Framework/Crystal/src/IndexPeaks.cpp index 726d6d0b145..39731bee085 100644 --- a/Framework/Crystal/src/IndexPeaks.cpp +++ b/Framework/Crystal/src/IndexPeaks.cpp @@ -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)); diff --git a/Framework/Crystal/src/IndexPeaksWithSatellites.cpp b/Framework/Crystal/src/IndexPeaksWithSatellites.cpp index b3483b10b5c..82c382a2d7c 100644 --- a/Framework/Crystal/src/IndexPeaksWithSatellites.cpp +++ b/Framework/Crystal/src/IndexPeaksWithSatellites.cpp @@ -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 diff --git a/Framework/Crystal/src/PredictSatellitePeaks.cpp b/Framework/Crystal/src/PredictSatellitePeaks.cpp index c8c47d44c66..3827fa7ccb8 100644 --- a/Framework/Crystal/src/PredictSatellitePeaks.cpp +++ b/Framework/Crystal/src/PredictSatellitePeaks.cpp @@ -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) && diff --git a/Framework/Crystal/test/FindUBUsingIndexedPeaksTest.h b/Framework/Crystal/test/FindUBUsingIndexedPeaksTest.h index a657f676b6a..ccd14cabc4c 100644 --- a/Framework/Crystal/test/FindUBUsingIndexedPeaksTest.h +++ b/Framework/Crystal/test/FindUBUsingIndexedPeaksTest.h @@ -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); diff --git a/Framework/Kernel/src/V3D.cpp b/Framework/Kernel/src/V3D.cpp index a2315c07fd9..a472c4e5ef3 100644 --- a/Framework/Kernel/src/V3D.cpp +++ b/Framework/Kernel/src/V3D.cpp @@ -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 diff --git a/Framework/MDAlgorithms/test/Integrate3DEventsTest.h b/Framework/MDAlgorithms/test/Integrate3DEventsTest.h index 030cf9c32f7..5e289b8439a 100644 --- a/Framework/MDAlgorithms/test/Integrate3DEventsTest.h +++ b/Framework/MDAlgorithms/test/Integrate3DEventsTest.h @@ -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); diff --git a/Framework/MDAlgorithms/test/IntegrateEllipsoidsWithSatellitesTest.h b/Framework/MDAlgorithms/test/IntegrateEllipsoidsWithSatellitesTest.h index 34b02803a9d..4e77b6a0f99 100644 --- a/Framework/MDAlgorithms/test/IntegrateEllipsoidsWithSatellitesTest.h +++ b/Framework/MDAlgorithms/test/IntegrateEllipsoidsWithSatellitesTest.h @@ -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() { -- GitLab