48 "An input workspace.");
51 "A monitor workspace associated with the input workspace.");
53 "The name for the output workspace.");
54 this->
declareProperty(
"TofRangeOffset", 0.0,
"An addition to the TOF axis for monitor integration.");
63 const std::string reductionManagerName = this->
getProperty(
"ReductionProperties");
64 std::shared_ptr<PropertyManager> reductionManager;
68 throw std::runtime_error(
"DgsPreprocessData cannot run without a reduction PropertyManager.");
72 const std::string doneLog =
"DirectInelasticReductionNormalisedBy";
77 std::string incidentBeamNorm = reductionManager->getProperty(
"IncidentBeamNormalisation");
78 g_log.
notice() <<
"Incident beam norm method = " << incidentBeamNorm <<
'\n';
81 bool normAlreadyDone = inputWS->run().hasProperty(doneLog);
83 if (
"None" != incidentBeamNorm && !normAlreadyDone) {
86 if (
"SNS" == facility) {
87 incidentBeamNorm =
"ByCurrent";
89 const std::string normAlg =
"Normalise" + incidentBeamNorm;
91 norm->setProperty(
"InputWorkspace", inputWS);
92 norm->setProperty(
"OutputWorkspace", outputWS);
93 if (
"ToMonitor" == incidentBeamNorm) {
95 double rangeOffset = this->
getProperty(
"TofRangeOffset");
96 double rangeMin =
getDblPropOrParam(
"MonitorIntRangeLow", reductionManager,
"norm-mon1-min", inputWS);
97 rangeMin += rangeOffset;
99 double rangeMax =
getDblPropOrParam(
"MonitorIntRangeHigh", reductionManager,
"norm-mon1-max", inputWS);
100 rangeMax += rangeOffset;
102 specnum_t monSpec =
static_cast<specnum_t>(inputWS->getInstrument()->getNumberParameter(
"norm-mon1-spec")[0]);
103 if (
"ISIS" == facility) {
104 norm->setProperty(
"MonitorSpectrum", monSpec);
110 throw std::runtime_error(
"SNS instruments require monitor workspaces "
111 "for monitor normalisation.");
113 std::size_t monIndex = monitorWS->getIndexFromSpectrumNumber(monSpec);
114 norm->setProperty(
"MonitorWorkspace", monitorWS);
115 norm->setProperty(
"MonitorWorkspaceIndex", monIndex);
117 norm->setProperty(
"IntegrationRangeMin", rangeMin);
118 norm->setProperty(
"IntegrationRangeMax", rangeMax);
119 norm->setProperty(
"IncludePartialBins",
true);
121 norm->executeAsChildAlg();
123 outputWS = norm->getProperty(
"OutputWorkspace");
126 addLog->setProperty(
"Workspace", outputWS);
127 addLog->setProperty(
"LogName", doneLog);
128 addLog->setProperty(
"LogText", normAlg);
129 addLog->executeAsChildAlg();
131 if (normAlreadyDone) {
132 g_log.
information() <<
"Preprocessing already done on " << inputWS->getName() <<
'\n';
#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.
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.
void information(const std::string &msg)
Logs at information level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
DgsPreprocessData : This algorithm is responsible for normalising the data to current (proton charge)...
int version() const override
Algorithm's version for identification.
const std::string category() const override
Algorithm's category for identification.
void exec() override
Execute the algorithm.
void init() override
Initialize the algorithm's properties.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
int32_t specnum_t
Typedef for a spectrum Number.
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.