17#include "MantidIndexing/IndexInfo.h"
19#include "MantidTypes/SpectrumDefinition.h"
45 const auto blocksize = inputWS->blocksize();
46 const auto nreports(
static_cast<size_t>(inputWS->getNumberHistograms() * blocksize));
47 m_progress = std::make_unique<API::Progress>(
this, 0.0, 1.0, nreports);
54 const size_t nenergyBins = blocksize;
57 const auto &
X = inputWS->x(0);
60 std::vector<SpectrumDefinition> detIDMapping(outputWS->getNumberHistograms());
63 for (int64_t i = 0; i < static_cast<int64_t>(nTheta); ++i)
73 const auto &spectrumInfo = inputWS->spectrumInfo();
76 const double thetaLower = theta - halfWidth;
77 const double thetaUpper = theta + halfWidth;
79 for (
size_t j = 0; j < nenergyBins; ++j) {
80 m_progress->report(
"Computing polygon intersections");
83 const double dE_j =
X[j];
84 const double dE_jp1 =
X[j + 1];
89 const V2D lr(dE_jp1, lrQ);
97 const MantidVec::difference_type qIndex = std::upper_bound(
m_Qout.begin(),
m_Qout.end(), lrQ) -
m_Qout.begin();
98 if (qIndex != 0 && qIndex <
static_cast<int>(
m_Qout.size())) {
104 detIDMapping[qIndex - 1].add(spectrumInfo.spectrumDefinition(i)[0].first);
116 auto outputIndices = outputWS->indexInfo();
117 outputIndices.setSpectrumDefinitions(std::move(detIDMapping));
118 outputWS->setIndexInfo(outputIndices);
123 replaceNans->setChild(
true);
124 replaceNans->initialize();
125 replaceNans->setProperty(
"InputWorkspace", outputWS);
126 replaceNans->setProperty(
"OutputWorkspace", outputWS);
127 replaceNans->setProperty(
"NaNValue", 0.0);
128 replaceNans->setProperty(
"InfinityValue", 0.0);
129 replaceNans->setProperty(
"BigNumberThreshold", DBL_MAX);
130 replaceNans->execute();
153 const size_t nhist =
workspace.getNumberHistograms();
156 double minTheta(DBL_MAX), maxTheta(-DBL_MAX);
158 const auto &spectrumInfo =
workspace.spectrumInfo();
159 for (int64_t i = 0; i < static_cast<int64_t>(nhist); ++i) {
160 m_progress->report(
"Calculating detector angles");
162 if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i))
167 }
catch (std::runtime_error &) {
171 const double theta = spectrumInfo.twoTheta(i);
173 minTheta = std::min(minTheta, theta);
174 maxTheta = std::max(maxTheta, theta);
178 throw std::runtime_error(
"Unexpected inconsistency found. The number of detectors is 0"
179 ", and the theta width parameter cannot be calculated.");
181 m_thetaWidth = (maxTheta - minTheta) /
static_cast<double>(ndets);
#define DECLARE_ALGORITHM(classname)
IPeaksWorkspace_sptr workspace
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_CRITICAL(name)
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
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.
Base MatrixWorkspace Abstract Class.
Rebins both axes of a two-dimensional workspace to the given parameters.
std::unique_ptr< API::Progress > m_progress
Progress reporter.
double m_thetaWidth
Theta width.
void init() override
Initialize the algorithm.
void initThetaCache(const API::MatrixWorkspace &workspace)
Init the theta index.
std::vector< double > m_thetaPts
Input theta points.
SofQWPolygon()
Default constructor.
void initCachedValues(const API::MatrixWorkspace_const_sptr &workspace)
Init variables cache base on the given workspace.
SofQCommon m_EmodeProperties
void exec() override
Run the algorithm.
std::vector< double > m_Qout
Output Q axis.
static void createCommonInputProperties(API::Algorithm &alg)
Create the input properties on the given algorithm object.
A ConvexPolygon with only 4 vertices.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void information(const std::string &msg)
Logs at information level.
Implements a 2-dimensional vector embedded in a 3D space, i.e.
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
MANTID_DATAOBJECTS_DLL void normaliseOutput(const API::MatrixWorkspace_sptr &outputWS, const API::MatrixWorkspace_const_sptr &inputWS, API::Progress *progress=nullptr)
Compute sqrt of errors and put back in bin width division if necessary.
MANTID_DATAOBJECTS_DLL void rebinToOutput(const Geometry::Quadrilateral &inputQ, const API::MatrixWorkspace_const_sptr &inputWS, const size_t i, const size_t j, API::MatrixWorkspace &outputWS, const std::vector< double > &verticalAxis)
Rebin the input quadrilateral to to output grid.
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
double getEFixed(const Geometry::IDetector &det) const
Get the efixed value for the given detector.
double q(const double deltaE, const double twoTheta, const Geometry::IDetector *det) const
Calculate the Q value.
void initCachedValues(const API::MatrixWorkspace &workspace, API::Algorithm *const hostAlgorithm)
The procedure analyses emode and efixed properties provided to the algorithm and identify the energy ...