Skip to content
Snippets Groups Projects
Commit c5237be3 authored by Matthew D Jones's avatar Matthew D Jones
Browse files

Re #14613 Use functions that return mask values (0) for MDEWs

parent e48518c4
No related branches found
No related tags found
No related merge requests found
...@@ -264,6 +264,12 @@ public: ...@@ -264,6 +264,12 @@ public:
virtual uint32_t getDepth() const = 0; virtual uint32_t getDepth() const = 0;
virtual signal_t getSignalNormalized() const = 0; virtual signal_t getSignalNormalized() const = 0;
virtual signal_t getSignalWithMask() const = 0;
virtual signal_t getSignalNormalizedWithMask() const = 0;
virtual signal_t getSignalByNEventsWithMask() const {
return this->getSignalWithMask() / static_cast<signal_t>(this->getNPoints());
}
virtual void calcVolume() = 0; virtual void calcVolume() = 0;
virtual void setInverseVolume(const coord_t) = 0; virtual void setInverseVolume(const coord_t) = 0;
virtual void setSignal(const signal_t) = 0; virtual void setSignal(const signal_t) = 0;
......
...@@ -254,6 +254,16 @@ public: ...@@ -254,6 +254,16 @@ public:
*/ */
virtual signal_t getError() const { return sqrt(m_errorSquared); } virtual signal_t getError() const { return sqrt(m_errorSquared); }
//-----------------------------------------------------------------------------------------------
/** Returns the integrated signal from all points within or mask value.
*/
virtual signal_t getSignalWithMask() const {
if (this->getIsMasked()) {
return m_maskValue;
}
return m_signal;
}
//----------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------
/** Returns the integrated error squared from all points within. /** Returns the integrated error squared from all points within.
*/ */
...@@ -303,6 +313,17 @@ public: ...@@ -303,6 +313,17 @@ public:
return m_errorSquared * m_inverseVolume; return m_errorSquared * m_inverseVolume;
} }
//-----------------------------------------------------------------------------------------------
/** Returns the integrated signal from all points within, normalized for the
* cell volume
*/
virtual signal_t getSignalNormalizedWithMask() const {
if (this->getIsMasked()) {
return m_maskValue;
}
return m_signal * m_inverseVolume;
}
//----------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------
/** For testing, mostly: return the recursion depth of this box. /** For testing, mostly: return the recursion depth of this box.
* 0 is the top-level box, 1 is one deeper, etc. * 0 is the top-level box, 1 is one deeper, etc.
...@@ -367,6 +388,9 @@ protected: ...@@ -367,6 +388,9 @@ protected:
/// Mutex for modifying the event list or box averages /// Mutex for modifying the event list or box averages
Mantid::Kernel::Mutex m_dataMutex; Mantid::Kernel::Mutex m_dataMutex;
// Value to be returned for masked data when plotting
static constexpr signal_t m_maskValue = 0.0;
private: private:
MDBoxBase(const MDBoxBase<MDE, nd> &box); MDBoxBase(const MDBoxBase<MDE, nd> &box);
......
...@@ -41,7 +41,8 @@ Determine which normalization function will be called on an IMDNode ...@@ -41,7 +41,8 @@ Determine which normalization function will be called on an IMDNode
*/ */
NormFuncIMDNodePtr makeMDEventNormalizationFunction( NormFuncIMDNodePtr makeMDEventNormalizationFunction(
VisualNormalization normalizationOption, VisualNormalization normalizationOption,
Mantid::API::IMDEventWorkspace const *const ws); Mantid::API::IMDEventWorkspace const *const ws,
const bool hasMask);
/** /**
Determine which normalization function will be called on an IMDIterator of an IMDWorkspace Determine which normalization function will be called on an IMDIterator of an IMDWorkspace
......
...@@ -14,9 +14,10 @@ This is used for visualisation of IMDEventWorkspaces. ...@@ -14,9 +14,10 @@ This is used for visualisation of IMDEventWorkspaces.
@param ws : workspace to fetch defaults from if needed @param ws : workspace to fetch defaults from if needed
@return member function to use on IMDNodes @return member function to use on IMDNodes
*/ */
NormFuncIMDNodePtr makeMDEventNormalizationFunction( NormFuncIMDNodePtr
VisualNormalization normalizationOption, makeMDEventNormalizationFunction(VisualNormalization normalizationOption,
Mantid::API::IMDEventWorkspace const *const ws) { Mantid::API::IMDEventWorkspace const *const ws,
const bool hasMask) {
using namespace Mantid::API; using namespace Mantid::API;
...@@ -29,12 +30,24 @@ NormFuncIMDNodePtr makeMDEventNormalizationFunction( ...@@ -29,12 +30,24 @@ NormFuncIMDNodePtr makeMDEventNormalizationFunction(
NormFuncIMDNodePtr normalizationFunction; NormFuncIMDNodePtr normalizationFunction;
if (normalizationOption == Mantid::VATES::NumEventsNormalization) { // Avoid checking every box for a mask if there is no mask in the workspace
normalizationFunction = &IMDNode::getSignalByNEvents; // by using different functions
} else if (normalizationOption == Mantid::VATES::NoNormalization) { if (hasMask) {
normalizationFunction = &IMDNode::getSignal; if (normalizationOption == Mantid::VATES::NumEventsNormalization) {
normalizationFunction = &IMDNode::getSignalByNEventsWithMask;
} else if (normalizationOption == Mantid::VATES::NoNormalization) {
normalizationFunction = &IMDNode::getSignalWithMask;
} else {
normalizationFunction = &IMDNode::getSignalNormalizedWithMask;
}
} else { } else {
normalizationFunction = &IMDNode::getSignalNormalized; if (normalizationOption == Mantid::VATES::NumEventsNormalization) {
normalizationFunction = &IMDNode::getSignalByNEvents;
} else if (normalizationOption == Mantid::VATES::NoNormalization) {
normalizationFunction = &IMDNode::getSignal;
} else {
normalizationFunction = &IMDNode::getSignalNormalized;
}
} }
return normalizationFunction; return normalizationFunction;
...@@ -57,21 +70,17 @@ createIteratorWithNormalization(const VisualNormalization normalizationOption, ...@@ -57,21 +70,17 @@ createIteratorWithNormalization(const VisualNormalization normalizationOption,
if (normalizationOption == AutoSelect) { if (normalizationOption == AutoSelect) {
// enum to enum. // enum to enum.
targetNormalization = targetNormalization =
static_cast<MDNormalization>(ws->displayNormalization()); static_cast<MDNormalization>(ws->displayNormalization());
} } else {
else {
targetNormalization = static_cast<MDNormalization>(normalizationOption); targetNormalization = static_cast<MDNormalization>(normalizationOption);
} }
// Create the iterator // Create the iterator
IMDIterator * iterator = ws->createIterator(); IMDIterator *iterator = ws->createIterator();
// Set normalization // Set normalization
iterator->setNormalization(targetNormalization); iterator->setNormalization(targetNormalization);
// Return it // Return it
return iterator; return iterator;
} }
} }
} }
\ No newline at end of file
...@@ -25,7 +25,6 @@ namespace Mantid { ...@@ -25,7 +25,6 @@ namespace Mantid {
namespace VATES { namespace VATES {
/*Constructor /*Constructor
@param thresholdRange : Threshold range strategy @param thresholdRange : Threshold range strategy
@param normalizationOption : Info object setting how normalization should be @param normalizationOption : Info object setting how normalization should be
...@@ -103,7 +102,8 @@ void vtkMDHexFactory::doCreate( ...@@ -103,7 +102,8 @@ void vtkMDHexFactory::doCreate(
vtkIdList *hexPointList = vtkIdList::New(); vtkIdList *hexPointList = vtkIdList::New();
hexPointList->SetNumberOfIds(8); hexPointList->SetNumberOfIds(8);
NormFuncIMDNodePtr normFunction = makeMDEventNormalizationFunction(m_normalizationOption, ws.get()); NormFuncIMDNodePtr normFunction = makeMDEventNormalizationFunction(
m_normalizationOption, ws.get(), ws.get()->hasMask());
// This can be parallelized // This can be parallelized
// cppcheck-suppress syntaxError // cppcheck-suppress syntaxError
...@@ -112,7 +112,7 @@ void vtkMDHexFactory::doCreate( ...@@ -112,7 +112,7 @@ void vtkMDHexFactory::doCreate(
// Get the box here // Get the box here
size_t i = size_t(ii); size_t i = size_t(ii);
API::IMDNode *box = boxes[i]; API::IMDNode *box = boxes[i];
Mantid::signal_t signal_normalized = (box->*normFunction)(); Mantid::signal_t signal_normalized = (box->*normFunction)();
if (!isSpecial(signal_normalized) && if (!isSpecial(signal_normalized) &&
m_thresholdRange->inRange(signal_normalized)) { m_thresholdRange->inRange(signal_normalized)) {
......
...@@ -111,7 +111,7 @@ namespace Mantid ...@@ -111,7 +111,7 @@ namespace Mantid
{ {
progressUpdating.eventRaised(double(iBox)*progressFactor); progressUpdating.eventRaised(double(iBox)*progressFactor);
Mantid::signal_t signal_normalized= it->getNormalizedSignal(); Mantid::signal_t signal_normalized= it->getNormalizedSignalWithMask();
if (!isSpecial( signal_normalized ) && m_thresholdRange->inRange(signal_normalized)) if (!isSpecial( signal_normalized ) && m_thresholdRange->inRange(signal_normalized))
{ {
useBox[iBox] = true; useBox[iBox] = true;
......
...@@ -107,7 +107,7 @@ namespace Mantid ...@@ -107,7 +107,7 @@ namespace Mantid
{ {
progressUpdating.eventRaised(progressFactor * double(iBox)); progressUpdating.eventRaised(progressFactor * double(iBox));
Mantid::signal_t signal = it->getNormalizedSignal(); Mantid::signal_t signal = it->getNormalizedSignalWithMask();
if (!isSpecial( signal ) && m_thresholdRange->inRange(signal)) if (!isSpecial( signal ) && m_thresholdRange->inRange(signal))
{ {
useBox[iBox] = true; useBox[iBox] = true;
......
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