Skip to content

Commit

Permalink
Re #11619. Added ExtractSpectra algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Apr 24, 2015
1 parent 101f2a2 commit 197abe3
Show file tree
Hide file tree
Showing 5 changed files with 688 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Expand Up @@ -99,6 +99,7 @@ set ( SRC_FILES
src/ExtractMask.cpp
src/ExtractMaskToTable.cpp
src/ExtractSingleSpectrum.cpp
src/ExtractSpectra.cpp
src/FFT.cpp
src/FFTDerivative.cpp
src/FFTSmooth.cpp
Expand Down Expand Up @@ -357,6 +358,7 @@ set ( INC_FILES
inc/MantidAlgorithms/ExtractMask.h
inc/MantidAlgorithms/ExtractMaskToTable.h
inc/MantidAlgorithms/ExtractSingleSpectrum.h
inc/MantidAlgorithms/ExtractSpectra.h
inc/MantidAlgorithms/FFT.h
inc/MantidAlgorithms/FFTDerivative.h
inc/MantidAlgorithms/FFTSmooth.h
Expand Down Expand Up @@ -622,6 +624,7 @@ set ( TEST_FILES
ExtractMaskTest.h
ExtractMaskToTableTest.h
ExtractSingleSpectrumTest.h
ExtractSpectraTest.h
FFTDerivativeTest.h
FFTSmooth2Test.h
FFTTest.h
Expand Down
@@ -0,0 +1,79 @@
#ifndef MANTID_ALGORITHMS_EXTRACTSPECTRA_H_
#define MANTID_ALGORITHMS_EXTRACTSPECTRA_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/EventWorkspace.h"

namespace Mantid {
namespace Algorithms {

/** Extracts specified spectra from a workspace and places them in a new
workspace.
Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ExtractSpectra : public API::Algorithm {
public:
ExtractSpectra();
virtual ~ExtractSpectra();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;

private:
void init();
void exec();
void execEvent();

void checkProperties();
std::size_t getXMin(const int wsIndex = 0);
std::size_t getXMax(const int wsIndex = 0);
void cropRagged(API::MatrixWorkspace_sptr outputWorkspace, int inIndex,
int outIndex);

/// The input workspace
API::MatrixWorkspace_sptr m_inputWorkspace;
DataObjects::EventWorkspace_sptr eventW;
/// The bin index to start the cropped workspace from
std::size_t m_minX;
/// The bin index to end the cropped workspace at
std::size_t m_maxX;
/// The spectrum index to start the cropped workspace from
specid_t m_minSpec;
/// The spectrum index to end the cropped workspace at
specid_t m_maxSpec;
/// Flag indicating whether the input workspace has common boundaries
bool m_commonBoundaries;
/// Flag indicating whether we're dealing with histogram data
bool m_histogram;
/// Flag indicating whether XMin and/or XMax has been set
bool m_croppingInX;
};

} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHMS_EXTRACTSPECTRA_H_ */

0 comments on commit 197abe3

Please sign in to comment.