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"
23#include "MantidKernel/Matrix.h"
24
25namespace Mantid {
26namespace Crystal {
27
33class MANTID_CRYSTAL_DLL PeakHKLErrors : public API::ParamFunction, public API::IFunction1D {
34public:
36
37 std::string name() const override { return std::string("PeakHKLErrors"); };
38
39 virtual int version() const { return 1; };
40
41 const std::string category() const override { return "Calibration"; };
42
43 void function1D(double *out, const double *xValues, const size_t nData) const override;
44
45 void functionDeriv1D(Mantid::API::Jacobian *out, const double *xValues, const size_t nData) override;
46
47 void init() override;
48
66 static DataObjects::Peak createNewPeak(const DataObjects::Peak &peak_old, const Geometry::Instrument_sptr &instrNew,
67 double T0, double L0);
68
69 static void cLone(std::shared_ptr<Geometry::ParameterMap> &pmap,
70 const std::shared_ptr<const Geometry::IComponent> &component,
71 std::shared_ptr<const Geometry::ParameterMap> &pmapSv);
72
73 void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks, const std::string &OptRuns,
74 std::map<int, Mantid::Kernel::Matrix<double>> &Res) const;
75 size_t nAttributes() const override { return (size_t)2; }
76
77 static Kernel::Matrix<double> DerivRotationMatrixAboutRegAxis(double theta, char axis);
78
79 static Kernel::Matrix<double> RotationMatrixAboutRegAxis(double theta, char axis);
80
81 std::shared_ptr<Geometry::Instrument> getNewInstrument(const DataObjects::PeaksWorkspace_sptr &peaksWs) const;
82
83 std::vector<std::string> getAttributeNames() const override { return {"OptRuns", "PeakWorkspaceName"}; }
84
85 IFunction::Attribute getAttribute(const std::string &attName) const override {
86 if (attName == "OptRuns")
87 return IFunction::Attribute(OptRuns);
88
89 if (attName == "PeakWorkspaceName")
90 return IFunction::Attribute(PeakWorkspaceName);
91
92 throw std::invalid_argument("Not a valid attribute name");
93 }
94
95 void setAttribute(const std::string &attName, const IFunction::Attribute &value) override {
96 if (attName == "OptRuns") {
97 OptRuns = value.asString();
98
99 if (OptRuns.empty())
100 return;
101
102 if (OptRuns.at(0) != '/')
103 OptRuns = "/" + OptRuns;
104
105 if (OptRuns.at(OptRuns.size() - 1) != '/')
106 OptRuns += "/";
107
108 if (initMode == 1) {
109 setUpOptRuns();
110 initMode = 2;
111 } else if (initMode == 2) // Woops cannot do twice
112 throw std::invalid_argument("OptRuns can only be set once");
113
114 return;
115 }
116
117 if (attName == "PeakWorkspaceName") {
118 PeakWorkspaceName = value.asString();
119 return;
120 }
121
122 throw std::invalid_argument("Not a valid attribute name");
123 }
124
125 bool hasAttribute(const std::string &attName) const override {
126 if (attName == "OptRuns")
127 return true;
128
129 if (attName == "PeakWorkspaceName")
130 return true;
131
132 return false;
133 }
134
135private:
136 std::string OptRuns;
137
138 std::string PeakWorkspaceName;
139
140 int initMode; // 0 not invoked, 1 invoked but no OptRuns , 2 invoked and
141 // OptRuns setup
142
143 void setUpOptRuns();
144
145 mutable std::shared_ptr<Geometry::Instrument> instChange;
146 mutable bool hasParameterMap = false;
148 mutable std::shared_ptr<const Geometry::ParameterMap> pmapSv;
149};
150} // namespace Crystal
151} // 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:43
Attribute is a non-fitting parameter.
Definition IFunction.h:285
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::shared_ptr< Geometry::Instrument > instChange
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.
std::shared_ptr< const Geometry::ParameterMap > pmapSv
Structure describing a single-crystal peak.
Definition Peak.h:34
Numerical Matrix class.
Definition Matrix.h:42
Class for 3D vectors.
Definition V3D.h:34
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.
Helper class which provides the Collimation Length for SANS instruments.
Generate a tableworkspace to store the calibration results.