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) {
29 PyErr_Warn(PyExc_DeprecationWarning, "'IDetector.getID' is deprecated in Mantid 7.0, "
30 "use 'DetectorInfo.detectorIDs' instead. "
31 "For more information, see the instrument access layers concept page: "
32 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
33 return self.getID();
34}
35
36double solidAngleDeprecated(const IDetector &self, const V3D &observer) {
37 PyErr_Warn(PyExc_DeprecationWarning, "'IDetector.solidAngle' is deprecated in Mantid 7.0, "
38 "use 'ComponentInfo.solidAngle' instead. "
39 "For more information, see the instrument access layers concept page: "
40 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
41 // Redirect through the preferred ComponentInfo access layer. A detector's
42 // component index equals its detector index.
43 const auto &parameterMap = self.parameterMap();
44 const auto index = parameterMap.detectorInfo().indexOf(self.getID());
45 return parameterMap.componentInfo().solidAngle(index, Mantid::Geometry::SolidAngleParams(observer));
46}
47
48double getTwoThetaDeprecated(const IDetector &self, const V3D &observer, const V3D &axis) {
49 PyErr_Warn(PyExc_DeprecationWarning, "'IDetector.getTwoTheta' is deprecated in Mantid 7.0, "
50 "use 'DetectorInfo.twoTheta' instead. "
51 "For more information, see the instrument access layers concept page: "
52 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
53 return self.getTwoTheta(observer, axis);
54}
55
56double getPhiDeprecated(const IDetector &self) {
57 PyErr_Warn(PyExc_DeprecationWarning, "'IDetector.getPhi' is deprecated in Mantid 7.0, "
58 "use 'DetectorInfo.azimuthal' instead. "
59 "For more information, see the instrument access layers concept page: "
60 "https://docs.mantidproject.org/nightly/concepts/InstrumentAccessLayers.html");
61 return self.getPhi();
62}
63} // namespace
64
66 register_ptr_to_python<std::shared_ptr<IDetector>>();
67 register_ptr_to_python<std::shared_ptr<const IDetector>>();
68
69 class_<IDetector, bases<IObjComponent>, boost::noncopyable>("IDetector", no_init)
70 .def("getID", &getIDDeprecated, arg("self"), "Returns the detector ID (deprecated, use DetectorInfo.detectorIDs)")
71 .def("solidAngle", &solidAngleDeprecated, (arg("self"), arg("observer")),
72 "Return the solid angle in steradians between this "
73 "detector and an observer (deprecated, use ComponentInfo.solidAngle)")
74 .def("getTwoTheta", &getTwoThetaDeprecated, (arg("self"), arg("observer"), arg("axis")),
75 "Calculate the angle between this detector, another component and "
76 "an axis (deprecated, use DetectorInfo.twoTheta)")
77 .def("getPhi", &getPhiDeprecated, arg("self"),
78 "Returns the azimuthal angle of this detector (deprecated, use DetectorInfo.azimuthal)");
79}
#define GET_POINTER_SPECIALIZATION(TYPE)
Definition GetPointer.h:17
void export_IDetector()
Definition IDetector.cpp:65
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:43
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:34
int32_t detid_t
Typedef for a detector ID.