21void
Plus::performBinaryOperation(const HistogramData::Histogram &lhs, const HistogramData::Histogram &
rhs,
22 HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) {
23 std::transform(lhs.y().begin(), lhs.y().end(),
rhs.y().begin(), YOut.begin(), std::plus<>());
29 HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) {
30 using std::placeholders::_1;
31 std::transform(lhs.y().begin(), lhs.y().end(), YOut.begin(), [rhsY](
double l) { return l + rhsY; });
35 double rhsE2 = rhsE * rhsE;
36 std::transform(lhs.e().begin(), lhs.e().end(), EOut.begin(),
37 [rhsE2](
double l) { return std::sqrt(l * l + rhsE2); });
71 "list in an EventWorkspace. Try switching to a Workspace2D before "
88 "cannot add a number to an event list "
89 "in an EventWorkspace. Try switching to "
90 "a Workspace2D before adding.");
136 if (lhs->size() > 1 &&
rhs->size() > 1) {
137 if (lhs->YUnit() !=
rhs->YUnit()) {
138 g_log.
error(
"The two workspaces are not compatible because they have "
139 "different units for the data (Y).");
142 if (lhs->isDistribution() !=
rhs->isDistribution()) {
143 g_log.
error(
"The two workspaces are not compatible because one is "
144 "flagged as a distribution.");
182 if (lhs->getNumberHistograms() ==
rhs->getNumberHistograms()) {
185 return "Number of histograms not identical.";
191 if (
rhs->size() > lhs->size()) {
#define DECLARE_ALGORITHM(classname)
const std::vector< double > & rhs
This class stores information regarding an experimental run as a series of log entries.
bool m_do2D_even_for_SingleColumn_on_rhs
Special case for plus/minus: if there is only one bin on the RHS, use the 2D method (appending event ...
bool m_keepEventWorkspace
Variable set to true if the operation allows the output to stay as an EventWorkspace.
virtual bool checkCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const
Checks the compatibility of the two workspaces.
DataObjects::EventWorkspace_sptr m_eout
Output EventWorkspace.
virtual std::string checkSizeCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const
Checks the overall size compatibility of two workspaces.
bool m_useHistogramForRhsEventWorkspace
Are we going to use the histogram representation of the RHS event list when performing the operation?...
bool m_matchXSize
matchXSize set to true if the X sizes of histograms must match.
bool m_flipSides
flipSides set to true if the rhs and lhs operands should be flipped - for commutative binary operatio...
DataObjects::EventWorkspace_const_sptr m_erhs
Right-hand side EventWorkspace.
DataObjects::EventWorkspace_const_sptr m_elhs
Left-hand side EventWorkspace.
API::MatrixWorkspace_const_sptr m_rhs
Right-hand side workspace.
virtual void checkRequirements()
Check what operation will be needed in order to apply the operation to these two types of workspaces.
API::MatrixWorkspace_const_sptr m_lhs
Left-hand side workspace.
Plus performs the addition of two input workspaces.
void performEventBinaryOperation(DataObjects::EventList &lhs, const DataObjects::EventList &rhs) override
Carries out the binary operation IN-PLACE on a single EventList, with another EventList as the right-...
bool checkUnitCompatibility(const API::MatrixWorkspace_const_sptr &lhs, const API::MatrixWorkspace_const_sptr &rhs) const
Return true if the units and distribution-type of the workspaces make them compatible.
std::string checkSizeCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override
Performs a simple check to see if the sizes of two workspaces are compatible for a binary operation I...
void checkRequirements() override
Check what operation will be needed in order to apply the operation to these two types of workspaces.
void operateOnRun(const API::Run &lhs, const API::Run &rhs, API::Run &ans) const override
Adds the integrated proton currents, proton charges, of the two input workspaces together.
void performBinaryOperation(const HistogramData::Histogram &lhs, const HistogramData::Histogram &rhs, HistogramData::HistogramY &YOut, HistogramData::HistogramE &EOut) override
Carries out the binary operation on a single spectrum, with another spectrum as the right-hand operan...
bool checkCompatibility(const API::MatrixWorkspace_const_sptr lhs, const API::MatrixWorkspace_const_sptr rhs) const override
Check the given workspaces for unit, distribution and binary operation compatibility.
Marks code as not implemented yet.
void error(const std::string &msg)
Logs at error level.
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::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Functor used for computing the sum of the square values of a vector, using the accumulate algorithm.