-
Notifications
You must be signed in to change notification settings - Fork 121
/
SphericalAbsorption.h
124 lines (108 loc) · 4.55 KB
/
SphericalAbsorption.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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2010 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
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidAlgorithms/DllConfig.h"
#include "MantidGeometry/IDetector.h"
namespace Mantid {
// forward declaration from other Mantid modules
namespace API {
class Sample;
}
namespace Kernel {
class V3D;
}
namespace Geometry {
class IObject;
}
namespace Algorithms {
/** A spherical absorption correction algorithm.
Common Properties:
<UL>
<LI> InputWorkspace - The name of the input workspace. </LI>
<LI> OutputWorkspace - The name of the output workspace. Can be the same as
the input one. </LI>
<LI> AttenuationXSection - The attenuation cross-section for the sample
material in barns. </LI>
<LI> ScatteringXSection - The scattering cross-section for the sample
material in barns. </LI>
<LI> SampleNumberDensity - The number density of the sample in
Angstrom^-3.</LI>
</UL>
This class, which must be overridden to provide the specific sample geometry
and integration
elements, uses a numerical integration method to calculate attenuation
factors resulting
from absorption and single scattering in a sample. Factors are calculated
for each spectrum
(i.e. detector position) and wavelength point, as defined by the input
workspace.
Path lengths through the sample are then calculated for the centre-point of
each element
and a numerical integration is carried out using these path lengths over the
volume elements.
This algorithm assumes that the beam comes along the Z axis, that Y is up
and that the sample is at the origin.
@author Vickie Lynch, SNS
@date 08/16/2011
*/
class MANTID_ALGORITHMS_DLL SphericalAbsorption : public API::Algorithm {
public:
/// (Empty) Constructor
SphericalAbsorption();
/// Algorithm's category for identification
const std::string category() const override {
return "CorrectionFunctions\\AbsorptionCorrections";
}
/// Algorithm's name
const std::string name() const override { return "SphericalAbsorption"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Calculates bin-by-bin or event correction factors for attenuation "
"due to absorption and scattering in a 'spherical' sample.";
}
/// Algorithm's version
int version() const override { return (1); }
const std::vector<std::string> seeAlso() const override {
return {"AbsorptionCorrection"};
}
protected:
API::MatrixWorkspace_sptr m_inputWS; ///< A pointer to the input workspace
const Geometry::IObject *m_sampleObject; ///< Local cache of sample object.
Kernel::V3D m_beamDirection; ///< The direction of the beam.
std::vector<double> m_L1s, ///< Cached L1 distances
m_elementVolumes; ///< Cached element volumes
std::vector<Kernel::V3D> m_elementPositions; ///< Cached element positions
size_t m_numVolumeElements; ///< The number of volume elements
double m_sampleVolume; ///< The total volume of the sample
private:
/// Initialisation code
void init() override;
/// Execution code
void exec() override;
void retrieveBaseProperties();
void constructSample(API::Sample &sample);
void calculateDistances(const Geometry::IDetector_const_sptr &detector,
std::vector<double> &L2s) const;
inline double doIntegration(const double &lambda,
const std::vector<double> &L2s) const;
inline double doIntegration(const double &lambda_i, const double &lambda_f,
const std::vector<double> &L2s) const;
double m_refAtten; ///< The attenuation cross-section in 1/m at 1.8A
double m_scattering; ///< The scattering cross-section in 1/m
int64_t n_lambda; ///< The number of points in wavelength, the rest is
/// interpolated linearly
int64_t x_step; ///< The step in bin number between adjacent points
int64_t m_emode; ///< The energy mode: 0 - elastic, 1 - direct, 2 - indirect
double m_lambdaFixed; ///< The wavelength corresponding to the fixed energy,
/// if provided
};
} // namespace Algorithms
} // namespace Mantid