18using namespace Kernel;
20using namespace DataObjects;
29 "The name of the first input workspace");
31 "The name of the second input workspace");
33 "Verify that the supplied data do not overlap");
35 "The label to set the Y axis to");
37 "The unit to set the Y axis to");
39 "If true, the algorithm will check that the two input workspaces have matching bins.");
56 if (((eventWs1) && (!eventWs2)) || ((!eventWs1) && (eventWs2))) {
57 const std::string message(
"Only one of the input workspaces are of type "
58 "EventWorkspace; please use matching workspace "
59 "types (both EventWorkspace or both "
62 throw std::invalid_argument(message);
68 const std::string message(
"The bins do not match in the input workspaces. "
69 "Consider using RebinToWorkspace to preprocess "
70 "the workspaces before conjoining them.");
72 throw std::invalid_argument(message);
75 if (eventWs1 && eventWs2) {
100 if (ws1->isRaggedWorkspace() || ws2->isRaggedWorkspace()) {
120 bool checkSpectra)
const {
123 std::set<specnum_t> spectra;
124 std::set<detid_t> detectors;
126 for (
size_t i = 0; i < nhist1; ++i) {
129 spectra.insert(spectrum);
130 const auto &dets = spec.getDetectorIDs();
131 for (
auto const &det : dets) {
132 detectors.insert(det);
139 for (
size_t j = 0; j < nhist2; ++j) {
143 if (spectrum > 0 && spectra.find(spectrum) != spectra.end()) {
144 g_log.
error() <<
"The input workspaces have overlapping spectrum numbers " << spectrum <<
"\n";
145 throw std::invalid_argument(
"The input workspaces have overlapping spectrum numbers");
148 const auto &dets = spec.getDetectorIDs();
149 const auto it = std::find_if(dets.cbegin(), dets.cend(),
150 [&detectors](
const auto &det) { return detectors.find(det) != detectors.cend(); });
151 if (it != dets.cend()) {
152 g_log.
error() <<
"The input workspaces have common detectors: " << (*it) << std::endl;
153 throw std::invalid_argument(
"The input workspaces have common detectors");
179 output->history().addHistory(ws1.
getHistory());
203 output->history().addHistory(ws1.
getHistory());
258 AnalysisDataService::Instance().remove(
getPropertyValue(
"InputWorkspace2"));
#define DECLARE_ALGORITHM(classname)
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual bool processGroups()
Process WorkspaceGroup inputs.
specnum_t getSpectrumNo() const
void setSpectrumNo(specnum_t num)
Sets the spectrum number of this spectrum.
Base MatrixWorkspace Abstract Class.
virtual ISpectrum & getSpectrum(const size_t index)=0
Return the underlying ISpectrum ptr at the given workspace index.
virtual std::size_t getNumberHistograms() const =0
Returns the number of histograms in the workspace.
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.
A property class for workspaces.
const WorkspaceHistory & getHistory() const
Returns a reference to the WorkspaceHistory const.
Joins two partial, non-overlapping workspaces into one.
void checkForOverlap(const API::MatrixWorkspace &ws1, const API::MatrixWorkspace &ws2, bool checkSpectra) const
Checks that the two input workspaces have non-overlapping spectra numbers and contributing detectors.
bool processGroups() override
Appends the removal of the empty group after execution to the Algorithm::processGroups() method.
void exec() override
Executes the algorithm.
void fixSpectrumNumbers(const API::MatrixWorkspace &ws1, const API::MatrixWorkspace &ws2, API::MatrixWorkspace &output) override
Abstract method to be implemented in concrete algorithm classes.
bool m_overlapChecked
True if spectra overlap.
API::MatrixWorkspace_sptr conjoinHistograms(const API::MatrixWorkspace &ws1, const API::MatrixWorkspace &ws2)
Conjoin two histogram workspaces together, including the history.
void setYUnitAndLabel(API::MatrixWorkspace &ws) const
API::MatrixWorkspace_sptr conjoinEvents(const DataObjects::EventWorkspace &ws1, const DataObjects::EventWorkspace &ws2)
Conjoin two event workspaces together, including the history.
bool checkBinning(const API::MatrixWorkspace_const_sptr &ws1, const API::MatrixWorkspace_const_sptr &ws2) const
Checks whether the binning is consistent between two workspaces.
void checkCompatibility(const API::MatrixWorkspace &ws1, const API::MatrixWorkspace &ws2)
Checks that the two input workspace have the same instrument, unit and distribution flag.
DataObjects::EventWorkspace_sptr execEvent(const DataObjects::EventWorkspace &eventWs1, const DataObjects::EventWorkspace &eventWs2)
Executes the algorithm for event workspace inputs.
void getMinMax(const API::MatrixWorkspace &ws, specnum_t &min, specnum_t &max)
Determine the minimum and maximum spectra ids.
API::MatrixWorkspace_sptr execWS2D(const API::MatrixWorkspace &ws1, const API::MatrixWorkspace &ws2)
Executes the algorithm for histogram workspace inputs.
This class is intended to fulfill the design specified in <https://github.com/mantidproject/documents...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
The concrete, templated class for properties.
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
Kernel::Logger g_log("DetermineSpinStateOrder")
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
int32_t specnum_t
Typedef for a spectrum Number.
static bool matchingBins(const std::shared_ptr< const MatrixWorkspace > &ws1, const std::shared_ptr< const MatrixWorkspace > &ws2, const bool firstOnly=false)
Checks whether the bins (X values) of two workspace are the same.
@ InOut
Both an input & output workspace.
@ Input
An input workspace.