Peak.h 7.13 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(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
37
       double m_Wavelength);
38
39
40
41
42
43
  Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
       double m_Wavelength, const Mantid::Kernel::V3D &HKL);
  Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
       double m_Wavelength, const Mantid::Kernel::V3D &HKL,
       const Mantid::Kernel::Matrix<double> &goniometer);
  Peak(const Geometry::Instrument_const_sptr &m_inst, double scattering,
44
45
       double m_Wavelength);

46
  /// Copy constructor
47
  Peak(const Peak &other);
48
49
50
// MSVC 2015 won't build with noexcept.
// error C2610: 'Mantid::DataObjects::Peak::Peak(Mantid::DataObjects::Peak &&)
// noexcept': is not a special member function which can be defaulted
Hahn, Steven's avatar
Hahn, Steven committed
51
#if defined(_MSC_VER) && _MSC_VER <= 1900
52
53
54
  Peak(Peak &&);
  Peak &operator=(Peak &&);
#else
Hahn, Steven's avatar
Hahn, Steven committed
55
56
  Peak(Peak &&) noexcept;
  Peak &operator=(Peak &&) noexcept;
57
#endif
58

59
  // Construct a peak from a reference to the interface
60

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

63
64
  void setDetectorID(int id) override;
  int getDetectorID() const override;
65
66
67
68
  void addContributingDetID(const int id);
  void removeContributingDetector(const int id);
  const std::set<int> &getContributingDetIDs() const;

69
  void setInstrument(const Geometry::Instrument_const_sptr &inst) override;
70
71
  Geometry::IDetector_const_sptr getDetector() const override;
  Geometry::Instrument_const_sptr getInstrument() const override;
72

73
  bool findDetector() override;
74

75
  int getRunNumber() const override;
76
  void setRunNumber(int m_runNumber) override;
77

78
  double getMonitorCount() const override;
79
  void setMonitorCount(double m_monitorCount) override;
80

81
82
83
84
85
86
87
  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;
88
  void setBankName(std::string m_bankName);
89
  void setHKL(double H, double K, double L) override;
90
  void setHKL(const Mantid::Kernel::V3D &HKL) override;
91
92
  void resetHKL();

93
94
95
96
  Mantid::Kernel::V3D getQLabFrame() const override;
  Mantid::Kernel::V3D getQSampleFrame() const override;
  Mantid::Kernel::V3D getDetectorPosition() const override;
  Mantid::Kernel::V3D getDetectorPositionNoCheck() const override;
97

Hahn, Steven's avatar
Hahn, Steven committed
98
99
100
101
102
103
  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;
104

105
106
107
108
109
  void setWavelength(double wavelength) override;
  double getWavelength() const override;
  double getScattering() const override;
  double getDSpacing() const override;
  double getTOF() const override;
110

111
112
  double getInitialEnergy() const override;
  double getFinalEnergy() const override;
113
114
  void setInitialEnergy(double m_initialEnergy) override;
  void setFinalEnergy(double m_finalEnergy) override;
115

116
117
  double getIntensity() const override;
  double getSigmaIntensity() const override;
118

119
120
  void setIntensity(double m_intensity) override;
  void setSigmaIntensity(double m_sigmaIntensity) override;
121

122
  double getBinCount() const override;
123
  void setBinCount(double m_binCount) override;
124

125
  Mantid::Kernel::Matrix<double> getGoniometerMatrix() const override;
126
127
  void setGoniometerMatrix(
      const Mantid::Kernel::Matrix<double> &goniometerMatrix) override;
128

129
130
131
  std::string getBankName() const override;
  int getRow() const override;
  int getCol() const override;
132
133
  void setRow(int m_row);
  void setCol(int m_col);
134

135
136
137
  Mantid::Kernel::V3D getDetPos() const override;
  double getL1() const override;
  double getL2() const override;
138

139
  double getValueByColName(const std::string &name_in) const;
140

141
  /// Get the peak shape.
142
  const Mantid::Geometry::PeakShape &getPeakShape() const override;
143
144

  /// Set the PeakShape
145
  void setPeakShape(Mantid::Geometry::PeakShape *shape);
146

147
  /// Set the PeakShape
148
  void setPeakShape(Mantid::Geometry::PeakShape_const_sptr shape);
149

150
  /// Assignment
151
  Peak &operator=(const Peak &other);
152

153
private:
154
  bool findDetector(const Mantid::Kernel::V3D &beam);
155

156
157
158
159
160
  /// Shared pointer to the instrument (for calculating some values )
  Geometry::Instrument_const_sptr m_inst;

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

162
  /// Name of the parent bank
163
  std::string m_bankName;
164

165
  /// ID of the detector
166
  int m_detectorID;
167

168
169
  /// H of the peak
  double m_H;
170

171
172
  /// K of the peak
  double m_K;
173

174
175
  /// L of the peak
  double m_L;
176

177
  /// Integrated peak intensity
178
  double m_intensity;
179

180
  /// Error (sigma) on peak intensity
181
  double m_sigmaIntensity;
182

183
  /// Count in the bin at the peak
184
  double m_binCount;
185

186
  /// Initial energy of neutrons at the peak
187
  double m_initialEnergy;
188

189
  /// Final energy of the neutrons at peak (normally same as m_InitialEnergy)
190
  double m_finalEnergy;
191

192
193
  /// Orientation matrix of the goniometer angles.
  Mantid::Kernel::Matrix<double> m_GoniometerMatrix;
194

195
196
197
  /// 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;
198

199
  /// Originating run number for this peak
200
  int m_runNumber;
201

202
  /// Integrated monitor count over TOF range for this run
203
  double m_monitorCount;
204

205
  /// Cached row in the detector
206
  int m_row;
207

208
  /// Cached column in the detector
209
  int m_col;
210

211
212
213
214
215
216
  /// Cached source position
  Mantid::Kernel::V3D sourcePos;
  /// Cached sample position
  Mantid::Kernel::V3D samplePos;
  /// Cached detector position
  Mantid::Kernel::V3D detPos;
217

218
  /// save values before setHKL is called for use in SortHKL
219
220
221
  double m_orig_H;
  double m_orig_K;
  double m_orig_L;
222

223
224
  /// List of contributing detectors IDs
  std::set<int> m_detIDs;
Owen Arnold's avatar
Owen Arnold committed
225
226

  /// Peak shape
227
  Mantid::Geometry::PeakShape_const_sptr m_peakShape;
228
229
230

  /// Static logger
  static Mantid::Kernel::Logger g_log;
231
232

  // ki-kf for Inelastic convention; kf-ki for Crystallography convention
233
  std::string convention;
234
};
235
236
237
238

} // namespace Mantid
} // namespace DataObjects

239
#endif /* MANTID_DATAOBJECTS_PEAK_H_ */