/
ConvertToYSpace.h
98 lines (83 loc) · 3.1 KB
/
ConvertToYSpace.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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2013 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/SpectrumInfo.h"
#include "MantidCurveFitting/DllConfig.h"
#include "MantidGeometry/IComponent.h"
#include "MantidGeometry/IDetector.h"
namespace Mantid {
namespace Kernel {
class V3D;
}
namespace Geometry {
class ParameterMap;
}
namespace CurveFitting {
namespace Algorithms {
/// Simple data structure to store nominal detector values
/// It avoids some functions taking a huge number of arguments
struct DetectorParams {
double l1; ///< source-sample distance in metres
double l2; ///< sample-detector distance in metres
Kernel::V3D pos; ///< Full 3D position
double theta; ///< scattering angle in radians
double t0; ///< time delay in seconds
double efixed; ///< final energy
};
/**
Takes a workspace with X axis in TOF and converts it to Y-space where the
transformation is defined
by equation (7) in http://link.aip.org/link/doi/10.1063/1.3561493?ver=pdfcov
*/
class MANTID_CURVEFITTING_DLL ConvertToYSpace final : public API::Algorithm {
public:
/// Constructor
ConvertToYSpace();
const std::string name() const override;
/// Summary of algorithms purpose
const std::string summary() const override {
return "Converts workspace in units of TOF to Y-space as defined in "
"Compton scattering field";
}
int version() const override;
const std::string category() const override;
/// Creates a POD struct containing the required detector parameters for this
/// spectrum
static DetectorParams getDetectorParameters(const API::MatrixWorkspace_const_sptr &ws, const size_t index);
/// Retrieve a component parameter
static double getComponentParameter(const Geometry::IComponent &det, const Geometry::ParameterMap &pmap,
const std::string &name);
/// Convert single time value to Y,Q & Ei values
static void calculateY(double &yspace, double &qspace, double &ei, const double mass, const double tsec,
const double k1, const double v1, const DetectorParams &detpar);
private:
void init() override;
void exec() override;
/// Perform the conversion to Y-space
bool convert(const size_t index);
/// Check and store appropriate input data
void retrieveInputs();
/// Create the output workspace
void createOutputWorkspace();
/// Compute & store the parameters that are fixed during the correction
void cacheInstrumentGeometry();
/// Input workspace
API::MatrixWorkspace_sptr m_inputWS;
/// The input mass in AMU
double m_mass;
/// Source-sample distance
double m_l1;
/// Sample position
Kernel::V3D m_samplePos;
/// Output workspace
API::MatrixWorkspace_sptr m_outputWS;
API::MatrixWorkspace_sptr m_qOutputWS;
};
} // namespace Algorithms
} // namespace CurveFitting
} // namespace Mantid