Skip to content
Snippets Groups Projects
Commit ceee0f7d authored by Simon Heybrock's avatar Simon Heybrock
Browse files

Re #21128. Add MatrixWorkspace::setMaskedBins.

To be used by ExtractSpectra2.
parent 0eced040
No related merge requests found
...@@ -451,6 +451,7 @@ public: ...@@ -451,6 +451,7 @@ public:
/// index, weight> /// index, weight>
typedef std::map<size_t, double> MaskList; typedef std::map<size_t, double> MaskList;
const MaskList &maskedBins(const size_t &workspaceIndex) const; const MaskList &maskedBins(const size_t &workspaceIndex) const;
void setMaskedBins(const size_t workspaceIndex, const MaskList &maskedBins);
// Methods handling the internal monitor workspace // Methods handling the internal monitor workspace
virtual void virtual void
......
...@@ -1084,6 +1084,16 @@ MatrixWorkspace::maskedBins(const size_t &workspaceIndex) const { ...@@ -1084,6 +1084,16 @@ MatrixWorkspace::maskedBins(const size_t &workspaceIndex) const {
return it->second; return it->second;
} }
/** Set the list of masked bins for given workspaceIndex. Not thread safe.
*
* No data is masked and previous masking for any bin for this workspace index
* is overridden, so this should only be used for copying flags into a new
* workspace, not for performing masking operations. */
void MatrixWorkspace::setMaskedBins(const size_t workspaceIndex,
const MaskList &maskedBins) {
m_masks[workspaceIndex] = maskedBins;
}
/** Sets the internal monitor workspace to the provided workspace. /** Sets the internal monitor workspace to the provided workspace.
* This method is intended for use by data-loading algorithms. * This method is intended for use by data-loading algorithms.
* Note that no checking is performed as to whether this workspace actually * Note that no checking is performed as to whether this workspace actually
......
...@@ -742,6 +742,16 @@ public: ...@@ -742,6 +742,16 @@ public:
} }
} }
void testSetMaskedBins() {
auto ws = makeWorkspaceWithDetectors(2, 2);
ws->flagMasked(0, 1);
ws->flagMasked(1, 0);
ws->setMaskedBins(1, ws->maskedBins(0));
TS_ASSERT(ws->hasMaskedBins(1));
TS_ASSERT_EQUALS(ws->maskedBins(1).size(), 1);
TS_ASSERT_EQUALS(ws->maskedBins(0).begin()->first, 1);
}
void testSize() { void testSize() {
WorkspaceTester wkspace; WorkspaceTester wkspace;
wkspace.initialize(1, 4, 3); wkspace.initialize(1, 4, 3);
......
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