17using namespace Kernel;
25 "Workspace to be corrected");
27 "Workspace containing the monitor counts for the sample data");
29 std::vector<std::string> exts{
"_event.nxs",
".nxs",
".nxs.h5"};
30 declareProperty(std::make_unique<API::FileProperty>(
"ReferenceFluxFilename",
"",
API::FileProperty::Load, exts),
31 "File containing the reference flux spectrum.");
33 declareProperty(
"ReductionProperties",
"__sans_reduction_properties",
Direction::Input);
35 "Corrected workspace.");
40 Progress progress(
this, 0.0, 1.0, 10);
41 progress.
report(
"Setting up beam flux correction");
49 auto algProp = std::make_unique<AlgorithmProperty>(
"BeamFluxAlgorithm");
50 algProp->setValue(toString());
58 progress.
report(
"Loading reference data");
62 progress.
report(
"Rebinning reference data");
64 convAlg->setProperty(
"InputWorkspace", fluxRefWS);
65 convAlg->executeAsChildAlg();
66 fluxRefWS = convAlg->getProperty(
"OutputWorkspace");
69 rebinAlg->setProperty(
"WorkspaceToRebin", fluxRefWS);
70 rebinAlg->setProperty(
"WorkspaceToMatch", inputWS);
71 rebinAlg->executeAsChildAlg();
74 progress.
report(
"Rebinning monitor data");
76 rebinAlg->setProperty(
"WorkspaceToRebin", monitorWS);
77 rebinAlg->setProperty(
"WorkspaceToMatch", inputWS);
78 rebinAlg->executeAsChildAlg();
79 monitorWS = rebinAlg->getProperty(
"OutputWorkspace");
81 progress.
report(
"Correcting input data");
86 divideAlg->setProperty(
"LHSWorkspace", inputWS);
87 divideAlg->setProperty(
"RHSWorkspace", monitorWS);
88 divideAlg->executeAsChildAlg();
92 divideAlg->setProperty(
"LHSWorkspace", outputWS);
93 divideAlg->setProperty(
"RHSWorkspace", scaledfluxRefWS);
94 divideAlg->executeAsChildAlg();
95 outputWS = divideAlg->getProperty(
"OutputWorkspace");
96 setProperty(
"OutputWorkspace", outputWS);
97 setProperty(
"OutputMessage",
"Flux correction applied\n" +
m_output_message);
106 const std::string referenceFluxFile =
getPropertyValue(
"ReferenceFluxFilename");
107 Poco::Path path(referenceFluxFile);
108 const std::string entryName =
"SANSBeamFluxCorrection_" + path.getBaseName();
109 std::string fluxRefWSName =
"__beam_flux_reference_" + path.getBaseName();
118 loadAlg->setProperty(
"Filename", referenceFluxFile);
119 loadAlg->executeAsChildAlg();
121 fluxRefWS = std::dynamic_pointer_cast<MatrixWorkspace>(tmpWS);
#define DECLARE_ALGORITHM(classname)
@ Load
allowed here which will be passed to the algorithm
std::shared_ptr< Kernel::PropertyManager > getProcessProperties(const std::string &propertyManager=std::string()) const
Get the property manager object of a given name from the property manager data service,...
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) override
Create a Child Algorithm.
Kernel::IPropertyManager::TypedValue getProperty(const std::string &name) const override
Get the property held by this object.
std::string getPropertyValue(const std::string &name) const override
Get the property held by this object.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Performs beam flux correction on TOF SANS data.
std::string m_output_message
void exec() override
Execution code.
std::shared_ptr< Kernel::PropertyManager > m_reductionManager
API::MatrixWorkspace_sptr loadReference()
It's assumed that both the flux reference files are simple Nexus files since they have to produced by...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ InOut
Both an input & output workspace.
@ Input
An input workspace.
@ Output
An output workspace.