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

#include "MantidAPI/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
23
24
25
26
27
28
29
30
namespace Mantid {
namespace DataObjects {

/** Structure describing a single-crystal peak
 *
 * @author Janik Zikovsky
 * @date 2011-04-15 13:24:07.963491
 */
class DLLExport Peak : public API::IPeak {
public:
  /// Allow PeakColumn class to directly access members.
  friend class PeakColumn;

  Peak();
  Peak(Geometry::Instrument_const_sptr m_inst, Mantid::Kernel::V3D QLabFrame,
31
        boost::optional<double> detectorDistance = boost::optional<double>());
32
33
  Peak(Geometry::Instrument_const_sptr m_inst, Mantid::Kernel::V3D QSampleFrame,
       Mantid::Kernel::Matrix<double> goniometer,
34
       boost::optional<double> detectorDistance = boost::optional<double>());
35
36
37
38
39
40
41
42
43
44
  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);

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

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

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
87
88
  explicit Peak(const API::IPeak &ipeak);
  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;

  void setQSampleFrame(Mantid::Kernel::V3D QSampleFrame,
89
                       boost::optional<double> detectorDistance = boost::optional<double>());
90
  void setQLabFrame(Mantid::Kernel::V3D QLabFrame,
91
                    boost::optional<double> detectorDistance = boost::optional<double>());
92
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

  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;

126
  /// Get the peak shape.
Owen Arnold's avatar
Owen Arnold committed
127
  const Mantid::Geometry::PeakShape& getPeakShape() const;
128
129

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

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

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

138
private:
139

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
149
  /// Name of the parent bank
  std::string m_BankName;
150

151
152
  /// ID of the detector
  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
164
  /// Integrated peak intensity
  double m_Intensity;
165

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

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

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

175
176
  /// Final energy of the neutrons at peak (normally same as m_InitialEnergy)
  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
186
  /// Originating run number for this peak
  int m_RunNumber;
187

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

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

194
195
  /// Cached column in the detector
  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
205
206
207
  /// save values before setHKL is called for use in SortHKL
  double orig_H;
  double orig_K;
  double 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
219
220
221

} // namespace Mantid
} // namespace DataObjects

222
#endif /* MANTID_DATAOBJECTS_PEAK_H_ */