Mantid
Loading...
Searching...
No Matches
DetectorGroup.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 +
10#include <boost/python/class.hpp>
11
14using namespace boost::python;
15
16namespace {
17bool isMaskedDeprecated(const DetectorGroup &self) {
18 if (PyErr_Warn(PyExc_DeprecationWarning, "'DetectorGroup::isMasked' is deprecated, "
19 "use 'SpectrumInfo::isMasked' instead.") < 0)
20 throw boost::python::error_already_set();
21 const auto &dets = self.getDetectors();
22 bool masked = true;
23 for (const auto &det : dets) {
24 const auto &detInfo = det->parameterMap().detectorInfo();
25 masked &= detInfo.isMasked(det->index());
26 }
27 return masked;
28}
29
30bool isMonitorDeprecated(const DetectorGroup &self) {
31 if (PyErr_Warn(PyExc_DeprecationWarning, "'DetectorGroup::isMonitor' is "
32 "deprecated, use "
33 "'SpectrumInfo::isMonitor' instead.") < 0)
34 throw boost::python::error_already_set();
35 const auto &dets = self.getDetectors();
36 return std::all_of(dets.cbegin(), dets.cend(),
37 [](const auto &det) { return det->parameterMap().detectorInfo().isMonitor(det->index()); });
38}
39} // namespace
40
42 class_<DetectorGroup, bases<IDetector>, boost::noncopyable>("DetectorGroup", no_init)
43 .def("isMasked", &isMaskedDeprecated, arg("self"),
44 "Returns the value of the masked flag. True means ignore this "
45 "detector")
46 .def("isMonitor", &isMonitorDeprecated, arg("self"),
47 "Returns True if the detector is marked as a monitor in the IDF")
48 .def("getDetectorIDs", &DetectorGroup::getDetectorIDs, arg("self"),
49 "Returns the list of detector IDs within this group")
50 .def("getNameSeparator", &DetectorGroup::getNameSeparator, arg("self"),
51 "Returns separator for list of names of detectors");
52}
void export_DetectorGroup()
Holds a collection of detectors.
std::string getNameSeparator() const
Return separator for list of names of detectors.
std::vector< detid_t > getDetectorIDs() const
What detectors are contained in the group?
std::vector< IDetector_const_sptr > getDetectors() const
What detectors are contained in the group?
Interface class for detector objects.
Definition IDetector.h:37