Skip to content

Commit

Permalink
Merge pull request mantidproject#37653 from robertapplin/0-normalise-…
Browse files Browse the repository at this point in the history
…by-original-sample

Use original sample integral to normalise randomized sample
In Inelastic->Data Processor interface IQT calculation
  • Loading branch information
RichardWaiteSTFC committed Jul 22, 2024
2 parents cbfb0b1 + 01996ad commit 4d2e8dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 4 additions & 2 deletions Framework/Algorithms/inc/MantidAlgorithms/CalculateIqt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -54,6 +53,9 @@ class MANTID_ALGORITHMS_DLL CalculateIqt final : public API::Algorithm {
API::MatrixWorkspace_sptr
setErrorsToStandardDeviation(const std::vector<API::MatrixWorkspace_sptr> &simulatedWorkspaces);
API::MatrixWorkspace_sptr setErrorsToZero(const std::vector<API::MatrixWorkspace_sptr> &simulatedWorkspaces);

API::MatrixWorkspace_sptr m_sampleIntegral;
API::MatrixWorkspace_sptr m_resolutionIntegral;
};

} // namespace Algorithms
Expand Down
23 changes: 13 additions & 10 deletions Framework/Algorithms/src/CalculateIqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions docs/source/release/v6.11.0/Inelastic/Bugfixes/37653.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed a bug in the Monte Carlo error calculation on the I(Q, t) tab of the :ref:`Data Processor Interface <interface-inelastic-data-processor>` where the first bin had an error of zero.

0 comments on commit 4d2e8dc

Please sign in to comment.