Mantid
Loading...
Searching...
No Matches
DetectorInfo.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2016 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
9#include <memory>
10#include <mutex>
11#include <unordered_map>
12#include <vector>
13
14#include "MantidGeometry/DllConfig.h"
16#include "MantidKernel/Quat.h"
17#include "MantidKernel/V3D.h"
18#include "MantidTypes/Core/DateAndTime.h"
19
20namespace Mantid {
21using detid_t = int32_t;
22namespace Beamline {
23class DetectorInfo;
24}
25namespace API {
26class SpectrumInfo;
27}
28namespace Geometry {
29class IDetector;
30class Instrument;
31class ReferenceFrame;
32class ParameterInfo;
33
51class MANTID_GEOMETRY_DLL DetectorInfo {
52public:
53 DetectorInfo(std::unique_ptr<Beamline::DetectorInfo> detectorInfo,
54 std::shared_ptr<const Geometry::Instrument> instrument,
55 std::shared_ptr<const std::vector<detid_t>> detectorIds,
56 std::shared_ptr<const std::unordered_map<detid_t, size_t>> detIdToIndexMap,
57 std::shared_ptr<ParameterInfo> parameterInfo, std::shared_ptr<ReferenceFrame const> referenceFrame);
58 DetectorInfo(const DetectorInfo &other);
59 DetectorInfo &operator=(const DetectorInfo &rhs);
61
62 bool isEquivalent(const DetectorInfo &other) const;
63
64 size_t size() const;
65 size_t scanSize() const;
66 size_t getMemorySize() const;
67 bool isScanning() const;
68
69 bool isMonitor(const size_t index) const;
70 bool isMonitor(const std::pair<size_t, size_t> &index) const;
71 bool isMasked(const size_t index) const;
72 bool isMasked(const std::pair<size_t, size_t> &index) const;
73 bool hasMaskedDetectors() const;
74 double l2(const size_t index) const;
75 double l2(const std::pair<size_t, size_t> &index) const;
76 double twoTheta(const size_t index) const;
77 double twoTheta(const std::pair<size_t, size_t> &index) const;
78 double signedTwoTheta(const size_t index) const;
79 double signedTwoTheta(const std::pair<size_t, size_t> &index) const;
80 double azimuthal(const size_t index) const;
81 double azimuthal(const std::pair<size_t, size_t> &index) const;
82 double twoTheta(const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis) const;
83 double twoTheta(const std::pair<size_t, size_t> &index, const Kernel::V3D &observer, const Kernel::V3D &axis) const;
84 double signedTwoTheta(const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis,
85 const Kernel::V3D &instrumentUp) const;
86 double signedTwoTheta(const size_t index, const Kernel::V3D &observer, const Kernel::V3D &axis) const;
87 double signedTwoTheta(const std::pair<size_t, size_t> &index, const Kernel::V3D &observer,
88 const Kernel::V3D &axis) const;
89 double signedTwoTheta(const std::pair<size_t, size_t> &index, const Kernel::V3D &observer, const Kernel::V3D &axis,
90 const Kernel::V3D &instrumentUp) const;
91 double phi(const size_t index) const;
92 double phi(const std::pair<size_t, size_t> &index) const;
93 double phiOffset(const size_t index, const double offset) const;
94 double phiOffset(const std::pair<size_t, size_t> &index, const double offset) const;
95 std::tuple<double, double, double> diffractometerConstants(const size_t index, std::vector<detid_t> &calibratedDets,
96 std::vector<detid_t> &uncalibratedDets) const;
97 double difcUncalibrated(const size_t index) const;
98 std::pair<double, double> geographicalAngles(const size_t index) const;
99 std::pair<double, double> geographicalAngles(const std::pair<size_t, size_t> &index) const;
100 Kernel::V3D position(const size_t index) const;
101 Kernel::V3D position(const std::pair<size_t, size_t> &index) const;
102 std::vector<Kernel::V3D> allPositions() const;
103 Kernel::Quat rotation(const size_t index) const;
104 Kernel::Quat rotation(const std::pair<size_t, size_t> &index) const;
105 std::vector<Kernel::Quat> allRotations() const;
106 std::vector<Kernel::V3D> allScaleFactors() const;
107
108 void setMasked(const size_t index, bool masked);
109 void setMasked(const std::pair<size_t, size_t> &index, bool masked);
110 void clearMaskFlags();
111
112 void setPosition(const size_t index, const Kernel::V3D &position);
113 void setPosition(const std::pair<size_t, size_t> &index, const Kernel::V3D &position);
114 void setRotation(const size_t index, const Kernel::Quat &rotation);
115 void setRotation(const std::pair<size_t, size_t> &index, const Kernel::Quat &rotation);
116 [[deprecated("DetectorInfo::detector has been deprecated in Mantid 7.1."
117 "See the 'Instrument Access via SpectrumInfo, DetectorInfo, ComponentInfo' concept page, "
118 "located at: https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html")]]
119 const Geometry::IDetector &detector(const size_t index) const;
120
121 // This does not really belong into DetectorInfo, but it seems to be useful
122 // while Instrument-2.0 does not exist.
123 Kernel::V3D sourcePosition() const;
124 Kernel::V3D samplePosition() const;
125 double l1() const;
126
127 const std::vector<detid_t> &detectorIDs() const;
130 size_t indexOf(const detid_t id) const;
131 detid_t detid(const size_t index) const;
132
133 size_t scanCount() const;
134 const std::vector<std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>> scanIntervals() const;
135
136 friend class API::SpectrumInfo;
137 friend class Instrument;
138
141 const DetectorInfoIterator<const DetectorInfo> cbegin() const;
143
144private:
145 [[deprecated("DetectorInfo::getDetector has been deprecated in Mantid 7.1."
146 "See the 'Instrument Access via SpectrumInfo, DetectorInfo, ComponentInfo' concept page, "
147 "located at: https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html")]]
148 const Geometry::IDetector &getDetector(const size_t index) const;
149 [[deprecated("DetectorInfo::getDetectorPtr has been deprecated in Mantid 7.1."
150 "See the 'Instrument Access via SpectrumInfo, DetectorInfo, ComponentInfo' concept page, "
151 "located at: https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html")]]
152 std::shared_ptr<const Geometry::IDetector> getDetectorPtr(const size_t index) const;
153 void clearPositionDependentParameters(const size_t index);
154
156 std::unique_ptr<Beamline::DetectorInfo> m_detectorInfo;
157
158 std::shared_ptr<Geometry::Instrument const> m_instrument;
159 std::shared_ptr<std::vector<detid_t> const> m_detectorIDs;
160 std::shared_ptr<std::unordered_map<detid_t, size_t> const> m_detIDToIndex;
161 std::shared_ptr<Geometry::ParameterInfo> m_parameterInfo;
162 std::shared_ptr<Geometry::ReferenceFrame const> m_referenceFrame;
163
164 mutable std::vector<std::shared_ptr<const Geometry::IDetector>> m_lastDetector;
165 mutable std::vector<size_t> m_lastIndex;
166};
167
170
171} // namespace Geometry
172} // namespace Mantid
const std::vector< double > & rhs
double position
Definition GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
PyObject * geographicalAngles(const SpectrumInfo &spectrumInfo, const size_t index)
Mantid::Kernel::Quat(ComponentInfo::* rotation)(const size_t) const
void(ComponentInfo::* setPosition)(const size_t, const Mantid::Kernel::V3D &)
void(ComponentInfo::* setRotation)(const size_t, const Mantid::Kernel::Quat &)
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
DetectorInfoIterator for random access iteration over DetectorInfo.
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
std::shared_ptr< std::vector< detid_t > const > m_detectorIDs
std::shared_ptr< Geometry::ReferenceFrame const > m_referenceFrame
std::shared_ptr< std::unordered_map< detid_t, size_t > const > m_detIDToIndex
std::shared_ptr< Geometry::Instrument const > m_instrument
std::shared_ptr< Geometry::ParameterInfo > m_parameterInfo
std::vector< std::shared_ptr< const Geometry::IDetector > > m_lastDetector
std::vector< size_t > m_lastIndex
std::unique_ptr< Beamline::DetectorInfo > m_detectorInfo
Pointer to the actual DetectorInfo object (non-wrapping part).
Interface class for detector objects.
Definition IDetector.h:37
Base Instrument Class.
Definition Instrument.h:50
Class for quaternions.
Definition Quat.h:38
Class for 3D vectors.
Definition V3D.h:35
DetectorInfoIterator< DetectorInfo > DetectorInfoIt
DetectorInfoIterator< const DetectorInfo > DetectorInfoConstIt
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.