22Kernel::Logger
g_log(
"WorkspaceFactory");
29 g_log.
debug() <<
"WorkspaceFactory created.\n";
58 size_t XLength,
size_t YLength)
const {
59 bool differentSize(
true);
61 if (NVectors ==
size_t(-1))
62 NVectors = parent->getNumberHistograms();
63 if (XLength ==
size_t(-1))
64 XLength = parent->dataX(0).size();
65 if (YLength ==
size_t(-1)) {
66 differentSize =
false;
67 YLength = parent->blocksize();
72 std::string id(parent->id());
73 if (
id ==
"EventWorkspace")
96 const bool differentSize)
const {
105 if (!differentSize) {
125 for (
size_t i = 0; i < parent.
m_axes.size(); ++i) {
126 if (parent.
m_axes[i]->isSpectra()) {
131 const bool isBinEdge =
dynamic_cast<const BinEdgeAxis *const
>(parent.
m_axes[i].get()) !=
nullptr;
132 const size_t newAxisLength = child.
m_axes[i]->length() + (isBinEdge ? 1 : 0);
133 const size_t oldAxisLength = parent.
m_axes[i]->length();
137 child.
m_axes[i] =
nullptr;
138 if (newAxisLength == oldAxisLength) {
140 child.
m_axes[i] = std::unique_ptr<Axis>(parent.
m_axes[i]->clone(&child));
143 child.
m_axes[i] = std::unique_ptr<Axis>(parent.
m_axes[i]->clone(newAxisLength, &child));
164 const size_t &XLength,
const size_t &YLength)
const {
169 throw std::runtime_error(
"Workspace was not created");
172 ws->initialize(NVectors, XLength, YLength);
180 ws = std::dynamic_pointer_cast<ITableWorkspace>(this->
create(className));
182 throw std::runtime_error(
"Class " + className +
" cannot be cast to ITableWorkspace");
194 ws = std::dynamic_pointer_cast<IPeaksWorkspace>(this->
create(className));
196 throw std::runtime_error(
"Class " + className +
" cannot be cast to IPeaksWorkspace");
Stores numeric values that are assumed to be bin edge values.
void copyExperimentInfoFrom(const ExperimentInfo *other)
Copy everything from the given experiment object.
void copyInfoFrom(const ISpectrum &other)
Copy spectrum number and detector IDs, but not X vector, from another ISpectrum.
Base MatrixWorkspace Abstract Class.
virtual ISpectrum & getSpectrum(const size_t index)=0
Return the underlying ISpectrum ptr at the given workspace index.
std::vector< std::unique_ptr< Axis > > m_axes
A vector of pointers to the axes for this workspace.
bool m_isInitialized
Has this workspace been initialised?
std::string m_YUnit
The unit for the data values (e.g. Counts)
virtual std::size_t getNumberHistograms() const =0
Returns the number of histograms in the workspace.
void setTitle(const std::string &) override
Sets MatrixWorkspace title.
std::map< int64_t, MaskList > m_masks
The set of masked bins in a map keyed on workspace index.
bool isDistribution() const
Are the Y-values dimensioned?
const std::string getTitle() const override
Gets MatrixWorkspace title (same as Run object run_title property)
void setDistribution(bool newValue)
Set the flag for whether the Y-values are dimensioned.
const Indexing::IndexInfo & indexInfo() const
Returns a const reference to the IndexInfo object of the workspace.
void setIndexInfoWithoutISpectrumUpdate(const Indexing::IndexInfo &indexInfo)
Variant of setIndexInfo, used by WorkspaceFactoryImpl.
void setYUnitLabel(const std::string &newLabel)
Sets a new caption for the data (Y axis) in the workspace.
void setYUnit(const std::string &newUnit)
Sets a new unit for the data (Y axis) in the workspace.
std::string m_YUnitLabel
A text label for use when plotting spectra.
void initializeFromParent(const MatrixWorkspace &parent, MatrixWorkspace &child, const bool differentSize) const
Initialize a workspace from its parent This sets values such as title, instrument,...
std::shared_ptr< ITableWorkspace > createTable(const std::string &className="TableWorkspace") const
Create a ITableWorkspace.
WorkspaceFactoryImpl()
Private Constructor for singleton class.
std::shared_ptr< IPeaksWorkspace > createPeaks(const std::string &className="PeaksWorkspace") const
Create a IPeaksWorkspace.
MatrixWorkspace_sptr create(const MatrixWorkspace_const_sptr &parent, size_t NVectors=size_t(-1), size_t XLength=size_t(-1), size_t YLength=size_t(-1)) const
Create a new instance of the same type of workspace as that given as argument.
Base Workspace Abstract Class.
const std::string & getComment() const
Get the workspace comment.
void setComment(const std::string &)
Set the comment field of the workspace.
The dynamic factory is a base dynamic factory for serving up objects in response to requests from oth...
Exception for when an item is not found in a collection.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
Helper class which provides the Collimation Length for SANS instruments.