Commit a32abcad authored by Danny Hindson's avatar Danny Hindson Committed by Zhang, Chen
Browse files

Fix bug in SaveGDA relating to d to TOF spacing conversion

difa and difc were back to front. Rather than swap here I've
changed the code to call the official unit conversion logic
in the dSpacing unit class
parent 5b3bd96d
......@@ -142,7 +142,7 @@ void SaveGDA::exec() {
const auto ws = inputWS->getItem(i);
const auto matrixWS = std::dynamic_pointer_cast<MatrixWorkspace>(ws);
const auto &d = matrixWS->x(0);
auto &x = matrixWS->dataX(0);
const size_t bankIndex(groupingScheme[i] - 1);
if (bankIndex >= calibParams.size()) {
throw Kernel::Exception::IndexError(bankIndex, calibParams.size(), "Bank number out of range");
......@@ -152,10 +152,16 @@ void SaveGDA::exec() {
// For historic reasons, TOF is scaled by 32 in MAUD
const static double tofScale = 32;
std::vector<double> tofScaled;
std::transform(d.begin(), d.end(), std::back_inserter(tofScaled), [&bankCalibParams](const double dVal) {
return (dVal * bankCalibParams.difa + dVal * dVal * bankCalibParams.difc + bankCalibParams.tzero) * tofScale;
Kernel::Units::dSpacing dSpacingUnit;
dSpacingUnit.toTOF(x, std::vector<double>{}, 0.,
{{Kernel::UnitParams::difa, bankCalibParams.difa},
{Kernel::UnitParams::difa, bankCalibParams.difc},
{Kernel::UnitParams::tzero, bankCalibParams.tzero}});
std::transform(x.begin(), x.end(), std::back_inserter(tofScaled),
[](const double tofVal) { return tofVal * tofScale; });
const auto averageDeltaTByT = computeAverageDeltaTByT(tofScaled);
const auto &intensity = matrixWS->y(0);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment