WeightingStrategy.h 4.37 KB
Newer Older
1
2
3
4
#ifndef MANTID_ALGORITHMS_WEIGHTINGSTRATEGY_H_
#define MANTID_ALGORITHMS_WEIGHTINGSTRATEGY_H_

#include "MantidKernel/System.h"
5
#include "MantidKernel/V3D.h"
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

namespace Mantid
{
namespace Algorithms
{

  /** WeightingStrategy : 
  
    Abstract weighting strategy, which can be applied to calculate individual 
    weights for each pixel based upon disance from epicenter. Generated for use with SmoothNeighbours.
    
    @date 2011-11-30

    Copyright © 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory

    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 WeightingStrategy
    {
    public:
      /// Constructor
      WeightingStrategy(const double cutOff);
      /// Constructor
      WeightingStrategy();
      /// Destructor
      virtual ~WeightingStrategy();
      /**
      Calculate the weight at distance from epicenter.
50
      @param distance : difference between the central detector location and the nearest neighbour
51
52
      @return calculated weight
      */
53
      virtual double weightAt(const Mantid::Kernel::V3D& distance) = 0;
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

      /**
      Calculate the weight at distance from epicenter.
      @param adjX : The number of Y (vertical) adjacent pixels to average together
      @param ix : current index x
      @param adjY : The number of X (vertical) adjacent pixels to average together
      @param iy : current index y
      */
      virtual double weightAt(const double& adjX,const double& ix, const double& adjY, const double& iy) = 0;
    protected:
      /// Cutoff member.
      double m_cutOff;
    };

    /*
    Flat (no weighting) strategy. Concrete WeightingStrategy
    */
    class DLLExport FlatWeighting : public WeightingStrategy
    {
    public:
      FlatWeighting();
      virtual ~FlatWeighting();
      virtual double weightAt(const double&,const double&, const double&, const double&);
77
      double weightAt(const Mantid::Kernel::V3D& );
78
79
80
81
82
83
84
85
86
87
    };

    /*
    Linear weighting strategy.
    */
    class DLLExport LinearWeighting : public WeightingStrategy
    {
    public: 
      LinearWeighting(const double cutOff);
      virtual ~LinearWeighting();
88
      double weightAt(const Mantid::Kernel::V3D& );
89
90
91
92
93
94
95
96
97
      virtual double weightAt(const double& adjX,const double& ix, const double& adjY, const double& iy);
    };

    /*
    Parabolic weighting strategy.
    */
    class DLLExport ParabolicWeighting : public WeightingStrategy
    {
    public: 
98
      ParabolicWeighting(const double cutOff);
99
      virtual ~ParabolicWeighting();
100
      double weightAt(const Mantid::Kernel::V3D& );
101
102
103
104
105
106
107
108
109
110
111
      virtual double weightAt(const double& adjX,const double& ix, const double& adjY, const double& iy);
    };

    /*
    Null weighting strategy.
    */
    class DLLExport NullWeighting : public WeightingStrategy
    {
    public:
      NullWeighting();
      virtual ~NullWeighting();
112
      double weightAt(const Mantid::Kernel::V3D& );
113
114
115
      virtual double weightAt(const double&,const double&, const double&, const double&);
    };

116
    /*
117
118
119
    Gaussian nD Strategy. 

    y = exp(-0.5*((r./p(1)).^2) where p = sqtr(2)*sigma
120
    */
121
    class DLLExport GaussianWeightingnD : public WeightingStrategy
122
123
    {
    public:
124
125
      GaussianWeightingnD(double cutOff, double sigma);
      virtual ~GaussianWeightingnD();
126
      virtual double weightAt(const Mantid::Kernel::V3D& );
127
128
129
130
131
132
      virtual double weightAt(const double&,const double&, const double&, const double&);
    private:
      double calculateGaussian(const double normalisedDistanceSq);
      double m_twiceSigmaSquared;
    };

133
134
135
} // namespace Algorithms
} // namespace Mantid

136
#endif  /* MANTID_ALGORITHMS_WEIGHTINGSTRATEGY_H_ */