Skip to content
Snippets Groups Projects
Commit be361025 authored by Raquel Alvarez's avatar Raquel Alvarez
Browse files

Re #17673 SofQWCentre

parent 7ef05a0b
No related branches found
No related tags found
No related merge requests found
......@@ -168,9 +168,9 @@ void SofQWCentre::exec() {
const size_t numDets = detectors.size();
const double numDets_d = static_cast<double>(
numDets); // cache to reduce number of static casts
const MantidVec &Y = inputWorkspace->readY(i);
const MantidVec &E = inputWorkspace->readE(i);
const MantidVec &X = inputWorkspace->readX(i);
const auto &Y = inputWorkspace->y(i);
const auto &E = inputWorkspace->e(i);
const auto &X = inputWorkspace->x(i);
// Loop over the detectors and for each bin calculate Q
for (size_t idet = 0; idet < numDets; ++idet) {
......@@ -233,10 +233,10 @@ void SofQWCentre::exec() {
// And add the data and it's error to that bin, taking into account
// the number of detectors contributing to this bin
outputWorkspace->dataY(qIndex)[j] += Y[j] / numDets_d;
outputWorkspace->mutableY(qIndex)[j] += Y[j] / numDets_d;
// Standard error on the average
outputWorkspace->dataE(qIndex)[j] =
sqrt((pow(outputWorkspace->readE(qIndex)[j], 2) + pow(E[j], 2)) /
outputWorkspace->mutableE(qIndex)[j] =
sqrt((pow(outputWorkspace->e(qIndex)[j], 2) + pow(E[j], 2)) /
numDets_d);
}
}
......@@ -327,8 +327,8 @@ void SofQWCentre::makeDistribution(API::MatrixWorkspace_sptr outputWS,
const size_t numQBins = outputWS->getNumberHistograms();
for (size_t i = 0; i < numQBins; ++i) {
MantidVec &Y = outputWS->dataY(i);
MantidVec &E = outputWS->dataE(i);
auto &Y = outputWS->mutableY(i);
auto &E = outputWS->mutableE(i);
std::transform(Y.begin(), Y.end(), Y.begin(),
std::bind2nd(std::divides<double>(), widths[i + 1]));
std::transform(E.begin(), E.end(), E.begin(),
......
......@@ -4,7 +4,6 @@
#include <cxxtest/TestSuite.h>
#include "MantidAlgorithms/SofQWCentre.h"
#include "MantidAPI/Axis.h"
#include "MantidDataHandling/LoadNexusProcessed.h"
#include "SofQWTest.h"
......@@ -44,18 +43,18 @@ public:
TS_ASSERT_EQUALS((*(result->getAxis(1)))(6), 2.0);
const double delta(1e-08);
TS_ASSERT_DELTA(result->readY(0)[1160], 54.85624399, delta);
TS_ASSERT_DELTA(result->readE(0)[1160], 0.34252858, delta);
TS_ASSERT_DELTA(result->readY(1)[1145], 22.72491806, delta);
TS_ASSERT_DELTA(result->readE(1)[1145], 0.19867742, delta);
TS_ASSERT_DELTA(result->readY(2)[1200], 6.76047436, delta);
TS_ASSERT_DELTA(result->readE(2)[1200], 0.10863549, delta);
TS_ASSERT_DELTA(result->readY(3)[99], 0.16439574, delta);
TS_ASSERT_DELTA(result->readE(3)[99], 0.03414360, delta);
TS_ASSERT_DELTA(result->readY(4)[1654], 0.069311442, delta);
TS_ASSERT_DELTA(result->readE(4)[1654], 0.007573484, delta);
TS_ASSERT_DELTA(result->readY(5)[1025], 0.226287179, delta);
TS_ASSERT_DELTA(result->readE(5)[1025], 0.02148236, delta);
TS_ASSERT_DELTA(result->y(0)[1160], 54.85624399, delta);
TS_ASSERT_DELTA(result->e(0)[1160], 0.34252858, delta);
TS_ASSERT_DELTA(result->y(1)[1145], 22.72491806, delta);
TS_ASSERT_DELTA(result->e(1)[1145], 0.19867742, delta);
TS_ASSERT_DELTA(result->y(2)[1200], 6.76047436, delta);
TS_ASSERT_DELTA(result->e(2)[1200], 0.10863549, delta);
TS_ASSERT_DELTA(result->y(3)[99], 0.16439574, delta);
TS_ASSERT_DELTA(result->e(3)[99], 0.03414360, delta);
TS_ASSERT_DELTA(result->y(4)[1654], 0.069311442, delta);
TS_ASSERT_DELTA(result->e(4)[1654], 0.007573484, delta);
TS_ASSERT_DELTA(result->y(5)[1025], 0.226287179, delta);
TS_ASSERT_DELTA(result->e(5)[1025], 0.02148236, delta);
}
};
......
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