Skip to content
Snippets Groups Projects
Commit bbc314ba authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #10208. Fix issues raised in testing.

parent 327030e8
No related branches found
No related tags found
No related merge requests found
......@@ -119,12 +119,20 @@ namespace Mantid
continue;
const double twoTheta = inWS->detectorTwoTheta(detector);
const double sinTheta = std::sin(twoTheta / 2);
double sinThetaSq = sinTheta * sinTheta;
for (size_t j = 0; j < inY.size(); ++j)
{
const double wL = isHist ? (0.5 * (inX[j] + inX[j + 1])) : inX[j];
double sinTheta = std::sin(twoTheta / 2);
double weight = sinTheta * sinTheta / (wL * wL * wL * wL);
if(wL == 0)
{
std::stringstream buffer;
buffer << "Cannot have zero values Wavelength. At workspace index: " << i;
throw std::runtime_error(buffer.str());
}
double weight = sinThetaSq / (wL * wL * wL * wL);
outY[j] *= weight;
outE[j] *= weight;
}
......
......@@ -115,6 +115,20 @@ public:
alg.setProperty("InputWorkspace", ws_tof), std::invalid_argument&);
}
void test_throws_if_wavelength_zero()
{
auto ws_lam = this->create_workspace(2 /*nBins*/);
ws_lam->dataX(0)[0] = 0; // Make wavelength zero
ws_lam->dataX(0)[1] = 0; // Make wavelength zero
LorentzCorrection alg;
alg.setChild(true);
alg.setRethrows(true);
alg.initialize();
alg.setProperty("InputWorkspace", ws_lam);
alg.setPropertyValue("OutputWorkspace", "temp");
TSM_ASSERT_THROWS("Should throw with zero wavelength values.", alg.execute(), std::runtime_error&);
}
void test_execute()
{
auto ws_lam = this->create_workspace(2 /*nBins*/);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment