GetEi.h 4.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
#ifndef MANTID_DATAHANDLING_GETEI_H_
#define MANTID_DATAHANDLING_GETEI_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"

namespace Mantid
{
namespace Algorithms
{
13
14
15
16
17
18
19
20
21
22
23
/** 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>
24

Nick Draper's avatar
Nick Draper committed
25
    @author Steve Williams ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
26
27
    @date 27/07/2009

Nick Draper's avatar
Nick Draper committed
28
    Copyright &copy; 2008-2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
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

    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://svn.mantidproject.org/mantid/trunk/Code/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
  virtual const std::string name() const { return "GetEi"; }
  /// Algorithm's version for identification overriding a virtual method
56
  virtual int version() const { return 1; }
57
  /// Algorithm's category for identification overriding a virtual method
58
59
60
  virtual const std::string category() const{return "CorrectionFunctions";}

private:
61
62
  /// Sets documentation strings for this algorithm
  virtual void initDocs();
63
64
65
66
  /// 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;
67
68
69
70
71
72
73
74
75
  /// 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();
  void exec();
76
  
77
78
  void getGeometry(API::MatrixWorkspace_const_sptr WS, int mon0Spec, int mon1Spec, double &monitor0Dist, double &monitor1Dist) const;
  std::vector<int> getMonitorSpecIndexs(API::MatrixWorkspace_const_sptr WS, int specNum1, int specNum2) const;
79
  double timeToFly(double s, double E_KE) const;
80
  double getPeakCentre(API::MatrixWorkspace_const_sptr WS, const int monitIn, const double peakTime);
81
82
  void extractSpec(int specInd, double start, double end);
  void getPeakEstimates(double &height, int &centreInd, double &background) const;
83
  double findHalfLoc(MantidVec::size_type startInd, const double height, const double noise, const direction go) const;
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  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 int 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
99
100
101
102
103
104
105
  static const double FIT_PEAK;                            ///< fraction required to find a peak
};

} // namespace Algorithms
} // namespace Mantid

#endif /*MANTID_DATAHANDLING_GETEI_H_*/