15using namespace Kernel;
17using namespace Geometry;
39 if (qResolution->getNumberHistograms() != dataWS->getNumberHistograms()) {
40 throw std::invalid_argument(
"The QResolution should have one spectrum"
41 "per spectrum of the input workspace");
46 auto reqX = dataWS->x(0).cbegin();
47 auto qResX = qResolution->x(0).cbegin();
48 for (; reqX != dataWS->x(0).end(); ++reqX, ++qResX) {
49 if (*reqX != *qResX) {
50 throw std::invalid_argument(
"The QResolution needs to have the same binning as"
51 "as the input workspace.");
68 if (dataWS->getNumberHistograms() < 1) {
69 throw std::invalid_argument(
"Empty data workspace passed, can not continue");
74 if (binAdj->getNumberHistograms() != 1) {
75 throw std::invalid_argument(
"The WavelengthAdj workspace must have one spectrum");
77 if (binAdj->y(0).size() != dataWS->y(0).size()) {
78 throw std::invalid_argument(
"The WavelengthAdj workspace's bins must "
79 "match those of the detector bank workspace");
81 auto reqX = dataWS->x(0).cbegin();
82 auto testX = binAdj->x(0).cbegin();
83 for (; reqX != dataWS->x(0).cend(); ++reqX, ++testX) {
84 if (*reqX != *testX) {
85 throw std::invalid_argument(
"The WavelengthAdj workspace must have "
86 "matching bins with the detector bank "
90 if (binAdj->isDistribution() != dataWS->isDistribution()) {
91 throw std::invalid_argument(
"The distrbution/raw counts status of the "
92 "wavelengthAdj and DetBankWorkspace must be "
93 "the same, use ConvertToDistribution");
95 }
else if (!dataWS->isDistribution()) {
103 if (detectAdj->blocksize() != 1) {
104 throw std::invalid_argument(
"The PixelAdj workspace must point to a "
105 "workspace with single bin spectra, as only "
106 "the first bin is used");
108 if (detectAdj->getNumberHistograms() != dataWS->getNumberHistograms()) {
109 throw std::invalid_argument(
"The PixelAdj workspace must have one "
110 "spectrum for each spectrum in the detector "
118 size_t num_histograms = dataWS->getNumberHistograms();
119 const auto &spectrumInfo = dataWS->spectrumInfo();
120 for (
size_t i = 0; i < num_histograms; i++) {
121 auto adj =
static_cast<double>(detectAdj->y(i)[0]);
124 if (!spectrumInfo.hasDetectors(i)) {
127 det_is_masked =
true;
129 det_is_masked = spectrumInfo.isMasked(i);
131 if (!det_is_masked) {
132 throw std::invalid_argument(
"Every detector with non-positive PixelAdj value must be masked");
151 const double RCut,
const double WCut,
const size_t wsInd)
const {
152 double l_WCutOver = 0.0;
154 if (RCut > 0 && WCut > 0) {
155 l_RCut = RCut / 1000.0;
157 l_WCutOver = WCut / l_RCut;
165 const V3D posOnBank = spectrumInfo.
position(wsInd);
166 double R = (posOnBank.
X() * posOnBank.
X()) + (posOnBank.
Y() * posOnBank.
Y());
169 const double WMin = l_WCutOver * (l_RCut - R);
170 const auto &Xs = dataWS->x(wsInd);
171 return std::lower_bound(Xs.begin(), Xs.end(), WMin) - Xs.begin();
189 "The name of the MatrixWorkspace to store sum of counts");
196 "The name of the MatrixWorkspace to store sum of normalising factors");
199 alg->
setProperty(
"sumOfNormFactors", sumOfNormFactors);
Base class from which all concrete algorithm classes should be derived.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
void setPropertyValue(const std::string &name, const std::string &value) override
Set the value of a property by string N.B.
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Kernel::V3D position(const size_t index) const
Returns the position of the spectrum with given index.
A property class for workspaces.
size_t waveLengthCutOff(const API::MatrixWorkspace_const_sptr &dataWS, const API::SpectrumInfo &spectrumInfo, const double RCut, const double WCut, const size_t wsInd) const
Finds the first index number of the first wavelength bin that should included based on the the calcul...
void outputParts(API::Algorithm *alg, const API::MatrixWorkspace_sptr &sumOfCounts, const API::MatrixWorkspace_sptr &sumOfNormFactors)
This method performs the common work between Qxy and Q1D2 if algorihtm parameter OutputParts=True.
void examineInput(const API::MatrixWorkspace_const_sptr &dataWS, const API::MatrixWorkspace_const_sptr &binAdj, const API::MatrixWorkspace_const_sptr &detectAdj, const API::MatrixWorkspace_const_sptr &qResolution)
Checks if workspaces input to Q1D or Qxy are reasonable.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
constexpr double X() const noexcept
Get x.
constexpr double Y() const noexcept
Get y.
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
@ Output
An output workspace.