14#include <boost/function.hpp>
46 "An input workspace.");
48 std::vector<std::string> propOptions;
49 propOptions.emplace_back(
LessThan());
53 "Selected threshold condition. Any value which does meet "
54 "this condition with respect to the ReferenceValue will be "
57 declareProperty(
"ReferenceValue", 0.0,
"Comparator value used by the Condition.");
60 "Flag for enabling overwriting "
61 "with a custom value. Defaults to "
62 "overwrite signals with zeros.");
64 declareProperty(
"CustomOverwriteValue", 0.0,
"Custom overwrite value for the signal. Defaults to zero.");
66 std::make_unique<EnabledWhenProperty>(
"OverwriteWithZero",
IS_NOT_DEFAULT));
69 "Output thresholded workspace.");
77 const std::string condition =
getProperty(
"Condition");
78 const double referenceValue =
getProperty(
"ReferenceValue");
79 const bool doOverwriteWithZero =
getProperty(
"OverwriteWithZero");
80 double customOverwriteValue =
getProperty(
"CustomOverwriteValue");
81 if (doOverwriteWithZero) {
82 customOverwriteValue = 0;
86 if (outWS != inputWS) {
87 g_log.
debug(
"Deep copy input workspace as output workspace.");
89 alg->setProperty(
"InputWorkspace", inputWS);
90 alg->executeAsChildAlg();
92 outWS = std::dynamic_pointer_cast<IMDHistoWorkspace>(temp);
95 const int64_t nPoints = inputWS->getNPoints();
97 using namespace std::placeholders;
98 boost::function<bool(
double)> comparitor = std::bind(std::less<double>(), std::placeholders::_1, referenceValue);
100 comparitor = std::bind(std::greater<double>(), std::placeholders::_1, referenceValue);
104 int64_t frequency = nPoints;
106 frequency = nPoints / 100;
110 for (int64_t i = 0; i < nPoints; ++i) {
112 const double signalAt = inputWS->getSignalAt(i);
113 if (comparitor(signalAt)) {
114 outWS->setSignalAt(i, customOverwriteValue);
116 if (i % frequency == 0) {
#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.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Helper class for reporting progress from algorithms.
A property class for workspaces.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void debug(const std::string &msg)
Logs at debug level.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
const std::string name() const override
Algorithm's name for identification.
std::shared_ptr< IMDHistoWorkspace > IMDHistoWorkspace_sptr
shared pointer to Mantid::API::IMDHistoWorkspace
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base 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.
std::string GreaterThan()
@ Input
An input workspace.
@ Output
An output workspace.