Peak.h 6.77 KB
Newer Older
1
2
#ifndef MANTID_DATAOBJECTS_PEAK_H_
#define MANTID_DATAOBJECTS_PEAK_H_
3

Owen Arnold's avatar
Owen Arnold committed
4
#include "MantidGeometry/Crystal/IPeak.h"
5
#include "MantidGeometry/Instrument.h"
6
#include "MantidKernel/Logger.h"
7
8
#include "MantidKernel/Matrix.h"
#include "MantidKernel/V3D.h"
9
#include "MantidKernel/PhysicalConstants.h"
10
#include "MantidKernel/System.h"
11
#include "MantidGeometry/Crystal/PeakShape.h"
12
#include <boost/shared_ptr.hpp>
13
14
#include <boost/optional.hpp>

15
16
17
18
19
20
21
22
namespace Mantid {
namespace DataObjects {

/** Structure describing a single-crystal peak
 *
 * @author Janik Zikovsky
 * @date 2011-04-15 13:24:07.963491
 */
Owen Arnold's avatar
Owen Arnold committed
23
class DLLExport Peak : public Geometry::IPeak {
24
25
26
27
28
29
public:
  /// Allow PeakColumn class to directly access members.
  friend class PeakColumn;

  Peak();
  Peak(Geometry::Instrument_const_sptr m_inst, Mantid::Kernel::V3D QLabFrame,
30
       boost::optional<double> detectorDistance = boost::optional<double>());
31
32
  Peak(Geometry::Instrument_const_sptr m_inst, Mantid::Kernel::V3D QSampleFrame,
       Mantid::Kernel::Matrix<double> goniometer,
33
       boost::optional<double> detectorDistance = boost::optional<double>());
34
  Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
35
       double m_Wavelength);
36
  Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
37
       double m_Wavelength, Mantid::Kernel::V3D HKL);
38
  Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
39
40
41
42
43
       double m_Wavelength, Mantid::Kernel::V3D HKL,
       Mantid::Kernel::Matrix<double> goniometer);
  Peak(Geometry::Instrument_const_sptr m_inst, double scattering,
       double m_Wavelength);

44
  /// Copy constructor
45
  Peak(const Peak &other);
46

47
  // Construct a peak from a reference to the interface
48

Owen Arnold's avatar
Owen Arnold committed
49
  explicit Peak(const Geometry::IPeak &ipeak);
50

51
52
  void setDetectorID(int id) override;
  int getDetectorID() const override;
53
54
55
56
  void addContributingDetID(const int id);
  void removeContributingDetector(const int id);
  const std::set<int> &getContributingDetIDs() const;

57
58
59
  void setInstrument(Geometry::Instrument_const_sptr inst) override;
  Geometry::IDetector_const_sptr getDetector() const override;
  Geometry::Instrument_const_sptr getInstrument() const override;
60

61
  bool findDetector() override;
62

63
  int getRunNumber() const override;
64
  void setRunNumber(int m_runNumber) override;
65

66
  double getMonitorCount() const override;
67
  void setMonitorCount(double m_monitorCount) override;
68

69
70
71
72
73
74
75
  double getH() const override;
  double getK() const override;
  double getL() const override;
  Mantid::Kernel::V3D getHKL() const override;
  void setH(double m_H) override;
  void setK(double m_K) override;
  void setL(double m_L) override;
76
  void setBankName(std::string m_bankName);
77
78
  void setHKL(double H, double K, double L) override;
  void setHKL(Mantid::Kernel::V3D HKL) override;
79
80
  void resetHKL();

81
82
83
84
  Mantid::Kernel::V3D getQLabFrame() const override;
  Mantid::Kernel::V3D getQSampleFrame() const override;
  Mantid::Kernel::V3D getDetectorPosition() const override;
  Mantid::Kernel::V3D getDetectorPositionNoCheck() const override;
85

86
87
88
89
90
91
  void setQSampleFrame(Mantid::Kernel::V3D QSampleFrame,
                       boost::optional<double> detectorDistance =
                           boost::optional<double>()) override;
  void setQLabFrame(Mantid::Kernel::V3D QLabFrame,
                    boost::optional<double> detectorDistance =
                        boost::optional<double>()) override;
92

93
94
95
96
97
  void setWavelength(double wavelength) override;
  double getWavelength() const override;
  double getScattering() const override;
  double getDSpacing() const override;
  double getTOF() const override;
