BasePeak.h 5.36 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once

#include "MantidGeometry/Crystal/IPeak.h"
#include "MantidGeometry/Crystal/PeakShape.h"
#include "MantidGeometry/Instrument.h"
#include "MantidKernel/Logger.h"
#include "MantidKernel/Matrix.h"
#include "MantidKernel/PhysicalConstants.h"
#include "MantidKernel/System.h"
#include "MantidKernel/V3D.h"
#include <boost/optional.hpp>
#include <memory>

namespace Mantid {

namespace Geometry {
class InstrumentRayTracer;
}

namespace DataObjects {

Whitfield, Ross's avatar
Whitfield, Ross committed
28
29
30
/** Structure describing a single-crystal peak. This is a partial
 * implementation of IPeak and should contain everything that is common
 * to Peak and LeanPeak.
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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
 *
 */
class DLLExport BasePeak : public Geometry::IPeak {
public:
  BasePeak();
  BasePeak(const Mantid::Kernel::Matrix<double> &goniometer);
  /// Copy constructor
  BasePeak(const BasePeak &other);

  // MSVC 2015/17 can build with noexcept = default however
  // intellisense still incorrectly reports this as an error despite compiling.
  // https://connect.microsoft.com/VisualStudio/feedback/details/1795240/visual-c-2015-default-move-constructor-and-noexcept-keyw
  // ord-bug For that reason we still use the supplied default which should be
  // noexcept once the above is fixed we can remove this workaround
#if defined(_MSC_VER) && _MSC_VER <= 1910
  BasePeak(BasePeak &&) = default;
  BasePeak &operator=(BasePeak &&) = default;
#else
  BasePeak(BasePeak &&) noexcept = default;
  BasePeak &operator=(BasePeak &&) noexcept = default;
#endif

  // Construct a peak from a reference to the interface
  explicit BasePeak(const Geometry::IPeak &ipeak);

  int getRunNumber() const override;
  void setRunNumber(int m_runNumber) override;

  double getMonitorCount() const override;
  void setMonitorCount(double m_monitorCount) override;

  double getH() const override;
  double getK() const override;
  double getL() const override;
  Mantid::Kernel::V3D getHKL() const override;
  bool isIndexed() const override;
  Mantid::Kernel::V3D getIntHKL() const override;
  Mantid::Kernel::V3D getIntMNP() const override;
  void setH(double m_H) override;
  void setK(double m_K) override;
  void setL(double m_L) override;
  void setBankName(std::string m_bankName);
  void setHKL(double H, double K, double L) override;
  void setHKL(const Mantid::Kernel::V3D &HKL) override;
  void setIntHKL(const Kernel::V3D &HKL) override;
  void setIntMNP(const Mantid::Kernel::V3D &MNP) override;

  double getIntensity() const override;
  double getSigmaIntensity() const override;
  double getIntensityOverSigma() const override;

  void setIntensity(double m_intensity) override;
  void setSigmaIntensity(double m_sigmaIntensity) override;

  double getBinCount() const override;
  void setBinCount(double m_binCount) override;

  Mantid::Kernel::Matrix<double> getGoniometerMatrix() const override;
89
  Mantid::Kernel::Matrix<double> getInverseGoniometerMatrix() const;
90
91
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
  void setGoniometerMatrix(
      const Mantid::Kernel::Matrix<double> &goniometerMatrix) override;

  std::string getBankName() const override;
  int getRow() const override;
  int getCol() const override;
  void setRow(int m_row);
  void setCol(int m_col);
  void setPeakNumber(int m_peakNumber) override;
  int getPeakNumber() const override;

  double getValueByColName(std::string colName) const;

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

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

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

  /// Assignment
  BasePeak &operator=(const BasePeak &other);

  void setAbsorptionWeightedPathLength(double pathLength) override;
  double getAbsorptionWeightedPathLength() const override;

118
119
120
121
122
123
protected:
  double calculateWavelengthFromQLab(const Mantid::Kernel::V3D qLab);

  // ki-kf for Inelastic convention; kf-ki for Crystallography convention
  std::string convention;

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
private:
  /// Name of the parent bank
  std::string m_bankName;

  /// H of the peak
  double m_H;

  /// K of the peak
  double m_K;

  /// L of the peak
  double m_L;

  /// Integrated peak intensity
  double m_intensity;

  /// Error (sigma) on peak intensity
  double m_sigmaIntensity;

  /// Count in the bin at the peak
  double m_binCount;

  /// absorption weighted path length (aka t bar)
  double m_absorptionWeightedPathLength;

149
150
151
152
153
154
155
  /// Orientation matrix of the goniometer angles.
  Mantid::Kernel::Matrix<double> m_GoniometerMatrix;

  /// 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;

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
  /// Originating run number for this peak
  int m_runNumber;

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

  /// Cached row in the detector
  int m_row;

  /// Cached column in the detector
  int m_col;

  int m_peakNumber;
  Mantid::Kernel::V3D m_intHKL;
  Mantid::Kernel::V3D m_intMNP;

  /// Peak shape
  Mantid::Geometry::PeakShape_const_sptr m_peakShape;

  /// Static logger
  static Mantid::Kernel::Logger g_log;
};

} // namespace DataObjects
} // namespace Mantid