Commit 817fd161 authored by Danny Hindson's avatar Danny Hindson
Browse files

Make MonteCarloAbsorption ignore masked detectors

This change makes the MonteCarloAbsorption algorithm ignore masked detectors
in the input workspace - in line with the behaviour of other correction algorithms
such as MayersSampleCorrection and CalculateCarpenterSampleCorrection
The algorithm outputs a masked spectra with all values equal to zero for each masked
spectrum in the input workspace. The Divide algorithm ignores masked spectra so if the
correction workspace is used as the rhs of a divide then it will be OK
parent f18a9593
......@@ -273,8 +273,8 @@ MatrixWorkspace_uptr MonteCarloAbsorption::doSimulation(
auto &outE = simulationWS.mutableE(i);
// The input was cloned so clear the errors out
outE = 0.0;
// Final detector position
if (!spectrumInfo.hasDetectors(i)) {
if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMasked(i)) {
// Per spectrum values
......@@ -10,6 +10,7 @@
#include "MantidAPI/FileFinder.h"
#include "MantidAPI/FrameworkManager.h"
#include "MantidAPI/Sample.h"
#include "MantidAPI/SpectrumInfo.h"
#include "MantidAlgorithms/ConvertUnits.h"
#include "MantidAlgorithms/MonteCarloAbsorption.h"
#include "MantidDataHandling/LoadBinaryStl.h"
......@@ -282,6 +283,26 @@ public:
void test_ignore_masked_spectra() {
using Mantid::Kernel::DeltaEMode;
TestWorkspaceDescriptor wsProps = {
5, 10, Environment::SampleOnly, DeltaEMode::Elastic, -1, -1};
auto testWS = setUpWS(wsProps);
testWS->mutableSpectrumInfo().setMasked(0, true);
auto mcAbsorb = createAlgorithm();
TS_ASSERT_THROWS_NOTHING(mcAbsorb->setProperty("InputWorkspace", testWS));
auto outputWS = getOutputWorkspace(mcAbsorb);
// should still output a spectra but it should also be masked and equal to
// zero
TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 5);
TS_ASSERT_EQUALS(outputWS->spectrumInfo().isMasked(0), true);
auto yData = outputWS->getSpectrum(0).dataY();
bool allZero = std::all_of(yData.begin(), yData.end(),
[](double i) { return i == 0; });
TS_ASSERT_EQUALS(allZero, true);
// Failure cases
......@@ -20,6 +20,7 @@ Algorithms
cost of cloning the inputWorkspace.
- Adjusted :ref:`AddPeak <algm-AddPeak>` to only allow peaks from the same instrument as the peaks worksapce to be added to that workspace.
- :ref:`MonteCarloAbsorption <algm-MonteCarloAbsorption>` Bug fixed where setting ResimulateTracksForDifferentWavelengths parameter to True was being ignored
- :ref:`MonteCarloAbsorption <algm-MonteCarloAbsorption>` Corrections are not calculated anymore for masked spectra
- :ref:`MaskDetectorsIf <algm-MaskDetectorsIf>` has received a number of updates:
- The algorithm now checks all of the data bins for each spectrum of a workspace, previously it only checked the first bin.
Markdown is supported
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