Newer
Older
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidWorkflowAlgorithms/HFIRSANSNormalise.h"
Federico Montesino Pouzols
committed
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidKernel/ListValidator.h"
#include <boost/algorithm/string.hpp>
Federico Montesino Pouzols
committed
#include "Poco/NumberFormatter.h"
Federico Montesino Pouzols
committed
namespace Mantid {
namespace WorkflowAlgorithms {
using namespace Kernel;
using namespace API;
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(HFIRSANSNormalise)
void HFIRSANSNormalise::init() {
declareProperty(
new WorkspaceProperty<>("InputWorkspace", "", Direction::Input),
"Workspace to be corrected");
std::vector<std::string> normOptions{"Monitor", "Timer"};
this->declareProperty("NormalisationType", "Monitor",
boost::make_shared<StringListValidator>(normOptions),
"Type of Normalisation to use");
declareProperty(
new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output),
"Corrected workspace");
declareProperty("OutputMessage", "", Direction::Output);
MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");
MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace");
std::string normalisation = getProperty("NormalisationType");
// Get the monitor or timer
boost::algorithm::to_lower(normalisation);
double norm_count =
inputWS->run().getPropertyValueAsType<double>(normalisation);
if (boost::iequals(normalisation, "monitor")) {
factor = 1.0e8 / norm_count;
IAlgorithm_sptr scaleAlg = createChildAlgorithm("Scale");
scaleAlg->setProperty("InputWorkspace", inputWS);
scaleAlg->setProperty("OutputWorkspace", outputWS);
scaleAlg->setProperty("Factor", factor);
scaleAlg->setProperty("Operation", "Multiply");
MatrixWorkspace_sptr scaledWS = scaleAlg->getProperty("OutputWorkspace");
setProperty("OutputWorkspace", scaledWS);
setProperty("OutputMessage", "Normalisation by " + normalisation + ": " +
Poco::NumberFormatter::format(norm_count));
}
} // namespace WorkflowAlgorithms
} // namespace Mantid