19#include "MantidTypes/SpectrumDefinition.h"
21#include <boost/format.hpp>
26using namespace Kernel;
28using namespace Geometry;
29using namespace DataObjects;
36 :
API::
Algorithm(), m_inputWS(), m_outputWS(), m_instrument(), m_l2(0.), m_wavelength(0.) {}
42 auto wsValidator = std::make_shared<CompositeValidator>();
47 "Name of the input workspace");
49 "Name of the output workspace, can be the same as the input");
82 const size_t numberOfSpectra =
m_inputWS->getNumberHistograms();
85 auto numberOfSpectra_i =
static_cast<int64_t
>(numberOfSpectra);
87 const auto &inputSpecInfo =
m_inputWS->spectrumInfo();
88 auto &outputDetInfo =
m_outputWS->mutableDetectorInfo();
92 for (int64_t i = 0; i < numberOfSpectra_i; ++i) {
97 if (inputSpecInfo.isMonitor(i))
101 if (!inputSpecInfo.hasUniqueDetector(i)) {
102 const auto errorMsg = boost::format(
"The detector for spectrum number %d was either not "
103 "found, or is a group.") %
105 throw std::runtime_error(errorMsg.str());
109 double thisDetL2 = inputSpecInfo.l2(i);
110 double deltaL2 = std::abs(thisDetL2 -
m_l2);
115 double r, theta, phi;
116 V3D oldPos = inputSpecInfo.position(i);
121 const auto detIndex = inputSpecInfo.spectrumDefinition(i)[0];
122 outputDetInfo.setPosition(detIndex, newPos);
126 prog.
report(
"Aligning elastic line...");
141 if (!run.hasProperty(s)) {
147 const std::string mesg =
"Cannot convert sample log '" + s +
"' to a number.";
148 throw std::runtime_error(mesg);
158 std::vector<std::string> prop =
m_instrument->getStringParameter(s);
160 const std::string mesg =
"Property <" + s +
"> doesn't exist!";
161 throw std::runtime_error(mesg);
163 g_log.
debug() <<
"prop[0] = " << prop[0] <<
'\n';
164 return boost::lexical_cast<double>(prop[0]);
174 return distance / velocity;
#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.
Base class from which all concrete algorithm classes should be derived.
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 validator which checks that a workspace contains histogram data (the default) or point data as requ...
Helper class for reporting progress from algorithms.
A property class for workspaces.
A validator which checks that the unit of the workspace referred to by a WorkspaceProperty is the exp...
Convert workspace to have a constant L2.
API::MatrixWorkspace_sptr m_outputWS
The output workspace, maybe the same as the input one.
double getRunProperty(const std::string &)
API::MatrixWorkspace_const_sptr m_inputWS
The user selected (input) workspace.
void exec() override
Executes the algorithm.
double calculateTOF(double)
Geometry::Instrument_const_sptr m_instrument
double getInstrumentProperty(const std::string &)
void init() override
Initialisation method.
void initWorkspaces()
Initialises input and output workspaces.
Exception for when an item is not found in a collection.
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 report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
Base class for properties.
virtual std::string value() const =0
Returns the value of the property as a string.
void spherical(const double R, const double theta, const double phi) noexcept
Sets the vector position based on spherical coordinates.
void getSpherical(double &R, double &theta, double &phi) const noexcept
Return the vector's position in spherical coordinates.
int convert(const std::string &A, T &out)
Convert a string into a number.
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.
static constexpr double NeutronMass
Mass of the neutron in kg.
static constexpr double h
Planck constant in J*s.
@ Input
An input workspace.
@ Output
An output workspace.