98

99
100
  double getInitialEnergy() const override;
  double getFinalEnergy() const override;
101
102
  void setInitialEnergy(double m_initialEnergy) override;
  void setFinalEnergy(double m_finalEnergy) override;
103

104
105
  double getIntensity() const override;
  double getSigmaIntensity() const override;
106

107
108
  void setIntensity(double m_intensity) override;
  void setSigmaIntensity(double m_sigmaIntensity) override;
109

110
  double getBinCount() const override;
111
  void setBinCount(double m_binCount) override;
112

113
  Mantid::Kernel::Matrix<double> getGoniometerMatrix() const override;
Lamar Moore's avatar
Lamar Moore committed
114
115
  void
  setGoniometerMatrix(Mantid::Kernel::Matrix<double> goniometerMatrix) override;
116

117
118
119
  std::string getBankName() const override;
  int getRow() const override;
  int getCol() const override;
120
121
  void setRow(int m_row);
  void setCol(int m_col);
122

123
124
125
  Mantid::Kernel::V3D getDetPos() const override;
  double getL1() const override;
  double getL2() const override;
126

127
  double getValueByColName(const std::string &name_in) const;
128

129
  /// Get the peak shape.
130
  const Mantid::Geometry::PeakShape &getPeakShape() const override;
131
132

  /// Set the PeakShape
133
  void setPeakShape(Mantid::Geometry::PeakShape *shape);
134

135
  /// Set the PeakShape
136
  void setPeakShape(Mantid::Geometry::PeakShape_const_sptr shape);
137

138
  /// Assignment
139
  Peak &operator=(const Peak &other);
140

141
private:
142
  bool findDetector(const Mantid::Kernel::V3D &beam);
143

144
145
146
147
148
  /// Shared pointer to the instrument (for calculating some values )
  Geometry::Instrument_const_sptr m_inst;

  /// Detector pointed to
  Geometry::IDetector_const_sptr m_det;
149

150
  /// Name of the parent bank
151
  std::string m_bankName;
152

153
  /// ID of the detector
154
  int m_detectorID;
155

156
157
  /// H of the peak
  double m_H;
158

159
160
  /// K of the peak
  double m_K;
161

162
163
  /// L of the peak
  double m_L;
164

165
  /// Integrated peak intensity
166
  double m_intensity;
167

168
  /// Error (sigma) on peak intensity
169
  double m_sigmaIntensity;
170

171
  /// Count in the bin at the peak
172
  double m_binCount;
173

174
  /// Initial energy of neutrons at the peak
175
  double m_initialEnergy;
176

177
  /// Final energy of the neutrons at peak (normally same as m_InitialEnergy)
178
  double m_finalEnergy;
179

180
181
  /// Orientation matrix of the goniometer angles.
  Mantid::Kernel::Matrix<double> m_GoniometerMatrix;
182

183
184
185
  /// Inverse of the goniometer rotation matrix; used to go from Q in lab frame
  /// to Q in sample frame
  Mantid::Kernel::Matrix<double> m_InverseGoniometerMatrix;
186

187
  /// Originating run number for this peak
188
  int m_runNumber;
189

190
  /// Integrated monitor count over TOF range for this run
191
  double m_monitorCount;
192

193
  /// Cached row in the detector
194
  int m_row;
195

196
  /// Cached column in the detector
197
  int m_col;
198

199
200
201
202
203
204
  /// Cached source position
  Mantid::Kernel::V3D sourcePos;
  /// Cached sample position
  Mantid::Kernel::V3D samplePos;
  /// Cached detector position
  Mantid::Kernel::V3D detPos;
205

206
  /// save values before setHKL is called for use in SortHKL
207
208
209
  double m_orig_H;
  double m_orig_K;
  double m_orig_L;
210

211
212
  /// List of contributing detectors IDs
  std::set<int> m_detIDs;
Owen Arnold's avatar
Owen Arnold committed
213
214

  /// Peak shape
215
  Mantid::Geometry::PeakShape_const_sptr m_peakShape;
216
217
218

  /// Static logger
  static Mantid::Kernel::Logger g_log;
219
220

  // ki-kf for Inelastic convention; kf-ki for Crystallography convention
221
  std::string convention;
222
};
223
224
225
226

} // namespace Mantid
} // namespace DataObjects

227
#endif /* MANTID_DATAOBJECTS_PEAK_H_ */