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
13#include "MantidAPI/TextAxis.h"
15#include "MantidHistogramData/BinEdges.h"
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);
58createWorkspaceWithIndirectInstrumentAndParameters(std::string const &analyser = "graphite");
59
63
64 template <typename T> SetUpADSWithWorkspace(std::string const &inputWSName, T const &workspace) {
65 Mantid::API::AnalysisDataService::Instance().addOrReplace(inputWSName, workspace);
66 }
67
68 template <typename T> void addOrReplace(std::string const &workspaceName, T const &workspace) {
69 Mantid::API::AnalysisDataService::Instance().addOrReplace(workspaceName, workspace);
70 }
71
72 bool doesExist(std::string const &workspaceName) {
73 return Mantid::API::AnalysisDataService::Instance().doesExist(workspaceName);
74 }
75
76 Mantid::API::MatrixWorkspace_sptr retrieveWorkspace(std::string const &workspaceName) {
77 return std::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
78 Mantid::API::AnalysisDataService::Instance().retrieve(workspaceName));
79 }
80};
81
83struct AreSpectraEqual : public boost::static_visitor<bool> {
84
85 template <typename T, typename U> bool operator()(const T &, const U &) const {
86 return false; // cannot compare different types
87 }
88
89 template <typename T> bool operator()(const T &lhs, const T &rhs) const { return lhs == rhs; }
90};
91
92} // namespace IndirectFitDataCreationHelper
93} // namespace Mantid
const std::vector< double > & rhs
IPeaksWorkspace_sptr workspace
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
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 createWorkspaceWithIndirectInstrumentAndParameters(std::string const &analyser="graphite")
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)