15#include "MantidHistogramData/Histogram.h"
23using namespace Kernel;
33 std::make_shared<HistogramValidator>()),
34 "The name of the Workspace2D to take as input");
36 "The name of the workspace in which to store the result");
38 declareProperty(
"ShowMin",
false,
"Flag to show minimum instead of maximum (default=false)");
41 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
42 mustBePositive->setLower(0);
43 declareProperty(
"StartWorkspaceIndex", 0, mustBePositive,
"Start spectrum number (default 0)");
68 const auto numberOfSpectra =
static_cast<int>(localworkspace->getNumberHistograms());
71 if (MinSpec > numberOfSpectra) {
76 MaxSpec = numberOfSpectra - 1;
77 if (MaxSpec > numberOfSpectra - 1 || MaxSpec < MinSpec) {
78 g_log.
warning(
"EndSpectrum out of range! Set to max detector number");
79 MaxSpec = numberOfSpectra;
81 if (MinRange > MaxRange) {
82 g_log.
warning(
"Range_upper is less than Range_lower. Will integrate up to "
90 outputWorkspace = create<HistoWorkspace>(*localworkspace, MaxSpec - MinSpec + 1, BinEdges(2));
95 for (
int i = MinSpec; i <= MaxSpec; ++i) {
97 int newindex = i - MinSpec;
99 outputWorkspace->getSpectrum(newindex).copyInfoFrom(localworkspace->getSpectrum(i));
102 auto &
X = localworkspace->x(i);
103 auto &
Y = localworkspace->y(i);
106 MantidVec::const_iterator lowit, highit;
110 lowit = std::lower_bound(
X.begin(),
X.end(), MinRange);
115 using std::placeholders::_1;
116 highit = std::find_if(lowit,
X.end(), std::bind(std::greater<double>(), _1, MaxRange));
120 if (lowit ==
X.end() || highit ==
X.begin() || lowit == highit)
126 MantidVec::difference_type distmin = std::distance(
X.begin(), lowit);
127 MantidVec::difference_type distmax = std::distance(
X.begin(), highit);
129 MantidVec::const_iterator maxY;
132 maxY = std::min_element(
Y.begin() + distmin,
Y.begin() + distmax);
134 maxY = std::max_element(
Y.begin() + distmin,
Y.begin() + distmax);
136 MantidVec::difference_type
d = std::distance(
Y.begin(), maxY);
138 outputWorkspace->mutableX(newindex)[0] = *(
X.begin() +
d);
139 outputWorkspace->mutableX(newindex)[1] = *(
X.begin() +
d + 1);
140 outputWorkspace->mutableY(newindex)[0] = *maxY;
#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 exec() override
Executes the algorithm.
void init() override
Initialisation method.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void warning(const std::string &msg)
Logs at warning 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.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.