44 declareProperty(
"ComponentName",
"",
"The name of the RectangularDetector to resize.");
45 declareProperty(
"ScaleX", 1.0,
"The scaling factor in the X direction. Default 1.0");
46 declareProperty(
"ScaleY", 1.0,
"The scaling factor in the Y direction. Default 1.0");
61 inst = std::const_pointer_cast<Instrument>(inputW->getInstrument());
63 throw std::runtime_error(
"Could not get a valid instrument from the "
64 "MatrixWorkspace provided as input");
67 inst = std::const_pointer_cast<Instrument>(inputP->getInstrument());
69 throw std::runtime_error(
"Could not get a valid instrument from the "
70 "PeaksWorkspace provided as input");
72 throw std::runtime_error(
"Could not get a valid instrument from the "
73 "workspace and it does not seem to be valid as "
74 "input (must be either MatrixWorkspace or "
82 if (ComponentName.empty())
83 throw std::runtime_error(
"You must specify a ComponentName.");
85 auto input = std::dynamic_pointer_cast<ExperimentInfo>(ws);
86 auto &componentInfo = input->mutableComponentInfo();
88 size_t componentIndex;
90 componentIndex = componentInfo.indexOfAny(ComponentName);
91 }
catch (std::invalid_argument &) {
92 throw std::runtime_error(
"Component with name " + ComponentName +
" was not found.");
94 if (!componentInfo.isGridDetector(componentIndex)) {
95 throw std::runtime_error(
"Component with name " + ComponentName +
" is not a RectangularDetector.");
97 auto oldscalex = componentInfo.getNumberParameter(componentIndex,
"scalex",
false);
98 auto oldscaley = componentInfo.getNumberParameter(componentIndex,
"scaley",
false);
100 componentInfo.addDouble(componentIndex,
"scalex",
ScaleX);
101 componentInfo.addDouble(componentIndex,
"scaley", ScaleY);
107 double relscalex =
ScaleX;
108 double relscaley = ScaleY;
109 if (!oldscalex.empty())
110 relscalex /= oldscalex[0];
111 if (!oldscaley.empty())
112 relscaley /= oldscaley[0];
#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.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
A property class for workspaces.
ResizeRectangularDetector : TODO: DESCRIPTION.
void init() override
Initialize the algorithm's properties.
void exec() override
Execute the algorithm.
int version() const override
Algorithm's version for identification.
const std::string category() const override
Algorithm's category for identification.
Takes a workspace and adjusts all the time bin values by the same multiplicative factor.
MANTID_API_DLL void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, const size_t componentIndex, const double scaleX, const double scaleY)
Helpers for resizing RectangularDetectors.
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< Instrument > Instrument_sptr
Shared pointer to an instrument object.
@ InOut
Both an input & output workspace.