-
Notifications
You must be signed in to change notification settings - Fork 122
/
AnvredCorrection.h
146 lines (124 loc) · 5.71 KB
/
AnvredCorrection.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
#ifndef MANTID_CRYSTAL_ANVREDCORRECTION_H_
#define MANTID_CRYSTAL_ANVREDCORRECTION_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/EventWorkspace.h"
namespace Mantid {
namespace Crystal {
const double pc[4][19] = {
{1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,
1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000,
1.0000},
{1.9368, 1.8653, 1.6908, 1.4981, 1.3532, 1.2746, 1.2530, 1.2714, 1.3093,
1.3559, 1.4019, 1.4434, 1.4794, 1.5088, 1.5317, 1.5489, 1.5608, 1.5677,
1.5700},
{0.0145, 0.1596, 0.5175, 0.9237, 1.2436, 1.4308, 1.4944, 1.4635, 1.3770,
1.2585, 1.1297, 1.0026, 0.8828, 0.7768, 0.6875, 0.6159, 0.5637, 0.5320,
0.5216},
{1.1386, 1.0604, 0.8598, 0.6111, 0.3798, 0.1962, 0.0652, -0.0198, -0.0716,
-0.0993, -0.1176, -0.1153, -0.1125, -0.1073, -0.1016, -0.0962, -0.0922,
-0.0898, -0.0892}};
const double MAX_WAVELENGTH = 50.0; // max in lamda_weight table
const double STEPS_PER_ANGSTROM = 100; // resolution of lamda table
const int NUM_WAVELENGTHS =
static_cast<int>(std::ceil(MAX_WAVELENGTH * STEPS_PER_ANGSTROM));
const double radtodeg_half = 180.0 / M_PI / 2.;
/** Calculates anvred correction factors for attenuation due to absorption and
scattering in a spherical sample.
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> PreserveEvents - Keep the output workspace as an EventWorkspace, if the
input has events.
<LI> OnlySphericalAbsorption - All corrections done if false (default). If
true, only the spherical absorption correction.
<LI> LinearScatteringCoef - Linear scattering coefficient in 1/cm
<LI> LinearAbsorptionCoef - Linear absorption coefficient at 1.8 Angstroms
in 1/cm.
<LI> Radius - Radius of the sample in centimeters.
</UL>
@author Vickie Lynch, Dennis Mikkelson SNS
@date 06/14/2011
Copyright © 2010 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 AnvredCorrection : public API::Algorithm {
public:
/// (Empty) Constructor
AnvredCorrection();
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "AnvredCorrection"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Calculates anvred correction factors for attenuation due to "
"absorption and scattering in a spherical sample";
}
/// Algorithm's version for identification overriding a virtual method
int version() const override { return 1; }
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override {
return "Crystal\\Corrections;CorrectionFunctions\\AbsorptionCorrections";
}
protected:
/** A virtual function in which additional properties of an algorithm should
* be declared.
* Called by init().
*/
virtual void defineProperties() { /*Empty in base class*/
}
/// A virtual function in which additional properties should be retrieved into
/// member variables.
virtual void retrieveProperties() { /*Empty in base class*/
}
API::MatrixWorkspace_sptr m_inputWS; ///< A pointer to the input workspace
/// Shared pointer to the event workspace
DataObjects::EventWorkspace_sptr eventW;
private:
/// Initialisation code
void init() override;
/// Execution code
void exec() override;
/// Event execution code
void execEvent();
/// Algorithm cleanup
void cleanup();
void retrieveBaseProperties();
// void constructSample(API::Sample& sample);
double getEventWeight(double lamda, double two_theta);
void BuildLamdaWeights();
double absor_sphere(double &twoth, double &wl);
void scale_init(Geometry::IDetector_const_sptr det,
Geometry::Instrument_const_sptr inst, double &L2,
double &depth, double &pathlength, std::string &bankName);
void scale_exec(std::string &bankName, double &lambda, double &depth,
Geometry::Instrument_const_sptr inst, double &pathlength,
double &value);
double m_smu; ///< linear scattering coefficient in 1/cm
double m_amu; ///< linear absoprtion coefficient in 1/cm
double m_radius; ///< sample radius in cm
double m_power_th; ///< Power of lamda in BuildLamdaWeights
std::vector<double> m_lamda_weight; ///< lmabda weights
bool m_onlySphericalAbsorption;
bool m_returnTransmissionOnly;
bool m_useScaleFactors;
};
} // namespace Crystal
} // namespace Mantid
#endif /* MANTID_CRYSTAL_ANVREDCORRECTION_H_*/