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.");
98 const std::string &resolvedName = componentInfo.name(componentIndex);
99 auto oldscalex =
pmap.getDouble(resolvedName, std::string(
"scalex"));
100 auto oldscaley =
pmap.getDouble(resolvedName, std::string(
"scaley"));
102 auto *componentID =
const_cast<IComponent *
>(componentInfo.componentID(componentIndex));
103 pmap.addDouble(componentID,
"scalex",
ScaleX);
104 pmap.addDouble(componentID,
"scaley", ScaleY);
105 pmap.clearPositionSensitiveCaches();
111 double relscalex =
ScaleX;
112 double relscaley = ScaleY;
113 if (!oldscalex.empty())
114 relscalex /= oldscalex[0];
115 if (!oldscaley.empty())
116 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.
base class for Geometric IComponent
Parameter map iterator typedef.
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< Instrument > Instrument_sptr
Shared pointer to an instrument object.
Generate a tableworkspace to store the calibration results.
@ InOut
Both an input & output workspace.