30const static std::string SIGMA(
"Sigma");
35namespace ColumnNames {
36const static std::string WS_INDEX(
"WorkspaceIndex");
37const static std::string PEAK_CENTRE(
"PeakCentre");
38const static std::string PEAK_CENTRE_ERR(
"PeakCentreError");
39const static std::string SIGMA(
"Sigma");
40const static std::string SIGMA_ERR(
"SigmaError");
41const static std::string HEIGHT(
"Height");
42const static std::string HEIGHT_ERR(
"HeightError");
43const static std::string CHI_SQUARED(
"chiSq");
44const static std::string STATUS(
"FitStatus");
52 ws->addColumn(
"int", ColumnNames::WS_INDEX);
53 ws->addColumn(
"double", ColumnNames::PEAK_CENTRE);
54 ws->addColumn(
"double", ColumnNames::PEAK_CENTRE_ERR);
55 ws->addColumn(
"double", ColumnNames::SIGMA);
56 ws->addColumn(
"double", ColumnNames::SIGMA_ERR);
57 ws->addColumn(
"double", ColumnNames::HEIGHT);
58 ws->addColumn(
"double", ColumnNames::HEIGHT_ERR);
59 ws->addColumn(
"double", ColumnNames::CHI_SQUARED);
60 ws->addColumn(
"str", ColumnNames::STATUS);
81 return "Creates a nominal EPP table compatible with what is returned by the "
89 auto inputWSValidator = std::make_shared<Kernel::CompositeValidator>();
90 inputWSValidator->add(std::make_shared<API::InstrumentValidator>());
91 inputWSValidator->add(std::make_shared<API::WorkspaceUnitValidator>(
"TOF"));
94 "An input workspace.");
96 "The calculated output EPP table.");
97 auto mustBePositive = std::make_shared<Kernel::BoundedValidator<double>>();
98 mustBePositive->setLower(0);
99 declareProperty(PropertyNames::SIGMA, 0.0, mustBePositive,
"The value to fill the Sigma column with.");
107 const auto &spectrumInfo = inputWS->spectrumInfo();
109 addEPPColumns(outputWS);
111 const size_t spectraCount = spectrumInfo.size();
112 outputWS->setRowCount(spectraCount);
113 const auto l1 = spectrumInfo.l1();
114 const double EFixed = inputWS->run().getPropertyAsSingleValue(
"Ei");
115 for (
size_t i = 0; i < spectraCount; ++i) {
116 const auto l2 = spectrumInfo.l2(i);
117 const auto elasticTOF =
119 outputWS->getRef<
int>(ColumnNames::WS_INDEX, i) =
static_cast<int>(i);
120 outputWS->getRef<
double>(ColumnNames::PEAK_CENTRE, i) = elasticTOF;
121 outputWS->getRef<
double>(ColumnNames::PEAK_CENTRE_ERR, i) = 0;
122 outputWS->getRef<
double>(ColumnNames::SIGMA, i) =
sigma;
123 outputWS->getRef<
double>(ColumnNames::SIGMA_ERR, i) = 0;
126 const auto elasticIndex = inputWS->yIndexOfX(elasticTOF, i);
127 height = inputWS->y(i)[elasticIndex];
128 }
catch (std::out_of_range &) {
129 std::ostringstream sout;
130 sout <<
"EPP out of TOF range for workspace index " << i <<
". Peak height set to zero.";
133 outputWS->getRef<
double>(ColumnNames::HEIGHT, i) =
height;
134 outputWS->getRef<
double>(ColumnNames::CHI_SQUARED, i) = 1;
135 outputWS->getRef<std::string>(ColumnNames::STATUS, i) =
"success";
146 std::map<std::string, std::string> issues;
150 }
else if (!inputWS->run().hasProperty(
"Ei")) {
#define DECLARE_ALGORITHM(classname)
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.
A property class for workspaces.
CreateEPP : Calculates the nominal elastic time-of flights for each spectrum and creates an elastic p...
std::map< std::string, std::string > validateInputs(void) override
Validate the algorithm's properties.
int version() const override
Algorithm's version for identification.
void exec() override
Execute the algorithm.
const std::string category() const override
Algorithm's category for identification.
void init() override
Initialize the algorithm's properties.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
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.
static double run(const std::string &src, const std::string &dest, const double srcValue, const double l1, const double l2, const double theta, const DeltaEMode::Type emode, const double efixed)
Convert a single value between the given units (as strings)
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
static const std::string OUTPUT_WORKSPACE
static const std::string INPUT_WORKSPACE
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.
@ Output
An output workspace.