15#include <boost/algorithm/string/predicate.hpp>
45 "An input workspace containing the detector vanadium data in TOF units.");
48 "A monitor workspace associated with the input workspace.");
53 "The name for the output workspace.");
61 g_log.
notice() <<
"Starting DgsProcessDetectorVanadium\n";
63 const std::string reductionManagerName = this->
getProperty(
"ReductionProperties");
64 std::shared_ptr<PropertyManager> reductionManager;
68 throw std::runtime_error(
"DgsProcessDetectorVanadium cannot run without a "
69 "reduction PropertyManager.");
78 norm->setProperty(
"InputWorkspace", inputWS);
79 norm->setProperty(
"OutputWorkspace", inputWS);
80 norm->setProperty(
"InputMonitorWorkspace", monWS);
81 norm->executeAsChildAlg();
83 inputWS = norm->getProperty(
"OutputWorkspace");
85 double detVanIntRangeLow =
getDblPropOrParam(
"DetVanIntRangeLow", reductionManager,
"wb-integr-min", inputWS);
87 double detVanIntRangeHigh =
getDblPropOrParam(
"DetVanIntRangeHigh", reductionManager,
"wb-integr-max", inputWS);
89 const std::string detVanIntRangeUnits = reductionManager->getProperty(
"DetVanIntRangeUnits");
91 if (
"TOF" != detVanIntRangeUnits) {
94 cnvun->setProperty(
"InputWorkspace", inputWS);
95 cnvun->setProperty(
"OutputWorkspace", inputWS);
96 cnvun->setProperty(
"Target", detVanIntRangeUnits);
97 cnvun->setProperty(
"EMode",
"Elastic");
98 cnvun->executeAsChildAlg();
99 inputWS = cnvun->getProperty(
"OutputWorkspace");
103 std::vector<double> binning{detVanIntRangeLow, detVanIntRangeHigh - detVanIntRangeLow, detVanIntRangeHigh};
106 rebin->setProperty(
"InputWorkspace", inputWS);
107 rebin->setProperty(
"OutputWorkspace", outputWS);
108 rebin->setProperty(
"PreserveEvents",
false);
109 rebin->setProperty(
"Params", binning);
110 rebin->executeAsChildAlg();
111 outputWS = rebin->getProperty(
"OutputWorkspace");
118 remap->setProperty(
"InputWorkspace", outputWS);
119 remap->setProperty(
"OutputWorkspace", outputWS);
120 remap->setProperty(
"MaskWorkspace", maskWS);
121 remap->executeAsChildAlg();
122 outputWS = remap->getProperty(
"OutputWorkspace");
125 if (
"ISIS" == facility) {
127 double wbScaleFactor = inputWS->getInstrument()->getNumberParameter(
"wb-scale-factor")[0];
128 outputWS *= wbScaleFactor;
131 if (reductionManager->existsProperty(
"SaveProcessedDetVan")) {
132 bool saveProc = reductionManager->getProperty(
"SaveProcessedDetVan");
134 std::string outputFile;
135 if (reductionManager->existsProperty(
"SaveProcDetVanFilename")) {
136 outputFile = reductionManager->getPropertyValue(
"SaveProcDetVanFilename");
138 if (outputFile.empty()) {
140 outputFile +=
".nxs";
144 if (!outputFile.empty() && !boost::starts_with(outputFile,
"ChildAlgOutput") &&
145 !boost::starts_with(outputFile,
"__")) {
147 save->setProperty(
"InputWorkspace", outputWS);
148 save->setProperty(
"FileName", outputFile);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
A property class for workspaces.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
DgsProcessDetectorVanadium : This is the algorithm responsible for processing the detector vanadium i...
void exec() override
Execute the algorithm.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
void init() override
Initialize the algorithm's properties.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
double getDblPropOrParam(const std::string &pmProp, Mantid::Kernel::PropertyManager_sptr &pm, const std::string &instParam, Mantid::API::MatrixWorkspace_sptr &ws, const double overrideValue=Mantid::EMPTY_DBL())
Function to get double property or instrument parameter value.
@ Input
An input workspace.
@ Output
An output workspace.