From fecb8914669d3bb6495437b4cbef0a423f34d4bf Mon Sep 17 00:00:00 2001 From: Applin Date: Thu, 11 Jul 2024 16:52:21 +0100 Subject: [PATCH 1/2] Use original sample to normalise randomized sample --- .../inc/MantidAlgorithms/CalculateIqt.h | 6 +++-- Framework/Algorithms/src/CalculateIqt.cpp | 23 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h index 0d6c9590e36f..6f56e451f766 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h @@ -43,8 +43,7 @@ class MANTID_ALGORITHMS_DLL CalculateIqt final : public API::Algorithm { API::MatrixWorkspace_sptr replaceSpecialValues(const API::MatrixWorkspace_sptr &workspace); API::MatrixWorkspace_sptr removeInvalidData(API::MatrixWorkspace_sptr workspace); - API::MatrixWorkspace_sptr normalizedFourierTransform(API::MatrixWorkspace_sptr workspace, - const std::string &rebinParams, const bool enforceNormalization); + API::MatrixWorkspace_sptr fourierTransform(API::MatrixWorkspace_sptr workspace, const std::string &rebinParams); API::MatrixWorkspace_sptr calculateIqt(API::MatrixWorkspace_sptr workspace, const API::MatrixWorkspace_sptr &resolutionWorkspace, const std::string &rebinParams, const bool enforceNormalization); @@ -54,6 +53,9 @@ class MANTID_ALGORITHMS_DLL CalculateIqt final : public API::Algorithm { API::MatrixWorkspace_sptr setErrorsToStandardDeviation(const std::vector &simulatedWorkspaces); API::MatrixWorkspace_sptr setErrorsToZero(const std::vector &simulatedWorkspaces); + + API::MatrixWorkspace_sptr m_sampleIntegral; + API::MatrixWorkspace_sptr m_resolutionIntegral; }; } // namespace Algorithms diff --git a/Framework/Algorithms/src/CalculateIqt.cpp b/Framework/Algorithms/src/CalculateIqt.cpp index d31050e0b67b..02f3723cb022 100644 --- a/Framework/Algorithms/src/CalculateIqt.cpp +++ b/Framework/Algorithms/src/CalculateIqt.cpp @@ -138,7 +138,14 @@ void CalculateIqt::exec() { bool enforceNormalization = getProperty("EnforceNormalization"); const int nIterations = getProperty("NumberOfIterations"); const int seed = getProperty("SeedValue"); - resolution = normalizedFourierTransform(resolution, rebinParams, enforceNormalization); + + m_sampleIntegral = integration(rebin(sampleWorkspace, rebinParams)); + m_resolutionIntegral = integration(rebin(resolution, rebinParams)); + + resolution = fourierTransform(resolution, rebinParams); + if (enforceNormalization) { + resolution = divide(resolution, m_resolutionIntegral); + } auto outputWorkspace = monteCarloErrorCalculation(sampleWorkspace, resolution, rebinParams, seed, calculateErrors, nIterations, enforceNormalization); @@ -265,24 +272,20 @@ MatrixWorkspace_sptr CalculateIqt::replaceSpecialValues(const MatrixWorkspace_sp return specialValuesAlgorithm->getProperty("OutputWorkspace"); } -MatrixWorkspace_sptr CalculateIqt::normalizedFourierTransform(MatrixWorkspace_sptr workspace, - const std::string &rebinParams, - const bool enforceNormalization) { +MatrixWorkspace_sptr CalculateIqt::fourierTransform(MatrixWorkspace_sptr workspace, const std::string &rebinParams) { workspace = rebin(workspace, rebinParams); - auto workspace_int = integration(workspace); workspace = convertToPointData(workspace); workspace = extractFFTSpectrum(workspace); - if (enforceNormalization) { - return divide(workspace, workspace_int); - } - // return the output workspace of ExtractFFTSpectrum return workspace; } MatrixWorkspace_sptr CalculateIqt::calculateIqt(MatrixWorkspace_sptr workspace, const MatrixWorkspace_sptr &resolutionWorkspace, const std::string &rebinParams, const bool enforceNormalization) { - workspace = normalizedFourierTransform(workspace, rebinParams, enforceNormalization); + workspace = fourierTransform(workspace, rebinParams); + if (enforceNormalization) { + workspace = divide(workspace, m_sampleIntegral); + } return divide(workspace, resolutionWorkspace); } From 01996adc81e7e3b91530f33727e011ab54d3f345 Mon Sep 17 00:00:00 2001 From: Applin Date: Mon, 15 Jul 2024 08:28:08 +0100 Subject: [PATCH 2/2] Add release note --- docs/source/release/v6.11.0/Inelastic/Bugfixes/37653.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/source/release/v6.11.0/Inelastic/Bugfixes/37653.rst diff --git a/docs/source/release/v6.11.0/Inelastic/Bugfixes/37653.rst b/docs/source/release/v6.11.0/Inelastic/Bugfixes/37653.rst new file mode 100644 index 000000000000..93033c0353e0 --- /dev/null +++ b/docs/source/release/v6.11.0/Inelastic/Bugfixes/37653.rst @@ -0,0 +1 @@ +- Fixed a bug in the Monte Carlo error calculation on the I(Q, t) tab of the :ref:`Data Processor Interface ` where the first bin had an error of zero. \ No newline at end of file