Newer
Older
Peterson, Peter
committed
#ifndef MANTID_DATAOBJECTS_EVENTWORKSPACE_H_
#define MANTID_DATAOBJECTS_EVENTWORKSPACE_H_ 1
Gigg, Martyn Anthony
committed
#include "MantidAPI/IEventWorkspace.h"
Janik Zikovsky
committed
#include "MantidDataObjects/EventList.h"
#include "MantidKernel/System.h"
#include <boost/date_time/posix_time/posix_time.hpp>
Janik Zikovsky
committed
#include <string>
namespace Mantid {
namespace API {
class Progress;
Peterson, Peter
committed
Janik Zikovsky
committed
Peterson, Peter
committed
/** \class EventWorkspace
This class is intended to fulfill the design specified in
<https://github.com/mantidproject/documents/tree/master/Design/Event
WorkspaceDetailed Design Document.doc>
Peterson, Peter
committed
*/
Peterson, Peter
committed
class DLLExport EventWorkspace : public API::IEventWorkspace {
Janik Zikovsky
committed
const std::string id() const override { return "EventWorkspace"; }
Peterson, Peter
committed
Peterson, Peter
committed
EventWorkspace();
~EventWorkspace() override;
Peterson, Peter
committed
/// Returns a clone of the workspace
std::unique_ptr<EventWorkspace> clone() const {
return std::unique_ptr<EventWorkspace>(doClone());
}
/// Returns a default-initialized clone of the workspace
std::unique_ptr<EventWorkspace> cloneEmpty() const {
return std::unique_ptr<EventWorkspace>(doCloneEmpty());
}
void init(const std::size_t &, const std::size_t &,
const std::size_t &) override;
void init(const std::size_t &NVectors,
const HistogramData::Histogram &histogram) override;
bool threadSafe() const override;
Janik Zikovsky
committed
//------------------------------------------------------------
// Returns the number of single indexable items in the workspace
std::size_t size() const override;
Peterson, Peter
committed
// Get the blocksize, aka the number of bins in the histogram
std::size_t blocksize() const override;
Peterson, Peter
committed
size_t getMemorySize() const override;
Janik Zikovsky
committed
// Get the number of histograms. aka the number of pixels or detectors.
std::size_t getNumberHistograms() const override;
Peterson, Peter
committed
EventList &getSpectrum(const size_t index) override;
const EventList &getSpectrum(const size_t index) const override;
Janik Zikovsky
committed
//------------------------------------------------------------
double getTofMin() const override;
Peterson, Peter
committed
double getTofMax() const override;
Peterson, Peter
committed
Mantid::Kernel::DateAndTime getPulseTimeMin() const override;
Mantid::Kernel::DateAndTime getPulseTimeMax() const override;
void getPulseTimeMinMax(Mantid::Kernel::DateAndTime &xmin,
Mantid::Kernel::DateAndTime &xmax) const;
Mantid::Kernel::DateAndTime
getTimeAtSampleMin(double tofOffset = 0) const override;
Mantid::Kernel::DateAndTime
getTimeAtSampleMax(double tofOffset = 0) const override;
double getEventXMin() const;
double getEventXMax() const;
void getEventXMinMax(double &xmin, double &xmax) const;
MantidVec &dataX(const std::size_t) override;
MantidVec &dataY(const std::size_t) override;
MantidVec &dataE(const std::size_t) override;
MantidVec &dataDx(const std::size_t) override;
const MantidVec &dataX(const std::size_t) const override;
const MantidVec &dataY(const std::size_t) const override;
const MantidVec &dataE(const std::size_t) const override;
const MantidVec &dataDx(const std::size_t) const override;
Kernel::cow_ptr<HistogramData::HistogramX>
refX(const std::size_t) const override;
Peterson, Peter
committed
/// Generate a new histogram from specified event list at the given index.
void generateHistogram(const std::size_t index, const MantidVec &X,
MantidVec &Y, MantidVec &E,
bool skipError = false) const override;
/// Generate a new histogram from specified event list at the given index.
void generateHistogramPulseTime(const std::size_t index, const MantidVec &X,
MantidVec &Y, MantidVec &E,
bool skipError = false) const;
// Set the x-axis data (histogram bins) for all pixels
virtual void setAllX(const HistogramData::BinEdges &x);
Janik Zikovsky
committed
// The total number of events across all of the spectra.
std::size_t getNumberEvents() const override;
Mantid::API::EventType getEventType() const override;
Janik Zikovsky
committed
void switchEventType(const Mantid::API::EventType type);
// Returns true always - an EventWorkspace always represents histogramm-able
// data
bool isHistogramData() const override;
Janik Zikovsky
committed
void clearMRU() const override;
Janik Zikovsky
committed
Peterson, Peter
committed
EventSortType getSortType() const;
// Sort all event lists. Uses a parallelized algorithm
void sortAll(EventSortType sortType, Mantid::API::Progress *prog) const;
void sortAllOld(EventSortType sortType, Mantid::API::Progress *prog) const;
void getIntegratedSpectra(std::vector<double> &out, const double minX,
const double maxX,
const bool entireRange) const override;
EventWorkspace &operator=(const EventWorkspace &other) = delete;
Janik Zikovsky
committed
protected:
/// Protected copy constructor. May be used by childs for cloning.
EventWorkspace(const EventWorkspace &other);
private:
EventWorkspace *doClone() const override { return new EventWorkspace(*this); }
EventWorkspace *doCloneEmpty() const override { return new EventWorkspace(); }
/** A vector that holds the event list for each spectrum; the key is
* the workspace index, which is not necessarily the pixelid.
Janik Zikovsky
committed
*/
std::vector<EventList *> data;
Janik Zikovsky
committed
Janik Zikovsky
committed
/// Container for the MRU lists of the event lists contained.
Peterson, Peter
committed
};
/// shared pointer to the EventWorkspace class
Janik Zikovsky
committed
typedef boost::shared_ptr<EventWorkspace> EventWorkspace_sptr;
/// shared pointer to a const Workspace2D
Janik Zikovsky
committed
typedef boost::shared_ptr<const EventWorkspace> EventWorkspace_const_sptr;
Peterson, Peter
committed
} /// namespace DataObjects
} /// namespace Mantid
Peterson, Peter
committed
#endif /* MANTID_DATAOBJECTS_EVENTWORKSPACE_H_ */