Mantid
Loading...
Searching...
No Matches
IndirectFitDataCreationHelper.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
12#include "MantidAPI/TextAxis.h"
14#include "MantidHistogramData/BinEdges.h"
15
16#include <string>
17
18#include <boost/variant.hpp>
19#include <boost/variant/apply_visitor.hpp>
20#include <boost/variant/static_visitor.hpp>
21
22namespace Mantid {
23namespace IndirectFitDataCreationHelper {
25int const START_X_COLUMN(2);
26int const END_X_COLUMN(3);
28
30Mantid::API::MatrixWorkspace_sptr createWorkspace(int const &numberOfSpectra, int const &numberOfBins = 10);
31Mantid::API::MatrixWorkspace_sptr createInstrumentWorkspace(int const &xLength, int const &yLength);
33 std::vector<std::string> const &labels,
34 int const &numberOfBins = 10);
36 std::vector<double> const &labels,
37 int const &numberOfBins = 10);
38Mantid::API::WorkspaceGroup_sptr createGroupWorkspace(std::size_t const &numberOfWorkspaces, int const &numberOfSpectra,
39 int const &numberOfBins = 10);
40Mantid::API::WorkspaceGroup_sptr createGroupWorkspaceWithTextAxes(std::size_t const &numberOfWorkspaces,
41 std::vector<std::string> const &labels,
42 int const &numberOfSpectra,
43 int const &numberOfBins = 10);
44
45Mantid::API::TextAxis *getTextAxis(int const &numberOfSpectra, std::vector<std::string> const &labels);
46Mantid::API::NumericAxis *getNumericAxis(int const &numberOfLabels, std::vector<double> const &values);
47
50 Mantid::HistogramData::BinEdges const &binEdges);
52 int const &yLength);
54 int const &xLength, int const &yLength);
55Mantid::API::MatrixWorkspace_sptr createWorkspaceWithInstrument(int const &xLength, int const &yLength);
57
61
62 template <typename T> SetUpADSWithWorkspace(std::string const &inputWSName, T const &workspace) {
63 Mantid::API::AnalysisDataService::Instance().addOrReplace(inputWSName, workspace);
64 }
65
66 template <typename T> void addOrReplace(std::string const &workspaceName, T const &workspace) {
67 Mantid::API::AnalysisDataService::Instance().addOrReplace(workspaceName, workspace);
68 }
69
70 bool doesExist(std::string const &workspaceName) {
71 return Mantid::API::AnalysisDataService::Instance().doesExist(workspaceName);
72 }
73
74 Mantid::API::MatrixWorkspace_sptr retrieveWorkspace(std::string const &workspaceName) {
75 return std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
76 Mantid::API::AnalysisDataService::Instance().retrieve(workspaceName));
77 }
78};
79
81struct AreSpectraEqual : public boost::static_visitor<bool> {
82
83 template <typename T, typename U> bool operator()(const T &, const U &) const {
84 return false; // cannot compare different types
85 }
86
87 template <typename T> bool operator()(const T &lhs, const T &rhs) const { return lhs == rhs; }
88};
89
90} // namespace IndirectFitDataCreationHelper
91} // namespace Mantid
const std::vector< double > & rhs
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
Class to represent a numeric axis of a workspace.
Definition: NumericAxis.h:29
Class to represent a text axis of a workspace.
Definition: TextAxis.h:36
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< T > createWorkspace(InitArgs... args)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
Mantid::API::MatrixWorkspace_sptr createWorkspaceWithInstrument(int const &xLength, int const &yLength)
Mantid::API::NumericAxis * getNumericAxis(int const &numberOfLabels, std::vector< double > const &values)
Mantid::API::MatrixWorkspace_sptr setWorkspaceProperties(Mantid::API::MatrixWorkspace_sptr workspace, int const &xLength, int const &yLength)
Mantid::API::MatrixWorkspace_sptr createWorkspaceWithTextAxis(int const &numberOfSpectra, std::vector< std::string > const &labels, int const &numberOfBins=10)
Mantid::API::MatrixWorkspace_sptr setWorkspaceEFixed(Mantid::API::MatrixWorkspace_sptr workspace, int const &xLength)
Mantid::API::MatrixWorkspace_sptr setWorkspaceBinEdges(Mantid::API::MatrixWorkspace_sptr workspace, int const &yLength, Mantid::HistogramData::BinEdges const &binEdges)
Mantid::API::MatrixWorkspace_sptr createInstrumentWorkspace(int const &xLength, int const &yLength)
Mantid::API::WorkspaceGroup_sptr createGroupWorkspaceWithTextAxes(std::size_t const &numberOfWorkspaces, std::vector< std::string > const &labels, int const &numberOfSpectra, int const &numberOfBins=10)
Mantid::API::MatrixWorkspace_sptr createWorkspaceWithBinValues(int const &numberOfSpectra, std::vector< double > const &labels, int const &numberOfBins=10)
Mantid::API::MatrixWorkspace_sptr createWorkspaceWithInelasticInstrument(int const &yLength)
Mantid::API::WorkspaceGroup_sptr createGroupWorkspace(std::size_t const &numberOfWorkspaces, int const &numberOfSpectra, int const &numberOfBins=10)
Mantid::API::TextAxis * getTextAxis(int const &numberOfSpectra, std::vector< std::string > const &labels)
int const START_X_COLUMN(2)
Commonly used constant variables.
Helper class which provides the Collimation Length for SANS instruments.
This is used to compare Spectra which is implemented as a boost::variant.
Simple struct used to access features of the ADS No destructor so ensure you tearDown the ADS.
Mantid::API::MatrixWorkspace_sptr retrieveWorkspace(std::string const &workspaceName)
void addOrReplace(std::string const &workspaceName, T const &workspace)
SetUpADSWithWorkspace(std::string const &inputWSName, T const &workspace)