25const
std::
string SetUB::name()
const {
return "SetUB"; }
36 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
37 mustBePositive->setLower(0.0);
38 auto reasonableAngle = std::make_shared<BoundedValidator<double>>();
39 reasonableAngle->setLower(5.0);
40 reasonableAngle->setUpper(175.0);
42 auto mustBe3D = std::make_shared<ArrayLengthValidator<double> >(3);
43 auto threeVthree = std::make_shared<ArrayLengthValidator<double> >(9);
45 std::vector<double> zeroes(9, 0.), u0(3, 0), v0(3, 0);
49 "An input workspace.");
52 "Lattice parameter a");
55 "Lattice parameter b");
58 "Lattice parameter c");
61 "Lattice parameter alpha (degrees)");
64 "Lattice parameter beta (degrees)");
67 "Lattice parameter gamma(degrees) ");
69 "Vector along k_i, when goniometer is at 0");
71 "In plane vector perpendicular to k_i, when goniometer is at 0");
74 "For an MD workspace, the sample number to wich to "
75 "attach an oriented lattice (starting from 0). No "
76 "number, or negative number, means that it will copy "
84 std::unique_ptr<Mantid::Geometry::OrientedLattice> lattice;
87 if (UBMatrix == zeroMatrix) {
88 double a, b, c, alpha, beta, gamma;
98 lattice = std::make_unique<OrientedLattice>(a, b, c, alpha, beta, gamma);
101 if (UBMatrix.determinant() == 0)
102 throw std::invalid_argument(
"UB matrix determinant is 0");
104 lattice = std::make_unique<OrientedLattice>();
105 lattice->setUB(UBMatrix);
114 if (mdws !=
nullptr) {
116 if ((sampleNumber ==
EMPTY_INT()) || (sampleNumber < 0))
118 for (uint16_t i = 0; i < mdws->getNumExperimentInfo(); i++) {
119 mdws->getExperimentInfo(i)->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>(*lattice));
123 if (
static_cast<uint16_t
>(sampleNumber) > (mdws->getNumExperimentInfo() - 1)) {
124 g_log.
warning() <<
"Number greater than the number of last sample in "
126 << (mdws->getNumExperimentInfo() - 1) <<
"). Will use sample number 0 instead\n";
129 mdws->getExperimentInfo(
static_cast<uint16_t
>(sampleNumber))
131 .setOrientedLattice(std::move(lattice));
137 throw std::invalid_argument(
"Wrong type of workspace");
138 ei->mutableSample().setOrientedLattice(std::move(lattice));
#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.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
A property class for workspaces.
SetUB : Algorithm to set the UB matrix, given lattice parameters and u and v vectors as defined in: h...
void init() override
Initialize the algorithm's properties.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
void exec() override
Execute the algorithm.
Class to implement UB matrix.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void warning(const std::string &msg)
Logs at warning level.
The concrete, templated class for properties.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< MultipleExperimentInfos > MultipleExperimentInfos_sptr
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
@ InOut
Both an input & output workspace.
@ Input
An input workspace.