8#include "MantidAPI/Algorithm.tcc"
16using Mantid::HistogramData::BinEdges;
23using namespace Kernel;
25using DataObjects::EventWorkspace;
30 declareWorkspaceInputProperties<MatrixWorkspace>(
"InputWorkspace",
31 "The name of the input workspace. Must contain histogram data.",
32 std::make_shared<HistogramValidator>());
34 "The name of the Workspace containing the masked bins.");
39 auto required = std::make_shared<BoundedValidator<double>>();
40 required->setUpper(std::numeric_limits<double>::max() * 0.99);
41 declareProperty(
"XMin", std::numeric_limits<double>::max(), required,
"The value to start masking from.");
42 declareProperty(
"XMax", std::numeric_limits<double>::max(), required,
"The value to end masking at.");
45 "Deprecated, use InputWorkspaceIndexSet.");
57 std::stringstream msg;
58 msg <<
"XMax (" <<
m_endX <<
") must be greater than XMin (" <<
m_startX <<
")";
60 throw std::invalid_argument(msg.str());
64 std::vector<int64_t> spectraList = this->
getProperty(
"SpectraList");
65 if (!spectraList.empty()) {
67 throw std::runtime_error(
"Cannot provide both InputWorkspaceIndexSet and "
68 "SpectraList at the same time.");
70 g_log.
warning(
"The 'SpectraList' property is deprecated. Use "
71 "'InputWorkspaceIndexSet' instead.");
75 std::tie(inputWS,
indexSet) = getWorkspaceAndIndices<MatrixWorkspace>(
"InputWorkspace");
79 if (outputWS != inputWS) {
80 outputWS = inputWS->clone();
84 if (std::dynamic_pointer_cast<const EventWorkspace>(inputWS)) {
87 MantidVec::difference_type startBin(0), endBin(0);
91 const bool commonBins = inputWS->isCommonBins();
93 auto X = inputWS->binEdges(0);
102 MantidVec::difference_type startBinLoop(startBin), endBinLoop(endBin);
104 this->
findIndices(outputWS->binEdges(wi), startBinLoop, endBinLoop);
107 for (
auto j =
static_cast<int>(startBinLoop); j < static_cast<int>(endBinLoop); ++j) {
108 outputWS->maskBin(wi, j);
119 auto outputWS = std::dynamic_pointer_cast<EventWorkspace>(outputMatrixWS);
126 for (
int i = 0; i < static_cast<int>(
indexSet.size());
135 outputWS->clearMRU();
144 MantidVec::difference_type &endBin) {
145 startBin = std::distance(
X.begin(), std::upper_bound(
X.cbegin(),
X.cend(),
m_startX));
148 auto last = std::lower_bound(
X.cbegin(),
X.cend(),
m_endX);
149 if (last ==
X.cend())
151 endBin = std::distance(
X.cbegin(), last);
#define DECLARE_ALGORITHM(classname)
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
bool isDefault(const std::string &name) const
Helper class for reporting progress from algorithms.
A property class for workspaces.
double m_endX
The range end point.
double m_startX
The range start point.
void execEvent()
Execution code for EventWorkspaces.
Indexing::SpectrumIndexSet indexSet
the list of Spectra (workspace index) to load
void exec() override
Execution code.
void init() override
Initialisation code.
void findIndices(const HistogramData::BinEdges &X, MantidVec::difference_type &startBin, MantidVec::difference_type &endBin)
Finds the indices of the bins at the limits of the range given.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
@ Output
An output workspace.