18Kernel::Logger logger(
"ApplyCalibration");
23using namespace Kernel;
30 "The name of the input workspace to apply the calibration to");
34 "The name of the table workspace containing the new "
35 "positions of detectors");
39 "Deprecated: Use Property 'CalibrationTable'");
55 if (!CalTable && !PosTable) {
56 throw std::runtime_error(
"Either CalibrationTable or PositionTable must be supplied");
58 if (PosTable && !CalTable) {
59 logger.notice(
"Property 'PositionTable' has been deprecated. Please use "
60 "'CalibrationTable' in its place\n");
65 std::vector<std::string> columnNames = CalTable->getColumnNames();
66 size_t numDetector = CalTable->rowCount();
70 if (std::find(columnNames.begin(), columnNames.end(),
"Detector Position") != columnNames.end()) {
71 auto &detectorInfo = inputWS->mutableDetectorInfo();
74 for (
size_t i = 0; i < numDetector; ++i) {
75 const auto index = detectorInfo.indexOf(detectorID[i]);
76 detectorInfo.setPosition(
index, detPos[i]);
81 if (std::find(columnNames.begin(), columnNames.end(),
"Detector Y Coordinate") != columnNames.end()) {
84 auto &detectorInfo = inputWS->mutableDetectorInfo();
87 for (
size_t i = 0; i < numDetector; ++i) {
88 const auto index = detectorInfo.indexOf(detectorID[i]);
89 V3D xyz = detectorInfo.position(
index);
90 detectorInfo.setPosition(
index,
V3D(xyz.
X(), yCoordinate[i], xyz.
Z()));
95 if (std::find(columnNames.begin(), columnNames.end(),
"Detector Width") != columnNames.end()) {
96 auto &detectorInfo = inputWS->detectorInfo();
97 auto &componentInfo = inputWS->mutableComponentInfo();
100 for (
size_t i = 0; i < numDetector; ++i) {
101 const auto index = detectorInfo.indexOf(detectorID[i]);
102 double nominalWidth = componentInfo.shape(
index).getBoundingBox().width().X();
103 V3D oldScaleFactor = componentInfo.scaleFactor(
index);
104 componentInfo.setScaleFactor(
index,
V3D(widths[i] / nominalWidth, oldScaleFactor.
Y(), oldScaleFactor.
Z()));
109 if (std::find(columnNames.begin(), columnNames.end(),
"Detector Height") != columnNames.end()) {
112 auto &detectorInfo = inputWS->mutableDetectorInfo();
113 auto &componentInfo = inputWS->mutableComponentInfo();
116 for (
size_t i = 0; i < numDetector; ++i) {
117 const auto index = detectorInfo.indexOf(detectorID[i]);
119 double nominalHeight = componentInfo.shape(
index).getBoundingBox().width().Y();
120 V3D oldScaleFactor = componentInfo.scaleFactor(
index);
121 componentInfo.setScaleFactor(
index,
V3D(oldScaleFactor.
X(),
height[i] / nominalHeight, oldScaleFactor.
Z()));
#define DECLARE_ALGORITHM(classname)
std::map< DeltaEMode::Type, std::string > index
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.
ColumnVector gives access to the column elements without alowing its resizing.
A property class for workspaces.
void exec() override
Overwrites Algorithm method.
void init() override
Overwrites Algorithm method. Does nothing at present.
constexpr double X() const noexcept
Get x.
constexpr double Y() const noexcept
Get y.
constexpr double Z() const noexcept
Get z.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ InOut
Both an input & output workspace.
@ Input
An input workspace.