21using namespace Kernel;
23using namespace DataObjects;
25Logger logger(
"CorelliCalibrationApply");
39 auto wsValidator = std::make_shared<InstrumentValidator>();
42 "CORELLI workspace to calibrate");
49 "TableWorkspace containing calibration table");
58 std::map<std::string, std::string> issues;
62 if (
ws->getInstrument()->getName() !=
"CORELLI") {
63 issues[
"Workspace"] =
"CORELLI only algorithm, aborting";
69 std::vector<std::string> colnames =
calTable->getColumnNames();
70 if (colnames.size() != refCalTableHeader.size()) {
71 issues[
"CalibrationTable"] =
"Headers of input calibration table does not match required";
73 for (
size_t i = 0; i < colnames.size(); i++) {
74 if (colnames[i] != refCalTableHeader[i]) {
75 issues[
"CalibrationTable"] =
"Header mismatch at " +
std::to_string(i);
88 g_log.
notice() <<
"Start applying CORELLI calibration\n";
92 auto wsName =
ws->getName();
95 const auto componentNames =
calTable->getColumn(0);
96 const auto x_poss =
calTable->getColumn(1);
97 const auto y_poss =
calTable->getColumn(2);
98 const auto z_poss =
calTable->getColumn(3);
99 const auto rotxs =
calTable->getColumn(4);
100 const auto rotys =
calTable->getColumn(5);
101 const auto rotzs =
calTable->getColumn(6);
102 const auto rotangs =
calTable->getColumn(7);
117 g_log.
notice() <<
"Translating each component using given Calibration table";
119 moveAlg->initialize();
120 moveAlg->setProperty(
"Workspace", wsName);
121 for (
size_t row_num = 0; row_num <
calTable->rowCount(); row_num++) {
122 moveAlg->setProperty(
"ComponentName", componentNames->cell<std::string>(row_num));
123 moveAlg->setProperty(
"X", x_poss->cell<
double>(row_num));
124 moveAlg->setProperty(
"Y", y_poss->cell<
double>(row_num));
125 moveAlg->setProperty(
"Z", z_poss->cell<
double>(row_num));
128 moveAlg->setProperty(
"RelativePosition",
false);
157 g_log.
notice() <<
"Rotating each component using given Calibration table";
159 rotateAlg->initialize();
160 rotateAlg->setProperty(
"Workspace", wsName);
161 for (
size_t row_num = 0; row_num <
calTable->rowCount(); row_num++) {
162 if (std::abs(rotangs->cell<
double>(row_num)) < 1e-8) {
165 rotateAlg->setProperty(
"ComponentName", componentNames->cell<std::string>(row_num));
166 rotateAlg->setProperty(
"X", rotxs->cell<
double>(row_num));
167 rotateAlg->setProperty(
"Y", rotys->cell<
double>(row_num));
168 rotateAlg->setProperty(
"Z", rotzs->cell<
double>(row_num));
169 rotateAlg->setProperty(
"Angle", rotangs->cell<
double>(row_num));
173 rotateAlg->setProperty(
"RelativeRotation",
false);
174 rotateAlg->execute();
180 g_log.
notice() <<
"Finished applying CORELLI calibration\n";
#define DECLARE_ALGORITHM(classname)
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
A property class for workspaces.
Apply calibration table for Corelli Powder Diffraction.
DataObjects::TableWorkspace_sptr calTable
std::map< std::string, std::string > validateInputs() override
Private validator for inputs.
void exec() override
Overwrites Algorithm method.
API::MatrixWorkspace_sptr ws
Members.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
static const std::vector< std::string > calibrationTableColumnNames
std::string to_string(const wide_integer< Bits, Signed > &n)
@ InOut
Both an input & output workspace.
@ Input
An input workspace.