Mantid
Loading...
Searching...
No Matches
CompareWorkspaces.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 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
11#include "MantidAlgorithms/DllConfig.h"
15
16namespace Mantid {
17namespace Algorithms {
18
60class MANTID_ALGORITHMS_DLL CompareWorkspaces final : public API::Algorithm {
61public:
63 const std::string name() const override { return "CompareWorkspaces"; }
64
66 int version() const override { return 1; }
67 const std::vector<std::string> seeAlso() const override { return {"CompareSampleLogs", "CloneWorkspace"}; }
68
70 const std::string category() const override { return "Utility\\Workspaces"; }
71
73 const std::string summary() const override {
74 return "Compares two workspaces for equality. This algorithm is mainly "
75 "intended for use by the Mantid development team as part of the "
76 "testing process.";
77 }
78
79 static bool withinAbsoluteTolerance(double x1, double x2, double atol, bool const nanEqual = false);
80 static bool withinRelativeTolerance(double x1, double x2, double rtol, bool const nanEqual = false);
81
82private:
84 void init() override;
85
87 void exec() override;
88
91 bool processGroups() override;
92
94 void processGroups(const std::shared_ptr<const API::WorkspaceGroup> &groupOne,
95 const std::shared_ptr<const API::WorkspaceGroup> &groupTwo);
96
97 void doComparison();
98
100 void doLeanElasticPeaksComparison(const DataObjects::LeanElasticPeaksWorkspace_sptr &tws1,
102 void doTableComparison(const API::ITableWorkspace_const_sptr &tws1, const API::ITableWorkspace_const_sptr &tws2);
103 void doMDComparison(const API::Workspace_sptr &w1, const API::Workspace_sptr &w2);
104 bool compareEventWorkspaces(const DataObjects::EventWorkspace &ews1, const DataObjects::EventWorkspace &ews2);
105 bool checkData(const API::MatrixWorkspace_const_sptr &ws1, const API::MatrixWorkspace_const_sptr &ws2);
106 bool checkAxes(const API::MatrixWorkspace_const_sptr &ws1, const API::MatrixWorkspace_const_sptr &ws2);
107 bool checkSpectraMap(const API::MatrixWorkspace_const_sptr &ws1, const API::MatrixWorkspace_const_sptr &ws2);
108 bool checkInstrument(const API::MatrixWorkspace_const_sptr &ws1, const API::MatrixWorkspace_const_sptr &ws2);
109 bool checkMasking(const API::MatrixWorkspace_const_sptr &ws1, const API::MatrixWorkspace_const_sptr &ws2);
110 bool checkSample(const API::Sample &sample1, const API::Sample &sample2);
111 bool checkRunProperties(const API::Run &run1, const API::Run &run2);
112
114 int compareEventsListInDetails(const DataObjects::EventList &el1, const DataObjects::EventList &el2, double tolTof,
115 double tolWeight, int64_t tolPulse, bool printdetails, size_t &numdiffpulse,
116 size_t &numdifftof, size_t &numdiffboth, size_t &numdiffweight) const;
117
119 void recordMismatch(const std::string &msg, std::string ws1 = "", std::string ws2 = "");
120
122 bool m_result{false};
123
125 std::function<bool(const double, const double)> m_compare;
126
129
131 std::unique_ptr<API::Progress> m_progress = nullptr;
132
138 bool m_parallelComparison{false};
139};
140
141} // namespace Algorithms
142} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
This class stores information regarding an experimental run as a series of log entries.
Definition Run.h:35
This class stores information about the sample used in particular run.
Definition Sample.h:33
Compares two workspaces for equality.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
API::ITableWorkspace_sptr m_messages
Mismatch messages that resulted from comparison.
std::function< bool(const double, const double)> m_compare
The comparison method to use (true if equal, false otherwise)
const std::string name() const override
Algorithm's name.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
A class for holding :
Definition EventList.h:57
This class is intended to fulfill the design specified in <https://github.com/mantidproject/documents...
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< const ITableWorkspace > ITableWorkspace_const_sptr
shared pointer to Mantid::API::ITableWorkspace (const version)
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< LeanElasticPeaksWorkspace > LeanElasticPeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
Helper class which provides the Collimation Length for SANS instruments.