Skip to content
Snippets Groups Projects
ClearMaskFlag.cpp 1.91 KiB
Newer Older
#include "MantidAlgorithms/ClearMaskFlag.h"

#include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidGeometry/IDetector.h"
#include "MantidGeometry/Instrument.h"
namespace Mantid {
namespace Algorithms {

using namespace API;
using Kernel::Direction;

// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(ClearMaskFlag)

/// Algorithm's name for identification. @see Algorithm::name
const std::string ClearMaskFlag::name() const { return "ClearMaskFlag"; }

/// Algorithm's version for identification. @see Algorithm::version
int ClearMaskFlag::version() const { return 1; }

/// Algorithm's category for identification. @see Algorithm::category
Nick Draper's avatar
Nick Draper committed
const std::string ClearMaskFlag::category() const {
  return "Transforms\\Masking";
}

/** Initialize the algorithm's properties.
 */
void ClearMaskFlag::init() {
  declareProperty(Kernel::make_unique<WorkspaceProperty<>>("Workspace", "",
                                                           Direction::InOut),
                  "Workspace to clear the mask flag of.");
  declareProperty("ComponentName", "",
                  "Specify the instrument component to clear the "
                  "mask. If empty clears the mask flag for "
                  "the whole instrument.");
}

/** Execute the algorithm.
 */
void ClearMaskFlag::exec() {
  MatrixWorkspace_sptr ws = getProperty("Workspace");
  std::string componentName = getPropertyValue("ComponentName");
  auto &detectorInfo = ws->mutableDetectorInfo();
    std::vector<IDetector_const_sptr> detectors;
    ws->getInstrument()->getDetectorsInBank(detectors, componentName);
    for (const auto &det : detectors) {
      auto index = detectorInfo.indexOf(det->getID());
      detectorInfo.setMasked(index, false);
    detectorInfo.clearMaskFlags();

} // namespace Algorithms
} // namespace Mantid