46 declareProperty(
"ComponentName",
"",
"The name of the RectangularDetector to resize.");
47 declareProperty(
"ScaleX", 1.0,
"The scaling factor in the X direction. Default 1.0");
48 declareProperty(
"ScaleY", 1.0,
"The scaling factor in the Y direction. Default 1.0");
63 inst = std::const_pointer_cast<Instrument>(inputW->getInstrument());
65 throw std::runtime_error(
"Could not get a valid instrument from the "
66 "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");
74 throw std::runtime_error(
"Could not get a valid instrument from the "
75 "workspace and it does not seem to be valid as "
76 "input (must be either MatrixWorkspace or "
84 if (ComponentName.empty())
85 throw std::runtime_error(
"You must specify a ComponentName.");
89 comp = inst->getComponentByName(ComponentName);
91 throw std::runtime_error(
"Component with name " + ComponentName +
" was not found.");
95 throw std::runtime_error(
"Component with name " + ComponentName +
" is not a RectangularDetector.");
97 auto input = std::dynamic_pointer_cast<ExperimentInfo>(ws);
99 auto oldscalex =
pmap.getDouble(det->getName(), std::string(
"scalex"));
100 auto oldscaley =
pmap.getDouble(det->getName(), std::string(
"scaley"));
102 pmap.addDouble(det->getComponentID(),
"scalex",
ScaleX);
103 pmap.addDouble(det->getComponentID(),
"scaley", ScaleY);
104 pmap.clearPositionSensitiveCaches();
110 double relscalex =
ScaleX;
111 double relscaley = ScaleY;
112 if (!oldscalex.empty())
113 relscalex /= oldscalex[0];
114 if (!oldscaley.empty())
115 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.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
MANTID_API_DLL void applyRectangularDetectorScaleToComponentInfo(Geometry::ComponentInfo &componentInfo, Geometry::IComponent *componentId, const double scaleX, const double scaleY)
Helpers for resizing RectangularDetectors.
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< const RectangularDetector > RectangularDetector_const_sptr
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
Generate a tableworkspace to store the calibration results.
@ InOut
Both an input & output workspace.