Newer
Older
Russell Taylor
committed
#ifndef MANTID_DATAOBJECTS_WORKSPACE2D_H_
#define MANTID_DATAOBJECTS_WORKSPACE2D_H_
Russell Taylor
committed
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/HistoWorkspace.h"
#include "MantidDataObjects/Histogram1D.h"
Russell Taylor
committed
Concrete workspace implementation. Data is a vector of Histogram1D.
Russell Taylor
committed
Since Histogram1D have share ownership of X, Y or E arrays,
duplication is avoided for workspaces for example with identical time bins.
\author Laurent C Chapon, ISIS, RAL
\date 26/09/2007
Copyright © 2007-9 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
Russell Taylor
committed
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Russell Taylor
committed
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Russell Taylor
committed
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Russell Taylor
committed
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
Russell Taylor
committed
*/
class DLLExport Workspace2D : public API::HistoWorkspace {
Russell Taylor
committed
Gets the name of the workspace type
Janik Zikovsky
committed
@return Standard string name
Russell Taylor
committed
*/
const std::string id() const override { return "Workspace2D"; }
Russell Taylor
committed
Workspace2D();
Workspace2D &operator=(const Workspace2D &other) = delete;
~Workspace2D() override;
/// Returns a clone of the workspace
std::unique_ptr<Workspace2D> clone() const {
return std::unique_ptr<Workspace2D>(doClone());
}
/// Returns a default-initialized clone of the workspace
std::unique_ptr<Workspace2D> cloneEmpty() const {
return std::unique_ptr<Workspace2D>(doCloneEmpty());
}
std::size_t getNumberHistograms() const override;
std::size_t size() const override;
std::size_t blocksize() const override;
Russell Taylor
committed
Histogram1D &getSpectrum(const size_t index) override;
const Histogram1D &getSpectrum(const size_t index) const override;
Janik Zikovsky
committed
/// Generate a new histogram by rebinning the existing histogram.
void generateHistogram(const std::size_t index, const MantidVec &X,
MantidVec &Y, MantidVec &E,
bool skipError = false) const override;
Russell Taylor
committed
Alex Buts
committed
@param mList :: a vector holding the monitor workspace indexes
*/
void setMonitorList(std::vector<specnum_t> &mList) { m_monitorList = mList; }
/// Copy the data (Y's) from an image to this workspace.
void setImageY(const API::MantidImage &image, size_t start = 0,
bool parallelExecution = true) override;
/// Copy the data from an image to this workspace's errors.
void setImageE(const API::MantidImage &image, size_t start = 0,
bool parallelExecution = true) override;
/// Copy the data from an image to this workspace's (Y's) and errors.
void setImageYAndE(const API::MantidImage &imageY,
const API::MantidImage &imageE, size_t start = 0,
bool loadAsRectImg = false, double scale_1 = 1.0,
Russell Taylor
committed
protected:
/// Protected copy constructor. May be used by childs for cloning.
Workspace2D(const Workspace2D &other);
Janik Zikovsky
committed
/// Called by initialize()
void init(const std::size_t &NVectors, const std::size_t &XLength,
const std::size_t &YLength) override;
void init(const std::size_t &NVectors,
const HistogramData::Histogram &histogram) override;
Janik Zikovsky
committed
Russell Taylor
committed
/// The number of vectors in the workspace
Janik Zikovsky
committed
Janik Zikovsky
committed
/// a vector holding workspace index of monitors in the workspace
std::vector<specnum_t> m_monitorList;
Gigg, Martyn Anthony
committed
Janik Zikovsky
committed
/// A vector that holds the 1D histograms
std::vector<Histogram1D *> data;
Janik Zikovsky
committed
Russell Taylor
committed
private:
Workspace2D *doClone() const override { return new Workspace2D(*this); }
Workspace2D *doCloneEmpty() const override { return new Workspace2D(); }
/// shared pointer to the Workspace2D class
Russell Taylor
committed
typedef boost::shared_ptr<Workspace2D> Workspace2D_sptr;
/// shared pointer to a const Workspace2D
Russell Taylor
committed
typedef boost::shared_ptr<const Workspace2D> Workspace2D_const_sptr;
Russell Taylor
committed
} // namespace DataObjects
Russell Taylor
committed
} // Namespace Mantid
Russell Taylor
committed
#endif /*MANTID_DATAOBJECTS_WORKSPACE2D_H_*/