10#include "MantidDataHandling/DllConfig.h"
18namespace DataHandling {
96 const std::string
name()
const override {
return "GroupDetectors"; };
98 const std::string
summary()
const override {
99 return "Sums spectra bin-by-bin, equivalent to grouping the data from a "
100 "set of detectors. Individual groups can be specified by passing "
101 "the algorithm a list of spectrum numbers, detector IDs or "
102 "workspace indices. Many spectra groups can be created in one "
103 "execution via an input file.";
108 const std::vector<std::string>
seeAlso()
const override {
return {
"SpatialGrouping"}; }
110 const std::string
category()
const override {
return "Transforms\\Grouping"; }
113 std::map<std::string, std::string> validateInputs()
override;
120 static void getList(
const std::string &line, std::vector<size_t> &outList);
141 double m_FracCompl = 0.0;
147 void init()
override;
148 void exec()
override;
156 std::vector<int64_t> &unUsedSpec);
159 std::vector<int64_t> &unUsedSpec);
166 int readInt(
const std::string &line);
168 void readFile(
const spec2index_map &specs2index, std::istream &File,
size_t &lineNum,
169 std::vector<int64_t> &unUsedSpec,
const bool ignoreGroupNumber);
173 void readSpectraIndexes(
const std::string &line,
const spec2index_map &specs2index, std::vector<size_t> &output,
174 std::vector<int64_t> &unUsedSpec,
const std::string &seperator =
"#");
178 double fileReadProg(DataHandling::GroupDetectors2::storage_map::size_type numGroupsRead,
179 DataHandling::GroupDetectors2::storage_map::size_type numInHists);
184 const double prog4Copy,
const bool keepAll,
const std::set<int64_t> &unGroupedSet,
185 Indexing::IndexInfo &indexInfo);
192 template <
class TIn,
class TOut>
193 void moveOthers(
const std::set<int64_t> &unGroupedSet,
const TIn &inputWS, TOut &outputWS,
size_t outIndex);
197 USED = 1000 - INT_MAX,
202 EMPTY_LINE = 1001 - INT_MAX,
217 static const int INTERVAL = 128;
232template <
class TIn,
class TOut>
235 g_log.
debug() <<
"Starting to copy the ungrouped spectra\n";
236 double prog4Copy = (1. - 1. *
static_cast<double>(
m_FracCompl)) /
static_cast<double>(unGroupedSet.size());
239 for (
auto copyFrIt : unGroupedSet) {
240 if (copyFrIt ==
USED)
242 size_t sourceIndex =
static_cast<size_t>(copyFrIt);
244 outputWS.getSpectrum(outIndex) = inputWS.getSpectrum(sourceIndex);
259 g_log.
debug() <<
name() <<
" copied " << unGroupedSet.size() - 1 <<
" ungrouped spectra\n";
IPeaksWorkspace_sptr workspace
Base class from which all concrete algorithm classes should be derived.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
void interruption_point()
This is called during long-running operations, and check if the algorithm has requested that it be ca...
provides a function that expands pairs of integers separated with a hyphen into a list of all the int...
RangeHelper()=default
this class can't be constructed it is just a holder for some static things
An algorithm for grouping detectors and their associated spectra into single spectra and DetectorGrou...
double m_FracCompl
An estimate of the percentage of the algorithm runtimes that has been completed.
static const double OPENINGFILE
required to check that the X bin boundaries are the same as a percentage of total algorithm run time
const std::string summary() const override
Summary of algorithms purpose.
storage_map m_GroupWsInds
stores lists of spectra indexes to group, although we never do an index search on it
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
int version() const override
Algorithm's version for identification overriding a virtual method.
void moveOthers(const std::set< int64_t > &unGroupedSet, const TIn &inputWS, TOut &outputWS, size_t outIndex)
Copy the ungrouped spectra from the input workspace to the output.
static const double CHECKBINS
a (worse case) estimate of the time
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
static const double READFILE
if a file must be read in estimate that
static const int INTERVAL
reading it will take this percentage of the algorithm execution time
@ USED
goes in the unGrouped spectra list to say that a
std::map< specnum_t, std::vector< size_t > > storage_map
used to store the lists of WORKSPACE INDICES that will be grouped, the keys are not used
void debug(const std::string &msg)
Logs at debug level.
@ TOK_IGNORE_EMPTY
ignore empty tokens
@ TOK_TRIM
remove leading and trailing whitespace from tokens
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const GroupingWorkspace > GroupingWorkspace_const_sptr
shared pointer to a const GroupingWorkspace
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
Helper class which provides the Collimation Length for SANS instruments.
std::unordered_map< specnum_t, size_t > spec2index_map
Map with key = spectrum number, value = workspace index.