Mantid
Loading...
Searching...
No Matches
PeakHKLErrors.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2012 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7/*
8 * PeakHKLErrors.h
9 *
10 * Created on: Jan 26, 2013
11 * Author: ruth
12 */
13
14#pragma once
15
16#include "MantidAPI/IFunction.h"
19#include "MantidCrystal/DllConfig.h"
22#include "MantidKernel/Matrix.h"
23
24namespace Mantid {
25namespace Crystal {
26
32class MANTID_CRYSTAL_DLL PeakHKLErrors : public API::ParamFunction, public API::IFunction1D {
33public:
35
36 std::string name() const override { return std::string("PeakHKLErrors"); };
37
38 virtual int version() const { return 1; };
39
40 const std::string category() const override { return "Calibration"; };
41
42 void function1D(double *out, const double *xValues, const size_t nData) const override;
43
44 void functionDeriv1D(Mantid::API::Jacobian *out, const double *xValues, const size_t nData) override;
45
46 void init() override;
47
64 static DataObjects::Peak createNewPeak(DataObjects::Peak const &peak_old, Kernel::V3D const &samplePos, double T0,
65 double L0);
66
67 void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks, const std::string &OptRuns,
68 std::map<int, Mantid::Kernel::Matrix<double>> &Res) const;
69 size_t nAttributes() const override { return (size_t)2; }
70
71 static Kernel::Matrix<double> DerivRotationMatrixAboutRegAxis(double theta, char axis);
72
73 static Kernel::Matrix<double> RotationMatrixAboutRegAxis(double theta, char axis);
74
75 std::vector<std::string> getAttributeNames() const override { return {"OptRuns", "PeakWorkspaceName"}; }
76
77 IFunction::Attribute getAttribute(const std::string &attName) const override {
78 if (attName == "OptRuns")
79 return IFunction::Attribute(OptRuns);
80
81 if (attName == "PeakWorkspaceName")
82 return IFunction::Attribute(PeakWorkspaceName);
83
84 throw std::invalid_argument("Not a valid attribute name");
85 }
86
87 void setAttribute(const std::string &attName, const IFunction::Attribute &value) override {
88 if (attName == "OptRuns") {
89 OptRuns = value.asString();
90
91 if (OptRuns.empty())
92 return;
93
94 if (OptRuns.at(0) != '/')
95 OptRuns = "/" + OptRuns;
96
97 if (OptRuns.at(OptRuns.size() - 1) != '/')
98 OptRuns += "/";
99
100 if (initMode == 1) {
101 setUpOptRuns();
102 initMode = 2;
103 } else if (initMode == 2) // Woops cannot do twice
104 throw std::invalid_argument("OptRuns can only be set once");
105
106 return;
107 }
108
109 if (attName == "PeakWorkspaceName") {
110 PeakWorkspaceName = value.asString();
111 return;
112 }
113
114 throw std::invalid_argument("Not a valid attribute name");
115 }
116
117 bool hasAttribute(const std::string &attName) const override {
118 if (attName == "OptRuns")
119 return true;
120
121 if (attName == "PeakWorkspaceName")
122 return true;
123
124 return false;
125 }
126
127private:
128 std::string OptRuns;
129
130 std::string PeakWorkspaceName;
131
132 int initMode; // 0 not invoked, 1 invoked but no OptRuns , 2 invoked and
133 // OptRuns setup
134
135 void setUpOptRuns();
136};
137} // namespace Crystal
138} // namespace Mantid
double value
The value of the point.
Definition FitMW.cpp:51
This is a specialization of IFunction for functions of one real argument.
Definition IFunction1D.h:42
Attribute is a non-fitting parameter.
Definition IFunction.h:286
Represents the Jacobian in IFitFunction::functionDeriv.
Definition Jacobian.h:22
Implements the part of IFunction interface dealing with parameters.
size_t nAttributes() const override
Returns the number of attributes associated with the function.
std::vector< std::string > getAttributeNames() const override
Returns a list of attribute names.
std::string name() const override
Returns the function's name.
IFunction::Attribute getAttribute(const std::string &attName) const override
Return a value of attribute attName.
virtual int version() const
bool hasAttribute(const std::string &attName) const override
Check if attribute attName exists.
const std::string category() const override
The categories the Fit function belong to.
void setAttribute(const std::string &attName, const IFunction::Attribute &value) override
Set a value to attribute attName.
Structure describing a single-crystal peak.
Definition Peak.h:34
Numerical Matrix class.
Definition Matrix.h:41
Class for 3D vectors.
Definition V3D.h:35
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
Helper class which provides the Collimation Length for SANS instruments.