12#include "MantidHistogramData/Histogram.h"
13#include "MantidHistogramData/HistogramBuilder.h"
35 "Name of input MatrixWorkspace to have Z-score calculated.");
38 "Name of the output Workspace2D containing the Z-scores.");
40 declareProperty(
"WorkspaceIndex",
EMPTY_INT(),
41 "Index of the spetrum to have Z-score calculated. "
42 "Default is to calculate for all spectra.");
53 bool zscoreforall =
false;
61 numspec = inpWS->getNumberHistograms();
65 size_t sizex = inpWS->x(0).size();
66 size_t sizey = inpWS->y(0).size();
68 HistogramBuilder builder;
71 builder.setDistribution(inpWS->isDistribution());
77 for (
size_t i = 0; i < numspec; ++i) {
85 wsindex =
static_cast<size_t>(inpwsindex);
86 if (wsindex >= inpWS->getNumberHistograms()) {
88 errmsg <<
"Input workspace index " << inpwsindex
89 <<
" is out of input workspace range = " << inpWS->getNumberHistograms() <<
'\n';
94 auto &inpY = inpWS->y(wsindex).rawData();
95 auto &inpE = inpWS->e(wsindex).rawData();
97 auto &histY = outWS->mutableY(i);
98 auto &histE = outWS->mutableE(i);
100 vector<double> yzscores =
getZscore(inpY);
101 vector<double> ezscores =
getZscore(inpE);
103 outWS->setSharedX(i, inpWS->sharedX(wsindex));
107 progress.report(
"Calculating Z Score");
#define DECLARE_ALGORITHM(classname)
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.
CalculateZscore : Calculate Zscore for a Matrix Workspace.
void exec() override
Implement abstract Algorithm methods.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
std::vector< double > getZscore(const std::vector< TYPE > &data)
Return the Z score values for a dataset.
Helper class which provides the Collimation Length for SANS instruments.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
@ Input
An input workspace.
@ Output
An output workspace.