18using namespace Kernel;
19using namespace Geometry;
30 "The name of the workspace for which the new instrument "
31 "configuration will have an effect. Any other workspaces "
32 "stored in the analysis data service will be unaffected.");
34 "The name of the component to rotate. "
35 "Component names are defined in the "
36 "instrument definition files.");
38 "The ID of the detector to rotate. If both "
39 "the component name and the detector ID "
40 "are set the latter will be used.");
46 "The property defining how the rotation should be "
47 "interpreted. If true it is a relative rotation. Otherwise "
48 "it is an absolute rotation.");
64 inst = std::const_pointer_cast<Instrument>(inputW->getInstrument());
66 throw std::runtime_error(
"Could not get a valid instrument from the "
67 "MatrixWorkspace provided as input");
69 inst = std::const_pointer_cast<Instrument>(inputP->getInstrument());
71 throw std::runtime_error(
"Could not get a valid instrument from the "
72 "PeaksWorkspace provided as input");
75 throw std::runtime_error(
"Could not get a valid instrument from the "
76 "workspace and it does not seem to be valid as "
77 "input (must be either MatrixWorkspace or "
81 const std::string ComponentName =
getProperty(
"ComponentName");
87 const bool relativeRotation =
getProperty(
"RelativeRotation");
90 throw std::invalid_argument(
"The rotation axis must not be a zero vector");
96 comp = inst->getDetector(DetID);
97 if (comp ==
nullptr) {
98 std::ostringstream mess;
99 mess <<
"Detector with ID " << DetID <<
" was not found.";
101 throw std::runtime_error(mess.str());
103 }
else if (!ComponentName.empty()) {
104 comp = inst->getComponentByName(ComponentName);
105 if (comp ==
nullptr) {
106 std::ostringstream mess;
107 mess <<
"Component with name " << ComponentName <<
" was not found.";
109 throw std::runtime_error(mess.str());
112 g_log.
error(
"DetectorID or ComponentName must be given.");
113 throw std::invalid_argument(
"DetectorID or ComponentName must be given.");
118 if (relativeRotation)
122 const auto componentId = comp->getComponentID();
124 auto &componentInfo = inputW->mutableComponentInfo();
127 auto &componentInfo = inputP->mutableComponentInfo();
128 componentInfo.setRotation(componentInfo.indexOf(componentId),
rotation);
#define DECLARE_ALGORITHM(classname)
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
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.
void exec() override
Overwrites Algorithm method.
void init() override
Overwrites Algorithm method.
RotateInstrumentComponent()
Default constructor.
void error(const std::string &msg)
Logs at error level.
std::vector< double > getRotation(bool check_normalisation=false, bool throw_on_errors=false) const
returns the rotation matrix defined by this quaternion as an 9-point
void setRotation(const double deg)
Set the rotation (both don't change rotation axis)
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 IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
@ InOut
Both an input & output workspace.