19using namespace Kernel;
27 "Workspace to be corrected");
29 "Workspace containing the monitor counts for the sample data");
31 std::vector<std::string> exts{
"_event.nxs",
".nxs",
".nxs.h5"};
32 declareProperty(std::make_unique<API::FileProperty>(
"ReferenceFluxFilename",
"",
API::FileProperty::Load, exts),
33 "File containing the reference flux spectrum.");
35 declareProperty(
"ReductionProperties",
"__sans_reduction_properties",
Direction::Input);
37 "Corrected workspace.");
42 Progress progress(
this, 0.0, 1.0, 10);
43 progress.
report(
"Setting up beam flux correction");
51 auto algProp = std::make_unique<AlgorithmProperty>(
"BeamFluxAlgorithm");
60 progress.
report(
"Loading reference data");
64 progress.
report(
"Rebinning reference data");
66 convAlg->setProperty(
"InputWorkspace", fluxRefWS);
67 convAlg->executeAsChildAlg();
68 fluxRefWS = convAlg->getProperty(
"OutputWorkspace");
71 rebinAlg->setProperty(
"WorkspaceToRebin", fluxRefWS);
72 rebinAlg->setProperty(
"WorkspaceToMatch", inputWS);
73 rebinAlg->executeAsChildAlg();
76 progress.
report(
"Rebinning monitor data");
78 rebinAlg->setProperty(
"WorkspaceToRebin", monitorWS);
79 rebinAlg->setProperty(
"WorkspaceToMatch", inputWS);
80 rebinAlg->executeAsChildAlg();
81 monitorWS = rebinAlg->getProperty(
"OutputWorkspace");
83 progress.
report(
"Correcting input data");
88 divideAlg->setProperty(
"LHSWorkspace", inputWS);
89 divideAlg->setProperty(
"RHSWorkspace", monitorWS);
90 divideAlg->executeAsChildAlg();
94 divideAlg->setProperty(
"LHSWorkspace", outputWS);
95 divideAlg->setProperty(
"RHSWorkspace", scaledfluxRefWS);
96 divideAlg->executeAsChildAlg();
97 outputWS = divideAlg->getProperty(
"OutputWorkspace");
98 setProperty(
"OutputWorkspace", outputWS);
99 setProperty(
"OutputMessage",
"Flux correction applied\n" +
m_output_message);
108 const std::string referenceFluxFile =
getPropertyValue(
"ReferenceFluxFilename");
109 std::filesystem::path path(referenceFluxFile);
110 const std::string entryName =
"SANSBeamFluxCorrection_" + path.stem().string();
111 std::string fluxRefWSName =
"__beam_flux_reference_" + path.stem().string();
120 loadAlg->setProperty(
"Filename", referenceFluxFile);
121 loadAlg->executeAsChildAlg();
123 fluxRefWS = std::dynamic_pointer_cast<MatrixWorkspace>(tmpWS);
127 AnalysisDataService::Instance().addOrReplace(fluxRefWSName, fluxRefWS);
#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.
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
std::string toString(const T &value)
Convert values to strings.
@ InOut
Both an input & output workspace.
@ Input
An input workspace.
@ Output
An output workspace.