16using Mantid::HistogramData::BinEdges;
23using namespace Kernel;
25using DataObjects::EventWorkspace;
30 declareWorkspaceInputProperties<MatrixWorkspace, static_cast<int>(IndexType::WorkspaceIndex) |
31 static_cast<int>(IndexType::SpectrumNum)>(
32 "InputWorkspace",
"The name of the input workspace. Must contain histogram data.",
33 std::make_shared<HistogramValidator>());
35 "The name of the Workspace containing the masked bins.");
40 auto required = std::make_shared<BoundedValidator<double>>();
41 required->setUpper(std::numeric_limits<double>::max() * 0.99);
42 declareProperty(
"XMin", std::numeric_limits<double>::max(), required,
"The value to start masking from.");
43 declareProperty(
"XMax", std::numeric_limits<double>::max(), required,
"The value to end masking at.");
46 "Deprecated, use InputWorkspaceIndexSet.");
58 std::stringstream msg;
59 msg <<
"XMax (" <<
m_endX <<
") must be greater than XMin (" <<
m_startX <<
")";
61 throw std::invalid_argument(msg.str());
65 std::vector<int64_t> spectraList = this->
getProperty(
"SpectraList");
66 if (!spectraList.empty()) {
68 throw std::runtime_error(
"Cannot provide both InputWorkspaceIndexSet and "
69 "SpectraList at the same time.");
71 g_log.
warning(
"The 'SpectraList' property is deprecated. Use "
72 "'InputWorkspaceIndexSet' instead.");
76 std::tie(inputWS,
indexSet) = getWorkspaceAndIndices<MatrixWorkspace>(
"InputWorkspace");
80 if (outputWS != inputWS) {
81 outputWS = inputWS->clone();
85 if (std::dynamic_pointer_cast<const EventWorkspace>(inputWS)) {
88 MantidVec::difference_type startBin(0), endBin(0);
92 const bool commonBins = inputWS->isCommonBins();
94 auto X = inputWS->binEdges(0);
103 MantidVec::difference_type startBinLoop(startBin), endBinLoop(endBin);
105 this->
findIndices(outputWS->binEdges(wi), startBinLoop, endBinLoop);
108 for (
auto j =
static_cast<int>(startBinLoop); j < static_cast<int>(endBinLoop); ++j) {
109 outputWS->maskBin(wi, j);
120 auto outputWS = std::dynamic_pointer_cast<EventWorkspace>(outputMatrixWS);
125 const auto timerStart = std::chrono::high_resolution_clock::now();
127 addTimer(
"sortEvents", timerStart, std::chrono::high_resolution_clock::now());
131 for (
int i = 0; i < static_cast<int>(
indexSet.size());
140 outputWS->clearMRU();
149 MantidVec::difference_type &endBin) {
150 startBin = std::distance(
X.begin(), std::upper_bound(
X.cbegin(),
X.cend(),
m_startX));
153 auto last = std::lower_bound(
X.cbegin(),
X.cend(),
m_endX);
154 if (last ==
X.cend())
156 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
void addTimer(const std::string &name, const Kernel::time_point_ns &begin, const Kernel::time_point_ns &end)
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.