-
Notifications
You must be signed in to change notification settings - Fork 122
/
PeakHKLErrors.h
176 lines (134 loc) · 5.35 KB
/
PeakHKLErrors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* PeakHKLErrors.h
*
* Created on: Jan 26, 2013
* Author: ruth
*/
#ifndef PEAKHKLERRORS_H_
#define PEAKHKLERRORS_H_
#include "MantidKernel/System.h"
#include "MantidAPI/IFunction.h"
#include "MantidGeometry/Instrument.h"
#include "MantidAPI/ParamFunction.h"
#include "MantidAPI/IFunction1D.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidAPI/IFunction.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidKernel/Matrix.h"
#include "MantidDataObjects/PeaksWorkspace.h"
namespace Mantid {
namespace Crystal {
/**
@author Ruth Mikkelson, SNS,ORNL
@date 01/26/2013
Copyright © 2012 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport PeakHKLErrors : public API::ParamFunction,
public API::IFunction1D {
public:
PeakHKLErrors();
std::string name() const override { return std::string("PeakHKLErrors"); };
virtual int version() const { return 1; };
const std::string category() const override { return "Calibration"; };
void function1D(double *out, const double *xValues,
const size_t nData) const override;
void functionDeriv1D(Mantid::API::Jacobian *out, const double *xValues,
const size_t nData) override;
void init() override;
/**
* Creates a new peak, matching the old peak except for a different
*instrument.
*
* The Time of flightis the same except offset by T0. L0 should be the L0
*for the new instrument.
* It is added as a parameter in case the instrument will have the initial
*flight path adjusted later.
* NOTE: the wavelength is changed.
*
* @param peak_old - The old peak
* @param instrNew -The new instrument
* @param T0 :
* @param L0 :
* @return The new peak with the new instrument( adjusted with the
*parameters) and time adjusted.
*/
static DataObjects::Peak createNewPeak(const Geometry::IPeak &peak_old,
Geometry::Instrument_sptr instrNew,
double T0, double L0);
static void cLone(boost::shared_ptr<Geometry::ParameterMap> &pmap,
boost::shared_ptr<const Geometry::IComponent> component,
boost::shared_ptr<const Geometry::ParameterMap> &pmapSv);
void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks,
const std::string &OptRuns,
std::map<int, Mantid::Kernel::Matrix<double>> &Res) const;
size_t nAttributes() const override { return (size_t)2; }
static Kernel::Matrix<double> DerivRotationMatrixAboutRegAxis(double theta,
char axis);
static Kernel::Matrix<double> RotationMatrixAboutRegAxis(double theta,
char axis);
boost::shared_ptr<Geometry::Instrument>
getNewInstrument(DataObjects::PeaksWorkspace_sptr Peaks) const;
std::vector<std::string> getAttributeNames() const override {
return {"OptRuns", "PeakWorkspaceName"};
}
IFunction::Attribute getAttribute(const std::string &attName) const override {
if (attName == "OptRuns")
return IFunction::Attribute(OptRuns);
if (attName == "PeakWorkspaceName")
return IFunction::Attribute(PeakWorkspaceName);
throw std::invalid_argument("Not a valid attribute name");
}
void setAttribute(const std::string &attName,
const IFunction::Attribute &value) override {
if (attName == "OptRuns") {
OptRuns = value.asString();
if (OptRuns.size() < 1)
return;
if (OptRuns.at(0) != '/')
OptRuns = "/" + OptRuns;
if (OptRuns.at(OptRuns.size() - 1) != '/')
OptRuns += "/";
if (initMode == 1) {
setUpOptRuns();
initMode = 2;
} else if (initMode == 2) // Woops cannot do twice
throw std::invalid_argument("OptRuns can only be set once");
return;
}
if (attName == "PeakWorkspaceName") {
PeakWorkspaceName = value.asString();
return;
}
throw std::invalid_argument("Not a valid attribute name");
}
bool hasAttribute(const std::string &attName) const override {
if (attName == "OptRuns")
return true;
if (attName == "PeakWorkspaceName")
return true;
return false;
}
private:
std::string OptRuns;
std::string PeakWorkspaceName;
int initMode; // 0 not invoked, 1 invoked but no OptRuns , 2 invoked and
// OptRuns setup
void setUpOptRuns();
};
}
}
#endif /* PEAKHKLERRORS_H_ */