13#include "MantidHistogramData/Histogram.h"
18using namespace Kernel;
20using namespace HistogramData;
21using namespace DataObjects;
26 auto wsVal = std::make_shared<CompositeValidator>();
34 declareProperty(
"RangeLower", 2000.0,
"The lower integration range");
35 declareProperty(
"RangeUpper", 19000.0,
"The upper integration range");
42 const auto nHist =
static_cast<int>(inputWS->getNumberHistograms());
44 const double rangeLower =
getProperty(
"RangeLower");
45 const double rangeUpper =
getProperty(
"RangeUpper");
46 const double steps = rangeUpper - rangeLower;
49 throw std::runtime_error(
"Cannot run this algorithm on an input workspace without any spectra. "
50 "It does not seem to make sense and the calculations done here will "
51 "will cause a division by zero.");
57 outputWs = create<MatrixWorkspace>(*inputWS, Points(1));
60 stdDevWs = create<MatrixWorkspace>(*outputWs);
67 integ->setProperty<
double>(
"RangeLower", rangeLower);
68 integ->setProperty<
double>(
"RangeUpper", rangeUpper);
78 power->setProperty<
double>(
"Exponent", 2.0);
89 integ->setProperty<
double>(
"RangeLower", rangeLower);
90 integ->setProperty<
double>(
"RangeUpper", rangeUpper);
97 algScale->initialize();
98 algScale->setProperty(
"InputWorkspace", int1);
99 algScale->setProperty(
"OutputWorkspace", int1);
100 algScale->setProperty(
"Factor", 1.0 / steps);
102 int1 = algScale->getProperty(
"OutputWorkspace");
107 algScale->setProperty(
"InputWorkspace", int2);
108 algScale->setProperty(
"OutputWorkspace", int2);
109 algScale->setProperty(
"Factor", 1.0 / steps);
111 int2 = algScale->getProperty(
"OutputWorkspace");
113 for (
int i = 0; i < nHist; i++) {
114 outputWs->setHistogram(i, Points{0.0}, Counts{1.0});
115 stdDevWs->setSharedX(i, outputWs->sharedX(i));
116 stdDevWs->mutableY(i)[0] = sqrt(int2->y(i)[0] - std::pow(int1->y(i)[0], 2));
139 const auto nhist =
static_cast<int>(valid->getNumberHistograms());
144 for (
int i = 0; i < nhist; i++) {
145 if (valid->y(i)[0] > 0) {
146 mean += values->y(i)[0];
147 mean2 += std::pow(values->y(i)[0], 2);
160 double stddev = sqrt((mean2 /
count) - std::pow(mean, 2));
162 double upper = mean + 3 * stddev;
163 double lower = mean - 3 * stddev;
164 double min = mean * 0.0001;
167 for (
int i = 0; i < nhist; i++) {
168 double value = values->y(i)[0];
170 valid->setCounts(i, counts);
172 valid->setCounts(i, counts);
173 }
else if (
value < min) {
174 valid->setCounts(i, counts);
177 progress.report(
"Calculating StdDev...");
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
double lower
lower and upper bounds on the multiplier, if known
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.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
A validator which checks that a workspace contains histogram data (the default) or point data as requ...
A validator which checks that a workspace has a valid instrument.
Helper class for reporting progress from algorithms.
A validator which checks whether the input workspace has the Spectra number in the axis.
A property class for workspaces.
A validator which checks that the unit of the workspace referred to by a WorkspaceProperty is the exp...
Identifies "bad" detectors based on their standard deviation, and how this differs from the standard ...
void getStdDev(API::Progress &progress, const Mantid::API::MatrixWorkspace_sptr &valid, const Mantid::API::MatrixWorkspace_sptr &values)
Main work portion of algorithm.
void exec() override
Executes the algorithm.
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< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ Input
An input workspace.
@ Output
An output workspace.