diff --git a/Framework/Crystal/src/PredictPeaks.cpp b/Framework/Crystal/src/PredictPeaks.cpp index aa09d91613aef9f6eb513be2e93f5a6fb3cc4708..c88e1bfd59c5bdf559398601376c11ca400893d3 100644 --- a/Framework/Crystal/src/PredictPeaks.cpp +++ b/Framework/Crystal/src/PredictPeaks.cpp @@ -505,17 +505,19 @@ void PredictPeaks::calculateQAndAddToOutput(const V3D &hkl, } else if (useExtendedDetectorSpace) { // use extended detector space to try and guess peak position - const auto component = + const auto returnedComponent = m_inst->getComponentByName("extended-detector-space"); - const auto c = boost::dynamic_pointer_cast<const ObjComponent>(component); - if (!c) + // Check that the component is valid + const auto component = + boost::dynamic_pointer_cast<const ObjComponent>(returnedComponent); + if (!component) throw std::runtime_error("PredictPeaks: user requested use of a extended " "detector space to predict peaks but there is no" "definition in the IDF"); // find where this Q vector should intersect with "extended" space Geometry::Track track(detInfo.samplePosition(), detectorDir); - if (!c->interceptSurface(track)) + if (!component->interceptSurface(track)) return; // The exit point is the vector to the place that we hit a detector diff --git a/Framework/Crystal/test/PredictPeaksTest.h b/Framework/Crystal/test/PredictPeaksTest.h index a1d1315d4e3d0c1fe66cdb41321c0f19d57e8e26..ef297ab7108c36d69cc87f019564c751fb405c85 100644 --- a/Framework/Crystal/test/PredictPeaksTest.h +++ b/Framework/Crystal/test/PredictPeaksTest.h @@ -249,7 +249,7 @@ public: class PredictPeaksTestPerformance : public CxxTest::TestSuite { public: - void test_many_peaks_rectangular() { + void test_manyPeaksRectangular() { MatrixWorkspace_sptr inWS = WorkspaceCreationHelper::create2DWorkspace(10000, 1); Instrument_sptr inst = @@ -272,7 +272,7 @@ public: alg.execute(); } - void test_many_peaks() { + void test_manyPeaks() { MatrixWorkspace_sptr inWS = WorkspaceCreationHelper::create2DWorkspace(10000, 1); Instrument_sptr inst = @@ -280,7 +280,7 @@ public: 3, V3D(0, 0, -1), V3D(0, 0, 0), 1.6, 1.0); inWS->setInstrument(inst); - // Set ub and Goniometer rotation + // Set UB matrix and Goniometer rotation WorkspaceCreationHelper::setOrientedLattice(inWS, 12.0, 12.0, 12.0); WorkspaceCreationHelper::setGoniometer(inWS, 0., 0., 0.); diff --git a/Testing/SystemTests/tests/analysis/ISIS_WISHSingleCrystalReduction.py b/Testing/SystemTests/tests/analysis/ISIS_WISHSingleCrystalReduction.py index 9cead1c8877fc25ad26ca0ec06517ec53bebcc06..a984f84b0b6f2c419c6bb89dd5f4c62d73f2ee15 100644 --- a/Testing/SystemTests/tests/analysis/ISIS_WISHSingleCrystalReduction.py +++ b/Testing/SystemTests/tests/analysis/ISIS_WISHSingleCrystalReduction.py @@ -1,4 +1,3 @@ - from mantid.simpleapi import * import stresstesting import numpy as np diff --git a/Testing/SystemTests/tests/analysis/PredictPeaksTest.py b/Testing/SystemTests/tests/analysis/PredictPeaksTest.py index e6e86d529e3e893c55fd4d95d0939acfe9713358..bec31c000614811b010cbdc2936577c823c28e62 100644 --- a/Testing/SystemTests/tests/analysis/PredictPeaksTest.py +++ b/Testing/SystemTests/tests/analysis/PredictPeaksTest.py @@ -72,6 +72,8 @@ class PredictPeaksTestTOPAZ(stresstesting.MantidStressTest): class PredictPeaksCalculateStructureFactorsTest(stresstesting.MantidStressTest): + expected_num_peaks = 546 + def runTest(self): simulationWorkspace = CreateSimulationWorkspace(Instrument='WISH', BinParams='0,1,2', @@ -89,9 +91,9 @@ class PredictPeaksCalculateStructureFactorsTest(stresstesting.MantidStressTest): MinDSpacing=0.5, MaxDSpacing=10, CalculateStructureFactors=True) - self.assertEquals(peaks.getNumberPeaks(), 546) + self.assertEquals(peaks.getNumberPeaks(), self.expected_num_peaks) - for i in range(546): + for i in range(self.expected_num_peaks): peak = peaks.getPeak(i) self.assertLessThan(0.0, peak.getIntensity()) @@ -100,6 +102,6 @@ class PredictPeaksCalculateStructureFactorsTest(stresstesting.MantidStressTest): MinDSpacing=0.5, MaxDSpacing=10, CalculateStructureFactors=False) - for i in range(546): + for i in range(self.expected_num_peaks): peak = peaks_no_sf.getPeak(i) self.assertEquals(0.0, peak.getIntensity())