23#include "MantidIndexing/GlobalSpectrumIndex.h"
24#include "MantidIndexing/IndexInfo.h"
31#include "MantidParallel/Collectives.h"
32#include "MantidParallel/Communicator.h"
33#include "MantidTypes/SpectrumDefinition.h"
35#include <boost/algorithm/string/join.hpp>
36#include <boost/algorithm/string/regex.hpp>
44using Mantid::Types::Core::DateAndTime;
48auto accumulate_if_finite = [](
const double accumulator,
const double newValue) {
49 if (std::isfinite(newValue)) {
50 return accumulator + newValue;
59using namespace Geometry;
64Kernel::Logger
g_log(
"MatrixWorkspace");
65constexpr const double EPSILON{1.0e-9};
75std::string appendUnitDenominatorUsingPer(std::string yLabel,
const MatrixWorkspace &
workspace,
bool useLatex) {
77 std::string xLabel =
workspace.getAxis(0)->unit()->label().latex();
79 yLabel +=
" per $" +
workspace.getAxis(0)->unit()->label().latex() +
"$";
81 std::string xLabel =
workspace.getAxis(0)->unit()->label().ascii();
83 yLabel +=
" per " +
workspace.getAxis(0)->unit()->label().ascii();
94std::string replacePerWithLatex(std::string yLabel) {
95 std::vector<std::string> splitVec;
96 boost::split_regex(splitVec, yLabel, boost::regex(
" per "));
97 if (splitVec.size() > 1) {
99 splitVec.erase(splitVec.begin());
100 std::string unitString = boost::algorithm::join(splitVec,
" ");
103 yLabel +=
"(" + unitString +
")$^{-1}$";
119 m_isInitialized(other.m_isInitialized), m_YUnit(other.m_YUnit), m_YUnitLabel(other.m_YUnitLabel),
120 m_isCommonBinsFlag(other.m_isCommonBinsFlag), m_masks(other.m_masks), m_indexInfoNeedsUpdate(false) {
121 m_axes.resize(other.m_axes.size());
122 for (
size_t i = 0; i <
m_axes.size(); ++i)
123 m_axes[i] = std::unique_ptr<Axis>(other.m_axes[i]->clone(
this));
149 std::vector<Indexing::SpectrumNumber> spectrumNumbers;
152 m_indexInfo->setSpectrumNumbers(std::move(spectrumNumbers));
163 throw std::invalid_argument(
"MatrixWorkspace::setIndexInfo: "
164 "Parallel::StorageMode in IndexInfo does not "
165 "match storage mode in workspace");
169 throw std::invalid_argument(
"MatrixWorkspace::setIndexInfo: IndexInfo size "
170 "does not match number of histograms in "
206 throw std::invalid_argument(
"MatrixWorkspace::setIndexInfo: IndexInfo size "
207 "does not match number of histograms in "
216 std::ostringstream os;
224 }
catch (std::length_error &) {
231 os <<
"Data points\n";
236 if (ax && ax->
unit())
237 os << ax->
unit()->caption() <<
" / " << ax->
unit()->label().ascii();
246 os <<
"Distribution: " << (
isDistribution() ?
"True" :
"False") <<
"\n";
264 if (NVectors == 0 || XLength == 0 || YLength == 0) {
265 throw std::out_of_range(
"All arguments to init must be positive and non-zero");
273 m_indexInfo = std::make_unique<Indexing::IndexInfo>(NVectors);
277 this->
init(NVectors, XLength, YLength);
278 }
catch (std::runtime_error &) {
288 Indexing::IndexInfo indices(NVectors);
290 indices.setSpectrumDefinitions(std::vector<SpectrumDefinition>(NVectors));
297 throw std::out_of_range(
"All arguments to init must be positive and non-zero");
333 if (
run().hasProperty(
"run_title")) {
348 }
catch (std::out_of_range &
e) {
350 spec.clearDetectorIDs();
352 g_log.
debug() <<
"Spectrum number " << spec.getSpectrumNo() <<
" not in map.\n";
371 std::vector<detid_t> pixelIDs = this->
getInstrument()->getDetectorIDs(!includeMonitors);
375 std::vector<detid_t>::const_iterator iend = pixelIDs.end();
376 for (std::vector<detid_t>::const_iterator it = pixelIDs.begin(); it != iend; ++it) {
383 spec.setSpectrumNo(specNo);
384 spec.setDetectorID(detId);
390 }
catch (std::runtime_error &) {
402 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
403 "axis[1] is not a SpectraAxis, so I cannot "
406 return ax->getSpectraIndexMap();
407 }
catch (std::runtime_error &) {
408 g_log.
error() <<
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: no elements!";
424 throw std::runtime_error(
"MatrixWorkspace::getSpectrumToWorkspaceIndexMap: "
425 "axis[1] is not a SpectraAxis, so I cannot "
429 specnum_t min = std::numeric_limits<specnum_t>::max();
431 specnum_t max = -std::numeric_limits<specnum_t>::max();
434 size_t length = ax->length();
435 for (
size_t i = 0; i < length; i++) {
447 std::vector<size_t> out(max - min + 1, 0);
450 for (
size_t i = 0; i < length; i++) {
452 out[spec + offset] = i;
465 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); workspaceIndex++) {
467 if (detList.size() > 1) {
489 bool ignoreIfNoValidDets)
const {
494 for (
size_t workspaceIndex = 0; workspaceIndex < this->
getNumberHistograms(); ++workspaceIndex) {
496 if (ignoreIfNoValidDets && !specInfo.hasDetectors(workspaceIndex)) {
501 if (throwIfMultipleDets) {
502 if (detList.size() > 1) {
503 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexMap(): more than 1 "
504 "detector for one histogram! I cannot generate a map of detector "
505 "ID to workspace index.");
509 if (detList.size() == 1)
510 map[*detList.begin()] = workspaceIndex;
513 for (
auto det : detList)
514 map[det] = workspaceIndex;
536 bool throwIfMultipleDets)
const {
538 std::vector<size_t> out;
543 const int outSize = maxId - minId + 1;
545 out.resize(outSize, std::numeric_limits<size_t>::max());
547 for (
size_t workspaceIndex = 0; workspaceIndex <
getNumberHistograms(); ++workspaceIndex) {
551 if (throwIfMultipleDets && (detList.size() > 1))
552 throw std::runtime_error(
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector(): more than 1 "
553 "detector for one histogram! I cannot generate a map of detector ID "
554 "to workspace index.");
558 for (
auto det : detList) {
559 int index = det + offset;
560 if (index < 0 || index >= outSize) {
561 g_log.
debug() <<
"MatrixWorkspace::getDetectorIDToWorkspaceIndexVector("
562 "): detector ID found ("
563 << det <<
" at workspace index " << workspaceIndex <<
") is invalid.\n";
566 out[
index] = workspaceIndex;
581 std::vector<size_t> indexList;
584 auto iter = spectraList.cbegin();
585 while (iter != spectraList.cend()) {
588 indexList.emplace_back(i);
608 throw std::runtime_error(
"Could not find spectrum number in any spectrum.");
624 throw std::runtime_error(
"MatrixWorkspace: Using getIndicesFromDetectorIDs "
625 "in a parallel run is most likely incorrect. "
628 std::map<detid_t, std::set<size_t>> detectorIDtoWSIndices;
631 for (
auto detID : detIDs) {
632 detectorIDtoWSIndices[detID].insert(i);
636 std::vector<size_t> indexList;
637 indexList.reserve(detIdList.size());
638 for (
const auto detId : detIdList) {
639 auto wsIndices = detectorIDtoWSIndices.find(detId);
640 if (wsIndices != detectorIDtoWSIndices.end()) {
641 std::copy(wsIndices->second.cbegin(), wsIndices->second.cend(), std::back_inserter(indexList));
655 std::vector<specnum_t> spectraList;
658 for (
auto detId : detIdList) {
659 bool foundDet =
false;
672 spectraList.emplace_back(foundSpecNum);
693 xmin = std::numeric_limits<double>::max();
698 for (
size_t workspaceIndex = 0; workspaceIndex < numberOfSpectra; workspaceIndex++) {
699 const auto &
dataX = this->
x(workspaceIndex);
700 const double xfront =
dataX.front();
701 const double xback =
dataX.back();
702 if (std::isfinite(xfront) && std::isfinite(xback)) {
711 std::vector<double> extrema(comm.size());
712 Parallel::all_gather(comm, xmin, extrema);
713 xmin = *std::min_element(extrema.begin(), extrema.end());
714 Parallel::all_gather(comm, xmax, extrema);
715 xmax = *std::max_element(extrema.begin(), extrema.end());
733 const bool entireRange)
const {
741 for (
int wksp_index = 0; wksp_index < static_cast<int>(this->
getNumberHistograms()); wksp_index++) {
744 const auto &
y = this->
y(wksp_index);
746 if ((
x.size() <= 1 + histogramOffset) && (!
y.empty())) {
747 out[wksp_index] =
y[0];
750 Mantid::MantidVec::const_iterator lowit, highit;
752 highit =
x.end() - histogramOffset;
758 lowit = std::lower_bound(
x.begin(),
x.end(), minX);
760 if (*(highit - 1 + histogramOffset) > maxX)
761 highit = std::upper_bound(lowit,
x.end(), maxX);
765 Mantid::MantidVec::difference_type distmin = std::distance(
x.begin(), lowit);
766 Mantid::MantidVec::difference_type distmax = std::distance(
x.begin(), highit);
768 if (distmin <= distmax) {
770 sum = std::accumulate(
y.begin() + distmin,
y.begin() + distmax, 0.0, accumulate_if_finite);
773 out[wksp_index] = sum;
790 if (!localInstrument) {
795 const size_t ndets = dets.size();
798 return localInstrument->getDetector(*dets.begin());
799 }
else if (ndets == 0) {
801 "detectors for this workspace "
806 auto dets_ptr = localInstrument->getDetectors(dets);
807 return std::make_shared<Geometry::DetectorGroup>(dets_ptr);
822 if (source ==
nullptr ||
sample ==
nullptr) {
824 "Instrument not sufficiently defined: failed to get source and/or "
829 const Kernel::V3D beamLine = samplePos - source->getPos();
835 const V3D &thetaSignAxis = instrument->getReferenceFrame()->vecThetaSign();
850 if (source ==
nullptr ||
sample ==
nullptr) {
852 "Instrument not sufficiently defined: failed to get source and/or "
857 const Kernel::V3D beamLine = samplePos - source->getPos();
875 if (axisIndex >=
m_axes.size()) {
879 return m_axes[axisIndex].get();
893 if (axisIndex >=
m_axes.size()) {
897 m_axes[axisIndex] = std::move(newAxis);
913 const auto &x0 = this->
x(0);
919 if (x0[1] == x0[0]) {
923 double diff = x0[1] / x0[0];
924 if (!std::isfinite(diff)) {
928 for (
size_t i = 1; i < x0.size() - 2; ++i) {
929 if (std::isfinite(x0[i + 1]) && std::isfinite(x0[i])) {
930 if (std::abs(x0[i + 1] / x0[i] - diff) >
EPSILON) {
967 retVal = appendUnitDenominatorUsingPer(retVal, *
this, useLatex);
975 retVal = appendUnitDenominatorUsingPer(retVal, *
this, useLatex);
978 retVal = replacePerWithLatex(retVal);
990 return getSpectrum(0).
yMode() == HistogramData::Histogram::YMode::Frequencies;
999 HistogramData::Histogram::YMode ymode =
1000 newValue ? HistogramData::Histogram::YMode::Frequencies : HistogramData::Histogram::YMode::Counts;
1025 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1026 "Histogram::Xmode is not BinEdges");
1030 throw std::logic_error(
"In MatrixWorkspace::isHistogramData(): "
1031 "Histogram::Xmode is not Points");
1055 const HistogramData::HistogramX *first = &
x(0);
1056 for (
size_t i = 1; i < numHist; ++i) {
1057 if (&
x(i) != first) {
1070 const size_t numBins =
x(0).size();
1071 for (
size_t i = 1; i < numHist; ++i) {
1072 if (
x(i).
size() != numBins) {
1080 const size_t lastSpec = numHist - 1;
1081 for (
size_t i = 0; i < lastSpec; ++i) {
1082 const auto &xi =
x(i);
1083 const auto &xip1 =
x(i + 1);
1084 for (
size_t j = 0; j < numBins; ++j) {
1085 const double a = xi[j];
1086 const double b = xip1[j];
1088 if (std::isfinite(a) && std::isfinite(b)) {
1089 if (std::abs(a - b) >
EPSILON) {
1094 }
else if ((std::isnan(a) != std::isnan(b)) || (std::isinf(a) != std::isinf(b))) {
1112 const HistogramData::HistogramX bins =
x(0);
1114 for (
size_t i = 0; i < bins.size(); ++i) {
1115 if (std::trunc(bins[i]) != bins[i])
1139 "MatrixWorkspace::maskBin,workspaceIndex");
1141 if (binIndex >=
y(workspaceIndex).
size())
1145 flagMasked(workspaceIndex, binIndex, weight);
1155 double &
y = this->
mutableY(workspaceIndex)[binIndex];
1156 (std::isnan(
y) || std::isinf(
y)) ?
y = 0. :
y *= (1 - weight);
1157 double &
e = this->
mutableE(workspaceIndex)[binIndex];
1158 (std::isnan(
e) || std::isinf(
e)) ?
e = 0. :
e *= (1 - weight);
1176 binList[binIndex] = weight;
1204 auto it =
m_masks.find(workspaceIndex);
1215 auto it =
m_masks.find(workspaceIndex);
1223 std::vector<size_t> maskedIds;
1227 [](
const auto &mb) { return mb.first; });
1257 if (monitorWS.get() ==
this) {
1258 throw std::runtime_error(
"To avoid memory leak, monitor workspace"
1259 " can not be the same workspace as the host workspace");
1281 auto lastX = this->
refX(0);
1283 auto X = this->
refX(wi);
1285 if (!(
X == lastX) || wi == 0)
1286 total += (*X).size() *
sizeof(double);
1305 DateAndTime startDate = log->
firstTime();
1306 DateAndTime reference(
"1991-01-01T00:00:00");
1310 while (startDate < reference && i < 100) {
1341 [[maybe_unused]]
const double tolerance)
const {
1343 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - Index out of range.");
1345 const auto &xValues = this->
x(index);
1346 const bool ascendingOrder = xValues.front() < xValues.back();
1347 const auto minX = ascendingOrder ? xValues.front() : xValues.back();
1348 const auto maxX = ascendingOrder ? xValues.back() : xValues.front();
1351 if (xValue < minX || xValue > maxX)
1352 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1353 "the range of the min and max bin edges.");
1357 if (xValue < minX - tolerance || xValue > maxX +
tolerance)
1358 throw std::out_of_range(
"MatrixWorkspace::yIndexOfX - X value is out of "
1359 "range for this point data.");
1373 const bool ascendingOrder)
const {
1375 if (ascendingOrder) {
1376 auto lowerIter = std::lower_bound(xValues.cbegin(), xValues.cend(), xValue);
1379 if (lowerIter == xValues.cbegin())
1382 hops = std::distance(xValues.cbegin(), lowerIter);
1384 auto lowerIter = std::lower_bound(xValues.crbegin(), xValues.crend(), xValue);
1386 if (lowerIter == xValues.crbegin())
1389 hops = xValues.size() - std::distance(xValues.crbegin(), lowerIter);
1406 auto const iter = std::find_if(xValues.cbegin(), xValues.cend(), [&xValue, &
tolerance](
double const &
value) {
1407 return std::abs(xValue - value) <= tolerance;
1409 if (iter != xValues.cend())
1410 return std::distance(xValues.cbegin(), iter);
1412 throw std::invalid_argument(
"MatrixWorkspace::yIndexOfX - the X value provided could not be found "
1413 "in the workspace containing point data.");
1425 if (0 == axisIndex) {
1427 }
else if (1 == axisIndex) {
1430 throw std::invalid_argument(
"Cannot have an index for a MatrixWorkspace "
1431 "axis that is not == 0 or == 1");
1447 if (unit && unit->unitID() !=
"Empty")
1448 return unit->caption();
1484 throw std::runtime_error(
"Not implemented");
1501 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1522 m_ws->getAxis(0)->unit()->label())) {}
1527 const auto &unit = axis->
unit();
1528 if (unit && unit->unitID() !=
"Empty")
1529 return unit->caption();
1531 return axis->title();
1560 throw std::runtime_error(
"Not implemented");
1567 std::string
toXMLString()
const override {
throw std::runtime_error(
"Not implemented"); }
1584 return std::make_shared<MWXDimension>(
this,
xDimensionId);
1585 }
else if (
index == 1) {
1587 return std::make_shared<MWDimension>(yAxis,
yDimensionId);
1589 throw std::invalid_argument(
"MatrixWorkspace only has 2 dimensions.");
1593 int nAxes = this->
axes();
1594 std::shared_ptr<IMDDimension> dim;
1595 for (
int i = 0; i < nAxes; i++) {
1597 if (knownId ==
id) {
1598 dim = std::make_shared<MWDimension>(this->
getAxis(i),
id);
1603 if (
nullptr == dim) {
1604 std::string message =
"Cannot find id : " +
id;
1605 throw std::overflow_error(message);
1617std::vector<std::unique_ptr<IMDIterator>>
1620 size_t numCores = suggestedNumCores;
1624 if (numCores > numElements)
1625 numCores = numElements;
1630 std::vector<std::unique_ptr<IMDIterator>> out;
1631 for (
size_t i = 0; i < numCores; i++) {
1632 size_t begin = (i * numElements) / numCores;
1633 size_t end = ((i + 1) * numElements) / numCores;
1634 if (end > numElements)
1636 out.emplace_back(std::make_unique<MatrixWorkspaceMDIterator>(
this, function, begin, end));
1667 if (this->
axes() != 2)
1668 throw std::invalid_argument(
"MatrixWorkspace::getSignalAtCoord() - "
1669 "Workspace can only have 2 axes, found " +
1679 }
catch (std::out_of_range &) {
1680 return std::numeric_limits<double>::quiet_NaN();
1684 const auto &yVals = this->
y(wi);
1685 double yBinSize(1.0);
1688 double currentVertical = ax1->operator()(wi, uVI);
1689 if (wi + 1 == nhist && nhist > 1)
1691 yBinSize = currentVertical - ax1->operator()(wi - 1, uVI);
1693 yBinSize = ax1->operator()(wi + 1, uVI) - currentVertical;
1698 const auto &xVals =
x(wi);
1705 }
catch (std::out_of_range &) {
1706 return std::numeric_limits<double>::quiet_NaN();
1709 double y = yVals[i];
1711 switch (normalization) {
1716 auto volume = yBinSize * (xVals[i + 1] - xVals[i]);
1717 if (volume == 0.0) {
1718 return std::numeric_limits<double>::quiet_NaN();
1729 return std::numeric_limits<double>::quiet_NaN();
1750 throw std::runtime_error(
"MatrixWorkspace::setMDMasking has no implementation");
1757 throw std::runtime_error(
"MatrixWorkspace::clearMDMasking has no implementation");
1781 size_t start,
size_t stop,
size_t width,
size_t indexStart,
1782 size_t indexEnd)
const {
1785 throw std::runtime_error(
"Cannot create image with width 0");
1796 throw std::runtime_error(
"Cannot create image for an empty data set.");
1799 if (start >= nHist) {
1800 throw std::runtime_error(
"Cannot create image: start index is out of range");
1803 if (stop >= nHist) {
1804 throw std::runtime_error(
"Cannot create image: stop index is out of range");
1808 size_t dataSize = stop - start + 1;
1809 size_t height = dataSize / width;
1812 if (
height * width != dataSize) {
1813 throw std::runtime_error(
"Cannot create image: the data set cannot form a rectangle.");
1820 if (indexEnd == 0) {
1822 if (!isHisto && indexEnd > 0)
1827 if (indexEnd < indexStart) {
1828 throw std::runtime_error(
"Cannot create image for an empty data set.");
1831 if (indexStart >= nBins || indexEnd > nBins || (!isHisto && indexEnd == nBins)) {
1832 throw std::runtime_error(
"Cannot create image: integration interval is out of range.");
1836 auto image = std::make_shared<MantidImage>(
height);
1841 if (isHisto && indexEnd == indexStart + 1) {
1843 for (
int i = 0; i < static_cast<int>(
height); ++i) {
1844 auto &row = (*image)[i];
1846 size_t spec = start +
static_cast<size_t>(i) * width;
1847 for (
size_t j = 0; j < width; ++j, ++spec) {
1848 row[j] = (this->*read)(spec)[indexStart];
1854 for (
int i = 0; i < static_cast<int>(
height); ++i) {
1855 auto &row = (*image)[i];
1857 size_t spec = start +
static_cast<size_t>(i) * width;
1858 for (
size_t j = 0; j < width; ++j, ++spec) {
1859 auto &V = (this->*read)(spec);
1860 row[j] = std::accumulate(V.begin() + indexStart, V.begin() + indexEnd, 0.0);
1869 std::pair<int64_t, int64_t> out(-1, -1);
1871 if (std::isnan(
value)) {
1872 for (int64_t i = idx.first; i < numHists; ++i) {
1873 const auto &
Y = this->
y(i);
1874 if (
auto it = std::find_if(std::next(
Y.begin(), idx.second),
Y.end(), [](
double v) { return std::isnan(v); });
1876 out = {i, std::distance(
Y.begin(), it)};
1881 for (int64_t i = idx.first; i < numHists; ++i) {
1882 const auto &
Y = this->
y(i);
1883 if (
auto it = std::find(std::next(
Y.begin(), idx.second),
Y.end(),
value); it !=
Y.end()) {
1884 out = {i, std::distance(
Y.begin(), it)};
1900 startX =
x(i).front();
1901 auto pStart =
getXIndex(i, startX,
true);
1902 if (pStart.second != 0.0) {
1903 throw std::runtime_error(
"Start X value is required to be on bin boundary.");
1907 auto pEnd =
getXIndex(i, endX,
false, pStart.first);
1908 if (pEnd.second != 0.0) {
1909 throw std::runtime_error(
"End X value is required to be on bin boundary.");
1911 return std::make_pair(pStart.first, pEnd.first);
1953 auto &
X = this->
x(i);
1958 return std::make_pair(nx, 0.0);
1959 if (start > 0 && start == nx - 1) {
1962 return std::make_pair(start, 0.0);
1963 return std::make_pair(nx, 0.0);
1970 return x <=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
1971 return x >=
X[start] ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
1975 if (
x <=
X[start]) {
1976 return isLeft ? std::make_pair(start, 0.0) : std::make_pair(nx, 0.0);
1979 if (
x >=
X.back()) {
1980 return !isLeft ? std::make_pair(nx - 1, 0.0) : std::make_pair(nx, 0.0);
1985 for (
auto ix =
X.begin() + start + 1; ix != end; ++ix) {
1987 auto index =
static_cast<size_t>(std::distance(
X.begin(), ix));
1994 return std::make_pair(nx, 0.0);
2006 size_t start, [[maybe_unused]]
bool parallelExecution) {
2010 if (image[0].empty())
2014 throw std::runtime_error(
"Cannot set image: a single bin workspace is expected.");
2017 size_t height = image.size();
2018 size_t width = image.front().size();
2019 size_t dataSize = width *
height;
2022 throw std::runtime_error(
"Cannot set image: image is bigger than workspace.");
2026 for (
int i = 0; i < static_cast<int>(
height); ++i) {
2027 auto &row = image[i];
2028 if (row.size() != width) {
2029 throw std::runtime_error(
"Canot set image: image is corrupted.");
2031 size_t spec = start +
static_cast<size_t>(i) * width;
2032 auto rowEnd = row.end();
2033 for (
auto pixel = row.begin(); pixel != rowEnd; ++pixel, ++spec) {
2034 (this->*dataVec)(spec)[0] = *pixel;
2061 throw std::logic_error(
"Setting spectrum numbers in MatrixWorkspace via "
2062 "ISpectrum::setSpectrumNo is not possible in MPI "
2063 "runs for distributed workspaces. Use IndexInfo.");
2079 size_t numberOfDetectors{detInfo.size()};
2080 if (numberOfDetectors == 0) {
2085 size_t numberOfSpectra = numberOfDetectors * detInfo.scanCount();
2087 throw std::invalid_argument(
"MatrixWorkspace: IndexInfo does not contain spectrum definitions so "
2088 "building a 1:1 mapping from spectra to detectors was attempted, but "
2089 "the number of spectra in the workspace is not equal to the number of "
2090 "detectors in the instrument.");
2091 std::vector<SpectrumDefinition> specDefs(
m_indexInfo->size());
2092 if (!detInfo.isScanning() && (numberOfSpectra ==
m_indexInfo->size())) {
2093 for (
size_t i = 0; i < numberOfSpectra; ++i)
2096 size_t specIndex = 0;
2097 size_t globalSpecIndex = 0;
2098 for (
size_t detIndex = 0; detIndex < detInfo.size(); ++detIndex) {
2099 for (
size_t time = 0; time < detInfo.scanCount(); ++time) {
2100 if (
m_indexInfo->isOnThisPartition(Indexing::GlobalSpectrumIndex(globalSpecIndex++)))
2101 specDefs[specIndex++].add(detIndex, time);
2105 m_indexInfo->setSpectrumDefinitions(std::move(specDefs));
2110 const auto &allDetIDs = detInfo.detectorIDs();
2111 const auto &specDefs =
m_indexInfo->spectrumDefinitions();
2113 enum class ErrorCode {
None, InvalidDetIndex, InvalidTimeIndex };
2114 std::atomic<ErrorCode> errorValue(ErrorCode::None);
2115#pragma omp parallel for
2116 for (int64_t i = 0; i <
size; ++i) {
2119 spec.setMatrixWorkspace(
nullptr, i);
2121 std::set<detid_t> detIDs;
2122 for (
const auto &
index : (*specDefs)[i]) {
2123 const size_t detIndex =
index.first;
2124 const size_t timeIndex =
index.second;
2125 if (detIndex >= allDetIDs.size()) {
2126 errorValue = ErrorCode::InvalidDetIndex;
2127 }
else if (timeIndex >= detInfo.scanCount()) {
2128 errorValue = ErrorCode::InvalidTimeIndex;
2130 detIDs.insert(allDetIDs[detIndex]);
2133 spec.setDetectorIDs(std::move(detIDs));
2135 switch (errorValue) {
2136 case ErrorCode::InvalidDetIndex:
2137 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2138 "detector index, i.e., the spectrum definition does not match "
2139 "the instrument in the workspace.");
2140 case ErrorCode::InvalidTimeIndex:
2141 throw std::invalid_argument(
"MatrixWorkspace: SpectrumDefinition contains an out-of-range "
2142 "time index for a detector, i.e., the spectrum definition does "
2143 "not match the instrument in the workspace.");
2144 case ErrorCode::None:;
2155IPropertyManager::getValue<Mantid::API::MatrixWorkspace_sptr>(
const std::string &name)
const {
2160 std::string message =
2161 "Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<MatrixWorkspace>.";
2162 throw std::runtime_error(message);
2168IPropertyManager::getValue<Mantid::API::MatrixWorkspace_const_sptr>(
const std::string &name)
const {
2169 auto *prop =
dynamic_cast<PropertyWithValue<Mantid::API::MatrixWorkspace_sptr> *
>(getPointerToProperty(name));
2171 return prop->operator()();
2173 std::string message =
2174 "Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<MatrixWorkspace>.";
2175 throw std::runtime_error(message);
double value
The value of the point.
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
const double EPSILON(1.0E-10)
#define PARALLEL_FOR_NO_WSP_CHECK()
#define PARALLEL_CRITICAL(name)
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
Class to represent the axis of a workspace.
virtual double getMin() const =0
returns min value defined on axis
virtual double getMax() const =0
returns max value defined on axis
const std::string & title() const
Returns the user-defined title for this axis.
virtual size_t indexOfValue(const double value) const =0
Find the index of the given double value.
virtual std::size_t length() const =0
Get the length of the axis.
virtual bool isNumeric() const
Returns true if the axis is numeric.
const std::shared_ptr< Kernel::Unit > & unit() const
The unit for this axis.
Stores numeric values that are assumed to be bin edge values.
This class is shared by a few Workspace types and holds information related to a particular experimen...
Run & mutableRun()
Writable version of the run object.
const SpectrumInfo & spectrumInfo() const
Return a reference to the SpectrumInfo object.
const Geometry::DetectorInfo & detectorInfo() const
Return a const reference to the DetectorInfo object.
const Run & run() const
Run details object access.
Geometry::Instrument_const_sptr getInstrument() const
Returns the parameterized instrument.
const Sample & sample() const
Sample accessors.
const std::string toString() const
Returns a string description of the object.
void setDetectorGrouping(const size_t index, const std::set< detid_t > &detIDs) const
Sets the detector grouping for the spectrum with the given index.
void setSpectrumDefinitions(Kernel::cow_ptr< std::vector< SpectrumDefinition > > spectrumDefinitions)
Sets the SpectrumDefinition for all spectra.
void setNumberOfDetectorGroups(const size_t count) const
Sets the number of detector groups.
Geometry::Instrument_const_sptr sptr_instrument
The base (unparametrized) instrument.
Basic MD Workspace Abstract Class.
virtual LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const
Method to generate a line plot through a MD-workspace.
HistogramData::Histogram::YMode yMode() const
specnum_t getSpectrumNo() const
bool hasDetectorID(const detid_t detID) const
Return true if the given detector ID is in the list for this ISpectrum.
virtual HistogramData::Histogram histogram() const
Returns the Histogram associated with this spectrum.
void setYMode(HistogramData::Histogram::YMode ymode)
const std::set< detid_t > & getDetectorIDs() const
Get a const reference to the detector IDs set.
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Kernel::TimeSeriesProperty< T > * getTimeSeriesProperty(const std::string &name) const
Returns a property as a time series property.
coord_t getX(size_t ind) const override
Get coordinate for index;.
size_t getNBoundaries() const override
number of bin boundaries (axis points)
const Geometry::MDFrame_const_uptr m_frame
const std::string m_dimensionId
std::string getName() const override
the name of the dimennlsion as can be displayed along the axis
std::string toXMLString() const override
size_t getNBins() const override
number of bins dimension have (an integrated has one).
const Kernel::MDUnit & getMDUnits() const override
coord_t getMinimum() const override
const Kernel::UnitLabel getUnits() const override
const std::string & getDimensionId() const override
short name which identify the dimension among other dimension.
coord_t getBinWidth() const override
Return the bin width taking into account if the stored values are actually bin centres or not.
void setRange(size_t, coord_t, coord_t) override
Change the extents and number of bins.
coord_t getMaximum() const override
const Geometry::MDFrame & getMDFrame() const override
bool getIsIntegrated() const override
if the dimension is integrated (e.g. have single bin)
MWDimension(const Axis *axis, std::string dimensionId)
An implementation of IMDDimension for MatrixWorkspace that points to the X vector of the first spectr...
const Geometry::MDFrame & getMDFrame() const override
coord_t getX(size_t ind) const override
Get coordinate for index;.
const Geometry::MDFrame_const_uptr m_frame
Unit.
const MatrixWorkspace * m_ws
Workspace we refer to.
std::string getName() const override
the name of the dimennlsion as can be displayed along the axis
const Kernel::UnitLabel getUnits() const override
size_t getNBins() const override
number of bins dimension have (an integrated has one).
size_t getNBoundaries() const override
number of axis points (bin boundaries)
MWXDimension(const MatrixWorkspace *ws, std::string dimensionId)
const std::string & getDimensionId() const override
short name which identify the dimension among other dimension.
MantidVec m_X
Cached X vector.
const std::string m_dimensionId
Dimension ID string.
bool getIsIntegrated() const override
if the dimension is integrated (e.g. have single bin)
std::string toXMLString() const override
void setRange(size_t, coord_t, coord_t) override
Change the extents and number of bins.
coord_t getMinimum() const override
coord_t the minimum extent of this dimension
coord_t getMaximum() const override
const Kernel::MDUnit & getMDUnits() const override
Base MatrixWorkspace Abstract Class.
std::string YUnitLabel(bool useLatex=false, bool plotAsDistribution=false) const
Returns a caption for the units of the data in the workspace.
const MaskList & maskedBins(const size_t &workspaceIndex) const
Returns the list of masked bins for a spectrum.
virtual std::pair< int64_t, int64_t > findY(double value, const std::pair< int64_t, int64_t > &idx={0, 0}) const
Find first index in Y equal to value.
std::vector< specnum_t > getSpectraFromDetectorIDs(const std::vector< detid_t > &detIdList) const
Converts a list of detector IDs to the corresponding spectrum numbers.
virtual Types::Core::DateAndTime getFirstPulseTime() const
Return the time of the first pulse received, by accessing the run's sample logs to find the proton_ch...
std::vector< std::unique_ptr< IMDIterator > > createIterators(size_t suggestedNumCores=1, Mantid::Geometry::MDImplicitFunction *function=nullptr) const override
Create iterators.
void rebuildSpectraMapping(const bool includeMonitors=true, const specnum_t specNumOffset=1)
Build the default spectra mapping, most likely wanted after an instrument update.
const MantidVec & readE(std::size_t const index) const
Deprecated, use e() instead.
virtual ISpectrum & getSpectrum(const size_t index)=0
Return the underlying ISpectrum ptr at the given workspace index.
std::vector< std::unique_ptr< Axis > > m_axes
A vector of pointers to the axes for this workspace.
virtual size_t getMemorySizeForXAxes() const
Returns the memory used (in bytes) by the X axes, handling ragged bins.
const HistogramData::HistogramE & e(const size_t index) const
double detectorSignedTwoTheta(const Geometry::IDetector &det) const
Returns the signed 2Theta scattering angle for a detector.
std::pair< size_t, size_t > getImageStartEndXIndices(size_t i, double startX, double endX) const
Get start and end x indices for images.
virtual void updateSpectraUsing(const SpectrumDetectorMapping &map)
bool hasAnyMaskedBins() const
Does this workspace contain any masked bins.
virtual bool isHistogramDataByIndex(std::size_t index=0) const
Whether the specified histogram contains histogram data (ie bins)
virtual std::vector< size_t > getDetectorIDToWorkspaceIndexVector(detid_t &offset, bool throwIfMultipleDets=false) const
Return a vector where: The index into the vector = DetectorID (pixel ID) + offset The value at that i...
Types::Core::DateAndTime getLastPulseTime() const
Return the time of the last pulse received, by accessing the run's sample logs to find the proton_cha...
virtual bool isCommonLogBins() const
Returns true if the workspace contains common X bins with log spacing.
std::pair< size_t, double > getXIndex(size_t i, double x, bool isLeft=true, size_t start=0) const
Return an index in the X vector for an x-value close to a given value.
void setUnmaskedBins(const size_t workspaceIndex)
Removes the mask from an index.
bool m_isInitialized
Has this workspace been initialised?
std::unique_ptr< Indexing::IndexInfo > m_indexInfo
std::atomic< bool > m_indexInfoNeedsUpdate
static const std::string xDimensionId
Dimension id for x-dimension.
double detectorTwoTheta(const Geometry::IDetector &det) const
Returns the 2Theta scattering angle for a detector.
std::string m_YUnit
The unit for the data values (e.g. Counts)
void updateCachedDetectorGrouping(const size_t index) const override
Update detector grouping for spectrum with given index.
virtual std::size_t blocksize() const =0
Returns the size of each block of data returned by the dataY accessors.
signal_t getSignalAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
Get the signal at a coordinate in the workspace.
MantidImage_sptr getImageY(size_t start=0, size_t stop=0, size_t width=0, double startX=EMPTY_DBL(), double endX=EMPTY_DBL()) const
Create an image of Ys.
std::shared_ptr< MatrixWorkspace > m_monitorWorkspace
A workspace holding monitor data relating to the main data in the containing workspace (null if none)...
virtual double getXMin() const
void initialize(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength)
Initialize the workspace.
virtual MantidVec & dataX(const std::size_t index)
Deprecated, use mutableX() instead. Returns the x data.
virtual void setMonitorWorkspace(const std::shared_ptr< MatrixWorkspace > &monitorWS)
Sets the internal monitor workspace to the provided workspace.
virtual std::size_t getNumberHistograms() const =0
Returns the number of histograms in the workspace.
void setMaskedBins(const size_t workspaceIndex, const MaskList &maskedBins)
Set the list of masked bins for given workspaceIndex.
std::size_t binIndexOfValue(Mantid::HistogramData::HistogramX const &xValues, const double xValue, const bool ascendingOrder) const
Returns the bin index of the given X value.
bool hasMaskedBins(const size_t &workspaceIndex) const
Does this spectrum contain any masked bins.
virtual bool hasOrientedLattice() const override
void setTitle(const std::string &) override
Sets MatrixWorkspace title.
bool hasGroupedDetectors() const
Does the workspace has any grouped detectors?
virtual std::vector< size_t > getSpectrumToWorkspaceIndexVector(specnum_t &offset) const
Return a vector where: The index into the vector = spectrum number + offset The value at that index =...
std::map< size_t, double > MaskList
Masked bins for each spectrum are stored as a set of pairs containing <bin index, weight>
std::mutex m_isCommonBinsMutex
A mutex protecting the update of m_isCommonBinsFlag.
virtual void setImageE(const MantidImage &image, size_t start=0, bool parallelExecution=true)
Copy the data from an image to this workspace's errors.
std::vector< size_t > getIndicesFromSpectra(const std::vector< specnum_t > &spectraList) const
Converts a list of spectrum numbers to the corresponding workspace indices.
void setImage(MantidVec &(MatrixWorkspace::*dataVec)(const std::size_t), const MantidImage &image, size_t start, bool parallelExecution)
Copy data from an image.
std::size_t yIndexOfX(const double xValue, const std::size_t &index=0, const double tolerance=0.0) const
Returns the y index which corresponds to the X Value provided.
~MatrixWorkspace() override
Delete.
std::map< int64_t, MaskList > m_masks
The set of masked bins in a map keyed on workspace index.
virtual void setImageY(const MantidImage &image, size_t start=0, bool parallelExecution=true)
Copy the data (Y's) from an image to this workspace.
MatrixWorkspace(const MatrixWorkspace &other)
Protected copy constructor. May be used by childs for cloning.
virtual MantidVec & dataE(const std::size_t index)
Deprecated, use mutableE() instead. Returns the error data.
bool isDistribution() const
Are the Y-values dimensioned?
void flagMasked(const size_t &index, const size_t &binIndex, const double &weight=1.0)
Writes the masking weight to m_masks (doesn't alter y-values).
virtual Kernel::cow_ptr< HistogramData::HistogramX > refX(const std::size_t index) const
Deprecated, use sharedX() instead. Returns a pointer to the x data.
MantidImage_sptr getImageE(size_t start=0, size_t stop=0, size_t width=0, double startX=EMPTY_DBL(), double endX=EMPTY_DBL()) const
Create an image of Es.
void setMDMasking(std::unique_ptr< Mantid::Geometry::MDImplicitFunction > maskingRegion) override
Apply masking.
void maskBin(const size_t &workspaceIndex, const size_t &binIndex, const double &weight=1.0)
Called by the algorithm MaskBins to mask a single bin for the first time, algorithms that later propa...
std::shared_ptr< MatrixWorkspace > monitorWorkspace() const
Returns a pointer to the internal monitor workspace.
LinePlot getLinePlot(const Mantid::Kernel::VMD &start, const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const override
Generate a line plot through the matrix workspace.
void invalidateCachedSpectrumNumbers()
std::vector< size_t > maskedBinsIndices(const size_t &workspaceIndex) const
virtual bool isIntegerBins() const
Returns true if the workspace has common, integer X bins.
HistogramData::Histogram histogram(const size_t index) const
Returns the Histogram at the given workspace index.
std::vector< size_t > getIndicesFromDetectorIDs(const std::vector< detid_t > &detIdList) const
Converts a list of detector IDs to the corresponding workspace indices.
const std::string getTitle() const override
Gets MatrixWorkspace title (same as Run object run_title property)
void setDistribution(bool newValue)
Set the flag for whether the Y-values are dimensioned.
size_t getMemorySize() const override
Get the footprint in memory in bytes.
const Indexing::IndexInfo & indexInfo() const
Returns a const reference to the IndexInfo object of the workspace.
virtual void getIntegratedSpectra(std::vector< double > &out, const double minX, const double maxX, const bool entireRange) const
Return a vector with the integrated counts for all spectra withing the given range.
uint64_t getNPoints() const override
Gets the number of points available on the workspace.
const MantidVec & readY(std::size_t const index) const
Deprecated, use y() instead.
detid2index_map getDetectorIDToWorkspaceIndexMap(bool throwIfMultipleDets=false, bool ignoreIfNoValidDets=false) const
Return a map where: KEY is the DetectorID (pixel ID) VALUE is the Workspace Index.
std::atomic< bool > m_isCommonBinsFlagValid
Flag indicating if the common bins flag is in a valid state.
std::string getDimensionIdFromAxis(const int &axisIndex) const
Getter for the dimension id based on the axis.
virtual Axis * getAxis(const std::size_t &axisIndex) const
Get a non owning pointer to a workspace axis.
size_t getNumDims() const override
virtual double getXMax() const
HistogramData::HistogramE & mutableE(const size_t index) &
std::mutex m_indexInfoMutex
void setIndexInfoWithoutISpectrumUpdate(const Indexing::IndexInfo &indexInfo)
Variant of setIndexInfo, used by WorkspaceFactoryImpl.
static const std::string yDimensionId
Dimensin id for y-dimension.
bool m_isCommonBinsFlag
Flag indicating whether the data has common bins.
void rebuildDetectorIDGroupings()
void buildDefaultSpectrumDefinitions()
spec2index_map getSpectrumToWorkspaceIndexMap() const
Return a map where: KEY is the Spectrum # VALUE is the Workspace Index.
const MantidVec & readX(std::size_t const index) const
Deprecated, use x() instead.
size_t getIndexFromSpectrumNumber(const specnum_t specNo) const
Given a spectrum number, find the corresponding workspace index.
void replaceAxis(const std::size_t &axisIndex, std::unique_ptr< Axis > newAxis)
Replaces one of the workspace's axes with the new one provided.
std::string YUnit() const
Returns the units of the data in the workspace.
virtual void getXMinMax(double &xmin, double &xmax) const
virtual std::size_t size() const =0
Returns the number of single indexable items in the workspace.
virtual void init(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength)=0
Initialises the workspace.
MantidImage_sptr getImage(const MantidVec &(MatrixWorkspace::*read)(std::size_t const) const, size_t start, size_t stop, size_t width, size_t indexStart, size_t indexEnd) const
Create an MantidImage instance.
virtual MantidVec & dataY(const std::size_t index)
Deprecated, use mutableY() instead. Returns the y data.
const std::string toString() const override
String description of state.
HistogramData::HistogramY & mutableY(const size_t index) &
Mantid::Kernel::SpecialCoordinateSystem getSpecialCoordinateSystem() const override
void setYUnitLabel(const std::string &newLabel)
Sets a new caption for the data (Y axis) in the workspace.
signal_t getSignalWithMaskAtCoord(const coord_t *coords, const Mantid::API::MDNormalization &normalization) const override
Get the signal at a coordinate in the workspace.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimension(size_t index) const override
Get a dimension.
virtual bool isCommonBins() const
Returns true if the workspace contains common X bins.
std::shared_ptr< const Geometry::IDetector > getDetector(const size_t workspaceIndex) const
Get the effective detector for the given spectrum.
void setYUnit(const std::string &newUnit)
Sets a new unit for the data (Y axis) in the workspace.
size_t numberOfAxis() const
Will return the number of Axis currently stored in the workspace it is not always safe to assume it i...
std::string m_YUnitLabel
A text label for use when plotting spectra.
virtual bool isHistogramData() const
Returns true if the workspace contains data in histogram form (as opposed to point-like)
void setIndexInfo(const Indexing::IndexInfo &indexInfo)
Sets the IndexInfo object of the workspace.
void clearMDMasking() override
Clear exsting masking.
std::size_t xIndexOfValue(const Mantid::HistogramData::HistogramX &xValues, const double xValue, const double tolerance) const
Returns the X index of the given X value.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimensionWithId(std::string id) const override
Get a dimension.
This class stores information regarding an experimental run as a series of log entries.
size_t getMemorySize() const override
Return an approximate memory size for the object in bytes.
bool hasOrientedLattice() const
Class to represent the spectra axis of a workspace.
A minimal class to hold the mapping between the spectrum number and its related detector ID numbers f...
const std::set< detid_t > & getDetectorIDsForSpectrumNo(const specnum_t spectrumNo) const
const std::set< detid_t > & getDetectorIDsForSpectrumIndex(const size_t spectrumIndex) const
bool indexIsSpecNumber() const
bool threadSafe() const override
Marks the workspace as safe for multiple threads to edit data simutaneously.
Parallel::StorageMode storageMode() const
Returns the storage mode (used for MPI runs)
virtual void setTitle(const std::string &)
Set the title of the workspace.
void setStorageMode(Parallel::StorageMode mode)
Sets the storage mode (used for MPI runs)
virtual const std::string getTitle() const
Get the workspace title.
GeneralFrame : Any MDFrame that isn't related to momemtum transfer.
Interface class for detector objects.
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 double getSignedTwoTheta(const Kernel::V3D &observer, const Kernel::V3D &axis, const Kernel::V3D &instrumentUp) const =0
Gives the signed angle of this detector object with respect to an axis.
The class describes one dimension of multidimensional dataset representing an orthogonal dimension an...
MDFrame : The coordinate frame for a dimension, or set of dimensions in a multidimensional workspace.
An "ImplicitFunction" defining a hyper-cuboid-shaped region in N dimensions.
virtual const std::string id() const =0
A string ID for the class.
Exception for index errors.
Exception for errors associated with the instrument definition.
Exception for when an item is not found in a collection.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
MDUnit : Unit type for multidimensional data types.
The concrete, templated class for properties.
virtual std::string value() const =0
Returns the value of the property as a string.
A specialised Property class for holding a series of time-value pairs.
Types::Core::DateAndTime firstTime() const
Returns the first time regardless of filter.
Types::Core::DateAndTime lastTime() const
Returns the last time.
Types::Core::DateAndTime nthTime(int n) const
Returns n-th time. NOTE: Complexity is order(n)! regardless of filter.
A base-class for the a class that is able to return unit labels in different representations.
bool nullVector(const double tolerance=1e-3) const noexcept
Determine if the point is null.
std::vector< std::vector< double > > MantidImage
typedef for the image type
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
MDNormalization
Enum describing different ways to normalize the signal in a MDWorkspace.
@ VolumeNormalization
Divide the signal by the volume of the box/bin.
@ NumEventsNormalization
Divide the signal by the number of events that contributed to it.
@ NoNormalization
Don't normalize = return raw counts.
std::shared_ptr< MantidImage > MantidImage_sptr
shared pointer to MantidImage
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
std::unique_ptr< const MDFrame > MDFrame_const_uptr
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
size_t MANTID_KERNEL_DLL indexOfValueFromCenters(const std::vector< double > &bin_centers, const double value)
Gets the bin of a value from a vector of bin centers and throws exception if out of range.
size_t MANTID_KERNEL_DLL indexOfValueFromEdges(const std::vector< double > &bin_edges, const double value)
Gets the bin of a value from a vector of bin edges.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.
std::unordered_map< specnum_t, size_t > spec2index_map
Map with key = spectrum number, value = workspace index.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
int32_t detid_t
Typedef for a detector ID.
std::unordered_map< detid_t, size_t > detid2index_map
Map with key = detector ID, value = workspace index.
double signal_t
Typedef for the signal recorded in a MDBox, etc.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
int32_t specnum_t
Typedef for a spectrum Number.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
std::string to_string(const wide_integer< Bits, Signed > &n)
Holds X, Y, E for a line plot.