Mantid
Loading...
Searching...
No Matches
IDetector.cpp
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 +
12#include "MantidKernel/V3D.h"
14#include <boost/python/class.hpp>
15#include <boost/python/register_ptr_to_python.hpp>
16
20using namespace boost::python;
21
23
24namespace {
25// Deprecation wrappers. Legacy detector access is being retired in favour of the
26// index-based DetectorInfo/ComponentInfo access layers. See the 'Instrument
27// Access via SpectrumInfo, DetectorInfo, ComponentInfo' concept page.
28Mantid::detid_t getIDDeprecated(const IDetector &self) {
37 return self.getID();
38}
39
40double solidAngleDeprecated(const IDetector &self, const V3D &observer) {
41 if (PyErr_Warn(PyExc_DeprecationWarning,
42 "'IDetector.solidAngle' is deprecated in Mantid 7.0, "
43 "use 'ComponentInfo.solidAngle' instead. "
44 "For more information, see the instrument access layers concept page: "
45 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html") < 0)
46 throw boost::python::error_already_set();
47 // Redirect through the preferred ComponentInfo access layer. A detector's
48 // component index equals its detector index.
49 const auto &parameterMap = self.parameterMap();
50 const auto index = parameterMap.detectorInfo().indexOf(self.getID());
51 return parameterMap.componentInfo().solidAngle(index, Mantid::Geometry::SolidAngleParams(observer));
52}
53
54double getTwoThetaDeprecated(const IDetector &self, const V3D &observer, const V3D &axis) {
55 if (PyErr_Warn(PyExc_DeprecationWarning,
56 "'IDetector.getTwoTheta' is deprecated in Mantid 7.0, "
57 "use 'DetectorInfo.twoTheta' instead. "
58 "For more information, see the instrument access layers concept page: "
59 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html") < 0)
60 throw boost::python::error_already_set();
61 return self.getTwoTheta(observer, axis);
62}
63
64double getPhiDeprecated(const IDetector &self) {
65 if (PyErr_Warn(PyExc_DeprecationWarning,
66 "'IDetector.getPhi' is deprecated in Mantid 7.0, "
67 "use 'DetectorInfo.azimuthal' instead. "
68 "For more information, see the instrument access layers concept page: "
69 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html") < 0)
70 throw boost::python::error_already_set();
71 return self.getPhi();
72}
73} // namespace
74
76 register_ptr_to_python<std::shared_ptr<IDetector>>();
77 register_ptr_to_python<std::shared_ptr<const IDetector>>();
78
79 class_<IDetector, bases<IObjComponent>, boost::noncopyable>("IDetector", no_init)
80 .def("getID", &getIDDeprecated, arg("self"), "Returns the detector ID (deprecated, use DetectorInfo.detectorIDs)")
81 .def("solidAngle", &solidAngleDeprecated, (arg("self"), arg("observer")),
82 "Return the solid angle in steradians between this "
83 "detector and an observer (deprecated, use ComponentInfo.solidAngle)")
84 .def("getTwoTheta", &getTwoThetaDeprecated, (arg("self"), arg("observer"), arg("axis")),
85 "Calculate the angle between this detector, another component and "
86 "an axis (deprecated, use DetectorInfo.twoTheta)")
87 .def("getPhi", &getPhiDeprecated, arg("self"),
88 "Returns the azimuthal angle of this detector (deprecated, use DetectorInfo.azimuthal)");
89}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
void export_IDetector()
Definition IDetector.cpp:75
std::map< DeltaEMode::Type, std::string > index
size_t indexOf(const detid_t id) const
Returns the index of the detector with the given detector ID.
Interface class for detector objects.
Definition IDetector.h:37
virtual double getPhi() const =0
Gives the phi of this detector object in radians.
virtual double getTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis) const =0
Gives the angle of this detector object with respect to an axis.
virtual detid_t getID() const =0
Get the detector ID.
virtual const ParameterMap & parameterMap() const =0
Helper for legacy access mode. Returns a reference to the ParameterMap.
Object Component class, this class brings together the physical attributes of the component to the po...
const Geometry::DetectorInfo & detectorInfo() const
Only for use by ExperimentInfo. Returns a reference to the DetectorInfo.
Class for 3D vectors.
Definition V3D.h:35
int32_t detid_t
Typedef for a detector ID.