Mantid
Loading...
Searching...
No Matches
Histogram1D.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 +
7#pragma once
8
10#include "MantidDataObjects/DllConfig.h"
12
13namespace Mantid {
14namespace DataObjects {
18class MANTID_DATAOBJECTS_DLL Histogram1D : public Mantid::API::ISpectrum {
19private:
21 HistogramData::Histogram m_histogram;
22
23public:
24 Histogram1D(HistogramData::Histogram::XMode xmode, HistogramData::Histogram::YMode ymode);
25
26 Histogram1D(const Histogram1D &) = default;
27 Histogram1D(Histogram1D &&) = default;
28 Histogram1D(const ISpectrum &other);
29
30 Histogram1D &operator=(const Histogram1D &) = default;
32 Histogram1D &operator=(const ISpectrum &rhs);
33
34 void copyDataFrom(const ISpectrum &source) override;
35
36 void setX(const Kernel::cow_ptr<HistogramData::HistogramX> &X) override;
37 MantidVec &dataX() override;
38 const MantidVec &dataX() const override;
39 const MantidVec &readX() const override;
41
42 MantidVec &dataDx() override;
43 const MantidVec &dataDx() const override;
44 const MantidVec &readDx() const override;
45
47 void clearData() override;
48
50 const MantidVec &dataY() const override { return m_histogram.dataY(); }
52 const MantidVec &dataE() const override { return m_histogram.dataE(); }
53
55 MantidVec &dataY() override { return m_histogram.dataY(); }
57 MantidVec &dataE() override { return m_histogram.dataE(); }
58
59 virtual std::size_t size() const { return m_histogram.readY().size(); }
60
62 bool isError() const { return readE().empty(); }
63
65 size_t getMemorySize() const override {
66 return ((readX().size() + readY().size() + readE().size()) * sizeof(double));
67 }
68
69private:
70 using ISpectrum::copyDataInto;
71 void copyDataInto(Histogram1D &sink) const override;
72
73 void checkAndSanitizeHistogram(HistogramData::Histogram &histogram) override;
74 const HistogramData::Histogram &histogramRef() const override { return m_histogram; }
75 HistogramData::Histogram &mutableHistogramRef() override { return m_histogram; }
76};
77
78} // namespace DataObjects
79} // Namespace Mantid
const std::vector< double > & rhs
A "spectrum" is an object that holds the data for a particular spectrum, in particular:
Definition: ISpectrum.h:39
1D histogram implementation.
Definition: Histogram1D.h:18
Histogram1D & operator=(Histogram1D &&)=default
HistogramData::Histogram m_histogram
Histogram object holding the histogram data.
Definition: Histogram1D.h:21
const MantidVec & dataE() const override
Deprecated, use e() instead. Returns the error data const.
Definition: Histogram1D.h:52
const MantidVec & dataY() const override
Deprecated, use y() instead. Returns the y data const.
Definition: Histogram1D.h:50
virtual std::size_t size() const
get pseudo size
Definition: Histogram1D.h:59
MantidVec & dataY() override
Deprecated, use mutableY() instead. Returns the y data.
Definition: Histogram1D.h:55
Histogram1D(const Histogram1D &)=default
Histogram1D & operator=(const Histogram1D &)=default
Histogram1D(Histogram1D &&)=default
const HistogramData::Histogram & histogramRef() const override
Definition: Histogram1D.h:74
bool isError() const
Checks for errors.
Definition: Histogram1D.h:62
MantidVec & dataE() override
Deprecated, use mutableE() instead. Returns the error data.
Definition: Histogram1D.h:57
size_t getMemorySize() const override
Gets the memory size of the histogram.
Definition: Histogram1D.h:65
HistogramData::Histogram & mutableHistogramRef() override
Definition: Histogram1D.h:75
Implements a copy on write data template.
Definition: cow_ptr.h:41
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition: cow_ptr.h:172