Mantid
Loading...
Searching...
No Matches
EventWorkspace.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 "MantidAPI/ISpectrum.h"
11#include "MantidDataObjects/DllConfig.h"
13#include <boost/date_time/posix_time/posix_time.hpp>
14#include <string>
15
16namespace Mantid {
17namespace API {
18class Progress;
19}
20
21namespace DataObjects {
22class EventWorkspaceMRU;
23
31class MANTID_DATAOBJECTS_DLL EventWorkspace : public API::IEventWorkspace {
32
33public:
34 // The name of the workspace type.
35 const std::string id() const override { return "EventWorkspace"; }
36
37 // Constructor
38 EventWorkspace(const Parallel::StorageMode storageMode = Parallel::StorageMode::Cloned);
39
40 // Destructor
41 ~EventWorkspace() override;
42
44 std::unique_ptr<EventWorkspace> clone() const { return std::unique_ptr<EventWorkspace>(doClone()); }
45
47 std::unique_ptr<EventWorkspace> cloneEmpty() const { return std::unique_ptr<EventWorkspace>(doCloneEmpty()); }
48
49 // Initialize the pixels
50 void init(const std::size_t &, const std::size_t &, const std::size_t &) override;
51 void init(const HistogramData::Histogram &histogram) override;
52
53 bool threadSafe() const override;
54
55 //------------------------------------------------------------
56
58 bool isRaggedWorkspace() const override;
59
60 // Returns the number of single indexable items in the workspace
61 std::size_t size() const override;
62
63 // Get the blocksize, aka the number of bins in the histogram
64 std::size_t blocksize() const override;
66 std::size_t getNumberBins(const std::size_t &index) const override;
68 std::size_t getMaxNumberBins() const override;
69
70 // Get the number of histograms. aka the number of pixels or detectors.
71 std::size_t getNumberHistograms() const override;
72
73 size_t getMemorySize() const override;
74
75 EventList &getSpectrum(const size_t index) override {
76 invalidateCommonBinsFlag();
77 return getSpectrumWithoutInvalidation(index);
78 }
79 const EventList &getSpectrum(const size_t index) const override;
80 EventList *getSpectrumUnsafe(const size_t index);
81
82 //------------------------------------------------------------
83
84 double getTofMin() const override;
85
86 double getTofMax() const override;
87
88 Mantid::Types::Core::DateAndTime getPulseTimeMin() const override;
89 Mantid::Types::Core::DateAndTime getPulseTimeMax() const override;
90 void getPulseTimeMinMax(Mantid::Types::Core::DateAndTime &xmin, Mantid::Types::Core::DateAndTime &xmax) const;
91
92 Mantid::Types::Core::DateAndTime getTimeAtSampleMin(double tofOffset = 0) const override;
93
94 Mantid::Types::Core::DateAndTime getTimeAtSampleMax(double tofOffset = 0) const override;
95
96 double getEventXMin() const;
97 double getEventXMax() const;
98 void getEventXMinMax(double &xmin, double &xmax) const;
99
100 MantidVec &dataX(const std::size_t) override;
101 MantidVec &dataY(const std::size_t) override;
102 MantidVec &dataE(const std::size_t) override;
103 MantidVec &dataDx(const std::size_t) override;
104 const MantidVec &dataX(const std::size_t) const override;
105 const MantidVec &dataY(const std::size_t) const override;
106 const MantidVec &dataE(const std::size_t) const override;
107 const MantidVec &dataDx(const std::size_t) const override;
108 Kernel::cow_ptr<HistogramData::HistogramX> refX(const std::size_t) const override;
109
111 void generateHistogram(const std::size_t index, const MantidVec &X, MantidVec &Y, MantidVec &E,
112 bool skipError = false) const override;
113
115 void generateHistogramPulseTime(const std::size_t index, const MantidVec &X, MantidVec &Y, MantidVec &E,
116 bool skipError = false) const;
117
118 // Set the x-axis data (histogram bins) for all pixels
119 void setAllX(const HistogramData::BinEdges &x) override;
120
121 // Update all X values to fit around all events
122 void resetAllXToSingleBin() override;
123
124 // The total number of events across all of the spectra.
125 std::size_t getNumberEvents() const override;
126
127 // Type of the events
128 Mantid::API::EventType getEventType() const override;
129
130 // Change the event type
131 void switchEventType(const Mantid::API::EventType type);
132
133 // Returns true always - an EventWorkspace always represents histogramm-able
134 // data
135 bool isHistogramData() const override;
136
137 std::size_t MRUSize() const;
138
139 void clearMRU() const override;
140
141 EventSortType getSortType() const;
142
143 // Sort all event lists. Uses a parallelized algorithm
144 void sortAll(EventSortType sortType, Mantid::API::Progress *prog) const;
145 void sortAllOld(EventSortType sortType, Mantid::API::Progress *prog) const;
146
147 void getIntegratedSpectra(std::vector<double> &out, const double minX, const double maxX,
148 const bool entireRange) const override;
149 EventWorkspace &operator=(const EventWorkspace &other) = delete;
150
151protected:
153 EventWorkspace(const EventWorkspace &other);
154
155private:
156 EventWorkspace *doClone() const override { return new EventWorkspace(*this); }
157 EventWorkspace *doCloneEmpty() const override { return new EventWorkspace(storageMode()); }
158
159 EventList &getSpectrumWithoutInvalidation(const size_t index) override;
160
164 std::vector<std::unique_ptr<EventList>> data;
165
167 mutable std::unique_ptr<EventWorkspaceMRU> mru;
168};
169
171using EventWorkspace_sptr = std::shared_ptr<EventWorkspace>;
173using EventWorkspace_const_sptr = std::shared_ptr<const EventWorkspace>;
174
175} // namespace DataObjects
176} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
This class provides an interface to an EventWorkspace.
Helper class for reporting progress from algorithms.
Definition: Progress.h:25
A class for holding :
Definition: EventList.h:56
This class is intended to fulfill the design specified in <https://github.com/mantidproject/documents...
std::vector< std::unique_ptr< EventList > > data
A vector that holds the event list for each spectrum; the key is the workspace index,...
EventList & getSpectrum(const size_t index) override
Return the underlying ISpectrum ptr at the given workspace index.
const std::string id() const override
Return the workspace typeID.
EventWorkspace & operator=(const EventWorkspace &other)=delete
EventWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
EventWorkspace * doCloneEmpty() const override
Virtual cloneEmpty method.
std::unique_ptr< EventWorkspaceMRU > mru
Container for the MRU lists of the event lists contained.
void sortAllOld(EventSortType sortType, Mantid::API::Progress *prog) const
std::unique_ptr< EventWorkspace > clone() const
Returns a clone of the workspace.
std::unique_ptr< EventWorkspace > cloneEmpty() const
Returns a default-initialized clone of the workspace.
Implements a copy on write data template.
Definition: cow_ptr.h:41
EventType
What kind of event list is being stored.
Definition: IEventList.h:18
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
EventSortType
How the event list is sorted.
Definition: EventList.h:31
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
Definition: MultiThreaded.h:22
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