diff --git a/Framework/Crystal/src/IndexPeaks.cpp b/Framework/Crystal/src/IndexPeaks.cpp index 2ff5722a0e5412830265ee1a5c0e3368c89ccba2..5b285719fa91b1f919c421a65afa976b4fe91a5c 100644 --- a/Framework/Crystal/src/IndexPeaks.cpp +++ b/Framework/Crystal/src/IndexPeaks.cpp @@ -35,6 +35,9 @@ void IndexPeaks::init() { mustBePositive, Direction::Input), "Satellite Indexing Tolerance (0.15)"); + this->declareProperty("RoundHKLs", true, + "Round H, K and L values to integers"); + this->declareProperty("CommonUBForAll", false, "Index all orientations with a common UB"); @@ -85,6 +88,7 @@ void IndexPeaks::exec() { "ERROR: The stored UB is not a valid orientation matrix"); } + bool round_hkls = this->getProperty("RoundHKLs"); bool commonUB = this->getProperty("CommonUBForAll"); std::vector<Peak> &peaks = ws->getPeaks(); @@ -202,8 +206,11 @@ void IndexPeaks::exec() { if (o_lattice.getMaxOrder() == 0) // If data not modulated, recalculate fractional HKL { - num_indexed = IndexingUtils::CalculateMillerIndices( - tempUB, q_vectors, tolerance, miller_indices, average_error); + if (!round_hkls) // If user wants fractional hkls, recalculate them + { + num_indexed = IndexingUtils::CalculateMillerIndices( + tempUB, q_vectors, tolerance, miller_indices, average_error); + } total_indexed += num_indexed; total_error += average_error * num_indexed; diff --git a/Framework/DataObjects/inc/MantidDataObjects/Peak.h b/Framework/DataObjects/inc/MantidDataObjects/Peak.h index a908711e07f84c1fbe65af6af82788b8b74e48f4..222a8edd08bde4426c77d5ff1473a5e08a3b67ef 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Peak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Peak.h @@ -254,7 +254,9 @@ private: Mantid::Kernel::V3D m_modulatedStructure; /// integer HKL of the peak - std::array<int, 3> m_intHKL; + int m_intH; + int m_intK; + int m_intL; /// List of contributing detectors IDs std::set<int> m_detIDs; diff --git a/Framework/DataObjects/src/Peak.cpp b/Framework/DataObjects/src/Peak.cpp index 2f815b58f24cfc86e30fab30d7f5550766760264..6370f0422cc0e18b86443a9567678b49567b1d20 100644 --- a/Framework/DataObjects/src/Peak.cpp +++ b/Framework/DataObjects/src/Peak.cpp @@ -30,7 +30,7 @@ Peak::Peak() m_finalEnergy(0.), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0), - m_peakNumber(0), m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{{0, 0, 0}}, + m_peakNumber(0), m_modulatedStructure(V3D(0, 0, 0)), m_intH(0), m_intK(0), m_intL(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); } @@ -52,7 +52,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), - m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{{0, 0, 0}}, + m_modulatedStructure(V3D(0, 0, 0)), m_intH(0), m_intK(0), m_intL(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); @@ -80,7 +80,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, m_binCount(0), m_GoniometerMatrix(goniometer), m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0), m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), - m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{{0, 0, 0}}, + m_modulatedStructure(V3D(0, 0, 0)), m_intH(0), m_intK(0), m_intL(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8) @@ -104,7 +104,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), - m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{{0, 0, 0}}, + m_modulatedStructure(V3D(0, 0, 0)), m_intH(0), m_intK(0), m_intL(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); @@ -127,12 +127,13 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), - m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{{0, 0, 0}}, + m_modulatedStructure(V3D(0, 0, 0)), m_intH(0), m_intK(0), m_intL(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); this->setDetectorID(m_detectorID); this->setWavelength(m_Wavelength); + this->setIntHKL(HKL); } //---------------------------------------------------------------------------------------------- @@ -152,7 +153,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(goniometer), m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0), m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), - m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{{0, 0, 0}}, + m_modulatedStructure(V3D(0, 0, 0)), m_intH(0), m_intK(0), m_intL(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8) @@ -161,6 +162,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, this->setInstrument(m_inst); this->setDetectorID(m_detectorID); this->setWavelength(m_Wavelength); + this->setIntHKL(HKL); } //---------------------------------------------------------------------------------------------- /** Constructor @@ -176,7 +178,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, double scattering, m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0), - m_peakNumber(0), m_modulatedStructure(V3D(0, 0, 0)), m_intHKL{{0, 0, 0}}, + m_peakNumber(0), m_modulatedStructure(V3D(0, 0, 0)), m_intH(0), m_intK(0), m_intL(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); @@ -207,7 +209,7 @@ Peak::Peak(const Peak &other) m_orig_H(other.m_orig_H), m_orig_K(other.m_orig_K), m_orig_L(other.m_orig_L), m_peakNumber(other.m_peakNumber), m_modulatedStructure(other.m_modulatedStructure), - m_intHKL(other.m_intHKL), m_detIDs(other.m_detIDs), + m_intH(other.m_intH), m_intK(other.m_intK),m_intL(other.m_intL), m_detIDs(other.m_detIDs), m_peakShape(other.m_peakShape->clone()), convention(other.convention) {} //---------------------------------------------------------------------------------------------- @@ -230,9 +232,9 @@ Peak::Peak(const Geometry::IPeak &ipeak) m_col(ipeak.getCol()), m_orig_H(0.), m_orig_K(0.), m_orig_L(0.), m_peakNumber(ipeak.getPeakNumber()), m_modulatedStructure(ipeak.getIntMNP()), - m_intHKL{{static_cast<int>(ipeak.getIntHKL()[0]), - static_cast<int>(ipeak.getIntHKL()[1]), - static_cast<int>(ipeak.getIntHKL()[2])}}, + m_intH(static_cast<int>(ipeak.getIntHKL()[0])), + m_intK(static_cast<int>(ipeak.getIntHKL()[1])), + m_intL(static_cast<int>(ipeak.getIntHKL()[2])), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8) @@ -765,21 +767,30 @@ Mantid::Kernel::V3D Peak::getHKL() const { return V3D(m_H, m_K, m_L); } /** Return the int HKL vector */ Mantid::Kernel::V3D Peak::getIntHKL() const { - return V3D(m_intHKL[0], m_intHKL[1], m_intHKL[2]); + return V3D(m_intH, m_intK, m_intL); } //---------------------------------------------------------------------------------------------- /** Set the H index of this peak * @param m_H :: index to set */ -void Peak::setH(double m_H) { this->m_H = m_H; } +void Peak::setH(double m_H) { + this->m_H = m_H; + this->m_intH = boost::math::iround(m_H); +} /** Set the K index of this peak * @param m_K :: index to set */ -void Peak::setK(double m_K) { this->m_K = m_K; } +void Peak::setK(double m_K) { + this->m_K = m_K; + this->m_intK = boost::math::iround(m_K); +} /** Set the L index of this peak * @param m_L :: index to set */ -void Peak::setL(double m_L) { this->m_L = m_L; } +void Peak::setL(double m_L) { + this->m_L = m_L; + this->m_intL = boost::math::iround(m_L); +} /** Set the BankName of this peak * @param m_bankName :: index to set */ @@ -831,8 +842,9 @@ void Peak::setHKL(const Mantid::Kernel::V3D &HKL) { * @param HKL :: vector with integer x,y,z -> h,k,l */ void Peak::setIntHKL(const Mantid::Kernel::V3D &HKL) { - m_intHKL = {{boost::math::iround(HKL.X()), boost::math::iround(HKL.Y()), - boost::math::iround(HKL.Z())}}; + m_intH = boost::math::iround(HKL.X()); + m_intK = boost::math::iround(HKL.Y()); + m_intL = boost::math::iround(HKL.Z()); } //---------------------------------------------------------------------------------------------- @@ -1068,6 +1080,7 @@ Peak &Peak::operator=(const Peak &other) { m_orig_K = other.m_orig_K; m_orig_L = other.m_orig_L; m_detIDs = other.m_detIDs; + convention = other.convention; m_peakShape.reset(other.m_peakShape->clone()); } return *this; diff --git a/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py b/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py index 44a3b037cae9c33970ca84ca23baf425c1ceb214..b18b1f52803b859536651f011c72e5150e9290db 100644 --- a/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py +++ b/Testing/SystemTests/tests/analysis/ReduceOneSCD_Run.py @@ -21,6 +21,9 @@ import stresstesting import os from mantid.api import * from mantid.simpleapi import * +from mantid import config +# Make this test use crystallography convention +config['Q.convention'] = 'Crystallography' class ReduceOneSCD_Run( stresstesting.MantidStressTest):