16namespace DataHandling {
20using namespace Kernel;
21using namespace Geometry;
28 "The name of the workspace containing the instrument component to be scaled.");
30 "The name of the component to scale. Component names are "
31 "defined in the instrument definition files. A pathname "
32 "delineated by '/' may be used for non-unique name.");
34 "A 3D vector specifying the scaling factors for the component.");
36 declareProperty(
"ScalePixelSizes",
true,
"Scale the pixel dimensions of the detector.");
39 std::map<std::string, std::string> result;
50 inst = inputW->getInstrument();
53 inst = inputP->getInstrument();
56 result[
"Workspace"] =
"Input workspace must be either MatrixWorkspace or PeaksWorkspace.";
62 result[
"Workspace"] =
"Could not get a valid instrument from the provided workspace.";
67 std::string componentName =
getProperty(
"ComponentName");
68 if (componentName.empty()) {
69 result[
"ComponentName"] =
"ComponentName must be provided.";
73 m_comp = inst->getComponentByName(componentName);
75 result[
"ComponentName"] =
"Component with name " + componentName +
" was not found.";
81 result[
"ComponentInfo"] =
"Could not get component info from the workspace.";
88 result[
"ComponentName"] =
"Cannot scale a detector. Please provide a non-detector component name.";
98 std::vector<double> scalingsXYZ =
getProperty(
"Scalings");
99 Kernel::V3D scalings(scalingsXYZ[0], scalingsXYZ[1], scalingsXYZ[2]);
100 const bool scalePixels =
getProperty(
"ScalePixelSizes");
102 const auto componentId =
m_comp->getComponentID();
106 std::vector<size_t> detectors;
108 for (
const auto &detector : detectors) {
111 detector,
V3D(oldScale.X() * scalings.
X(), oldScale.Y() * scalings.
Y(), oldScale.Z() * scalings.
Z()));
#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.
ScaleInstrumentComponent()
Mantid::Geometry::IComponent_const_sptr m_comp
Mantid::Geometry::ComponentInfo * m_componentInfo
void init() override
Implement abstract Algorithm methods.
void exec() override
Implement abstract Algorithm methods.
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
void scaleComponent(const size_t componentIndex, const Kernel::V3D &newScaling)
void setScaleFactor(const size_t componentIndex, const Kernel::V3D &scaleFactor)
std::vector< size_t > detectorsInSubtree(size_t componentIndex) const
bool isDetector(const size_t componentIndex) const
size_t indexOf(Geometry::IComponent const *id) const
Kernel::V3D scaleFactor(const size_t componentIndex) const
Support for a property that holds an array of values.
constexpr double X() const noexcept
Get x.
constexpr double Y() const noexcept
Get y.
constexpr double Z() const noexcept
Get z.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
Helper class which provides the Collimation Length for SANS instruments.
@ InOut
Both an input & output workspace.