Mantid
Loading...
Searching...
No Matches
MuonGroupCountsCalculator.cpp
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 +
8
10
12
13//----------------------------------------------------------------------------------------------
23 const std::vector<int> &summedPeriods,
24 const std::vector<int> &subtractedPeriods, const int groupIndex)
25 : MuonGroupCalculator(inputWS, summedPeriods, subtractedPeriods, groupIndex) {}
26
33 int numPeriods = m_inputWS->getNumberOfEntries();
34 if (numPeriods > 1) {
35 // Several periods supplied
37 if (!m_subtractedPeriods.empty()) {
39 tempWS = subtractWorkspaces(tempWS, toSubtractWS);
40 }
41 outWS = extractSpectrum(tempWS, m_groupIndex);
42 } else {
43 // Only one period supplied
44 outWS = extractSpectrum(m_inputWS->getItem(0), m_groupIndex);
45 }
46 return outWS;
47}
48
49} // namespace Mantid::WorkflowAlgorithms
API::MatrixWorkspace_sptr subtractWorkspaces(const API::MatrixWorkspace_sptr &lhs, const API::MatrixWorkspace_sptr &rhs) const
Subtracts one workspace from another (lhs - rhs)
const API::WorkspaceGroup_sptr m_inputWS
Input workspace.
const std::vector< int > m_subtractedPeriods
List of subtracted periods.
API::MatrixWorkspace_sptr sumPeriods(const std::vector< int > &periodsToSum) const
Sums the specified periods in the input workspace group.
API::MatrixWorkspace_sptr extractSpectrum(const API::Workspace_sptr &inputWS, const int index) const
Extracts a single spectrum from a workspace.
const std::vector< int > m_summedPeriods
List of summed periods.
MuonGroupCalculator : Base class for Muon group counts/asymmetry calculators.
const int m_groupIndex
Workspace index of the group to analyse.
Mantid::API::MatrixWorkspace_sptr calculate() const override
Performs group counts calculation.
MuonGroupCountsCalculator(const Mantid::API::WorkspaceGroup_sptr &inputWS, const std::vector< int > &summedPeriods, const std::vector< int > &subtractedPeriods, const int groupIndex)
Constructor.
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class