-
Notifications
You must be signed in to change notification settings - Fork 122
/
GetEi.h
127 lines (108 loc) · 5.28 KB
/
GetEi.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
#ifndef MANTID_DATAHANDLING_GETEI_H_
#define MANTID_DATAHANDLING_GETEI_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidKernel/cow_ptr.h"
#include "MantidGeometry/IDTypes.h"
namespace Mantid {
namespace Algorithms {
/** Requires an estimate for the initial neutron energy which it uses to
search for monitor peaks and from these calculate an accurate energy
Required Properties:
<UL>
<LI>InputWorkspace - The X units of this workspace must be time of flight
with times in micro-seconds</LI>
<LI>Monitor1ID - The detector ID of the first monitor</LI>
<LI>Monitor2ID - The detector ID of the second monitor</LI>
<LI>EnergyEstimate - An approximate value for the typical incident energy,
energy of neutrons leaving the source (meV)</LI>
<LI>IncidentEnergy - The calculated energy</LI>
</UL>
@author Steve Williams ISIS Rutherford Appleton Laboratory & NScD Oak Ridge
National Laboratory
@date 27/07/2009
Copyright © 2008-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 GetEi : public API::Algorithm {
public:
GetEi();
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "GetEi"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Calculates the kinetic energy of neutrons leaving the source based "
"on the time it takes for them to travel between two monitors.";
}
/// 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 "Inelastic\\Ei"; }
private:
/// name of the tempory workspace that we create and use
API::MatrixWorkspace_sptr m_tempWS;
/// An estimate of the percentage of the algorithm runtimes that has been
/// completed
double m_fracCompl;
/// used by the function findHalfLoc to indicate whether to search left or
/// right
enum direction {
GO_LEFT = -1, ///< flag value to serch left
GO_RIGHT = 1 ///< flag value to search right
};
// Implement abstract Algorithm methods
void init() override;
void exec() override;
void getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec,
specnum_t mon1Spec, double &monitor0Dist,
double &monitor1Dist) const;
std::vector<size_t> getMonitorWsIndexs(API::MatrixWorkspace_const_sptr WS,
specnum_t specNum1,
specnum_t specNum2) const;
double timeToFly(double s, double E_KE) const;
double getPeakCentre(API::MatrixWorkspace_const_sptr WS, const size_t monitIn,
const double peakTime);
void extractSpec(int wsInd, double start, double end);
void getPeakEstimates(double &height, int64_t ¢reInd,
double &background) const;
double findHalfLoc(MantidVec::size_type startInd, const double height,
const double noise, const direction go) const;
double neutron_E_At(double speed) const;
void advanceProgress(double toAdd);
/// the range of TOF X-values over which the peak will be searched is double
/// this value, i.e. from the estimate of the peak position the search will go
/// forward by this fraction and back by this fraction
static const double HALF_WINDOW;
/// ignore an peaks that are less than this factor of the background
static const double PEAK_THRESH_H;
/// ignore peaks where the half width times the ratio of the peak height to
/// the background is less this
static const double PEAK_THRESH_A;
/// for peaks where the distance to the half heigth is less than this number
/// of bins in either direction e.g. the FWHM is less than twice this number
static const int64_t PEAK_THRESH_W;
// for estimating algorithm progress
static const double
CROP; ///< fraction of algorithm time taken up with running CropWorkspace
static const double GET_COUNT_RATE; ///< fraction of algorithm taken by a
/// single call to ConvertToDistribution
static const double FIT_PEAK; ///< fraction required to find a peak
};
} // namespace Algorithms
} // namespace Mantid
#endif /*MANTID_DATAHANDLING_GETEI_H_*/