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 <boost/optional.hpp>
18#include <memory>
19
20namespace Mantid {
21
22namespace Geometry {
23class InstrumentRayTracer;
24}
25
26namespace DataObjects {
27
34class MANTID_DATAOBJECTS_DLL Peak : public BasePeak {
35public:
36 Peak();
37 Peak(const Geometry::Instrument_const_sptr &m_inst, const Mantid::Kernel::V3D &QLabFrame,
38 boost::optional<double> detectorDistance = boost::none);
39 Peak(const Geometry::Instrument_const_sptr &m_inst, const Mantid::Kernel::V3D &QSampleFrame,
40 const Mantid::Kernel::Matrix<double> &goniometer, boost::optional<double> detectorDistance = boost::none);
41 Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, double m_Wavelength);
42 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, double scattering, double m_Wavelength);
47
49 Peak(const Peak &other);
50
51 // MSVC 2015/17 can build with noexcept = default however
52 // intellisense still incorrectly reports this as an error despite compiling.
53 // https://connect.microsoft.com/VisualStudio/feedback/details/1795240/visual-c-2015-default-move-constructor-and-noexcept-keyword-bug
54 // For that reason we still use the supplied default which should be noexcept
55 // once the above is fixed we can remove this workaround
56
57#if defined(_MSC_VER) && _MSC_VER <= 1910
58 Peak(Peak &&) = default;
59 Peak &operator=(Peak &&) = default;
60#else
61 Peak(Peak &&) noexcept = default;
62 Peak &operator=(Peak &&) noexcept = default;
63#endif
64
65 // Construct a peak from a reference to the interface
66
67 explicit Peak(const Geometry::IPeak &ipeak);
68
69 // Construct a peak from LeanPeak
71 boost::optional<double> detectorDistance = boost::none);
72
73 void setDetectorID(int id);
74 int getDetectorID() const;
75 void addContributingDetID(const int id);
76 void removeContributingDetector(const int id);
77 const std::set<int> &getContributingDetIDs() const;
78
79 void setInstrument(const Geometry::Instrument_const_sptr &inst);
80 Geometry::IDetector_const_sptr getDetector() const;
81 Geometry::Instrument_const_sptr getInstrument() const;
82 std::shared_ptr<const Geometry::ReferenceFrame> getReferenceFrame() const override;
83
84 int getCol() const override;
85 void setCol(int col);
86
87 int getRow() const override;
88 void setRow(int row);
89
90 std::string getBankName() const;
91 void setBankName(std::string bankName);
92
93 bool findDetector();
94 bool findDetector(const Geometry::InstrumentRayTracer &tracer);
95
96 Mantid::Kernel::V3D getQLabFrame() const override;
97 Mantid::Kernel::V3D getQSampleFrame() const override;
98 Mantid::Kernel::V3D getDetectorPosition() const;
99 Mantid::Kernel::V3D getDetectorPositionNoCheck() const;
100
101 void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame,
102 boost::optional<double> detectorDistance = boost::none) override;
103 void setQLabFrame(const Mantid::Kernel::V3D &qLab, boost::optional<double> detectorDistance = boost::none) override;
104
105 void setWavelength(double wavelength) override;
106 double getWavelength() const override;
107 double getScattering() const override;
108 double getAzimuthal() const override;
109 double getDSpacing() const override;
110 double getTOF() const override;
111
112 double getInitialEnergy() const override;
113 double getFinalEnergy() const override;
114 double getEnergyTransfer() const override;
115 void setInitialEnergy(double m_initialEnergy) override;
116 void setFinalEnergy(double m_finalEnergy) override;
117
118 virtual Mantid::Kernel::V3D getDetPos() const;
119 double getL1() const override;
120 double getL2() const override;
121
123 Peak &operator=(const Peak &other);
124
126 Kernel::V3D getVirtualDetectorPosition(const Kernel::V3D &detectorDir) const;
127
128 double getValueByColName(std::string colName) const override;
129
130private:
131 bool findDetector(const Mantid::Kernel::V3D &beam, const Geometry::InstrumentRayTracer &tracer);
132
135
138
140 std::string m_bankName;
141
143 int m_row;
144
146 int m_col;
147
150
153
156
159
162
164 std::set<int> m_detIDs;
165
168};
169
170using Peak_uptr = std::unique_ptr<Peak>;
171
172} // namespace DataObjects
173} // 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:137
int m_row
Cached row in the detector.
Definition: Peak.h:143
Peak(Peak &&) noexcept=default
static Mantid::Kernel::Logger g_log
Static logger.
Definition: Peak.h:167
std::set< int > m_detIDs
List of contributing detectors IDs.
Definition: Peak.h:164
std::string m_bankName
Name of the parent bank.
Definition: Peak.h:140
Mantid::Kernel::V3D detPos
Cached detector position.
Definition: Peak.h:161
double m_initialEnergy
Initial energy of neutrons at the peak.
Definition: Peak.h:152
Geometry::Instrument_const_sptr m_inst
Shared pointer to the instrument (for calculating some values )
Definition: Peak.h:134
Mantid::Kernel::V3D sourcePos
Cached source position.
Definition: Peak.h:158
int m_col
Cached column in the detector.
Definition: Peak.h:146
Peak(const Peak &other)
Copy constructor.
double m_finalEnergy
Final energy of the neutrons at peak (normally same as m_InitialEnergy)
Definition: Peak.h:155
int m_detectorID
ID of the detector.
Definition: Peak.h:149
HKL : HKL MDFrame.
Definition: HKL.h:21
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:52
Numerical Matrix class.
Definition: Matrix.h:42
Class for 3D vectors.
Definition: V3D.h:34
std::unique_ptr< Peak > Peak_uptr
Definition: Peak.h:170
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.