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"
14#include <boost/date_time/posix_time/posix_time.hpp>
15#include <string>
16
17namespace Mantid {
18namespace API {
19class Progress;
20}
21
22namespace DataObjects {
23class EventWorkspaceMRU;
24
32class MANTID_DATAOBJECTS_DLL EventWorkspace : public API::IEventWorkspace {
33
34public:
35 // The name of the workspace type.
36 const std::string id() const override { return "EventWorkspace"; }
37
38 // Constructor
40
41 // Destructor
42 ~EventWorkspace() override;
43
45 std::unique_ptr<EventWorkspace> clone() const { return std::unique_ptr<EventWorkspace>(doClone()); }
46
48 std::unique_ptr<EventWorkspace> cloneEmpty() const { return std::unique_ptr<EventWorkspace>(doCloneEmpty()); }
49
50 // Initialize the pixels
51 void init(const std::size_t &, const std::size_t &, const std::size_t &) override;
52 void init(const HistogramData::Histogram &histogram) override;
53
54 bool threadSafe() const override;
55
56 //------------------------------------------------------------
57
59 bool isRaggedWorkspace() const override;
60
61 // Returns the number of single indexable items in the workspace
62 std::size_t size() const override;
63
64 // Get the blocksize, aka the number of bins in the histogram
65 std::size_t blocksize() const override;
67 std::size_t getNumberBins(const std::size_t &index) const override;
69 std::size_t getMaxNumberBins() const override;
70
71 // Get the number of histograms. aka the number of pixels or detectors.
72 std::size_t getNumberHistograms() const override;
73
74 size_t getMemorySize() const override;
75
76 EventList &getSpectrum(const size_t index) override {
77 invalidateCommonBinsFlag();
78 return getSpectrumWithoutInvalidation(index);
79 }
80 const EventList &getSpectrum(const size_t index) const override;
81 EventList *getSpectrumUnsafe(const size_t index);
82
83 //------------------------------------------------------------
84
85 double getTofMin() const override;
86
87 double getTofMax() const override;
88
89 Mantid::Types::Core::DateAndTime getPulseTimeMin() const override;
90 Mantid::Types::Core::DateAndTime getPulseTimeMax() const override;
91 void getPulseTimeMinMax(Mantid::Types::Core::DateAndTime &xmin, Mantid::Types::Core::DateAndTime &xmax) const;
92
93 Mantid::Types::Core::DateAndTime getTimeAtSampleMin(double tofOffset = 0) const override;
94
95 Mantid::Types::Core::DateAndTime getTimeAtSampleMax(double tofOffset = 0) const override;
96
97 double getEventXMin() const;
98 double getEventXMax() const;
99 void getEventXMinMax(double &xmin, double &xmax) const;
100
101 [[deprecated("use mutableX() instead")]]
102 MantidVec &dataX(const std::size_t) override;
103 [[deprecated("use mutableY() instead")]]
104 MantidVec &dataY(const std::size_t) override;
105 [[deprecated("use mutableE() instead")]]
106 MantidVec &dataE(const std::size_t) override;
107 [[deprecated("use mutableDx() instead")]]
108 MantidVec &dataDx(const std::size_t) override;
109 [[deprecated("use x() instead")]]
110 const MantidVec &dataX(const std::size_t) const override;
111 [[deprecated("use y() instead")]]
112 const MantidVec &dataY(const std::size_t) const override;
113 [[deprecated("use e() instead")]]
114 const MantidVec &dataE(const std::size_t) const override;
115 [[deprecated("use dx() instead")]]
116 const MantidVec &dataDx(const std::size_t) const override;
117 [[deprecated("use sharedX() instead")]]
118 Kernel::cow_ptr<HistogramData::HistogramX> refX(const std::size_t) const override;
119
121 void generateHistogram(const std::size_t index, std::span<double const> X, MantidVec &Y, MantidVec &E,
122 bool skipError = false) const override;
123
125 void generateHistogramPulseTime(const std::size_t index, std::span<double const> X, MantidVec &Y, MantidVec &E,
126 bool skipError = false) const;
127
128 // Set the x-axis data (histogram bins) for all pixels
129 void setAllX(const HistogramData::BinEdges &x) override;
130
131 // Update all X values to fit around all events
132 void resetAllXToSingleBin() override;
133
134 // The total number of events across all of the spectra.
135 std::size_t getNumberEvents() const override;
136
137 // Type of the events
138 Mantid::API::EventType getEventType() const override;
139
140 // Change the event type
141 void switchEventType(const Mantid::API::EventType type);
142
143 // Returns true always - an EventWorkspace always represents histogramm-able
144 // data
145 bool isHistogramData() const override;
146
147 std::size_t MRUSize() const;
148
149 void clearMRU() const override;
150
151 EventSortType getSortType() const;
152
153 // Sort all event lists. Uses a parallelized algorithm
154 void sortAll(EventSortType sortType, Mantid::API::Progress *prog) const;
155
156 void getIntegratedSpectra(std::vector<double> &out, const double minX, const double maxX,
157 const bool entireRange) const override;
158 EventWorkspace &operator=(const EventWorkspace &other) = delete;
159
160protected:
162 EventWorkspace(const EventWorkspace &other);
163
164private:
165 EventWorkspace *doClone() const override { return new EventWorkspace(*this); }
166 EventWorkspace *doCloneEmpty() const override { return new EventWorkspace(); }
167
168 EventList &getSpectrumWithoutInvalidation(const size_t index) override;
169
173 std::vector<std::unique_ptr<EventList>> data;
174
176 mutable std::unique_ptr<EventWorkspaceMRU> mru;
177};
178
180using EventWorkspace_sptr = std::shared_ptr<EventWorkspace>;
182using EventWorkspace_const_sptr = std::shared_ptr<const EventWorkspace>;
183
184} // namespace DataObjects
185} // namespace Mantid
186
187// Instantiated and exported by DataObjects/src/PropertyWithValue.cpp
189 Mantid::Kernel::PropertyWithValue<std::shared_ptr<Mantid::DataObjects::EventWorkspace>>);
190
191#ifndef DataObjects_EXPORTS
193namespace Mantid::API {
195extern template class MANTID_DATAOBJECTS_DLL WorkspaceProperty<DataObjects::EventWorkspace>;
197} // namespace Mantid::API
198#endif
MANTID_DATAOBJECTS_EXTERN_TEMPLATE(Mantid::Kernel::PropertyWithValue< std::shared_ptr< Mantid::DataObjects::EventWorkspace > >)
std::map< DeltaEMode::Type, std::string > index
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:57
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.
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.
The concrete, templated class for properties.
Implements a copy on write data template.
Definition cow_ptr.h:41
EventType
What kind of event list is being stored.
Definition IEventList.h:19
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
EventSortType
How the event list is sorted.
Definition EventList.h:32
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.
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