19using namespace Kernel;
21using HistogramData::Histogram;
25 "Name of the input workspace");
27 "The name of the workspace to be created as the output of the algorithm");
28 std::vector<int> npts0{3};
29 auto min = std::make_shared<Kernel::ArrayBoundedValidator<int>>();
33 "The number of points to average over (minimum 3). If an even number is\n"
34 "given, it will be incremented by 1 to make it odd (default value 3)");
37 "Optional: GroupingWorkspace to use for vector of NPoints.");
44 std::vector<int> nptsGroup =
getProperty(
"NPoints");
49 groupWS->makeDetectorIDToGroupVector(
udet2group, nGroups);
54 const auto vecSize =
static_cast<int>(
inputWorkspace->blocksize());
61 for (
int i = 0; i < static_cast<int>(
inputWorkspace->getNumberHistograms()); ++i) {
63 int npts = nptsGroup[0];
70 npts = nptsGroup[
group - 1];
73 if (npts >= vecSize) {
74 g_log.
error(
"The number of averaging points requested is larger than the "
76 throw std::out_of_range(
"The number of averaging points requested is "
77 "larger than the spectrum length");
104 const auto &dets =
inputWorkspace->getSpectrum(wi).getDetectorIDs();
107 g_log.
debug() << wi <<
" <- this workspace index is empty!\n";
111 auto it = dets.cbegin();
120 for (; it != dets.end(); ++it)
133Histogram
smooth(
const Histogram &histogram,
unsigned int const npts) {
137 Histogram smoothed(histogram);
139 auto const &
Y = histogram.y().rawData();
140 auto const &E = histogram.e().rawData();
141 auto &newY = smoothed.mutableY();
142 auto &newE = smoothed.mutableE();
#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.
Helper class for reporting progress from algorithms.
A property class for workspaces.
std::vector< int > udet2group
void init() override
Initialisation code.
API::MatrixWorkspace_const_sptr inputWorkspace
int validateSpectrumInGroup(size_t wi)
Verify that all the contributing detectors to a spectrum belongs to the same group.
void exec() override
Execution code.
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 debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void information(const std::string &msg)
Logs at information level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
HistogramData::Histogram smooth(const HistogramData::Histogram &histogram, unsigned int const npts)
std::shared_ptr< GroupingWorkspace > GroupingWorkspace_sptr
shared pointer to the GroupingWorkspace class
std::vector< T > boxcarErrorSmooth(std::vector< T > const &input, unsigned int const numPoints)
Performs boxcar (moving average) smoothing on the input data, using error propagation formula.
std::vector< T > boxcarSmooth(std::vector< T > const &input, unsigned int const numPoints)
Performs boxcar (moving average) smoothing on the input data.
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.
@ Input
An input workspace.
@ Output
An output workspace.