11#include "MantidDataObjects/DllConfig.h"
21const int UNSET_GROUP{-1};
62 for (
auto detID : detIDs) {
63 detIDToGroup[detID] =
group;
85 for (
auto detID : detIDs) {
89 if (detIDToGroup.size() <
static_cast<size_t>(detID + 1))
90 detIDToGroup.resize(detID + 1);
91 detIDToGroup[detID] =
group;
100 std::set<int> groupIDs;
104 if (!includeUnsetGroup &&
group == UNSET_GROUP)
106 groupIDs.insert(
group);
108 std::vector<int> output(groupIDs.begin(), groupIDs.end());
115 return static_cast<int>(groups.size());
119 std::vector<detid_t> detectorIDs;
123 if (
group == groupID) {
126 std::transform(detIDs.cbegin(), detIDs.cend(), std::back_inserter(detectorIDs),
127 [](
const auto &detID) { return static_cast<int>(detID); });
141IPropertyManager::getValue<Mantid::DataObjects::GroupingWorkspace_sptr>(
const std::string &
name)
const {
147 std::string message =
148 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<GroupingWorkspace>.";
149 throw std::runtime_error(message);
155IPropertyManager::getValue<Mantid::DataObjects::GroupingWorkspace_const_sptr>(
const std::string &
name)
const {
159 return prop->operator()();
161 std::string message =
162 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<GroupingWorkspace>.";
163 throw std::runtime_error(message);
#define DECLARE_WORKSPACE(classname)
A GroupingWorkspace is a subclass of Workspace2D where each spectrum has a single number entry,...
void makeDetectorIDToGroupVector(std::vector< int > &detIDToGroup, int64_t &ngroups) const
Fill a map where the index is detector ID and the value is the group number by using the values in Y.
int getTotalGroups() const
void makeDetectorIDToGroupMap(std::map< detid_t, int > &detIDToGroup, int64_t &ngroups) const
Fill a map with key = detector ID, value = group number by using the values in Y.
int translateToGroupID(const int n) const
std::vector< detid_t > getDetectorIDsOfGroup(const int groupID) const
GroupingWorkspace()=default
std::vector< int > getGroupIDs(const bool includeUnsetGroup=true) const
std::set< detid_t > getDetectorIDs(const std::size_t workspaceIndex) const
Return the detector ID at the given workspace index (i.e., spectrum/histogram index)
std::size_t getNumberHistograms() const override
Returns the histogram number.
The concrete, templated class for properties.
std::shared_ptr< const GroupingWorkspace > GroupingWorkspace_const_sptr
shared pointer to a const GroupingWorkspace
std::shared_ptr< GroupingWorkspace > GroupingWorkspace_sptr
shared pointer to the GroupingWorkspace class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.