20auto constexpr MISSING_Y_VALUE = 1.0;
23std::string
const FLOOD_WORKSPACE(
"FloodWorkspace");
36 for (
size_t i = 0; i < nSpec; ++i) {
37 eventWS->getSpectrum(i).switchTo(EventType::WEIGHTED);
47 auto const &floodBlockSize = flood->blocksize();
49 for (
auto i = 0;
auto const &specNum : indexList) {
51 flood->mutableY(i).assign(floodBlockSize, MISSING_Y_VALUE);
66 const std::vector<int64_t> &indexList) {
68 auto const floodBlocksize = flood->blocksize();
69 const ISpectrum *missingSpectrum =
nullptr;
70 for (
size_t i = 0; i < indexList.size(); ++i) {
71 auto const j = (indexList)[i];
73 if (missingSpectrum) {
76 newFlood->mutableY(i).assign(floodBlocksize, MISSING_Y_VALUE);
77 newFlood->mutableE(i).assign(floodBlocksize, 0.0);
78 missingSpectrum = &newFlood->getSpectrum(i);
81 newFlood->getSpectrum(i).
copyDataFrom(flood->getSpectrum(j));
96 return "Algorithm to apply a flood correction to a workspace.";
102 return {
"ReflectometryReductionOneAuto",
"CreateFloodWorkspace"};
110 "The workspace to correct.");
113 "The flood workspace.");
116 "The corrected workspace.");
123 auto indexTable = std::make_shared<std::vector<int64_t>>();
124 if (input->size() != flood->size()) {
126 flood = makeEqualSizes(input, flood, *indexTable);
129 auto const inputXUnitId = input->getAxis(0)->unit()->unitID();
130 bool const doConvertUnits = ((flood->getAxis(0)->unit()->unitID() != inputXUnitId) && (inputXUnitId !=
"Empty"));
131 bool const doRebin = flood->blocksize() > 1;
134 if (doConvertUnits) {
136 convert->setProperty(
"InputWorkspace", flood);
137 convert->setProperty(
"Target", inputXUnitId);
138 convert->setProperty(
"OutputWorkspace",
"dummy");
140 flood = convert->getProperty(
"OutputWorkspace");
143 rebin->setProperty(
"WorkspaceToRebin", flood);
144 rebin->setProperty(
"WorkspaceToMatch", input);
145 rebin->setProperty(
"OutputWorkspace",
"dummy");
147 flood =
rebin->getProperty(
"OutputWorkspace");
148 resetMissingSpectra(flood, *indexTable);
152 divide->setProperty(
"LHSWorkspace", input);
153 divide->setProperty(
"RHSWorkspace", flood);
154 divide->setProperty(
"OutputWorkspace",
"dummy");
157 correctEvents(output.get());
#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.
This class provides an interface to an EventWorkspace.
A "spectrum" is an object that holds the data for a particular spectrum, in particular:
virtual void copyDataFrom(const ISpectrum &source)=0
Copy data from another ISpectrum with double-dynamic dispatch.
Base MatrixWorkspace Abstract Class.
virtual std::size_t getNumberHistograms() const =0
Returns the number of histograms in the workspace.
A property class for workspaces.
Algorithm to apply a flood correction workspace to a reflectometry data workspace.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
void init() override
Virtual method - must be overridden by concrete algorithm.
const std::string category() const override
function to return a category of the algorithm.
void exec() override
Virtual method - must be overridden by concrete algorithm.
const std::string summary() const override
function returns a summary message that will be displayed in the default GUI, and in the help.
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
static BinaryOperationTable_sptr buildBinaryOperationTable(const API::MatrixWorkspace_const_sptr &lhs, const API::MatrixWorkspace_const_sptr &rhs)
Build up an BinaryOperationTable for performing a binary operation e.g.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
void MANTID_KERNEL_DLL rebin(const std::vector< double > &xold, const std::vector< double > &yold, const std::vector< double > &eold, const std::vector< double > &xnew, std::vector< double > &ynew, std::vector< double > &enew, bool distribution, bool addition=false)
Rebins data according to a new output X array.
String constants for algorithm's properties.
static const std::string INPUT_WORKSPACE
static const std::string OUTPUT_WORKSPACE
@ Input
An input workspace.
@ Output
An output workspace.