9#include "MantidAPI/DllConfig.h"
11#include "MantidHistogramData/Histogram.h"
18namespace DataObjects {
44 void copyInfoFrom(
const ISpectrum &other);
49 [[deprecated(
"use setSharedX() instead")]]
51 [[deprecated(
"use mutableX() instead")]]
53 [[deprecated(
"use x() instead")]]
55 [[deprecated(
"use x() instead")]]
57 [[deprecated(
"use sharedX() instead")]]
60 [[deprecated(
"use mutableDx() instead")]]
62 [[deprecated(
"use dx() instead")]]
64 [[deprecated(
"use dx() instead")]]
69 [[deprecated(
"use mutableY() instead")]]
71 [[deprecated(
"use mutableE() instead")]]
74 [[deprecated(
"use y() instead")]]
76 [[deprecated(
"use e() instead")]]
78 [[deprecated(
"use y() instead")]]
80 [[deprecated(
"use e() instead")]]
85 virtual std::pair<double, double> getXDataRange()
const;
87 void addDetectorID(
const detid_t detID);
88 void addDetectorIDs(
const std::set<detid_t> &detIDs);
89 void addDetectorIDs(
const std::vector<detid_t> &detIDs);
90 void setDetectorID(
const detid_t detID);
91 void setDetectorIDs(
const std::set<detid_t> &detIDs);
92 void setDetectorIDs(std::set<detid_t> &&detIDs);
94 bool hasDetectorID(
const detid_t detID)
const;
95 const std::set<detid_t> &getDetectorIDs()
const;
97 void clearDetectorIDs();
108 virtual HistogramData::Histogram
histogram()
const {
return histogramRef(); }
111 HistogramData::Histogram hist(std::forward<T>(data)...);
114 checkAndSanitizeHistogram(hist);
115 mutableHistogramRef() = std::move(hist);
118 HistogramData::Histogram::YMode
yMode()
const {
return histogramRef().yMode(); }
119 void setYMode(HistogramData::Histogram::YMode ymode) { mutableHistogramRef().setYMode(ymode); }
121 checkIsYAndEWritable();
122 mutableHistogramRef().convertToCounts();
125 checkIsYAndEWritable();
126 mutableHistogramRef().convertToFrequencies();
129 HistogramData::BinEdges
binEdges()
const {
return histogramRef().binEdges(); }
130 HistogramData::Points
points()
const {
return histogramRef().points(); }
132 return histogramRef().pointStandardDeviations();
135 mutableHistogramRef().setBinEdges(std::forward<T>(data)...);
137 template <
typename... T>
void setPoints(T &&...data) & {
139 checkWorksWithPoints();
140 mutableHistogramRef().setPoints(std::forward<T>(data)...);
145 mutableHistogramRef().setPointVariances(std::forward<T>(data)...);
148 mutableHistogramRef().setPointStandardDeviations(std::forward<T>(data)...);
150 virtual HistogramData::Counts
counts()
const {
return histogramRef().counts(); }
151 virtual HistogramData::CountVariances
countVariances()
const {
return histogramRef().countVariances(); }
153 return histogramRef().countStandardDeviations();
155 virtual HistogramData::Frequencies
frequencies()
const {
return histogramRef().frequencies(); }
156 virtual HistogramData::FrequencyVariances
frequencyVariances()
const {
return histogramRef().frequencyVariances(); }
158 return histogramRef().frequencyStandardDeviations();
160 template <
typename... T>
void setCounts(T &&...data) & {
162 checkIsYAndEWritable();
163 mutableHistogramRef().setCounts(std::forward<T>(data)...);
166 checkIsYAndEWritable();
167 mutableHistogramRef().setCountVariances(std::forward<T>(data)...);
170 checkIsYAndEWritable();
171 mutableHistogramRef().setCountStandardDeviations(std::forward<T>(data)...);
174 checkIsYAndEWritable();
175 mutableHistogramRef().setFrequencies(std::forward<T>(data)...);
178 checkIsYAndEWritable();
179 mutableHistogramRef().setFrequencyVariances(std::forward<T>(data)...);
182 checkIsYAndEWritable();
183 mutableHistogramRef().setFrequencyStandardDeviations(std::forward<T>(data)...);
185 const HistogramData::HistogramX &
x()
const {
return histogramRef().x(); }
186 virtual const HistogramData::HistogramY &
y()
const {
return histogramRef().y(); }
187 virtual const HistogramData::HistogramE &
e()
const {
return histogramRef().e(); }
188 const HistogramData::HistogramDx &
dx()
const {
return histogramRef().dx(); }
189 HistogramData::HistogramX &
mutableX() & {
return mutableHistogramRef().mutableX(); }
190 HistogramData::HistogramDx &
mutableDx() & {
return mutableHistogramRef().mutableDx(); }
192 checkIsYAndEWritable();
193 return mutableHistogramRef().mutableY();
196 checkIsYAndEWritable();
197 return mutableHistogramRef().mutableE();
206 checkIsYAndEWritable();
207 mutableHistogramRef().setSharedY(
y);
210 checkIsYAndEWritable();
211 mutableHistogramRef().setSharedE(e);
214 void resize(
size_t n) { mutableHistogramRef().resize(
n); }
215 size_t size()
const {
return histogramRef().size(); }
239 void invalidateCachedSpectrumNumbers()
const;
240 void invalidateSpectrumDefinition()
const;
std::map< DeltaEMode::Type, std::string > index
A "spectrum" is an object that holds the data for a particular spectrum, in particular:
void setHistogram(T &&...data)
Sets the Histogram associated with this spectrum.
virtual HistogramData::FrequencyVariances frequencyVariances() const
void setFrequencyVariances(T &&...data) &
HistogramData::Histogram::YMode yMode() const
virtual HistogramData::FrequencyStandardDeviations frequencyStandardDeviations() const
HistogramData::HistogramY & mutableY() &
HistogramData::Points points() const
virtual const MantidVec & dataX() const =0
const HistogramData::HistogramX & x() const
virtual const HistogramData::HistogramE & e() const
void setSharedDx(const Kernel::cow_ptr< HistogramData::HistogramDx > &dx) &
virtual MantidVec & dataY()=0
virtual const MantidVec & readX() const =0
void setPointStandardDeviations(T &&...data) &
void setCountVariances(T &&...data) &
virtual MantidVec & dataE()=0
std::set< detid_t > detectorIDs
Set of the detector IDs associated with this spectrum.
void setSharedY(const Kernel::cow_ptr< HistogramData::HistogramY > &y) &
void setCountStandardDeviations(T &&...data) &
virtual const MantidVec & dataDx() const =0
virtual HistogramData::Frequencies frequencies() const
void setPointVariances(T &&...data) &
virtual void setX(const Kernel::cow_ptr< HistogramData::HistogramX > &X)=0
void setBinEdges(T &&...data) &
virtual HistogramData::Histogram & mutableHistogramRef()=0
virtual size_t getMemorySize() const =0
const HistogramData::HistogramDx & dx() const
HistogramData::HistogramDx & mutableDx() &
void convertToFrequencies()
virtual void checkWorksWithPoints() const
virtual const MantidVec & readDx() const =0
virtual ~ISpectrum()=default
virtual HistogramData::Histogram histogram() const
Returns the Histogram associated with this spectrum.
virtual HistogramData::Counts counts() const
void setYMode(HistogramData::Histogram::YMode ymode)
Kernel::cow_ptr< HistogramData::HistogramX > sharedX() const
void setFrequencies(T &&...data) &
virtual const HistogramData::HistogramY & y() const
virtual HistogramData::CountStandardDeviations countStandardDeviations() const
void setSharedE(const Kernel::cow_ptr< HistogramData::HistogramE > &e) &
HistogramData::BinEdges binEdges() const
void setCounts(T &&...data) &
virtual MantidVec & dataDx()=0
virtual void clearData()=0
virtual const HistogramData::Histogram & histogramRef() const =0
virtual Kernel::cow_ptr< HistogramData::HistogramY > sharedY() const
virtual Kernel::cow_ptr< HistogramData::HistogramE > sharedE() const
virtual void checkAndSanitizeHistogram(HistogramData::Histogram &)
virtual HistogramData::CountVariances countVariances() const
void setPoints(T &&...data) &
virtual const MantidVec & dataE() const =0
virtual Kernel::cow_ptr< HistogramData::HistogramX > ptrX() const =0
Kernel::cow_ptr< HistogramData::HistogramDx > sharedDx() const
virtual void copyDataFrom(const ISpectrum &source)=0
Copy data from another ISpectrum with double-dynamic dispatch.
void setSharedX(const Kernel::cow_ptr< HistogramData::HistogramX > &x) &
HistogramData::HistogramX & mutableX() &
HistogramData::HistogramE & mutableE() &
void setFrequencyStandardDeviations(T &&...data) &
virtual MantidVec & dataX()=0
virtual void checkIsYAndEWritable() const
virtual const MantidVec & dataY() const =0
HistogramData::PointStandardDeviations pointStandardDeviations() const
Base MatrixWorkspace Abstract Class.
1D histogram implementation.
Implements a copy on write data template.
Helper class that implements ISpectrum.
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
int32_t specnum_t
Typedef for a spectrum Number.