He3TubeEfficiency.h 4.35 KB
Newer Older
1
2
3
4
#ifndef MANTID_ALGORITHM_HE3TUBEEFFICIENCY_H_
#define MANTID_ALGORITHM_HE3TUBEEFFICIENCY_H_

#include "MantidAPI/Algorithm.h"
5
#include "MantidGeometry/V3D.h"
6
#include <map>
7
8
9
10
11
12
13
14
15
#include <vector>

namespace Mantid
{
namespace Algorithms
{
/**
    Corrects the input workspace for helium3 tube efficiency based on an
    exponential parameterization. The algorithm expects the input workspace
16
17
18
19
20
21
22
23
24
25
26
27
28
    units to be wavelength. The formula for the efficiency is given here.

    \f[
    \epsilon = \frac{A}{1-e^{\frac{-\alpha P (L - 2W) \lambda}{T sin(\theta)}}}
    \f]

    where \f$A\f$ is a dimensionless scaling factor, \f$\alpha\f$ is a constant
    with units \f$(Kelvin / (metres\: \AA\: atm))\f$, \f$P\f$ is pressure in
    units of \f$atm\f$, \f$L\f$ is the tube diameter in units of \f$metres\f$,
    \f$W\f$ is the tube thickness in units of \f$metres\f$, \f$T\f$ is the
    temperature in units of \f$Kelvin\f$, \f$sin(\theta)\f$ is the angle of
    the neutron trajectory with respect to the long axis of the He3 tube and
    \f$\lambda\f$ is in units of \f$\AA\f$.
29
30
31
32

    @author Michael Reuter
    @date 30/09/2010

33
    Copyright &copy; 2008-10 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
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

    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 He3TubeEfficiency: public API::Algorithm
{
public:
  /// Default constructor
  He3TubeEfficiency();
  /// Virtual destructor
  virtual ~He3TubeEfficiency();
  /// Algorithm's name for identification overriding a virtual method
  virtual const std::string name() const { return "He3TubeEfficiency"; }
  /// Algorithm's version for identification overriding a virtual method
  virtual int version() const { return 1; }
  /// Algorithm's category for identification overriding a virtual method
  virtual const std::string category() const{ return "CorrectionFunctions"; }

private:
68
69
  /// Sets documentation strings for this algorithm
  virtual void initDocs();
70
71
72
73
74
75
  // Implement abstract Algorithm methods
  void init();
  void exec();

  /// Correct the given spectra index for efficiency
  void correctForEfficiency(int spectraIndex);
76
77
78
79
80
81
  /// Sets the detector geometry cache if necessary
  void getDetectorGeometry(boost::shared_ptr<Geometry::IDetector> det,
      double & detRadius, Geometry::V3D & detAxis);
  /// Computes the distance to the given shape from a starting point
  double distToSurface(const Geometry::V3D start,
      const Geometry::Object *shape) const;
82
  /// Calculate the detector efficiency
83
84
  double detectorEfficiency(const double alpha,
      const double scale_fac = 1.0) const;
85
86
  /// Log any errors with spectra that occurred
  void logErrors() const;
87
88
89
  /// Retrieve the detector parameters from workspace or detector properties
  double getParameter(std::string wsPropName, int currentIndex,
      std::string detPropName, boost::shared_ptr<Geometry::IDetector> idet);
90
91
92
93
94
95
96

  /// The user selected (input) workspace
  API::MatrixWorkspace_const_sptr inputWS;
  /// The output workspace, maybe the same as the input one
  API::MatrixWorkspace_sptr outputWS;
  /// Map that stores additional properties for detectors
  const Geometry::ParameterMap *paraMap;
97
98
99
100
  /// A lookup of previously seen shape objects used to save calculation time as most detectors have the same shape
  std::map<const Geometry::Object *, std::pair<double, Geometry::V3D> > shapeCache;
  /// Sample position
  Geometry::V3D samplePos;
101
102
  /// The spectra numbers that were skipped
  std::vector<int> spectraSkipped;
103
104
  /// Algorithm progress keeper
  API::Progress *progress;
105
106
107
108
109
110
};

} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHM_HE3TUBEEFFICIENCY_H_ */