Peak.h 7.41 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
51
#if defined(_MSC_VER) && _MSC_VER <= 1910
52
53
  Peak(Peak &&);
  Peak &operator=(Peak &&);
54
55
56
#elif defined(__GNUC__) && (__GNUC__ == 5)
  Peak(Peak &&) noexcept = default;
  Peak &operator=(Peak &&) noexcept = default;
57
#else
Hahn, Steven's avatar
Hahn, Steven committed
58
59
  Peak(Peak &&) noexcept;
  Peak &operator=(Peak &&) noexcept;
60
#endif
61

62
  // Construct a peak from a reference to the interface
63

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

66
67
  void setDetectorID(int id) override;
  int getDetectorID() const override;
68
69
70
71
  void addContributingDetID(const int id);
  void removeContributingDetector(const int id);
  const std::set<int> &getContributingDetIDs() const;

72
  void setInstrument(const Geometry::Instrument_const_sptr &inst) override;
73
74
  Geometry::IDetector_const_sptr getDetector() const override;
  Geometry::Instrument_const_sptr getInstrument() const override;
75

76
  bool findDetector() override;
77

78
  int getRunNumber() const override;
79
  void setRunNumber(int m_runNumber) override;
80

81
  double getMonitorCount() const override;
82
  void setMonitorCount(double m_monitorCount) override;
83

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

96
97
98
99
  Mantid::Kernel::V3D getQLabFrame() const override;
  Mantid::Kernel::V3D getQSampleFrame() const override;
  Mantid::Kernel::V3D getDetectorPosition() const override;
  Mantid::Kernel::V3D getDetectorPositionNoCheck() const override;
100

Hahn, Steven's avatar
Hahn, Steven committed
101
102
103
104
105
106
  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;
107

108
109
110
111
112
  void setWavelength(double wavelength) override;
  double getWavelength() const override;
  double getScattering() const override;
  double getDSpacing() const override;
  double getTOF() const override;
113

114
115
  double getInitialEnergy() const override;
  double getFinalEnergy() const override;
116
117
  void setInitialEnergy(double m_initialEnergy) override;
  void setFinalEnergy(double m_finalEnergy) override;
118

119
120
  double getIntensity() const override;
  double getSigmaIntensity() const override;
121

122
123
  void setIntensity(double m_intensity) override;
  void setSigmaIntensity(double m_sigmaIntensity) override;
124

125
  double getBinCount() const override;
126
  void setBinCount(double m_binCount) override;
127

128
  Mantid::Kernel::Matrix<double> getGoniometerMatrix() const override;
129
130
  void setGoniometerMatrix(
      const Mantid::Kernel::Matrix<double> &goniometerMatrix) override;
131

132
133
134
  std::string getBankName() const override;
  int getRow() const override;
  int getCol() const override;
135
136
  void setRow(int m_row);
  void setCol(int m_col);
137

138
  virtual Mantid::Kernel::V3D getDetPos() const override;
139
140
  double getL1() const override;
  double getL2() const override;
141

142
  double getValueByColName(const std::string &name_in) const;
143

144
  /// Get the peak shape.
145
  const Mantid::Geometry::PeakShape &getPeakShape() const override;
146
147

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

150
  /// Set the PeakShape
151
  void setPeakShape(Mantid::Geometry::PeakShape_const_sptr shape);
152

153
  /// Assignment
154
  Peak &operator=(const Peak &other);
155

156
  /// Get the approximate position of a peak that falls off the detectors
157
  Kernel::V3D getVirtualDetectorPosition(const Kernel::V3D &detectorDir) const;
158

159
private:
160
  bool findDetector(const Mantid::Kernel::V3D &beam);
161

162
163
164
165
166
  /// Shared pointer to the instrument (for calculating some values )
  Geometry::Instrument_const_sptr m_inst;

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

168
  /// Name of the parent bank
169
  std::string m_bankName;
170

171
  /// ID of the detector
172
  int m_detectorID;
173

174
175
  /// H of the peak
  double m_H;
176

177
178
  /// K of the peak
  double m_K;
179

180
181
  /// L of the peak
  double m_L;
182

183
  /// Integrated peak intensity
184
  double m_intensity;
185

186
  /// Error (sigma) on peak intensity
187
  double m_sigmaIntensity;
188

189
  /// Count in the bin at the peak
190
  double m_binCount;
191

192
  /// Initial energy of neutrons at the peak
193
  double m_initialEnergy;
194

195
  /// Final energy of the neutrons at peak (normally same as m_InitialEnergy)
196
  double m_finalEnergy;
197

198
199
  /// Orientation matrix of the goniometer angles.
  Mantid::Kernel::Matrix<double> m_GoniometerMatrix;
200

201
202
203
  /// 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;
204

205
  /// Originating run number for this peak
206
  int m_runNumber;
207

208
  /// Integrated monitor count over TOF range for this run
209
  double m_monitorCount;
210

211
  /// Cached row in the detector
212
  int m_row;
213

214
  /// Cached column in the detector
215
  int m_col;
216

217
218
219
220
221
222
  /// Cached source position
  Mantid::Kernel::V3D sourcePos;
  /// Cached sample position
  Mantid::Kernel::V3D samplePos;
  /// Cached detector position
  Mantid::Kernel::V3D detPos;
223

224
  /// save values before setHKL is called for use in SortHKL
225
226
227
  double m_orig_H;
  double m_orig_K;
  double m_orig_L;
228

229
230
  /// List of contributing detectors IDs
  std::set<int> m_detIDs;
Owen Arnold's avatar
Owen Arnold committed
231
232

  /// Peak shape
233
  Mantid::Geometry::PeakShape_const_sptr m_peakShape;
234
235
236

  /// Static logger
  static Mantid::Kernel::Logger g_log;
237
238

  // ki-kf for Inelastic convention; kf-ki for Crystallography convention
239
  std::string convention;
240
};
241
242
243
244

} // namespace Mantid
} // namespace DataObjects

245
#endif /* MANTID_DATAOBJECTS_PEAK_H_ */