Skip to content

Commit

Permalink
refs #5626. Compute the error.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jul 20, 2012
1 parent dd9b1f2 commit 43c301a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/NormaliseByDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ namespace Mantid
outIntensity[i] = values[i];
}
denominatorWS->dataY(wsIndex) = outIntensity;
denominatorWS->dataE(wsIndex) = MantidVec(nInputBins, 0);
}

/**
Expand All @@ -174,7 +175,7 @@ namespace Mantid
const size_t nHistograms = inWS->getNumberHistograms();
if(m_parallelExecution == true)
{
PARALLEL_FOR2(inWS, denominatorWS)
PARALLEL_FOR2(inWS, denominatorWS)
for(int wsIndex = 0; wsIndex < nHistograms; ++wsIndex)
{
PARALLEL_START_INTERUPT_REGION
Expand Down
14 changes: 14 additions & 0 deletions Code/Mantid/Framework/Algorithms/test/NormaliseByDetectorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,15 @@ class NormaliseByDetectorTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(4, xValues.size());

const MantidVec& yInputValues = inputWS->readY(wsIndex);
const MantidVec& eInputValues = inputWS->readE(wsIndex);

for(size_t binIndex = 0; binIndex < (xValues.size() - 1); ++binIndex)
{
const double wavelength = (xValues[binIndex] + xValues[binIndex+1])/2;
const double expectedValue = yInputValues[binIndex] / ( (2*wavelength) + 1 ); // According to the equation written into the instrument parameter file for the instrument component link.
TS_ASSERT_EQUALS(expectedValue, yValues[binIndex]);
const double expectedError = (eInputValues[binIndex] * expectedValue) / yInputValues[binIndex]; // e = Ein/Ydenom so, since Yout = Yin/Ydenom, e = Ein * Yout / Yin
TS_ASSERT_EQUALS(expectedError, eValues[binIndex]);
}
}
}
Expand Down Expand Up @@ -422,6 +425,7 @@ class NormaliseByDetectorTest : public CxxTest::TestSuite

const MantidVec& yInputValues = inputWS->readY(wsIndex);
const MantidVec& xInputValues = inputWS->readX(wsIndex);
const MantidVec& eInputValues = inputWS->readE(wsIndex);

for(size_t binIndex = 0; binIndex < (xInputValues.size() - 1); ++binIndex)
{
Expand All @@ -431,6 +435,10 @@ class NormaliseByDetectorTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(expectedValue, yValuesParallel[binIndex]);
// Compare results from different execution types.
TS_ASSERT_EQUALS(yValuesSequential[binIndex], yValuesParallel[binIndex]);
// Compare the errors calculated.
const double expectedError = (eInputValues[binIndex] * expectedValue) / yInputValues[binIndex]; // e = Ein/Ydenom so, since Yout = Yin/Ydenom, e = Ein * Yout / Yin
TS_ASSERT_EQUALS(expectedError, eValuesParallel[binIndex]);
TS_ASSERT_EQUALS(expectedError, eValuesSequential[binIndex]);
}
}
}
Expand All @@ -457,12 +465,15 @@ class NormaliseByDetectorTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(4, xValues.size());

const MantidVec& yInputValues = inputWS->readY(wsIndex);
const MantidVec& eInputValues = inputWS->readE(wsIndex);

for(size_t binIndex = 0; binIndex < (xValues.size() - 1); ++binIndex)
{
const double wavelength = (xValues[binIndex] + xValues[binIndex+1])/2;
const double expectedValue = yInputValues[binIndex] / ( (1*wavelength) + static_cast<double>(wsIndex) ); // According to the equation written into the instrument parameter file for the detector component link.
const double expectedError = (eInputValues[binIndex] * expectedValue) / yInputValues[binIndex]; // e = Ein/Ydenom so, since Yout = Yin/Ydenom, e = Ein * Yout / Yin
TS_ASSERT_EQUALS(expectedValue, yValues[binIndex]);
TS_ASSERT_EQUALS(expectedError, eValues[binIndex]);
}
}
}
Expand Down Expand Up @@ -496,12 +507,15 @@ class NormaliseByDetectorTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS(4, xValues.size());

const MantidVec& yInputValues = completeWS->readY(wsIndex);
const MantidVec& eInputValues = completeWS->readE(wsIndex);

for(size_t binIndex = 0; binIndex < (xValues.size() - 1); ++binIndex)
{
const double wavelength = (xValues[binIndex] + xValues[binIndex+1])/2;
const double expectedValue = yInputValues[binIndex] / ( (1*static_cast<double>(wsIndex)*wavelength) + 3.0 ); // According to the equation written into the instrument parameter file for the detector component link.
const double expectedError = (eInputValues[binIndex] * expectedValue) / yInputValues[binIndex]; // e = Ein/Ydenom so, since Yout = Yin/Ydenom, e = Ein * Yout / Yin
TS_ASSERT_EQUALS(expectedValue, yValues[binIndex]);
TS_ASSERT_EQUALS(expectedError, eValues[binIndex]);
}
}

Expand Down

0 comments on commit 43c301a

Please sign in to comment.