Peak.h 6.24 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
35
36
37
38
39
40
41
42
43
  Peak(Geometry::Instrument_const_sptr m_inst, int m_DetectorID,
       double m_Wavelength);
  Peak(Geometry::Instrument_const_sptr m_inst, int m_DetectorID,
       double m_Wavelength, Mantid::Kernel::V3D HKL);
  Peak(Geometry::Instrument_const_sptr m_inst, int m_DetectorID,
       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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  virtual ~Peak();

  void setDetectorID(int id);
  int getDetectorID() const;
  void addContributingDetID(const int id);
  void removeContributingDetector(const int id);
  const std::set<int> &getContributingDetIDs() const;

  void setInstrument(Geometry::Instrument_const_sptr inst);
  Geometry::IDetector_const_sptr getDetector() const;
  Geometry::Instrument_const_sptr getInstrument() const;

  bool findDetector();

  int getRunNumber() const;
  void setRunNumber(int m_RunNumber);

  double getMonitorCount() const;
  void setMonitorCount(double m_MonitorCount);

  double getH() const;
  double getK() const;
  double getL() const;
  Mantid::Kernel::V3D getHKL() const;
  void setH(double m_H);
  void setK(double m_K);
  void setL(double m_L);
  void setBankName(std::string m_BankName);
  void setHKL(double H, double K, double L);
  void setHKL(Mantid::Kernel::V3D HKL);
  void resetHKL();

  Mantid::Kernel::V3D getQLabFrame() const;
  Mantid::Kernel::V3D getQSampleFrame() const;
  Mantid::Kernel::V3D getDetectorPosition() const;
  Mantid::Kernel::V3D getDetectorPositionNoCheck() const;

87
88
89
90
91
92
  void setQSampleFrame(
      Mantid::Kernel::V3D QSampleFrame,
      boost::optional<double> detectorDistance = boost::optional<double>());
  void setQLabFrame(
      Mantid::Kernel::V3D QLabFrame,
      boost::optional<double> detectorDistance = boost::optional<double>());
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

  void setWavelength(double wavelength);
  double getWavelength() const;
  double getScattering() const;
  double getDSpacing() const;
  double getTOF() const;

  double getInitialEnergy() const;
  double getFinalEnergy() const;
  void setInitialEnergy(double m_InitialEnergy);
  void setFinalEnergy(double m_FinalEnergy);

  double getIntensity() const;
  double getSigmaIntensity() const;

  void setIntensity(double m_Intensity);
  void setSigmaIntensity(double m_SigmaIntensity);

  double getBinCount() const;
  void setBinCount(double m_BinCount);

  Mantid::Kernel::Matrix<double> getGoniometerMatrix() const;
  void setGoniometerMatrix(Mantid::Kernel::Matrix<double> m_GoniometerMatrix);

  std::string getBankName() const;
  int getRow() const;
  int getCol() const;

  Mantid::Kernel::V3D getDetPos() const;
  double getL1() const;
  double getL2() const;

  double getValueByColName(const std::string &name) const;

127
  /// Get the peak shape.
128
  const Mantid::Geometry::PeakShape &getPeakShape() const;
129
130

  /// Set the PeakShape
131
  void setPeakShape(Mantid::Geometry::PeakShape *shape);
132

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

136
  /// Assignment
137
  Peak &operator=(const Peak &other);
138

139
private:
140
  bool findDetector(const Mantid::Kernel::V3D &beam);
141

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

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

148
  /// Name of the parent bank
149
  std::string m_bankName;
150

151
  /// ID of the detector
152
  int m_detectorID;
153

154
155
  /// H of the peak
  double m_H;
156

157
158
  /// K of the peak
  double m_K;
159

160
161
  /// L of the peak
  double m_L;
162

163
  /// Integrated peak intensity
164
  double m_intensity;
165

166
  /// Error (sigma) on peak intensity
167
  double m_sigmaIntensity;
168

169
  /// Count in the bin at the peak
170
  double m_binCount;
171

172
  /// Initial energy of neutrons at the peak
173
  double m_initialEnergy;
174

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

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

181
182
183
  /// 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;
184

185
  /// Originating run number for this peak
186
  int m_runNumber;
187

188
  /// Integrated monitor count over TOF range for this run
189
  double m_monitorCount;
190

191
  /// Cached row in the detector
192
  int m_row;
193

194
  /// Cached column in the detector
195
  int m_col;
196

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

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

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

  /// Peak shape
213
  Mantid::Geometry::PeakShape_const_sptr m_peakShape;
214
215
216

  /// Static logger
  static Mantid::Kernel::Logger g_log;
217
218

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

} // namespace Mantid
} // namespace DataObjects

225
#endif /* MANTID_DATAOBJECTS_PEAK_H_ */