LeanElasticPeak.h 4.73 KB
Newer Older
1
2
3
4
5
6
7
8
// 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

9
#include "MantidDataObjects/BasePeak.h"
10
#include "MantidGeometry/Crystal/IPeak.h"
11
#include "MantidGeometry/Instrument/ReferenceFrame.h"
12
13
14
15
16
17
18
19
20
21
22
23
#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 DataObjects {

Whitfield, Ross's avatar
Whitfield, Ross committed
24
/** Structure describing a single-crystal peak. This is a version of
25
26
27
28
 * Peak that doesn't require the instrument and also assuming elastic
 * scattering. The peak is described only by the Q-sample
 * position. Optionally if the wavelength and goniometer is provided
 * other properties can be calculated.
29
30
 *
 */
31
class DLLExport LeanElasticPeak : public BasePeak {
32
33
34
35
public:
  /// Allow PeakColumn class to directly access members.
  friend class PeakColumn;

36
37
38
39
  LeanElasticPeak();
  LeanElasticPeak(const Mantid::Kernel::V3D &QSampleFrame);
  LeanElasticPeak(const Mantid::Kernel::V3D &QSampleFrame,
                  const Mantid::Kernel::Matrix<double> &goniometer,
40
41
42
                  boost::optional<std::shared_ptr<Geometry::ReferenceFrame>>
                      refFrame = boost::none);
  LeanElasticPeak(const Mantid::Kernel::V3D &QSampleFrame, double wavelength);
43
44

  /// Copy constructor
45
  LeanElasticPeak(const LeanElasticPeak &other);
46
47
48
49
50
51
52

  // 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-keyword-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
53
54
  LeanElasticPeak(LeanElasticPeak &&) = default;
  LeanElasticPeak &operator=(LeanElasticPeak &&) = default;
55
#else
56
57
  LeanElasticPeak(LeanElasticPeak &&) noexcept = default;
  LeanElasticPeak &operator=(LeanElasticPeak &&) noexcept = default;
58
59
#endif

60
  // Construct a peak from a reference to the interface
61
  explicit LeanElasticPeak(const Geometry::IPeak &ipeak);
62

Whitfield, Ross's avatar
Whitfield, Ross committed
63
  void setDetectorID(int) override;
64
65
  int getDetectorID() const override;

Whitfield, Ross's avatar
Whitfield, Ross committed
66
  void setInstrument(const Geometry::Instrument_const_sptr &) override;
67
68
  Geometry::IDetector_const_sptr getDetector() const override;
  Geometry::Instrument_const_sptr getInstrument() const override;
69
70
71
  void setReferenceFrame(std::shared_ptr<Geometry::ReferenceFrame> frame);
  std::shared_ptr<const Geometry::ReferenceFrame>
  getReferenceFrame() const override;
72
73

  bool findDetector() override;
Whitfield, Ross's avatar
Whitfield, Ross committed
74
  bool findDetector(const Geometry::InstrumentRayTracer &) override;
75

Whitfield, Ross's avatar
Whitfield, Ross committed
76
77
  void setSamplePos(double, double, double) override;
  void setSamplePos(const Mantid::Kernel::V3D &) override;
78
79
80
81
82
83

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

Whitfield, Ross's avatar
Whitfield, Ross committed
84
85
  void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
                       boost::optional<double> = boost::none) override;
86
87
  void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
                       const Mantid::Kernel::Matrix<double> &goniometer);
Whitfield, Ross's avatar
Whitfield, Ross committed
88
89
  void setQLabFrame(const Mantid::Kernel::V3D &qLab,
                    boost::optional<double> = boost::none) override;
90

91
92
  void setWavelength(double wavelength) override;
  double getWavelength() const override;
93
94
95
96
97
  double getScattering() const override;
  double getAzimuthal() const override;
  double getDSpacing() const override;
  double getTOF() const override;

98
99
100
101
102
103
  double getInitialEnergy() const override;
  double getFinalEnergy() const override;
  double getEnergyTransfer() const override;
  void setInitialEnergy(double m_initialEnergy) override;
  void setFinalEnergy(double m_finalEnergy) override;

104
105
106
107
108
109
  virtual Mantid::Kernel::V3D getDetPos() const override;
  virtual Mantid::Kernel::V3D getSamplePos() const override;
  double getL1() const override;
  double getL2() const override;

  /// Assignment
110
  LeanElasticPeak &operator=(const LeanElasticPeak &other);
111
112

private:
113
114
  /// Q_sample vector
  Mantid::Kernel::V3D m_Qsample;
115

116
  /// Wavelength of neutrons at the peak
117
118
  double m_wavelength;

119
120
  std::shared_ptr<Geometry::ReferenceFrame> m_refFrame;

121
122
123
124
125
126
  /// Static logger
  static Mantid::Kernel::Logger g_log;
};

} // namespace DataObjects
} // namespace Mantid