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"
17#include "MantidKernel/Quat.h"
18#include "MantidKernel/V3D.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;
31
49class MANTID_GEOMETRY_DLL DetectorInfo {
50public:
51 DetectorInfo(std::unique_ptr<Beamline::DetectorInfo> detectorInfo,
52 std::shared_ptr<const Geometry::Instrument> instrument,
53 std::shared_ptr<const std::vector<detid_t>> detectorIds,
54 std::shared_ptr<const std::unordered_map<detid_t, size_t>> detIdToIndexMap);
55 DetectorInfo(const DetectorInfo &other);
56 DetectorInfo &operator=(const DetectorInfo &rhs);
58
59 bool isEquivalent(const DetectorInfo &other) const;
60
61 size_t size() const;
62 size_t scanSize() const;
63 bool isScanning() const;
64
65 bool isMonitor(const size_t index) const;
66 bool isMonitor(const std::pair<size_t, size_t> &index) const;
67 bool isMasked(const size_t index) const;
68 bool isMasked(const std::pair<size_t, size_t> &index) const;
69 bool hasMaskedDetectors() const;
70 double l2(const size_t index) const;
71 double l2(const std::pair<size_t, size_t> &index) const;
72 double twoTheta(const size_t index) const;
73 double twoTheta(const std::pair<size_t, size_t> &index) const;
74 double signedTwoTheta(const size_t index) const;
75 double signedTwoTheta(const std::pair<size_t, size_t> &index) const;
76 double azimuthal(const size_t index) const;
77 double azimuthal(const std::pair<size_t, size_t> &index) const;
78 std::tuple<double, double, double> diffractometerConstants(const size_t index, std::vector<detid_t> &calibratedDets,
79 std::vector<detid_t> &uncalibratedDets) const;
80 double difcUncalibrated(const size_t index) const;
81 std::pair<double, double> geographicalAngles(const size_t index) const;
82 std::pair<double, double> geographicalAngles(const std::pair<size_t, size_t> &index) const;
83 Kernel::V3D position(const size_t index) const;
84 Kernel::V3D position(const std::pair<size_t, size_t> &index) const;
85 Kernel::Quat rotation(const size_t index) const;
86 Kernel::Quat rotation(const std::pair<size_t, size_t> &index) const;
87
88 void setMasked(const size_t index, bool masked);
89 void setMasked(const std::pair<size_t, size_t> &index, bool masked);
90 void clearMaskFlags();
91
92 void setPosition(const size_t index, const Kernel::V3D &position);
93 void setPosition(const std::pair<size_t, size_t> &index, const Kernel::V3D &position);
94 void setRotation(const size_t index, const Kernel::Quat &rotation);
95 void setRotation(const std::pair<size_t, size_t> &index, const Kernel::Quat &rotation);
96
97 const Geometry::IDetector &detector(const size_t index) const;
98
99 // This does not really belong into DetectorInfo, but it seems to be useful
100 // while Instrument-2.0 does not exist.
101 Kernel::V3D sourcePosition() const;
102 Kernel::V3D samplePosition() const;
103 double l1() const;
104
105 const std::vector<detid_t> &detectorIDs() const;
108 size_t indexOf(const detid_t id) const;
109
110 size_t scanCount() const;
111 const std::vector<std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>> scanIntervals() const;
112
113 friend class API::SpectrumInfo;
114 friend class Instrument;
115
118 const DetectorInfoIterator<const DetectorInfo> cbegin() const;
120
121private:
122 const Geometry::IDetector &getDetector(const size_t index) const;
123 std::shared_ptr<const Geometry::IDetector> getDetectorPtr(const size_t index) const;
124 void clearPositionDependentParameters(const size_t index);
125
127 std::unique_ptr<Beamline::DetectorInfo> m_detectorInfo;
128
129 std::shared_ptr<const Geometry::Instrument> m_instrument;
130 std::shared_ptr<const std::vector<detid_t>> m_detectorIDs;
131 std::shared_ptr<const std::unordered_map<detid_t, size_t>> m_detIDToIndex;
132
133 mutable std::vector<std::shared_ptr<const Geometry::IDetector>> m_lastDetector;
134 mutable std::vector<size_t> m_lastIndex;
135};
136
139
140} // namespace Geometry
141} // namespace Mantid
const std::vector< double > & rhs
double position
Definition: GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
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....
Definition: SpectrumInfo.h:53
DetectorInfoIterator for random access iteration over DetectorInfo.
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
Definition: DetectorInfo.h:49
std::shared_ptr< const Geometry::Instrument > m_instrument
Definition: DetectorInfo.h:129
std::shared_ptr< const std::unordered_map< detid_t, size_t > > m_detIDToIndex
Definition: DetectorInfo.h:131
std::vector< std::shared_ptr< const Geometry::IDetector > > m_lastDetector
Definition: DetectorInfo.h:133
std::vector< size_t > m_lastIndex
Definition: DetectorInfo.h:134
std::unique_ptr< Beamline::DetectorInfo > m_detectorInfo
Pointer to the actual DetectorInfo object (non-wrapping part).
Definition: DetectorInfo.h:127
std::shared_ptr< const std::vector< detid_t > > m_detectorIDs
Definition: DetectorInfo.h:130
Interface class for detector objects.
Definition: IDetector.h:43
Base Instrument Class.
Definition: Instrument.h:47
Class for quaternions.
Definition: Quat.h:39
Class for 3D vectors.
Definition: V3D.h:34
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
Definition: SpectrumInfo.h:21