Peak.h 6.8 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
public:
  /// Allow PeakColumn class to directly access members.
  friend class PeakColumn;

  Peak();
Hahn, Steven's avatar
Hahn, Steven committed
29
30
31
  Peak(const Geometry::Instrument_const_sptr &m_inst,
       const Mantid::Kernel::V3D &QLabFrame,
       boost::optional<double> detectorDistance = boost::none);
32
33
34
  Peak(const Geometry::Instrument_const_sptr &m_inst,
       const Mantid::Kernel::V3D &QSampleFrame,
       const Mantid::Kernel::Matrix<double> &goniometer,
Hahn, Steven's avatar
Hahn, Steven committed
35
       boost::optional<double> detectorDistance = boost::none);
36
  Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
37
       double m_Wavelength);
38
  Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
39
       double m_Wavelength, Mantid::Kernel::V3D HKL);
40
  Peak(Geometry::Instrument_const_sptr m_inst, int m_detectorID,
41
42
43
44
45
       double m_Wavelength, Mantid::Kernel::V3D HKL,
       Mantid::Kernel::Matrix<double> goniometer);
  Peak(Geometry::Instrument_const_sptr m_inst, double scattering,
       double m_Wavelength);

46
  /// Copy constructor
47
  Peak(const Peak &other);
Hahn, Steven's avatar
Hahn, Steven committed
48
49
  Peak(Peak &&) noexcept;
  Peak &operator=(Peak &&) noexcept;
50

51
  // Construct a peak from a reference to the interface
52

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

55
56
  void setDetectorID(int id) override;
  int getDetectorID() const override;
57
58
59
60
  void addContributingDetID(const int id);
  void removeContributingDetector(const int id);
  const std::set<int> &getContributingDetIDs() const;

61
  void setInstrument(const Geometry::Instrument_const_sptr &inst) override;
62
63
  Geometry::IDetector_const_sptr getDetector() const override;
  Geometry::Instrument_const_sptr getInstrument() const override;
64

65
  bool findDetector() override;
66

67
  int getRunNumber() const override;
68
  void setRunNumber(int m_runNumber) override;
69

70
  double getMonitorCount() const override;
71
  void setMonitorCount(double m_monitorCount) override;
72

73
74
75
76
77
78
79
  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;
80
  void setBankName(std::string m_bankName);
81
  void setHKL(double H, double K, double L) override;
82
  void setHKL(const Mantid::Kernel::V3D &HKL) override;
83
84
  void resetHKL();

85
86
87
88
  Mantid::Kernel::V3D getQLabFrame() const override;
  Mantid::Kernel::V3D getQSampleFrame() const override;
  Mantid::Kernel::V3D getDetectorPosition() const override;
  Mantid::Kernel::V3D getDetectorPositionNoCheck() const override;
89

Hahn, Steven's avatar
Hahn, Steven committed
90
91
92
93
94
95
  void setQSampleFrame(
      const Mantid::Kernel::V3D &QSampleFrame,
      boost::optional<double> detectorDistance = boost::none) override;
  void
  setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
               boost::optional<double> detectorDistance = boost::none) override;
96

97
98
99
100
101
  void setWavelength(double wavelength) override;
  double getWavelength() const override;
  double getScattering() const override;
  double getDSpacing() const override;
  double getTOF() const override;
102

103
104
  double getInitialEnergy() const override;
  double getFinalEnergy() const override;
105
106
  void setInitialEnergy(double m_initialEnergy) override;
  void setFinalEnergy(double m_finalEnergy) override;
107

108
109
  double getIntensity() const override;
  double getSigmaIntensity() const override;
110

111
112
  void setIntensity(double m_intensity) override;
  void setSigmaIntensity(double m_sigmaIntensity) override;
113

114
  double getBinCount() const override;
115
  void setBinCount(double m_binCount) override;
116

117
  Mantid::Kernel::Matrix<double> getGoniometerMatrix() const override;
118
119
  void setGoniometerMatrix(
      const Mantid::Kernel::Matrix<double> &goniometerMatrix) override;
120

121
122
123
  std::string getBankName() const override;
  int getRow() const override;
  int getCol() const override;
124
125
  void setRow(int m_row);
  void setCol(int m_col);
126

127
128
129
  Mantid::Kernel::V3D getDetPos() const override;
  double getL1() const override;
  double getL2() const override;
130

131
  double getValueByColName(const std::string &name_in) const;
132

133
  /// Get the peak shape.
134
  const Mantid::Geometry::PeakShape &getPeakShape() const override;
135
136

  /// Set the PeakShape
137
  void setPeakShape(Mantid::Geometry::PeakShape *shape);
138

139
  /// Set the PeakShape
140
  void setPeakShape(Mantid::Geometry::PeakShape_const_sptr shape);
141

142
  /// Assignment
143
  Peak &operator=(const Peak &other);
144

145
private:
146
  bool findDetector(const Mantid::Kernel::V3D &beam);
147

148
149
150
151
152
  /// Shared pointer to the instrument (for calculating some values )
  Geometry::Instrument_const_sptr m_inst;

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

154
  /// Name of the parent bank
155
  std::string m_bankName;
156

157
  /// ID of the detector
158
  int m_detectorID;
159

160
161
  /// H of the peak
  double m_H;
162

163
164
  /// K of the peak
  double m_K;
165

166
167
  /// L of the peak
  double m_L;
168

169
  /// Integrated peak intensity
170
  double m_intensity;
171

172
  /// Error (sigma) on peak intensity
173
  double m_sigmaIntensity;
174

175
  /// Count in the bin at the peak
176
  double m_binCount;
177

178
  /// Initial energy of neutrons at the peak
179
  double m_initialEnergy;
180

181
  /// Final energy of the neutrons at peak (normally same as m_InitialEnergy)
182
  double m_finalEnergy;
183

184
185
  /// Orientation matrix of the goniometer angles.
  Mantid::Kernel::Matrix<double> m_GoniometerMatrix;
186

187
188
189
  /// 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;
190

191
  /// Originating run number for this peak
192
  int m_runNumber;
193

194
  /// Integrated monitor count over TOF range for this run
195
  double m_monitorCount;
196

197
  /// Cached row in the detector
198
  int m_row;
199

200
  /// Cached column in the detector
201
  int m_col;
202

203
204
205
206
207
208
  /// Cached source position
  Mantid::Kernel::V3D sourcePos;
  /// Cached sample position
  Mantid::Kernel::V3D samplePos;
  /// Cached detector position
  Mantid::Kernel::V3D detPos;
209

210
  /// save values before setHKL is called for use in SortHKL
211
212
213
  double m_orig_H;
  double m_orig_K;
  double m_orig_L;
214

215
216
  /// List of contributing detectors IDs
  std::set<int> m_detIDs;
Owen Arnold's avatar
Owen Arnold committed
217
218

  /// Peak shape
219
  Mantid::Geometry::PeakShape_const_sptr m_peakShape;
220
221
222

  /// Static logger
  static Mantid::Kernel::Logger g_log;
223
224

  // ki-kf for Inelastic convention; kf-ki for Crystallography convention
225
  std::string convention;
226
};
227
228
229
230

} // namespace Mantid
} // namespace DataObjects

231
#endif /* MANTID_DATAOBJECTS_PEAK_H_ */