Mantid
Loading...
Searching...
No Matches
Peak.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
13#include "MantidKernel/Logger.h"
14#include "MantidKernel/Matrix.h"
16#include "MantidKernel/V3D.h"
17#include <memory>
18#include <optional>
19
20namespace Mantid {
21
22namespace Geometry {
23class InstrumentRayTracer;
24}
25
26namespace DataObjects {
27
34class MANTID_DATAOBJECTS_DLL Peak : public BasePeak {
35public:
36 // TODO: constructors currently require a legacy instrument pointer
37 // Future work for Instrument 2.0 most change this to work with ComponentInfo and DetectorInfo instead
38 Peak();
39 Peak(const Geometry::Instrument_const_sptr &m_inst, const Mantid::Kernel::V3D &QLabFrame,
40 std::optional<double> detectorDistance = std::nullopt);
41 Peak(const Geometry::Instrument_const_sptr &m_inst, const Mantid::Kernel::V3D &QSampleFrame,
42 const Mantid::Kernel::Matrix<double> &goniometer, std::optional<double> detectorDistance = std::nullopt);
43 Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, double m_Wavelength);
44 Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, double m_Wavelength,
46 Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, double m_Wavelength,
48 Peak(const Geometry::Instrument_const_sptr &m_inst, double scattering, double m_Wavelength);
49
51 Peak(const Peak &other);
52
53 // MSVC 2015/17 can build with noexcept = default however
54 // intellisense still incorrectly reports this as an error despite compiling.
55 // https://connect.microsoft.com/VisualStudio/feedback/details/1795240/visual-c-2015-default-move-constructor-and-noexcept-keyword-bug
56 // For that reason we still use the supplied default which should be noexcept
57 // once the above is fixed we can remove this workaround
58
59#if defined(_MSC_VER) && _MSC_VER <= 1910
60 Peak(Peak &&) = default;
61 Peak &operator=(Peak &&) = default;
62#else
63 Peak(Peak &&) noexcept = default;
64 Peak &operator=(Peak &&) noexcept = default;
65#endif
66
67 // Construct a peak from a reference to the interface
68
69 explicit Peak(const Geometry::IPeak &ipeak);
70
71 // Construct a peak from LeanPeak
73 std::optional<double> detectorDistance = std::nullopt);
74
75 void setDetectorID(int id);
76 int getDetectorID() const override;
77 void addContributingDetID(const int id);
78 void removeContributingDetector(const int id);
79 const std::set<int> &getContributingDetIDs() const;
80
81 void setInstrument(const Geometry::Instrument_const_sptr &inst);
82 Geometry::IDetector_const_sptr getDetector() const;
83 Geometry::Instrument_const_sptr getInstrument() const;
84 std::shared_ptr<const Geometry::ReferenceFrame> getReferenceFrame() const override;
85
86 int getCol() const override;
87 void setCol(int col);
88
89 int getRow() const override;
90 void setRow(int row);
91
92 const std::string &getBankName() const;
93 void setBankName(std::string bankName);
94
95 bool findDetector();
96 bool findDetector(const Geometry::InstrumentRayTracer &tracer);
97
98 Mantid::Kernel::V3D getQLabFrame() const override;
99 Mantid::Kernel::V3D getQSampleFrame() const override;
100 Mantid::Kernel::V3D getDetectorPosition() const;
101 Mantid::Kernel::V3D getDetectorPositionNoCheck() const;
102
103 void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
104 std::optional<double> detectorDistance = std::nullopt) override;
105 void setQLabFrame(const Mantid::Kernel::V3D &qLab, std::optional<double> detectorDistance = std::nullopt) final;
106
107 void setWavelength(double wavelength) override;
108 double getWavelength() const override;
109 double getScattering() const override;
110 double getAzimuthal() const override;
111 double getDSpacing() const override;
112 double getTOF() const override;
113 const Mantid::Kernel::V3D &getCachedDetectorPosition() const { return detPos; }
114
115 double getInitialEnergy() const override;
116 double getFinalEnergy() const override;
117 double getEnergyTransfer() const override;
118 void setInitialEnergy(double m_initialEnergy) override;
119 void setFinalEnergy(double m_finalEnergy) override;
120
121 virtual Mantid::Kernel::V3D getDetPos() const;
122 double getL1() const override;
123 double getL2() const override;
124
125 Mantid::Kernel::V3D getDetectorDirectionSampleFrame() const override;
126 Mantid::Kernel::V3D getSourceDirectionSampleFrame() const override;
127
129 Peak &operator=(const Peak &other);
130
132 Kernel::V3D getVirtualDetectorPosition(const Kernel::V3D &detectorDir) const;
133
134 double getValueByColName(std::string colName) const override;
135
136private:
137 bool findDetector(const Mantid::Kernel::V3D &beam, const Geometry::InstrumentRayTracer &tracer);
138
141
144
146 std::string m_bankName;
147
149 int m_row;
150
152 int m_col;
153
156
159
162
165
168
170 std::set<int> m_detIDs;
171
174};
175
176using Peak_uptr = std::unique_ptr<Peak>;
177
178} // namespace DataObjects
179} // namespace Mantid
Structure describing a single-crystal peak.
Definition BasePeak.h:33
Structure describing a single-crystal peak.
Structure describing a single-crystal peak.
Definition Peak.h:34
Geometry::IDetector_const_sptr m_det
Detector pointed to.
Definition Peak.h:143
int m_row
Cached row in the detector.
Definition Peak.h:149
Peak(Peak &&) noexcept=default
static Mantid::Kernel::Logger g_log
Static logger.
Definition Peak.h:173
std::set< int > m_detIDs
List of contributing detectors IDs.
Definition Peak.h:170
std::string m_bankName
Name of the parent bank.
Definition Peak.h:146
Mantid::Kernel::V3D detPos
Cached detector position.
Definition Peak.h:167
double m_initialEnergy
Initial energy of neutrons at the peak.
Definition Peak.h:158
Geometry::Instrument_const_sptr m_inst
Shared pointer to the instrument (for calculating some values )
Definition Peak.h:140
Mantid::Kernel::V3D sourcePos
Cached source position.
Definition Peak.h:164
int m_col
Cached column in the detector.
Definition Peak.h:152
const Mantid::Kernel::V3D & getCachedDetectorPosition() const
Definition Peak.h:113
Peak(const Peak &other)
Copy constructor.
double m_finalEnergy
Final energy of the neutrons at peak (normally same as m_InitialEnergy)
Definition Peak.h:161
int m_detectorID
ID of the detector.
Definition Peak.h:155
HKL : HKL MDFrame.
Definition HKL.h:20
Structure describing a single-crystal peak.
Definition IPeak.h:26
This class is responsible for tracking rays and accumulating a list of objects that are intersected a...
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
Numerical Matrix class.
Definition Matrix.h:42
Class for 3D vectors.
Definition V3D.h:34
std::unique_ptr< Peak > Peak_uptr
Definition Peak.h:176
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
Definition IDetector.h:102
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
Helper class which provides the Collimation Length for SANS instruments.