Mantid
Loading...
Searching...
No Matches
PeakHKLErrors.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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.cpp
9 *
10 * Created on: Jan 26, 2013
11 * Author: ruth
12 */
19#include "MantidAPI/Sample.h"
23#include "MantidKernel/Unit.h"
24
25#include <boost/algorithm/string/classification.hpp>
26#include <boost/algorithm/string/split.hpp>
27#include <boost/math/special_functions/round.hpp>
28
29using namespace Mantid::DataObjects;
30using namespace Mantid::API;
31using namespace Mantid::Kernel;
32using namespace Mantid::Kernel::Units;
34
35namespace Mantid::Crystal {
36namespace {
38Kernel::Logger g_log("PeakHKLErrors");
39} // namespace
40
41DECLARE_FUNCTION(PeakHKLErrors)
42
43PeakHKLErrors::PeakHKLErrors() : ParamFunction(), IFunction1D(), OptRuns(""), PeakWorkspaceName("") { initMode = 0; }
44
46 declareParameter("SampleXOffset", 0.0, "Sample x offset");
47 declareParameter("SampleYOffset", 0.0, "Sample y offset");
48 declareParameter("SampleZOffset", 0.0, "Sample z offset");
49 declareParameter("GonRotx", 0.0, "3rd Rotation of Goniometer about the x axis");
50 declareParameter("GonRoty", 0.0, "2nd Rotation of Goniometer about the y axis");
51 declareParameter("GonRotz", 0.0, "1st Rotation of Goniometer about the z axis");
52 initMode = 1;
53 if (OptRuns.empty())
54 return;
55
56 initMode = 2;
58}
64
65 std::vector<std::string> OptRunNums;
66 std::string OptRunstemp(OptRuns);
67 if (!OptRuns.empty() && OptRuns.at(0) == '/')
68 OptRunstemp = OptRunstemp.substr(1, OptRunstemp.size() - 1);
69
70 if (!OptRunstemp.empty() && OptRunstemp.at(OptRunstemp.size() - 1) == '/')
71 OptRunstemp.pop_back();
72
73 boost::split(OptRunNums, OptRunstemp, boost::is_any_of("/"));
74
75 for (const auto &OptRunNum : OptRunNums) {
76 declareParameter("phi" + OptRunNum, 0.0, "Phi sample orientation value");
77 declareParameter("chi" + OptRunNum, 0.0, "Chi sample orientation value");
78 declareParameter("omega" + OptRunNum, 0.0, "Omega sample orientation value");
79 }
80}
81
93void PeakHKLErrors::getRun2MatMap(PeaksWorkspace_sptr &Peaks, const std::string &OptRuns,
94 std::map<int, Mantid::Kernel::Matrix<double>> &Res) const {
95
96 for (int i = 0; i < Peaks->getNumberPeaks(); ++i) {
97 const Geometry::IPeak &peak_old = Peaks->getPeak(i);
98
99 int runNum = peak_old.getRunNumber();
100 std::string runNumStr = std::to_string(runNum);
101 size_t N = OptRuns.find("/" + runNumStr + "/");
102 if (N < OptRuns.size()) {
103 double chi = getParameter("chi" + boost::lexical_cast<std::string>(runNumStr));
104 double phi = getParameter("phi" + boost::lexical_cast<std::string>(runNumStr));
105 double omega = getParameter("omega" + boost::lexical_cast<std::string>(runNumStr));
107 uniGonio.makeUniversalGoniometer();
108 uniGonio.setRotationAngle("phi", phi);
109 uniGonio.setRotationAngle("chi", chi);
110 uniGonio.setRotationAngle("omega", omega);
111 Res[runNum] = uniGonio.getR();
112 }
113 }
114}
115
127 int cint = toupper(axis);
128 auto c = static_cast<char>(cint);
129 std::string S(std::string("") + c);
130 size_t axisPos = std::string("XYZ").find(S);
131
132 if (axisPos > 2) {
133 Matrix<double> Res(3, 3, true);
134
135 return Res;
136 }
137 double rTheta = theta / 180 * M_PI;
138 Matrix<double> Res(3, 3);
139 Res.zeroMatrix();
140 Res[axisPos][axisPos] = 1.0;
141 Res[(axisPos + 1) % 3][(axisPos + 1) % 3] = cos(rTheta);
142 Res[(axisPos + 1) % 3][(axisPos + 2) % 3] = -sin(rTheta);
143 Res[(axisPos + 2) % 3][(axisPos + 2) % 3] = cos(rTheta);
144 Res[(axisPos + 2) % 3][(axisPos + 1) % 3] = sin(rTheta);
145 return Res;
146}
147
160 int cint = toupper(axis);
161 auto c = static_cast<char>(cint);
162 std::string S(std::string("") + c);
163 size_t axisPos = std::string("XYZ").find(S);
164
165 if (axisPos > 2) {
166 Matrix<double> Res(3, 3, true);
167
168 return Res;
169 }
170 double rTheta = theta / 180 * M_PI;
171 Matrix<double> Res(3, 3);
172 Res.zeroMatrix();
173 Res[axisPos][axisPos] = 0.0;
174 Res[(axisPos + 1) % 3][(axisPos + 1) % 3] = -sin(rTheta);
175 Res[(axisPos + 1) % 3][(axisPos + 2) % 3] = -cos(rTheta);
176 Res[(axisPos + 2) % 3][(axisPos + 2) % 3] = -sin(rTheta);
177 Res[(axisPos + 2) % 3][(axisPos + 1) % 3] = cos(rTheta);
178 return Res * (M_PI / 180.);
179}
180
193void PeakHKLErrors::function1D(double *out, const double *xValues, const size_t nData) const {
194 PeaksWorkspace_sptr peaksWs = AnalysisDataService::Instance().retrieveWS<PeaksWorkspace>(PeakWorkspaceName);
195
196 if (!peaksWs)
197 throw std::invalid_argument("Peaks not stored under the name " + PeakWorkspaceName);
198
199 V3D const samplePosition = peaksWs->componentInfo().samplePosition();
200
201 std::map<int, Mantid::Kernel::Matrix<double>> RunNum2GonMatrixMap;
202 getRun2MatMap(peaksWs, OptRuns, RunNum2GonMatrixMap);
203 const DblMatrix &UBx = peaksWs->sample().getOrientedLattice().getUB();
204
205 DblMatrix UBinv(UBx);
206 UBinv.Invert();
207 UBinv /= (2 * M_PI);
208
209 double GonRotx = getParameter("GonRotx");
210 double GonRoty = getParameter("GonRoty");
211 double GonRotz = getParameter("GonRotz");
212 Matrix<double> GonRot = RotationMatrixAboutRegAxis(GonRotx, 'x') * RotationMatrixAboutRegAxis(GonRoty, 'y') *
213 RotationMatrixAboutRegAxis(GonRotz, 'z');
214
215 double ChiSqTot = 0.0;
216 for (size_t i = 0; i < nData; i += 3) {
217 int peakNum = boost::math::iround(xValues[i]);
218 const Peak &peak_old = peaksWs->getPeak(peakNum);
219
220 int runNum = peak_old.getRunNumber();
221 std::string runNumStr = std::to_string(runNum);
222 Peak peak = createNewPeak(peak_old, samplePosition, 0, peak_old.getL1());
223
224 size_t N = OptRuns.find("/" + runNumStr + "/");
225 if (N < OptRuns.size()) {
226 peak.setGoniometerMatrix(GonRot * RunNum2GonMatrixMap[runNum]);
227
228 } else {
229 peak.setGoniometerMatrix(GonRot * peak.getGoniometerMatrix());
230 }
231 V3D sampOffsets(getParameter("SampleXOffset"), getParameter("SampleYOffset"), getParameter("SampleZOffset"));
232 peak.setSamplePos(peak.getSamplePos() + sampOffsets);
233
234 V3D hkl = UBinv * peak.getQSampleFrame();
235
236 for (int k = 0; k < 3; k++) {
237 double d1 = hkl[k] - floor(hkl[k]);
238 if (d1 > .5)
239 d1 = d1 - 1;
240 if (d1 < -.5)
241 d1 = d1 + 1;
242
243 out[i + k] = d1;
244 ChiSqTot += d1 * d1;
245 }
246 }
247
248 g_log.debug() << "------------------------Function---------------------------"
249 "--------------------\n";
250 for (size_t p = 0; p < nParams(); p++) {
251 g_log.debug() << parameterName(p) << "(" << getParameter(p) << "),";
252 }
253 g_log.debug() << '\n';
254 g_log.debug() << "Off constraints=";
255 for (size_t p = 0; p < nParams(); p++) {
256 IConstraint *constr = getConstraint(p);
257 if (constr)
258 if ((constr->check() > 0))
259 g_log.debug() << "(" << parameterName(p) << "=" << constr->check() << ");";
260 }
261 g_log.debug() << '\n';
262
263 g_log.debug() << " Chi**2 = " << ChiSqTot << " nData = " << nData << '\n';
264}
265
266void PeakHKLErrors::functionDeriv1D(Jacobian *out, const double *xValues, const size_t nData) {
267 PeaksWorkspace_sptr peaksWs = AnalysisDataService::Instance().retrieveWS<PeaksWorkspace>(PeakWorkspaceName);
268
269 if (!peaksWs)
270 throw std::invalid_argument("Peaks not stored under the name " + PeakWorkspaceName);
271
272 const DblMatrix &UB = peaksWs->sample().getOrientedLattice().getUB();
273 DblMatrix UBinv(UB);
274 UBinv.Invert();
275 UBinv /= 2 * M_PI;
276
277 double GonRotx = getParameter("GonRotx");
278 double GonRoty = getParameter("GonRoty");
279 double GonRotz = getParameter("GonRotz");
280 Matrix<double> InvGonRotxMat = RotationMatrixAboutRegAxis(GonRotx, 'x');
281 Matrix<double> InvGonRotyMat = RotationMatrixAboutRegAxis(GonRoty, 'y');
282 Matrix<double> InvGonRotzMat = RotationMatrixAboutRegAxis(GonRotz, 'z');
283 Matrix<double> GonRot = InvGonRotxMat * InvGonRotyMat * InvGonRotzMat;
284
285 InvGonRotxMat.Invert();
286 InvGonRotyMat.Invert();
287 InvGonRotzMat.Invert();
288
289 std::map<int, Kernel::Matrix<double>> RunNums2GonMatrix;
290 getRun2MatMap(peaksWs, OptRuns, RunNums2GonMatrix);
291
292 g_log.debug() << "----------------------------Derivative------------------------\n";
293
294 auto const &componentInfo = peaksWs->componentInfo();
295 V3D const samplePosition = componentInfo.samplePosition();
296 const IPeak &ppeak = peaksWs->getPeak(0);
297 double L0 = ppeak.getL1();
298 double velocity = (L0 + ppeak.getL2()) / ppeak.getTOF();
299
300 double K = 2 * M_PI / ppeak.getWavelength() / velocity; // 2pi/lambda = K* velocity
301 V3D const beamDir = normalize(samplePosition - componentInfo.sourcePosition());
302
303 const size_t paramNums[] = {parameterIndex(std::string("SampleXOffset")),
304 parameterIndex(std::string("SampleYOffset")),
305 parameterIndex(std::string("SampleZOffset"))};
306
307 for (size_t i = 0; i < nData; i += 3) {
308 int peakNum = boost::math::iround(xValues[i]);
309 const Peak &peak_old = peaksWs->getPeak(peakNum);
310 Peak peak = createNewPeak(peak_old, samplePosition, 0, peak_old.getL1());
311
312 int runNum = peak_old.getRunNumber();
313 std::string runNumStr = std::to_string(runNum);
314
315 for (int kk = 0; kk < static_cast<int>(nParams()); kk++) {
316 out->set(i, kk, 0.0);
317 out->set(i + 1, kk, 0.0);
318 out->set(i + 2, kk, 0.0);
319 }
320
321 double chi, phi, omega;
322 size_t chiParamNum, phiParamNum, omegaParamNum;
323
324 size_t N = OptRuns.find("/" + runNumStr);
325 if (N < OptRuns.size()) {
326 chi = getParameter("chi" + (runNumStr));
327 phi = getParameter("phi" + (runNumStr));
328 omega = getParameter("omega" + (runNumStr));
329
330 peak.setGoniometerMatrix(GonRot * RunNums2GonMatrix[runNum]);
331
332 chiParamNum = parameterIndex("chi" + (runNumStr));
333 phiParamNum = parameterIndex("phi" + (runNumStr));
334 omegaParamNum = parameterIndex("omega" + (runNumStr));
335 } else {
336
338 std::vector<double> phichiOmega = Gon.getEulerAngles("YZY");
339 chi = phichiOmega[1];
340 phi = phichiOmega[2];
341 omega = phichiOmega[0];
342 // peak.setGoniometerMatrix( GonRot*Gon.getR());
343 chiParamNum = phiParamNum = omegaParamNum = nParams() + 10;
344 peak.setGoniometerMatrix(GonRot * peak.getGoniometerMatrix());
345 }
346 V3D sampOffsets(getParameter("SampleXOffset"), getParameter("SampleYOffset"), getParameter("SampleZOffset"));
347 peak.setSamplePos(peak.getSamplePos() + sampOffsets);
348 // NOTE:Use getQLabFrame except for below.
349 // For parameters the getGoniometerMatrix should remove GonRot, for derivs
350 // wrt GonRot*, wrt chi*,phi*,etc.
351
352 // Deriv wrt chi phi and omega
353 if (phiParamNum < nParams()) {
354 Matrix<double> chiMatrix = RotationMatrixAboutRegAxis(chi, 'z');
355 Matrix<double> phiMatrix = RotationMatrixAboutRegAxis(phi, 'y');
356 Matrix<double> omegaMatrix = RotationMatrixAboutRegAxis(omega, 'y');
357
358 Matrix<double> dchiMatrix = DerivRotationMatrixAboutRegAxis(chi, 'z');
359 Matrix<double> dphiMatrix = DerivRotationMatrixAboutRegAxis(phi, 'y');
360 Matrix<double> domegaMatrix = DerivRotationMatrixAboutRegAxis(omega, 'y');
361
362 Matrix<double> InvG = omegaMatrix * chiMatrix * phiMatrix;
363 InvG.Invert();
364 // Calculate Derivatives wrt chi(phi,omega) in degrees
365 Matrix<double> R = omegaMatrix * chiMatrix * dphiMatrix;
366 Matrix<double> InvR = InvG * R * InvG * -1;
367 V3D lab = peak.getQLabFrame();
368 V3D Dhkl0 = UBinv * InvR * lab;
369
370 R = omegaMatrix * dchiMatrix * phiMatrix;
371 InvR = InvG * R * InvG * -1;
372 V3D Dhkl1 = UBinv * InvR * peak.getQLabFrame();
373
374 R = domegaMatrix * chiMatrix * phiMatrix;
375 InvR = InvG * R * InvG * -1;
376 V3D Dhkl2 = UBinv * InvR * peak.getQLabFrame(); // R.transpose should be R inverse
377
378 out->set(i, chiParamNum, Dhkl1[0]);
379 out->set(i + 1, chiParamNum, Dhkl1[1]);
380 out->set(i + 2, chiParamNum, Dhkl1[2]);
381 out->set(i, phiParamNum, Dhkl0[0]);
382 out->set(i + 1, phiParamNum, Dhkl0[1]);
383 out->set(i + 2, phiParamNum, Dhkl0[2]);
384 out->set(i, omegaParamNum, Dhkl2[0]);
385 out->set(i + 1, omegaParamNum, Dhkl2[1]);
386 out->set(i + 2, omegaParamNum, Dhkl2[2]);
387
388 } // if optimize for chi phi and omega on this peak
389
390 //------------------------Goniometer Rotation Derivatives
391 //-----------------------
392 Matrix<double> InvGonRot(GonRot);
393 InvGonRot.Invert();
394 Matrix<double> InvGon = InvGonRot * peak.getGoniometerMatrix();
395 InvGon.Invert();
396 V3D DGonx = (UBinv * InvGon * InvGonRotzMat * InvGonRotyMat *
397 DerivRotationMatrixAboutRegAxis(-GonRotx, 'x') * // - gives inverse of GonRot
398 peak.getQLabFrame()) *
399 -1;
400
401 V3D DGony = (UBinv * InvGon * InvGonRotzMat * DerivRotationMatrixAboutRegAxis(-GonRoty, 'y') * InvGonRotxMat *
402 peak.getQLabFrame()) *
403 -1;
404 V3D DGonz = (UBinv * InvGon * DerivRotationMatrixAboutRegAxis(-GonRotz, 'z') * InvGonRotyMat * InvGonRotxMat *
405 peak.getQLabFrame()) *
406 -1;
407
408 size_t paramnum = parameterIndex("GonRotx");
409 out->set(i, paramnum, DGonx[0]);
410 out->set(i + 1, paramnum, DGonx[1]);
411 out->set(i + 2, paramnum, DGonx[2]);
412 out->set(i, parameterIndex("GonRoty"), DGony[0]);
413 out->set(i + 1, parameterIndex("GonRoty"), DGony[1]);
414 out->set(i + 2, parameterIndex("GonRoty"), DGony[2]);
415 out->set(i, parameterIndex("GonRotz"), DGonz[0]);
416 out->set(i + 1, parameterIndex("GonRotz"), DGonz[1]);
417 out->set(i + 2, parameterIndex("GonRotz"), DGonz[2]);
418 //-------------------- Sample Orientation derivatives
419 //----------------------------------
420 // Qlab = -KV + k|V|*beamdir
421 // D = pos-sampPos
422 //|V|= vmag=(L0 + D )/tof
423 // t1= tof - L0/|V| {time from sample to pixel}
424 // V = D/t1
425 V3D D = peak.getDetPos() - samplePosition;
426 double vmag = (L0 + D.norm()) / peak.getTOF();
427 double t1 = peak.getTOF() - L0 / vmag;
428
429 // Derivs wrt sample x, y, z
430 // Ddsx =( - 1, 0, 0), d|D|^2/dsx -> 2|D|d|D|/dsx =d(tranp(D)* D)/dsx =2
431 // Ddsx* tranp(D)
432 //|D| also called Dmag
433 V3D Dmagdsxsysz(D);
434 Dmagdsxsysz *= (-1 / D.norm());
435
436 V3D vmagdsxsysz = Dmagdsxsysz / peak.getTOF();
437
438 V3D t1dsxsysz = vmagdsxsysz * (L0 / vmag / vmag);
440 Gon.Invert();
441
442 // x=0 is deriv wrt SampleXoffset, x=1 is deriv wrt SampleYoffset, etc.
443 for (int x = 0; x < 3; x++) {
444 V3D pp;
445 pp[x] = 1;
446 V3D dQlab1 = pp / -t1 - D * (t1dsxsysz[x] / t1 / t1);
447 V3D dQlab2 = beamDir * vmagdsxsysz[x];
448 V3D dQlab = dQlab2 - dQlab1;
449 dQlab *= K;
450
451 V3D dQSamp = Gon * dQlab;
452 V3D dhkl = UBinv * dQSamp;
453
454 out->set(i, paramNums[x], dhkl[0]);
455 out->set(i + 1, paramNums[x], dhkl[1]);
456 out->set(i + 2, paramNums[x], dhkl[2]);
457 }
458 }
459}
460
461Peak PeakHKLErrors::createNewPeak(DataObjects::Peak const &peak_old, V3D const &samplePos, double T0, double L0) {
462 double T = peak_old.getTOF() + T0;
463
464 int ID = peak_old.getDetectorID();
465
466 Kernel::V3D hkl = peak_old.getHKL();
467 // peak_old.setDetectorID(ID); //set det positions
468 Peak peak(peak_old.getInstrument(), ID, peak_old.getWavelength(), hkl, peak_old.getGoniometerMatrix());
469 peak.setSamplePos(samplePos);
470
471 Wavelength wl;
472
473 wl.initialize(L0, 0,
474 {{UnitParams::l2, peak.getL2()},
475 {UnitParams::twoTheta, peak.getScattering()},
476 {UnitParams::efixed, peak_old.getInitialEnergy()}});
477
478 peak.setWavelength(wl.singleFromTOF(T));
479 peak.setIntensity(peak_old.getIntensity());
480 peak.setSigmaIntensity(peak_old.getSigmaIntensity());
481 peak.setRunNumber(peak_old.getRunNumber());
482 peak.setBinCount(peak_old.getBinCount());
483
485 return peak;
486}
487} // namespace Mantid::Crystal
#define DECLARE_FUNCTION(classname)
Macro for declaring a new type of function to be used with the FunctionFactory.
An interface to a constraint.
Definition IConstraint.h:26
virtual double check()=0
Returns a penalty number which is bigger than or equal to zero If zero it means that the constraint i...
This is a specialization of IFunction for functions of one real argument.
Definition IFunction1D.h:42
virtual IConstraint * getConstraint(size_t i) const
Get constraint of i-th parameter.
Represents the Jacobian in IFitFunction::functionDeriv.
Definition Jacobian.h:22
virtual void set(size_t iY, size_t iP, double value)=0
Set a value to a Jacobian matrix element.
Implements the part of IFunction interface dealing with parameters.
size_t parameterIndex(const std::string &name) const override
Returns the index of parameter name.
std::string parameterName(size_t i) const override
Returns the name of parameter i.
void declareParameter(const std::string &name, double initValue=0, const std::string &description="") override
Declare a new parameter.
size_t nParams() const override
Total number of parameters.
double getParameter(size_t i) const override
Get i-th parameter.
static Kernel::Matrix< double > DerivRotationMatrixAboutRegAxis(double theta, char axis)
Returns the derivative of the matrix corresponding to a rotation of theta(degrees) around axis with r...
void getRun2MatMap(DataObjects::PeaksWorkspace_sptr &Peaks, const std::string &OptRuns, std::map< int, Mantid::Kernel::Matrix< double > > &Res) const
Updates the map from run number to GoniometerMatrix.
static Kernel::Matrix< double > RotationMatrixAboutRegAxis(double theta, char axis)
Returns the matrix corresponding to a rotation of theta(degrees) around axis.
static DataObjects::Peak createNewPeak(DataObjects::Peak const &peak_old, Kernel::V3D const &samplePos, double T0, double L0)
Creates a new peak, matching the old peak, with its source and detector positions re-read from the ol...
void function1D(double *out, const double *xValues, const size_t nData) const override
Calculates the h,k, and l offsets from an integer for (some of )the peaks, given the parameter values...
void functionDeriv1D(Mantid::API::Jacobian *out, const double *xValues, const size_t nData) override
Derivatives of function with respect to active parameters.
void init() override
Function initialization. Declare function parameters in this method.
void setUpOptRuns()
Declares parameters for the chi,phi and omega angles for the run numbers where these will be optimize...
void setSigmaIntensity(double m_sigmaIntensity) override
Set the error on the integrated peak intensity.
Definition BasePeak.cpp:206
void setRunNumber(int m_runNumber) override
Set the run number that measured this peak.
Definition BasePeak.cpp:82
double getIntensity() const override
Return the integrated peak intensity.
Definition BasePeak.cpp:185
Mantid::Kernel::V3D getSamplePos() const override
Return the sample position vector.
Definition BasePeak.cpp:156
double getSigmaIntensity() const override
Return the error on the integrated peak intensity.
Definition BasePeak.cpp:188
int getRunNumber() const override
Return the run number this peak was measured at.
Definition BasePeak.cpp:78
void setIntensity(double m_intensity) override
Set the integrated peak intensity.
Definition BasePeak.cpp:198
Mantid::Kernel::V3D getHKL() const override
Return the HKL vector.
Definition BasePeak.cpp:103
double getBinCount() const override
Return the # of counts in the bin at its peak.
Definition BasePeak.cpp:182
Mantid::Kernel::Matrix< double > getGoniometerMatrix() const override
Get the goniometer rotation matrix at which this peak was measured.
Definition BasePeak.cpp:210
void setSamplePos(double samX, double samY, double samZ) override
Set sample position.
Definition BasePeak.cpp:162
void setGoniometerMatrix(const Mantid::Kernel::Matrix< double > &goniometerMatrix) override
Set the goniometer rotation matrix at which this peak was measured.
Definition BasePeak.cpp:220
void setBinCount(double m_binCount) override
Set the # of counts in the bin at its peak.
Definition BasePeak.cpp:202
Structure describing a single-crystal peak.
Definition Peak.h:34
Geometry::Instrument_const_sptr getInstrument() const
Return a shared ptr to the instrument for this peak.
Definition Peak.cpp:344
void setWavelength(double wavelength) override
Set the incident wavelength of the neutron.
Definition Peak.cpp:212
double getL1() const override
Return the L1 flight path length (source to sample), in meters.
Definition Peak.cpp:748
double getInitialEnergy() const override
Get the initial (incident) neutron energy in meV.
Definition Peak.cpp:729
Mantid::Kernel::V3D getQLabFrame() const override
Return the Q change (of the lattice, k_i - k_f) for this peak.
Definition Peak.cpp:475
int getDetectorID() const override
Get the ID of the detector at the center of the peak
Definition Peak.cpp:289
double getWavelength() const override
Calculate the neutron wavelength (in angstroms) at the peak (Note for inelastic scattering - it is th...
Definition Peak.cpp:382
double getTOF() const override
Calculate the time of flight (in microseconds) of the neutrons for this peak, using the geometry of t...
Definition Peak.cpp:397
virtual Mantid::Kernel::V3D getDetPos() const
Return the detector position vector.
Definition Peak.cpp:744
Mantid::Kernel::V3D getQSampleFrame() const override
Return the Q change (of the lattice, k_i - k_f) for this peak.
Definition Peak.cpp:506
double getL2() const override
Return the L2 flight path length (sample to detector), in meters.
Definition Peak.cpp:752
double getScattering() const override
Calculate the scattering angle of the peak
Definition Peak.cpp:415
The class PeaksWorkspace stores information about a set of SCD peaks.
Class to represent a particular goniometer setting, which is described by the rotation matrix.
Definition Goniometer.h:55
void setRotationAngle(const std::string &name, double value)
Set rotation angle for an axis using motor name.
std::vector< double > getEulerAngles(const std::string &convention="YZX")
Return Euler angles acording to a convention.
void makeUniversalGoniometer()
Make a default universal goniometer with phi,chi,omega angles according to SNS convention.
const Kernel::DblMatrix & getR() const
Return global rotation matrix.
Structure describing a single-crystal peak.
Definition IPeak.h:26
virtual double getTOF() const =0
virtual double getWavelength() const =0
virtual double getL2() const =0
virtual int getRunNumber() const =0
virtual double getL1() const =0
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
void debug(const std::string &msg)
Logs at debug level.
Definition Logger.cpp:145
Numerical Matrix class.
Definition Matrix.h:41
T Invert()
LU inversion routine.
Definition Matrix.cpp:924
void zeroMatrix()
Set the matrix to zero.
Definition Matrix.cpp:646
void initialize(const double &_l1, const int &_emode, const UnitParametersMap &params)
Initialize the unit to perform conversion using singleToTof() and singleFromTof()
Definition Unit.cpp:133
Wavelength in Angstrom.
Definition Unit.h:305
double singleFromTOF(const double tof) const override
Convert a single tof value to this unit.
Definition Unit.cpp:394
Class for 3D vectors.
Definition V3D.h:35
double norm() const noexcept
Definition V3D.h:270
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
The namespace for concrete units classes.
Definition IQTransform.h:18
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
Definition V3D.h:353
std::string to_string(const wide_integer< Bits, Signed > &n)