15#include "MantidHistogramData/Histogram.h"
23using namespace Kernel;
25using namespace DataObjects;
26using namespace HistogramData;
31 "The name of the input workspace.");
34 "The name of the output workspace.");
36 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
37 mustBePositive->setLower(0);
39 declareProperty(
"StartBin", 0, mustBePositive,
"Bin index to start from");
43 declareProperty(
"Factor", 0.0,
"The value by which to multiply the input data range");
56 const auto specSize =
static_cast<int>(inputWS->blocksize());
58 endBin = specSize - 1;
60 if (endBin >= specSize) {
62 throw std::out_of_range(
"EndBin out of range!");
64 if (endBin < startBin) {
65 g_log.
error(
"StartBin must be less than or equal to EndBin");
66 throw std::out_of_range(
"StartBin must be less than or equal to EndBin");
71 if (outputWS != inputWS) {
72 outputWS = create<MatrixWorkspace>(*inputWS);
77 const auto histogramCount =
static_cast<int>(inputWS->getNumberHistograms());
81 for (
int i = 0; i < histogramCount; ++i) {
83 outputWS->setHistogram(i, inputWS->histogram(i));
84 auto &newY = outputWS->mutableY(i);
85 auto &newE = outputWS->mutableE(i);
88 using std::placeholders::_1;
89 std::transform(newY.begin() + startBin, newY.begin() + endBin + 1, newY.begin() + startBin,
90 std::bind(std::multiplies<double>(), _1, factor));
91 std::transform(newE.begin() + startBin, newE.begin() + endBin + 1, newE.begin() + startBin,
92 std::bind(std::multiplies<double>(), _1, factor));
#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.
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void init() override
Initialisation code.
void exec() override
Execution code.
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.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace 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.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
@ Input
An input workspace.
@ Output
An output workspace.