Mantid
Loading...
Searching...
No Matches
Q1DWeighted.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include "MantidAPI/Axis.h"
12#include "MantidAPI/Run.h"
14#include "MantidAPI/TableRow.h"
30
31#include <boost/algorithm/string/split.hpp>
32
33#include <algorithm>
34
35constexpr double deg2rad = M_PI / 180.0;
36
37namespace Mantid::Algorithms {
38
39// Register the algorithm into the AlgorithmFactory
40DECLARE_ALGORITHM(Q1DWeighted)
41
42using namespace Kernel;
43using namespace API;
44using namespace Geometry;
45using namespace DataObjects;
46
48 auto wsValidator = std::make_shared<CompositeValidator>(CompositeRelation::OR);
49 auto monoValidator = std::make_shared<CompositeValidator>(CompositeRelation::AND);
50 auto monoUnitValidator = std::make_shared<CompositeValidator>(CompositeRelation::OR);
51 auto tofValidator = std::make_shared<CompositeValidator>(CompositeRelation::AND);
52
53 monoUnitValidator->add<WorkspaceUnitValidator>("Label"); // case for D16 omega scan, which has unit "Omega scan"
54 monoUnitValidator->add<WorkspaceUnitValidator>("Empty"); // case for kinetic data
55
56 monoValidator->add(monoUnitValidator);
57 monoValidator->add<HistogramValidator>(false);
58 monoValidator->add<InstrumentValidator>();
59
60 tofValidator->add<WorkspaceUnitValidator>("Wavelength");
61 tofValidator->add<HistogramValidator>(true);
62 tofValidator->add<InstrumentValidator>();
63
64 wsValidator->add(monoValidator);
65 wsValidator->add(tofValidator);
66
67 declareProperty(std::make_unique<WorkspaceProperty<>>("InputWorkspace", "", Direction::Input, wsValidator),
68 "Input workspace containing the SANS 2D data");
69 declareProperty(std::make_unique<WorkspaceProperty<>>("OutputWorkspace", "", Direction::Output),
70 "Workspace that will contain the I(Q) data");
71 declareProperty(std::make_unique<ArrayProperty<double>>("OutputBinning", std::make_shared<RebinParamsValidator>()),
72 "The new bin boundaries in the form: :math:`x_1,\\Delta x_1,x_2,\\Delta "
73 "x_2,\\dots,x_n`");
74
75 auto positiveInt = std::make_shared<BoundedValidator<int>>();
76 positiveInt->setLower(0);
77 auto positiveDouble = std::make_shared<BoundedValidator<double>>();
78 positiveDouble->setLower(0);
79
80 declareProperty("NPixelDivision", 1, positiveInt,
81 "Number of sub-pixels used for each detector pixel in each "
82 "direction.The total number of sub-pixels will be "
83 "NPixelDivision*NPixelDivision.");
84
85 // Wedge properties
86 declareProperty("NumberOfWedges", 2, positiveInt, "Number of wedges to calculate.");
87 declareProperty("WedgeAngle", 30.0, positiveDouble, "Opening angle of the wedge, in degrees.");
88 declareProperty("WedgeOffset", 0.0, positiveDouble, "Wedge offset relative to the horizontal axis, in degrees.");
89 declareProperty(std::make_unique<WorkspaceProperty<WorkspaceGroup>>("WedgeWorkspace", "", Direction::Output,
91 "Name for the WorkspaceGroup containing the wedge I(q) distributions.");
92
93 declareProperty("PixelSizeX", 5.15, positiveDouble, "Pixel size in the X direction (mm).");
94 declareProperty("PixelSizeY", 5.15, positiveDouble, "Pixel size in the Y direction (mm).");
95 declareProperty("ErrorWeighting", false, "Choose whether each pixel contribution will be weighted by 1/error^2.");
96
97 declareProperty("AsymmetricWedges", false, "Choose to produce the results for asymmetric wedges.");
98
99 declareProperty("AccountForGravity", false, "Take the nominal gravity drop into account.");
100
103 "Table workspace containing the shapes (sectors only) drawn in the "
104 "instrument viewer; if specified, the wedges properties defined above "
105 "are not taken into account.");
106}
107
109 MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace");
110 bootstrap(inputWS);
111 calculate(inputWS);
112 finalize(inputWS);
113}
114
121 // Get pixel size and pixel sub-division
122 m_pixelSizeX = getProperty("PixelSizeX");
123 m_pixelSizeY = getProperty("PixelSizeY");
124 m_pixelSizeX /= 1000.;
125 m_pixelSizeY /= 1000.;
126 m_nSubPixels = getProperty("NPixelDivision");
127
128 // Get weighting option
129 m_errorWeighting = getProperty("ErrorWeighting");
130
131 // Get gravity flag
132 m_correctGravity = getProperty("AccountForGravity");
133
134 // Calculate the output binning
135 const std::vector<double> binParams = getProperty("OutputBinning");
136
137 m_nQ = static_cast<size_t>(VectorHelper::createAxisFromRebinParams(binParams, m_qBinEdges)) - 1;
138
139 m_isMonochromatic = inputWS->getAxis(0)->unit()->unitID() != "Wavelength";
140 // number of spectra in the input
141 m_nSpec = inputWS->getNumberHistograms();
142
143 // get the number of wavelength bins / samples in the input, note that the input is a histogram
144 m_nBins = inputWS->readY(0).size();
145
146 m_wedgesParameters = std::vector<Q1DWeighted::Wedge>();
147
148 m_asymmWedges = getProperty("AsymmetricWedges");
149
150 if (isDefault("ShapeTable")) {
151 const int wedges = getProperty("NumberOfWedges");
152 m_nWedges = static_cast<size_t>(wedges);
153
154 // Get wedge properties
155 const double wedgeOffset = getProperty("WedgeOffset");
156 const double wedgeAngle = getProperty("WedgeAngle");
157
158 // Define wedges parameters in a general way
159 for (size_t iw = 0; iw < m_nWedges; ++iw) {
160 double innerRadius = 0.;
161
162 // Negative outer radius is taken as a convention for infinity
163 double outerRadius = -1.;
164 double centerX = 0.;
165 double centerY = 0.;
166 double angleRange = wedgeAngle * deg2rad;
167 double midAngle = M_PI * static_cast<double>(iw) / static_cast<double>(m_nWedges);
168 if (m_asymmWedges)
169 midAngle *= 2;
170 midAngle += wedgeOffset * deg2rad;
171
172 m_wedgesParameters.push_back(
173 Q1DWeighted::Wedge(innerRadius, outerRadius, centerX, centerY, midAngle, angleRange));
174 }
175 } else {
176 g_log.warning("This option is still in active development and might be "
177 "subject to changes in the next version.");
180 }
181
182 // we store everything in 3D arrays
183 // index 1 : is for the wedges + the one for the full integration, if there are no wedges, the 1st dimension will be 1
184 // index 2 : will iterate over lambda bins / over samples if monochromatic
185 // index 3 : will iterate over Q bins
186 // we want to do this, since we want to average the I(Q) in each lambda bin then average all the I(Q)s together (in
187 // the case of TOF)
188 m_intensities = std::vector<std::vector<std::vector<double>>>(
189 m_nWedges + 1, std::vector<std::vector<double>>(m_nBins, std::vector<double>(m_nQ, 0.0)));
192}
193
200 ITableWorkspace_sptr shapeWs = getProperty("ShapeTable");
201 size_t rowCount = shapeWs->rowCount();
202
203 std::map<std::string, std::vector<double>> viewportParams;
204
205 // by convention, the last row is supposed to be the viewport
206 getViewportParams(shapeWs->String(rowCount - 1, 1), viewportParams);
207
208 for (size_t i = 0; i < rowCount - 1; ++i) {
209 std::map<std::string, std::vector<std::string>> paramMap;
210 std::vector<std::string> splitParams;
211 boost::algorithm::split(splitParams, shapeWs->String(i, 1), boost::algorithm::is_any_of("\n"));
212 std::vector<std::string> params;
213 for (std::string val : splitParams) {
214 if (val.empty())
215 continue;
216 boost::algorithm::split(params, val, boost::algorithm::is_any_of("\t"));
217
218 // NB : the first value of the vector also is the key, and is not a meaningful value
219 paramMap[params[0]] = params;
220 }
221 if (paramMap["Type"][1] == "sector")
222 getWedgeParams(paramMap["Parameters"], viewportParams);
223 else
224 g_log.information() << "Shape " << i + 1 << " is of type " << paramMap["Type"][1]
225 << " which is not supported. This shape is ignored." << std::endl;
226 }
227
228 std::sort(m_wedgesParameters.begin(), m_wedgesParameters.end(),
229 [](const Q1DWeighted::Wedge &wedgeA, const Q1DWeighted::Wedge &wedgeB) {
230 return wedgeA.angleMiddle < wedgeB.angleMiddle;
231 });
232
234}
235
243void Q1DWeighted::getViewportParams(const std::string &viewport,
244 std::map<std::string, std::vector<double>> &viewportParams) {
245
246 std::vector<std::string> params;
247 boost::algorithm::split(params, viewport, boost::algorithm::is_any_of("\t, \n"));
248
249 if (params[0] != "Translation") {
250 g_log.error(
251 "No viewport found in the shape table. Please provide a table using shapes drawn in the Full3D projection.");
252 }
253
254 // Translation
255 viewportParams[params[0]] = std::vector<double>(2);
256 viewportParams[params[0]][0] = std::stod(params[1]);
257 viewportParams[params[0]][1] = std::stod(params[2]);
258
259 // Zoom
260 viewportParams[params[3]] = std::vector<double>(1);
261 viewportParams[params[3]][0] = std::stod(params[4]);
262
263 // Rotation quaternion
264 viewportParams[params[5]] = std::vector<double>(4);
265 viewportParams[params[5]][0] = std::stod(params[6]);
266 viewportParams[params[5]][1] = std::stod(params[7]);
267 viewportParams[params[5]][2] = std::stod(params[8]);
268 viewportParams[params[5]][3] = std::stod(params[9]);
269
270 double epsilon = 1e-10;
271
272 if (std::fabs(viewportParams["Rotation"][0]) > epsilon || std::fabs(viewportParams["Rotation"][1]) > epsilon ||
273 std::fabs(viewportParams["Rotation"][3]) > epsilon || std::fabs(viewportParams["Rotation"][2] - 1) > epsilon) {
274 g_log.warning("The shapes were created using a rotated viewport not using Z- projection, which is not supported. "
275 "Results are likely to be erroneous. Consider freezing the rotation in the instrument viewer.");
276 }
277}
278
284void Q1DWeighted::getWedgeParams(const std::vector<std::string> &params,
285 const std::map<std::string, std::vector<double>> &viewport) {
286 double zoom = viewport.at("Zoom")[0];
287
288 double innerRadius = std::stod(params[1]) / zoom;
289 double outerRadius = std::stod(params[2]) / zoom;
290
291 double startAngle = std::stod(params[3]);
292 double endAngle = std::stod(params[4]);
293
294 double centerAngle = (startAngle + endAngle) / 2;
295 if (endAngle < startAngle)
296 centerAngle = std::fmod(centerAngle + M_PI, 2 * M_PI);
297
298 double angleRange = std::fmod(endAngle - startAngle, 2 * M_PI);
299 angleRange = angleRange >= 0 ? angleRange : angleRange + 2 * M_PI;
300
301 // since the viewport was in Z-, the axis are inverted so we have to take the symmetry of the angle
302 centerAngle = std::fmod(3 * M_PI - centerAngle, 2 * M_PI);
303
304 double xOffset = viewport.at("Translation")[0];
305 double yOffset = viewport.at("Translation")[1];
306
307 double centerX = -(std::stod(params[5]) - xOffset) / zoom;
308 double centerY = (std::stod(params[6]) - yOffset) / zoom;
309
310 Q1DWeighted::Wedge wedge = Q1DWeighted::Wedge(innerRadius, outerRadius, centerX, centerY, centerAngle, angleRange);
311
312 if (m_asymmWedges || !checkIfSymetricalWedge(wedge)) {
313 m_wedgesParameters.push_back(wedge);
314 }
315}
316
325 return std::any_of(m_wedgesParameters.cbegin(), m_wedgesParameters.cend(),
326 [&wedge](const auto &params) { return wedge.isSymmetric(params); });
327}
328
336 for (size_t i = 0; i < m_wedgesParameters.size() - 1; ++i) {
337 if (m_wedgesParameters[i].angleMiddle == m_wedgesParameters[i + 1].angleMiddle) {
338 g_log.warning() << "Two of the given wedges are superposed, at " << m_wedgesParameters[i].angleMiddle / deg2rad
339 << " degrees." << std::endl;
340 ;
341 }
342 }
343}
344
351 // Set up the progress
352 Progress progress(this, 0.0, 1.0, m_nSpec * m_nBins);
353
354 const auto &spectrumInfo = inputWS->spectrumInfo();
355 const V3D sourcePos = spectrumInfo.sourcePosition();
356 const V3D samplePos = spectrumInfo.samplePosition();
357 // Beam line axis, to compute scattering angle
358 const V3D beamLine = samplePos - sourcePos;
359
360 const auto up = inputWS->getInstrument()->getReferenceFrame()->vecPointingUp();
361 double monoWavelength = 0;
362 if (m_isMonochromatic) {
363 if (inputWS->run().hasProperty("wavelength")) {
364 monoWavelength = inputWS->run().getPropertyAsSingleValue("wavelength");
365 } else
366 throw std::runtime_error("Could not find wavelength in the sample logs.");
367 }
368
370 // first we loop over spectra
371 for (int index = 0; index < static_cast<int>(m_nSpec); ++index) {
373 const auto i = static_cast<size_t>(index);
374 // skip spectra with no detectors, monitors or masked spectra
375 if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i) || spectrumInfo.isMasked(i)) {
376 continue;
377 }
378
379 // store masked bins
380 std::vector<size_t> maskedBins;
381 // check if we have masked bins
382 if (inputWS->hasMaskedBins(i)) {
383 maskedBins = inputWS->maskedBinsIndices(i);
384 }
385
386 // get readonly references to the input data
387 const auto &XIn = inputWS->x(i);
388 const auto &YIn = inputWS->y(i);
389 const auto &EIn = inputWS->e(i);
390
391 // get the position of the pixel wrt sample (normally 0,0,0).
392 const V3D pos = spectrumInfo.position(i) - samplePos;
393
394 // prepare a gravity helper, this is much faster than calculating
395 // on-the-fly, see the caching in the helper
396 GravitySANSHelper gravityHelper(spectrumInfo, i, 0.0);
397
398 // loop over bins
399 for (size_t j = 0; j < m_nBins; ++j) {
400
401 // skip if the bin is masked
402 if (std::binary_search(maskedBins.cbegin(), maskedBins.cend(), j)) {
403 continue;
404 }
405
406 const double wavelength = m_isMonochromatic ? monoWavelength : (XIn[j] + XIn[j + 1]) / 2.;
407
408 V3D correction;
409 if (m_correctGravity) {
410 correction = up * gravityHelper.gravitationalDrop(wavelength);
411 }
412
413 // Each pixel might be sub-divided in the number of pixels given as
414 // input parameter (NPixelDivision x NPixelDivision)
415 for (int isub = 0; isub < m_nSubPixels * m_nSubPixels; ++isub) {
416
417 // Find the position offset for this sub-pixel in real space
418 const double subY = m_pixelSizeY * ((isub % m_nSubPixels) - (m_nSubPixels - 1.0) / 2.0) / m_nSubPixels;
419 const double subX = m_pixelSizeX *
420 (floor(static_cast<double>(isub) / m_nSubPixels) - (m_nSubPixels - 1.0) * 0.5) /
422
423 // calculate Q
424 const V3D position = pos - V3D(subX, subY, 0.0) + correction;
425 const double sinTheta = sin(0.5 * position.angle(beamLine));
426 const double q = 4.0 * M_PI * sinTheta / wavelength;
427
428 if (q < m_qBinEdges.front() || q > m_qBinEdges.back()) {
429 continue;
430 }
431
432 // after check above, no need to wrap this in try catch
434
435 double w = 1.0;
436 if (m_errorWeighting) {
437 // When using the error as weight we have:
438 // w_i = 1/s_i^2 where s_i is the uncertainty on the ith
439 // pixel.
440 //
441 // I(q_i) = (sum over i of I_i * w_i) / (sum over i of w_i)
442 // where all pixels i contribute to the q_i bin, and I_i is
443 // the intensity in the ith pixel.
444 //
445 // delta I(q_i) = 1/sqrt( (sum over i of w_i) ) using simple
446 // error propagation.
447 double err = 1.0;
448 if (EIn[j] > 0)
449 err = EIn[j];
450 w /= m_nSubPixels * m_nSubPixels * err * err;
451 }
452 PARALLEL_CRITICAL(iqnorm) {
453 // Fill in the data for full azimuthal integral
454 m_intensities[0][j][k] += YIn[j] * w;
455 m_errors[0][j][k] += w * w * EIn[j] * EIn[j];
456 m_normalisation[0][j][k] += w;
457 }
458
459 for (size_t iw = 0; iw < m_nWedges; ++iw) {
460
462 double centerAngle = wedge.angleMiddle;
463 const V3D subPix = V3D(position.X(), position.Y(), 0.0);
464 const V3D center = V3D(wedge.centerX, wedge.centerY, 0);
465 double angle = std::fabs((subPix - center).angle(V3D(cos(centerAngle), sin(centerAngle), 0.0)));
466
467 // checks that the pixel is within the angular range or, if the
468 // integration is symmetrical, within the angular range + PI
469 bool isWithinAngularRange =
470 angle < wedge.angleRange * 0.5 || (!m_asymmWedges && std::fabs(M_PI - angle) < wedge.angleRange * 0.5);
471
472 bool isWithinRadii = subPix.distance(center) > wedge.innerRadius &&
473 (wedge.outerRadius <= 0 || subPix.distance(center) <= wedge.outerRadius);
474
475 if (isWithinAngularRange && isWithinRadii) {
476 PARALLEL_CRITICAL(iqnorm_wedges) {
477 // first index 0 is the full azimuth, need to offset+1
478 m_intensities[iw + 1][j][k] += YIn[j] * w;
479 m_errors[iw + 1][j][k] += w * w * EIn[j] * EIn[j];
480 m_normalisation[iw + 1][j][k] += w;
481 }
482 }
483 }
484 }
485 progress.report("Computing I(Q)");
486 }
488 }
490}
491
498 const size_t nSpectra = m_isMonochromatic ? m_nBins : 1;
500 setProperty("OutputWorkspace", outputWS);
501
502 // Create workspace group that holds output workspaces for wedges
503 auto wsgroup = std::make_shared<WorkspaceGroup>();
504 if (m_nWedges != 0) {
505 // Create wedge workspaces
506 for (size_t iw = 0; iw < m_nWedges; ++iw) {
508 wedgeWs->mutableRun().addProperty("wedge_angle", m_wedgesParameters[iw].angleMiddle / deg2rad, "degrees", true);
509 wsgroup->addWorkspace(wedgeWs);
510 }
511 // set the output property
512 std::string outputWSGroupName = getPropertyValue("WedgeWorkspace");
513 if (outputWSGroupName.empty()) {
514 std::string outputWSName = getPropertyValue("OutputWorkspace");
515 outputWSGroupName = outputWSName + "_wedges";
516 setPropertyValue("WedgeWorkspace", outputWSGroupName);
517 }
518 setProperty("WedgeWorkspace", wsgroup);
519 }
520
521 for (size_t iout = 0; iout < m_nWedges + 1; ++iout) {
522
523 auto ws = (iout == 0) ? outputWS : std::dynamic_pointer_cast<MatrixWorkspace>(wsgroup->getItem(iout - 1));
524
525 if (m_isMonochromatic) {
526 fillMonochromaticOutput(ws, iout);
527 } else {
528 fillTOFOutput(ws, iout);
529 }
530 }
531}
532
541
542 for (size_t iSample = 0; iSample < m_nBins; ++iSample) {
543 auto &YOut = outputWS->mutableY(iSample);
544 auto &EOut = outputWS->mutableE(iSample);
545
547 for (int iq = 0; iq < static_cast<int>(m_nQ); ++iq) {
549 const double norm = m_normalisation[iout][iSample][iq];
550 if (norm != 0.) {
551 YOut[iq] = m_intensities[iout][iSample][iq] / norm;
552 EOut[iq] = m_errors[iout][iSample][iq] / (norm * norm);
553 }
555 }
557 }
558}
559
566void Q1DWeighted::fillTOFOutput(MatrixWorkspace_sptr &outputWS, const size_t iout) {
567 auto &YOut = outputWS->mutableY(0);
568 auto &EOut = outputWS->mutableE(0);
569
570 std::vector<double> normLambda(m_nQ, 0.0);
571
572 for (size_t il = 0; il < m_nBins; ++il) {
574 for (int iq = 0; iq < static_cast<int>(m_nQ); ++iq) {
576 const double norm = m_normalisation[iout][il][iq];
577 if (norm != 0.) {
578 YOut[iq] += m_intensities[iout][il][iq] / norm;
579 EOut[iq] += m_errors[iout][il][iq] / (norm * norm);
580 normLambda[iq] += 1.;
581 }
583 }
585 }
586
587 for (size_t i = 0; i < m_nQ; ++i) {
588 YOut[i] /= normLambda[i];
589 EOut[i] = sqrt(EOut[i]) / normLambda[i];
590 }
591}
592
602 const std::vector<double> &binEdges, const size_t nSpectra) {
603
604 MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create(parent, nSpectra, nBins + 1, nBins);
605 outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("MomentumTransfer");
606 for (size_t iSpectra = 0; iSpectra < nSpectra; ++iSpectra) {
607 outputWS->setBinEdges(iSpectra, binEdges);
608 }
609 outputWS->setYUnitLabel("1/cm");
610 outputWS->setDistribution(true);
611 return outputWS;
612}
613
614} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
double position
Definition: GetAllEi.cpp:154
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
int nSpectra
#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...
Definition: MultiThreaded.h:94
#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.
constexpr double deg2rad
Definition: Q1DWeighted.cpp:35
double innerRadius
Definition: Rasterize.cpp:39
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
Definition: Algorithm.cpp:2026
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
Kernel::Logger & g_log
Definition: Algorithm.h:451
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Definition: Algorithm.cpp:231
bool isDefault(const std::string &name) const
Definition: Algorithm.cpp:2084
void setPropertyValue(const std::string &name, const std::string &value) override
Set the value of a property by string N.B.
Definition: Algorithm.cpp:1975
A validator which checks that a workspace contains histogram data (the default) or point data as requ...
A validator which checks that a workspace has a valid instrument.
Helper class for reporting progress from algorithms.
Definition: Progress.h:25
A property class for workspaces.
A validator which checks that the unit of the workspace referred to by a WorkspaceProperty is the exp...
A helper class for calculating neutron's gravitional drop.
double gravitationalDrop(const double wav) const
void getTableShapes()
Q1DWeighted::getTableShapes if the user provided a shape table, parse the stored values and get the v...
void bootstrap(const API::MatrixWorkspace_const_sptr &)
Q1DWeighted::bootstrap initializes the user inputs.
void fillTOFOutput(API::MatrixWorkspace_sptr &, const size_t)
Q1DWeighted::fillTOFOutput Fill in the output workspace for TOF input, averaging over lambda bins.
std::vector< Wedge > m_wedgesParameters
Definition: Q1DWeighted.h:128
std::vector< std::vector< std::vector< double > > > m_intensities
Definition: Q1DWeighted.h:120
bool checkIfSymetricalWedge(Wedge &Wedge)
Q1DWeighted::checkIfSymetricalWedge Check if the symetrical wedge to the one defined by the parameter...
void fillMonochromaticOutput(API::MatrixWorkspace_sptr &, const size_t)
Q1DWeighted::fillMonochromaticOutput Fill the output workspace for monochromatic, kinetic input.
std::vector< std::vector< std::vector< double > > > m_errors
Definition: Q1DWeighted.h:121
void finalize(const API::MatrixWorkspace_const_sptr &)
Q1DWeighted::finalize performs final averaging and sets the output workspaces.
void init() override
Initialisation code.
Definition: Q1DWeighted.cpp:47
void getViewportParams(const std::string &, std::map< std::string, std::vector< double > > &)
Q1DWeighted::getViewportParams get the parameters defining the viewport of the instrument view when t...
std::vector< double > m_qBinEdges
Definition: Q1DWeighted.h:123
void getWedgeParams(const std::vector< std::string > &, const std::map< std::string, std::vector< double > > &)
Q1DWeighted::getWedgeParams.
std::vector< std::vector< std::vector< double > > > m_normalisation
Definition: Q1DWeighted.h:122
API::MatrixWorkspace_sptr createOutputWorkspace(const API::MatrixWorkspace_const_sptr &, const size_t, const std::vector< double > &, const size_t)
Create an output workspace.
void checkIfSuperposedWedges()
Q1DWeighted::checkIfSuperposedWedges Check if some wedges ahev the same angleMiddle,...
void calculate(const API::MatrixWorkspace_const_sptr &)
Q1DWeighted::calculate Performs the azimuthal averaging for each wavelength bin.
void exec() override
Execution code.
Support for a property that holds an array of values.
Definition: ArrayProperty.h:28
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
void information(const std::string &msg)
Logs at information level.
Definition: Logger.cpp:105
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Class for 3D vectors.
Definition: V3D.h:34
double distance(const V3D &v) const noexcept
Calculates the distance between two vectors.
Definition: V3D.h:287
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
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
constexpr double deg2rad
Defines units/enum for Crystal work.
Definition: AngleUnits.h:20
size_t MANTID_KERNEL_DLL indexOfValueFromEdges(const std::vector< double > &bin_edges, const double value)
Gets the bin of a value from a vector of bin edges.
int MANTID_KERNEL_DLL createAxisFromRebinParams(const std::vector< double > &params, std::vector< double > &xnew, const bool resize_xnew=true, const bool full_bins_only=false, const double xMinHint=std::nan(""), const double xMaxHint=std::nan(""), const bool useReverseLogarithmic=false, const double power=-1)
Creates a new output X array given a 'standard' set of rebinning parameters.
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.
Definition: MultiThreaded.h:22
@ Input
An input workspace.
Definition: Property.h:53
@ Output
An output workspace.
Definition: Property.h:54