diff --git a/Framework/DataHandling/src/SaveGDA.cpp b/Framework/DataHandling/src/SaveGDA.cpp index 21c2ae40ecfc4371752acd8833788d13bbbe5a83..62678aeec97eb3f3e335894e06f96e33617539b5 100644 --- a/Framework/DataHandling/src/SaveGDA.cpp +++ b/Framework/DataHandling/src/SaveGDA.cpp @@ -158,7 +158,12 @@ void SaveGDA::exec() { const auto matrixWS = boost::dynamic_pointer_cast<MatrixWorkspace>(ws); const auto &d = matrixWS->x(0); - const auto &bankCalibParams = calibParams[groupingScheme[i] - 1]; + const size_t bankIndex(groupingScheme[i] - 1); + if (bankIndex >= calibParams.size()) { + throw Kernel::Exception::IndexError(bankIndex, calibParams.size(), + "Bank number out of range"); + } + const auto &bankCalibParams = calibParams[bankIndex]; // For historic reasons, TOF is scaled by 32 in MAUD const static double tofScale = 32; diff --git a/Framework/DataHandling/test/SaveGDATest.h b/Framework/DataHandling/test/SaveGDATest.h index 710ea6cd6a6a405da3101906b7f23acc74b387c4..1ba8206cdd6a37067e64bf19163e63b3bd546527 100644 --- a/Framework/DataHandling/test/SaveGDATest.h +++ b/Framework/DataHandling/test/SaveGDATest.h @@ -132,7 +132,7 @@ public: testAlg.initialize(); testAlg.setProperty("InputWorkspace", INPUT_GROUP_NAME); testAlg.setProperty("GSASParamFile", m_paramsFile.path()); - testAlg.setProperty("GroupingScheme", std::vector<int>({2, 3})); + testAlg.setProperty("GroupingScheme", std::vector<int>({1, 2})); Poco::TemporaryFile tempFile; const std::string &tempFileName = tempFile.path(); testAlg.setProperty("Filename", tempFileName); @@ -193,7 +193,7 @@ public: testAlg.initialize(); testAlg.setProperty("InputWorkspace", INPUT_GROUP_NAME); testAlg.setProperty("GSASParamFile", m_paramsFile.path()); - testAlg.setProperty("GroupingScheme", std::vector<int>({2, 3})); + testAlg.setProperty("GroupingScheme", std::vector<int>({1, 2})); Poco::TemporaryFile tempFile; const std::string &tempFileName = tempFile.path(); testAlg.setProperty("Filename", tempFileName); @@ -229,15 +229,15 @@ public: TS_ASSERT_EQUALS(error.size(), expectedNumPoints); // Test a few reference values - TS_ASSERT_EQUALS(tof[103], 99772); + TS_ASSERT_EQUALS(tof[103], 49920); TS_ASSERT_EQUALS(intensity[103], 1); TS_ASSERT_EQUALS(error[103], 34); - TS_ASSERT_EQUALS(tof[123], 100725); + TS_ASSERT_EQUALS(tof[123], 50398); TS_ASSERT_EQUALS(intensity[123], 1); TS_ASSERT_EQUALS(error[123], 35); - TS_ASSERT_EQUALS(tof[3000], 239053); + TS_ASSERT_EQUALS(tof[3000], 119009); TS_ASSERT_EQUALS(intensity[3000], 800); TS_ASSERT_EQUALS(error[3000], 894); }