Mantid
Loading...
Searching...
No Matches
WorkspaceCreationHelper.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 +
7/*********************************************************************************
8 * PLEASE READ THIS!!!!!!!
9 *
10 * This collection of functions MAY NOT be used in any test from a package
11 *below
12 * DataObjects (e.g. Kernel, Geometry, API).
13 * Conversely, this file MAY NOT be modified to use anything from a package
14 *higher
15 * than DataObjects (e.g. any algorithm), even if going via the factory.
16 *********************************************************************************/
20
24#include "MantidAPI/Sample.h"
41#include "MantidHistogramData/HistogramBuilder.h"
42#include "MantidHistogramData/HistogramDx.h"
43#include "MantidHistogramData/LinearGenerator.h"
44#include "MantidIndexing/IndexInfo.h"
49#include "MantidKernel/V3D.h"
52
53#include <cmath>
54#include <sstream>
55#include <utility>
56
58using namespace Mantid;
59using namespace Mantid::DataObjects;
60using namespace Mantid::Kernel;
61using namespace Mantid::API;
62using namespace Mantid::Geometry;
63using namespace Mantid::HistogramData;
66using Mantid::Types::Core::DateAndTime;
67using Mantid::Types::Event::TofEvent;
68
69StubAlgorithm::StubAlgorithm(size_t nSteps) : m_Progress(std::make_unique<API::Progress>(this, 0.0, 1.0, nSteps)) {}
70
71EPPTableRow::EPPTableRow(const double peakCentre_, const double sigma_, const double height_,
72 const FitStatus fitStatus_)
73 : peakCentre(peakCentre_), sigma(sigma_), height(height_), fitStatus(fitStatus_) {}
74
75EPPTableRow::EPPTableRow(const int index, const double peakCentre_, const double sigma_, const double height_,
76 const FitStatus fitStatus_)
77 : workspaceIndex(index), peakCentre(peakCentre_), sigma(sigma_), height(height_), fitStatus(fitStatus_) {}
78
83void removeWS(const std::string &name) { Mantid::API::AnalysisDataService::Instance().remove(name); }
84
97template <typename YType, typename EType> Histogram createHisto(bool isHistogram, YType &&yAxis, EType &&eAxis) {
98 // We don't need to check if y.size() == e.size() as the histogram
99 // type does this at construction
100 const size_t yValsSize = yAxis.size();
101 if (isHistogram) {
102 BinEdges xAxis(yValsSize + 1, LinearGenerator(1, 1));
103 Histogram histo{std::move(xAxis), std::forward<YType>(yAxis), std::forward<EType>(eAxis)};
104 return histo;
105 } else {
106 Points xAxis(yValsSize, LinearGenerator(1, 1));
107 Histogram pointsHisto{std::move(xAxis), std::forward<YType>(yAxis), std::forward<EType>(eAxis)};
108 return pointsHisto;
109 }
110}
111
113
114 MersenneTwister randomGen(DateAndTime::getCurrentTime().nanoseconds(), 0, std::numeric_limits<int>::max());
115
116 auto randFunc = [&randomGen] { return randomGen.nextValue(); };
117 Counts counts(size, randFunc);
118 CountStandardDeviations errorVals(size, randFunc);
119
120 auto retVal = std::make_shared<Workspace2D>();
121 retVal->initialize(1, createHisto(isHisto, counts, errorVals));
122 return retVal;
123}
124
125Workspace2D_sptr create1DWorkspaceConstant(int size, double value, double error, bool isHisto) {
126 Counts yVals(size, value);
127 CountStandardDeviations errVals(size, error);
128
129 auto retVal = std::make_shared<Workspace2D>();
130 retVal->initialize(1, createHisto(isHisto, yVals, errVals));
131 return retVal;
132}
133
134Workspace2D_sptr create1DWorkspaceConstantWithXerror(int size, double value, double error, double xError,
135 bool isHisto) {
136 auto ws = create1DWorkspaceConstant(size, value, error, isHisto);
137 auto dx1 = Kernel::make_cow<HistogramData::HistogramDx>(size, xError);
138 ws->setSharedDx(0, dx1);
139 return ws;
140}
141
142Workspace2D_sptr create1DWorkspaceFib(int size, bool isHisto) {
143 BinEdges xVals(size + 1, LinearGenerator(1, 1));
144 Counts yVals(size, FibSeries<double>());
145 CountStandardDeviations errVals(size);
146
147 auto retVal = std::make_shared<Workspace2D>();
148 retVal->initialize(1, createHisto(isHisto, yVals, errVals));
149 return retVal;
150}
151
152Workspace2D_sptr create2DWorkspace(size_t nhist, size_t numBoundaries) {
153 return create2DWorkspaceBinned(nhist, numBoundaries);
154}
155
163 Workspace2D_sptr out = create2DWorkspaceBinned(nhist, numBoundaries);
164 for (int workspaceIndex = 0; workspaceIndex < nhist; workspaceIndex++) {
165 std::vector<double> yValues(numBoundaries, static_cast<double>(workspaceIndex));
166 out->mutableY(workspaceIndex) = yValues;
167 }
168
169 return out;
170}
171
173
174 Workspace2D_sptr outputWS = create2DWorkspaceBinned(nHist, nBins);
175 auto newAxis = std::make_unique<NumericAxis>(nHist);
176 auto newAxisRaw = newAxis.get();
177 outputWS->replaceAxis(1, std::move(newAxis));
178 newAxisRaw->unit() = std::make_shared<Units::Degrees>();
179 for (int i = 0; i < nHist; ++i) {
180 newAxisRaw->setValue(i, i + 1);
181 }
182
183 return outputWS;
184}
185
200Workspace2D_sptr create2DWorkspaceWithValues(int64_t nHist, int64_t nBins, bool isHist,
201 const std::set<int64_t> &maskedWorkspaceIndices, double xVal, double yVal,
202 double eVal, bool hasDx = false) {
203 auto x1 = Kernel::make_cow<HistogramData::HistogramX>(isHist ? nBins + 1 : nBins, LinearGenerator(xVal, 1.0));
204 Counts y1(nBins, yVal);
205 CountStandardDeviations e1(nBins, eVal);
206 auto dx = Kernel::make_cow<HistogramData::HistogramDx>(nBins, yVal);
207 auto retVal = std::make_shared<Workspace2D>();
208 retVal->initialize(nHist, createHisto(isHist, y1, e1));
209 for (int i = 0; i < nHist; i++) {
210 retVal->setSharedX(i, x1);
211 if (hasDx)
212 retVal->setSharedDx(i, dx);
213 retVal->getSpectrum(i).setDetectorID(i);
214 retVal->getSpectrum(i).setSpectrumNo(i);
215 }
216 if (maskedWorkspaceIndices.size() > 0) {
217 retVal = maskSpectra(retVal, maskedWorkspaceIndices);
218 }
219 return retVal;
220}
221
222Workspace2D_sptr create2DWorkspaceWithValuesAndXerror(int64_t nHist, int64_t nBins, bool isHist, double xVal,
223 double yVal, double eVal, double dxVal,
224 const std::set<int64_t> &maskedWorkspaceIndices) {
225 auto ws = create2DWorkspaceWithValues(nHist, nBins, isHist, maskedWorkspaceIndices, xVal, yVal, eVal);
226 PointStandardDeviations dx1(nBins, dxVal);
227 for (int i = 0; i < nHist; i++) {
228 ws->setPointStandardDeviations(i, dx1);
229 }
230 return ws;
231}
232
233Workspace2D_sptr create2DWorkspace123(int64_t nHist, int64_t nBins, bool isHist,
234 const std::set<int64_t> &maskedWorkspaceIndices, bool hasDx) {
235 return create2DWorkspaceWithValues(nHist, nBins, isHist, maskedWorkspaceIndices, 1.0, 2.0, 3.0, hasDx);
236}
237
238Workspace2D_sptr create2DWorkspace154(int64_t nHist, int64_t nBins, bool isHist,
239 const std::set<int64_t> &maskedWorkspaceIndices, bool hasDx) {
240 return create2DWorkspaceWithValues(nHist, nBins, isHist, maskedWorkspaceIndices, 1.0, 5.0, 4.0, hasDx);
241}
242
243Workspace2D_sptr maskSpectra(Workspace2D_sptr workspace, const std::set<int64_t> &maskedWorkspaceIndices) {
244 const auto nhist = static_cast<int>(workspace->getNumberHistograms());
245 if (workspace->getInstrument()->nelements() == 0) {
246 // We need detectors to be able to mask them.
247 auto instrument = std::make_shared<Instrument>();
248 workspace->setInstrument(instrument);
249
250 std::string xmlShape = "<sphere id=\"shape\"> ";
251 xmlShape += R"(<centre x="0.0" y="0.0" z="0.0" /> )";
252 xmlShape += "<radius val=\"0.05\" /> ";
253 xmlShape += "</sphere>";
254 xmlShape += "<algebra val=\"shape\" /> ";
255
256 ShapeFactory sFactory;
257 auto shape = sFactory.createShape(xmlShape);
258 for (int i = 0; i < nhist; ++i) {
259 Detector *det = new Detector("det", detid_t(i + 1), shape, nullptr);
260 det->setPos(i, i + 1, 1);
261 instrument->add(det);
262 instrument->markAsDetector(det);
263 }
264 workspace->setInstrument(instrument);
265 // Set IndexInfo without explicit spectrum definitions to trigger building
266 // default mapping of spectra to detectors in new instrument.
267 workspace->setIndexInfo(Indexing::IndexInfo(nhist));
268 }
269
270 auto &spectrumInfo = workspace->mutableSpectrumInfo();
271 for (const auto index : maskedWorkspaceIndices)
272 spectrumInfo.setMasked(index, true);
273 return workspace;
274}
275
279WorkspaceGroup_sptr createWorkspaceGroup(int nEntries, int nHist, int nBins, const std::string &stem) {
280 auto group = std::make_shared<WorkspaceGroup>();
281 AnalysisDataService::Instance().add(stem, group);
282 for (int i = 0; i < nEntries; ++i) {
283 Workspace2D_sptr ws = create2DWorkspace(nHist, nBins);
284 std::ostringstream os;
285 os << stem << "_" << i;
286 AnalysisDataService::Instance().add(os.str(), ws);
287 group->add(os.str());
288 }
289 return group;
290}
291
296 // create workspace with 2 histograms
298
299 // create and replace histograms with ragged ones
300 MantidVec x_data{100., 200., 300., 400.};
301 MantidVec y_data{1., 1., 1.};
302 MantidVec e_data{1., 1., 1.};
303
304 MantidVec x_data2{200., 400., 600.};
305 MantidVec y_data2{1., 1.};
306 MantidVec e_data2{1., 1.};
307
308 // Update values based on version specification
309 if (version == 1) {
310 // different number of bins
311 x_data2 = {200., 400.};
312 y_data2 = {1.};
313 e_data2 = {1.};
314 } else if (version == 2) {
315 // same number of bins but different y values
316 y_data2 = {1., 2.};
317 } else if (version == 3) {
318 // same number of bins but different x values
319 x_data2 = {200., 500., 600.};
320 } else if (version == 4) {
321 // sets up histograms for the Multiply/Divide tests
322 y_data = {2., 2., 2.};
323 e_data = {2., 2., 2.};
324 y_data2 = {2., 2.};
325 e_data2 = {2., 2.};
326 }
327
328 Mantid::HistogramData::HistogramBuilder builder;
329 builder.setX(x_data);
330 builder.setY(y_data);
331 builder.setE(e_data);
332 raggedWS->setHistogram(0, builder.build());
333
334 Mantid::HistogramData::HistogramBuilder builder2;
335 builder2.setX(x_data2);
336 builder2.setY(y_data2);
337 builder2.setE(e_data2);
338 raggedWS->setHistogram(1, builder2.build());
339
340 return raggedWS;
341}
342
346Workspace2D_sptr create2DWorkspaceBinned(size_t nhist, size_t numVals, double x0, double deltax) {
347 BinEdges x(numVals + 1, LinearGenerator(x0, deltax));
348 Counts y(numVals, 2);
349 CountStandardDeviations e(numVals, M_SQRT2);
350 return create<Workspace2D>(nhist, Histogram(x, y, e));
351}
352
356Workspace2D_sptr create2DWorkspacePoints(size_t nhist, size_t numVals, double x0, double deltax) {
357 Points x(numVals, LinearGenerator(x0, deltax));
358 Counts y(numVals, 2);
359 CountStandardDeviations e(numVals, M_SQRT2);
360 return create<Workspace2D>(nhist, Histogram(x, y, e));
361}
362
369Workspace2D_sptr create2DWorkspaceNonUniformlyBinned(int nhist, const int numBoundaries, const double xBoundaries[],
370 bool hasDx) {
371 BinEdges x(xBoundaries, xBoundaries + numBoundaries);
372 const int numBins = numBoundaries - 1;
373 Counts y(numBins, 2);
374 CountStandardDeviations e(numBins, M_SQRT2);
375 auto dx = Kernel::make_cow<HistogramData::HistogramDx>(numBins, LinearGenerator(0.1, .1));
376 auto retVal = std::make_shared<Workspace2D>();
377 retVal->initialize(nhist, createHisto(true, y, e));
378 for (int i = 0; i < nhist; i++) {
379 retVal->setBinEdges(i, x);
380 if (hasDx)
381 retVal->setSharedDx(i, dx);
382 }
383 return retVal;
384}
385
393void addNoise(const Mantid::API::MatrixWorkspace_sptr &ws, double noise, const double lower, const double upper) {
394 const size_t seed(12345);
395 MersenneTwister randGen(seed, lower, upper);
396 for (size_t iSpec = 0; iSpec < ws->getNumberHistograms(); iSpec++) {
397 auto &mutableY = ws->mutableY(iSpec);
398 auto &mutableE = ws->mutableE(iSpec);
399 for (size_t i = 0; i < mutableY.size(); i++) {
400 mutableY[i] += noise * randGen.nextValue();
401 mutableE[i] += noise;
402 }
403 }
404}
405
412Workspace2D_sptr create2DWorkspaceWithFullInstrument(int nhist, int nbins, bool includeMonitors, bool startYNegative,
413 bool isHistogram, const std::string &instrumentName, bool hasDx) {
414 if (includeMonitors && nhist < 2) {
415 throw std::invalid_argument("Attempting to 2 include monitors for a "
416 "workspace with fewer than 2 histograms");
417 }
418
419 Workspace2D_sptr space;
420 // A 1:1 spectra is created by default
421 if (isHistogram)
422 space = create2DWorkspaceBinned(nhist, nbins, hasDx);
423 else
424 space = create2DWorkspace123(nhist, nbins, false, std::set<int64_t>(), hasDx);
425 // actually adds a property called run_title to the logs
426 space->setTitle("Test histogram");
427 space->getAxis(0)->setUnit("TOF");
428 space->setYUnit("Counts");
429
430 InstrumentCreationHelper::addFullInstrumentToWorkspace(*space, includeMonitors, startYNegative, instrumentName);
431
432 return space;
433}
434
435//================================================================================================================
436/*
437 * startTime is in seconds
438 */
440 size_t startTime, size_t firstInterval,
441 bool includeMonitors, bool startYNegative,
442 bool isHistogram,
443 const std::string &instrumentName) {
444
445 auto baseWS =
446 create2DWorkspaceWithFullInstrument(nhist, nbins, includeMonitors, startYNegative, isHistogram, instrumentName);
447
448 auto builder = ScanningWorkspaceBuilder(baseWS->getInstrument(), nTimeIndexes, nbins);
449
450 std::vector<double> timeRanges;
451 for (size_t i = 0; i < nTimeIndexes; ++i) {
452 timeRanges.emplace_back(double(i + firstInterval));
453 }
454
455 builder.setTimeRanges(DateAndTime(int(startTime), 0), timeRanges);
456
457 return builder.buildWorkspace();
458}
459
460//================================================================================================================
466Workspace2D_sptr create2DWorkspaceWithGeographicalDetectors(const int nlat, const int nlong, const double anginc,
467 const int nbins, const double x0, const double deltax,
468 const std::string &instrumentName,
469 const std::string &xunit) {
470 auto inputWorkspace = WorkspaceCreationHelper::create2DWorkspaceBinned(nlat * nlong, nbins, x0, deltax);
471 inputWorkspace->getAxis(0)->unit() = UnitFactory::Instance().create(xunit);
472
474 instrumentName);
475
476 return inputWorkspace;
477}
478
479//================================================================================================================
491 int numBins,
492 const std::string &instrumentName) {
493 Instrument_sptr inst =
494 ComponentCreationHelper::createTestInstrumentRectangular(numBanks, numPixels, 0.008, 5.0, false, instrumentName);
495 Workspace2D_sptr ws = create2DWorkspaceBinned(numBanks * numPixels * numPixels, numBins);
496 ws->setInstrument(inst);
497 ws->getAxis(0)->setUnit("dSpacing");
498 for (size_t wi = 0; wi < ws->getNumberHistograms(); wi++) {
499 ws->getSpectrum(wi).setDetectorID(detid_t(numPixels * numPixels + wi));
500 ws->getSpectrum(wi).setSpectrumNo(specnum_t(wi));
501 }
502
503 return ws;
504}
505
506//================================================================================================================
518 bool clearEvents) {
520 EventWorkspace_sptr ws = createEventWorkspace2(numBanks * numPixels * numPixels, 100);
521 ws->setInstrument(inst);
522
523 // Set the X axes
524 const auto &xVals = ws->x(0);
525 const size_t xSize = xVals.size();
526 auto ax0 = std::make_unique<NumericAxis>(xSize);
527 ax0->setUnit("dSpacing");
528 for (size_t i = 0; i < xSize; i++) {
529 ax0->setValue(i, xVals[i]);
530 }
531 ws->replaceAxis(0, std::move(ax0));
532
533 // re-assign detector IDs to the rectangular detector
534 const auto detIds = inst->getDetectorIDs();
535 for (int wi = 0; wi < static_cast<int>(ws->getNumberHistograms()); ++wi) {
536 ws->getSpectrum(wi).clearDetectorIDs();
537 if (clearEvents)
538 ws->getSpectrum(wi).clear(true);
539 ws->getSpectrum(wi).setDetectorID(detIds[wi]);
540 }
541 return ws;
542}
543
555 bool clearEvents) {
557 EventWorkspace_sptr ws = createEventWorkspace2(numBanks * numPixels * numPixels, 100);
558 ws->setInstrument(inst);
559
560 // Set the X axes
561 const auto &xVals = ws->x(0);
562 const size_t xSize = xVals.size();
563 auto ax0 = std::make_unique<NumericAxis>(xSize);
564 ax0->setUnit("dSpacing");
565 for (size_t i = 0; i < xSize; i++) {
566 ax0->setValue(i, xVals[i]);
567 }
568 ws->replaceAxis(0, std::move(ax0));
569
570 // re-assign detector IDs to the rectangular detector
571 const auto detIds = inst->getDetectorIDs();
572 for (int wi = 0; wi < static_cast<int>(ws->getNumberHistograms()); ++wi) {
573 ws->getSpectrum(wi).clearDetectorIDs();
574 if (clearEvents)
575 ws->getSpectrum(wi).clear(true);
576 ws->getSpectrum(wi).setDetectorID(detIds[wi]);
577 }
578 return ws;
579}
580
582 // Number of detectors in a bank as created by createTestInstrumentCylindrical
583 const int DETECTORS_PER_BANK(9);
584
585 V3D srcPos(0., 0., -10.), samplePos;
586 Instrument_sptr inst =
587 ComponentCreationHelper::createTestInstrumentCylindrical(numBanks, srcPos, samplePos, 0.0025, 0.005);
588 EventWorkspace_sptr ws = createEventWorkspace2(numBanks * DETECTORS_PER_BANK, 100);
589 ws->setInstrument(inst);
590
591 std::vector<detid_t> detectorIds = inst->getDetectorIDs();
592
593 // Should be equal if DETECTORS_PER_BANK is correct
594 assert(detectorIds.size() == ws->getNumberHistograms());
595
596 // Re-assign detector IDs
597 for (size_t wi = 0; wi < ws->getNumberHistograms(); wi++) {
598 ws->getSpectrum(wi).clearDetectorIDs();
599 if (clearEvents)
600 ws->getSpectrum(wi).clear(true);
601 ws->getSpectrum(wi).setDetectorID(detectorIds[wi]);
602 }
603
604 return ws;
605}
606
615DataObjects::Workspace2D_sptr reflectometryWorkspace(const double startX, const int nSpectra, const int nBins,
616 const double deltaX) {
617
618 auto workspace = create2DWorkspaceBinned(nSpectra, nBins, startX, deltaX);
619
620 workspace->setTitle("Test histogram"); // actually adds a property call run_title to the logs
621 workspace->getAxis(0)->setUnit("TOF");
622 workspace->setYUnit("Counts");
623 return workspace;
624}
625
642 const V3D &slit2Pos, const double vg1,
643 const double vg2, const V3D &sourcePos,
644 const V3D &monitorPos, const V3D &samplePos,
645 const V3D &detectorPos, const int nBins,
646 const double deltaX) {
647 Instrument_sptr instrument = std::make_shared<Instrument>();
648 instrument->setReferenceFrame(
649 std::make_shared<ReferenceFrame>(PointingAlong::Y, PointingAlong::X, Handedness::Left, "0,0,0"));
650
651 InstrumentCreationHelper::addSource(instrument, sourcePos, "source");
652 InstrumentCreationHelper::addMonitor(instrument, monitorPos, 1, "Monitor");
653 InstrumentCreationHelper::addSample(instrument, samplePos, "some-surface-holder");
654 InstrumentCreationHelper::addDetector(instrument, detectorPos, 2, "point-detector");
655 auto slit1 = InstrumentCreationHelper::addComponent(instrument, slit1Pos, "slit1");
656 auto slit2 = InstrumentCreationHelper::addComponent(instrument, slit2Pos, "slit2");
657
658 auto workspace = reflectometryWorkspace(startX, 2, nBins, deltaX);
659 workspace->setInstrument(instrument);
660
661 ParameterMap &pmap = workspace->instrumentParameters();
662 pmap.addDouble(slit1, "vertical gap", vg1);
663 pmap.addDouble(slit2, "vertical gap", vg2);
664
665 workspace->getSpectrum(0).setDetectorID(2);
666 workspace->getSpectrum(1).setDetectorID(1);
667
668 return workspace;
669}
670
690 const double startX, const double detSize, const V3D &slit1Pos, const V3D &slit2Pos, const double vg1,
691 const double vg2, const V3D &sourcePos, const V3D &monitorPos, const V3D &samplePos, const V3D &detectorCenterPos,
692 const int nSpectra, const int nBins, const double deltaX) {
693 Instrument_sptr instrument = std::make_shared<Instrument>();
694 instrument->setReferenceFrame(
695 std::make_shared<ReferenceFrame>(PointingAlong::Y /*up*/, PointingAlong::X /*along*/, Handedness::Left, "0,0,0"));
696
697 InstrumentCreationHelper::addSource(instrument, sourcePos, "source");
698 InstrumentCreationHelper::addSample(instrument, samplePos, "some-surface-holder");
699 InstrumentCreationHelper::addMonitor(instrument, monitorPos, 1, "Monitor");
700
701 const int nDet = nSpectra - 1;
702 const double minY = detectorCenterPos.Y() - detSize * (nDet - 1) / 2.;
703 for (int i = 0; i < nDet; ++i) {
704 const double y = minY + i * detSize;
705 const V3D pos{detectorCenterPos.X(), y, detectorCenterPos.Z()};
706 InstrumentCreationHelper::addDetector(instrument, pos, i + 2, "point-detector");
707 }
708 auto slit1 = InstrumentCreationHelper::addComponent(instrument, slit1Pos, "slit1");
709 auto slit2 = InstrumentCreationHelper::addComponent(instrument, slit2Pos, "slit2");
710
711 auto workspace = reflectometryWorkspace(startX, nSpectra, nBins, deltaX);
712 workspace->setInstrument(instrument);
713 ParameterMap &pmap = workspace->instrumentParameters();
714 pmap.addDouble(slit1, "vertical gap", vg1);
715 pmap.addDouble(slit2, "vertical gap", vg2);
716 for (int i = 0; i < nSpectra; ++i) {
717 workspace->getSpectrum(i).setDetectorID(i + 1);
718 }
719 return workspace;
720}
721
723 const V3D &sourcePosition, const std::vector<V3D> &detectorPositions) {
724 Instrument_sptr instrument = std::make_shared<Instrument>();
725 instrument->setReferenceFrame(std::make_shared<ReferenceFrame>(Y, X, Left, "0,0,0"));
726
727 InstrumentCreationHelper::addSource(instrument, sourcePosition, "source");
728 InstrumentCreationHelper::addSample(instrument, samplePosition, "sample");
729
730 for (int i = 0; i < static_cast<int>(detectorPositions.size()); ++i) {
731 std::stringstream buffer;
732 buffer << "detector_" << i;
733 InstrumentCreationHelper::addDetector(instrument, detectorPositions[i], i, buffer.str());
734
735 // Link it to the workspace
736 workspace->getSpectrum(i).addDetectorID(i);
737 }
738 workspace->setInstrument(instrument);
739}
740
741//================================================================================================================
743 return std::make_shared<WorkspaceSingleValue>(value, sqrt(value));
744}
745
747 return std::make_shared<WorkspaceSingleValue>(value, error);
748}
749
752 // get a proton charge
753 ew->mutableRun().integrateProtonCharge();
754}
755
761
768EventWorkspace_sptr createEventWorkspace2(int numPixels, int numBins) {
769 return createEventWorkspace(numPixels, numBins, 100, 0.0, 1.0, 2);
770}
771
774EventWorkspace_sptr createEventWorkspace(int numPixels, int numBins, int numEvents, double x0, double binDelta,
775 int eventPattern, int start_at_pixelID) {
776 return createEventWorkspaceWithStartTime(numPixels, numBins, numEvents, x0, binDelta, eventPattern, start_at_pixelID,
777 DateAndTime("2010-01-01T00:00:00"));
778}
779
783EventWorkspace_sptr createEventWorkspaceWithStartTime(int numPixels, int numBins, int numEvents, double x0,
784 double binDelta, int eventPattern, int start_at_pixelID,
785 DateAndTime run_start) {
786
787 // add one to the number of bins as this is histogram
788 numBins++;
789
790 auto retVal = std::make_shared<EventWorkspace>();
791 retVal->initialize(numPixels, 1, 1);
792
793 // Make fake events
794 if (eventPattern) // 0 == no events
795 {
796 size_t workspaceIndex = 0;
797 for (int pix = start_at_pixelID + 0; pix < start_at_pixelID + numPixels; pix++) {
798 EventList &el = retVal->getSpectrum(workspaceIndex);
799 el.setSpectrumNo(pix);
800 el.setDetectorID(pix);
801
802 for (int i = 0; i < numEvents; i++) {
803 if (eventPattern == 1) // 0, 1 diagonal pattern
804 el += TofEvent((pix + i + 0.5) * binDelta, run_start + double(i));
805 else if (eventPattern == 2) // solid 2
806 {
807 el += TofEvent((i + 0.5) * binDelta, run_start + double(i));
808 el += TofEvent((i + 0.5) * binDelta, run_start + double(i));
809 } else if (eventPattern == 3) // solid 1
810 {
811 el += TofEvent((i + 0.5) * binDelta, run_start + double(i));
812 } else if (eventPattern == 4) // Number of events per bin = pixelId (aka
813 // workspace index in most cases)
814 {
815 for (int q = 0; q < pix; q++)
816 el += TofEvent((i + 0.5) * binDelta, run_start + double(i));
817 }
818 }
819 workspaceIndex++;
820 }
821 }
822
823 retVal->setAllX(BinEdges(numBins, LinearGenerator(x0, binDelta)));
824
825 return retVal;
826}
827
828// =====================================================================================
831EventWorkspace_sptr createGroupedEventWorkspace(std::vector<std::vector<int>> const &groups, int numBins,
832 double binDelta, double xOffset) {
833
834 auto retVal = std::make_shared<EventWorkspace>();
835 retVal->initialize(groups.size(), 2, 1);
836
837 for (size_t g = 0; g < groups.size(); g++) {
838 retVal->getSpectrum(g).clearDetectorIDs();
839 std::vector<int> dets = groups[g];
840 for (auto det : dets) {
841 for (int i = 0; i < numBins; i++)
842 retVal->getSpectrum(g) += TofEvent((i + 0.5) * binDelta, 1);
843 retVal->getSpectrum(g).addDetectorID(det);
844 }
845 }
846
847 if (xOffset == 0.) {
848 retVal->setAllX(BinEdges(numBins, LinearGenerator(0.0, binDelta)));
849 } else {
850 for (size_t g = 0; g < groups.size(); g++) {
851 // Create the x-axis for histogramming.
852 const double x0 = xOffset * static_cast<double>(g);
853 retVal->setX(g, make_cow<HistogramX>(numBins, LinearGenerator(x0, binDelta)));
854 }
855 }
856
857 return retVal;
858}
859
860// =====================================================================================
868EventWorkspace_sptr createRandomEventWorkspace(size_t numbins, size_t numpixels, double bin_delta) {
869 auto retVal = std::make_shared<EventWorkspace>();
870 retVal->initialize(numpixels, numbins, numbins - 1);
871
872 // and X-axis for references:
873 auto pAxis0 = std::make_unique<NumericAxis>(numbins);
874 // Create the original X axis to histogram on.
875 // Create the x-axis for histogramming.
876 HistogramData::BinEdges axis(numbins, LinearGenerator(0.0, bin_delta));
877 for (int i = 0; i < static_cast<int>(numbins); ++i) {
878 pAxis0->setValue(i, axis[i]);
879 }
880 pAxis0->setUnit("TOF");
881
882 MersenneTwister randomGen(DateAndTime::getCurrentTime().nanoseconds(), 0, std::numeric_limits<int>::max());
883 // Make up some data for each pixels
884 for (size_t i = 0; i < numpixels; i++) {
885 // Create one event for each bin
886 EventList &events = retVal->getSpectrum(static_cast<detid_t>(i));
887 for (std::size_t ie = 0; ie < numbins; ie++) {
888 // Create a list of events, randomize
889 events += TofEvent(static_cast<double>(randomGen.nextValue()), static_cast<int64_t>(randomGen.nextValue()));
890 }
891 events.addDetectorID(detid_t(i));
892 }
893 retVal->setAllX(axis);
894 retVal->replaceAxis(0, std::move(pAxis0));
895
896 return retVal;
897}
898
899// =====================================================================================
903MatrixWorkspace_sptr createGroupedWorkspace2D(size_t numHist, int numBins, double binDelta) {
904 Workspace2D_sptr retVal = create2DWorkspaceBinned(static_cast<int>(numHist), numBins, 0.0, binDelta);
905 retVal->setInstrument(ComponentCreationHelper::createTestInstrumentCylindrical(static_cast<int>(numHist)));
906
907 for (int g = 0; g < static_cast<int>(numHist); g++) {
908 auto &spec = retVal->getSpectrum(g);
909 for (int i = 1; i <= 9; i++)
910 spec.addDetectorID(g * 9 + i);
911 spec.setSpectrumNo(g + 1); // Match detector ID and spec NO
912 }
913 return std::dynamic_pointer_cast<MatrixWorkspace>(retVal);
914}
915
916// =====================================================================================
917// RootOfNumHist == square root of hystohram number;
918MatrixWorkspace_sptr createGroupedWorkspace2DWithRingsAndBoxes(size_t RootOfNumHist, int numBins, double binDelta) {
919 size_t numHist = RootOfNumHist * RootOfNumHist;
920 Workspace2D_sptr retVal = create2DWorkspaceBinned(static_cast<int>(numHist), numBins, 0.0, binDelta);
921 retVal->setInstrument(ComponentCreationHelper::createTestInstrumentCylindrical(static_cast<int>(numHist)));
922 for (int g = 0; g < static_cast<int>(numHist); g++) {
923 auto &spec = retVal->getSpectrum(g);
924 spec.addDetectorID(g + 1); // Legacy comptibilty: Used to be default IDs in Workspace2D.
925 for (int i = 1; i <= 9; i++)
926 spec.addDetectorID(g * 9 + i);
927 spec.setSpectrumNo(g + 1); // Match detector ID and spec NO
928 }
929 return std::dynamic_pointer_cast<MatrixWorkspace>(retVal);
930}
931
932// not strictly creating a workspace, but really helpful to see what one
933// contains
935 const size_t numHists = ws->getNumberHistograms();
936 for (size_t i = 0; i < numHists; ++i) {
937 std::cout << "Histogram " << i << " = ";
938 const auto &y = ws->y(i);
939 for (size_t j = 0; j < y.size(); ++j) {
940 std::cout << y[j] << " ";
941 }
942 std::cout << '\n';
943 }
944}
946
947// not strictly creating a workspace, but really helpful to see what one
948// contains
950 const size_t numHists = ws->getNumberHistograms();
951 for (size_t i = 0; i < numHists; ++i) {
952 std::cout << "Histogram " << i << " = ";
953 const auto &x = ws->x(i);
954 for (size_t j = 0; j < x.size(); ++j) {
955 std::cout << x[j] << " ";
956 }
957 std::cout << '\n';
958 }
959}
960
961// not strictly creating a workspace, but really helpful to see what one
962// contains
964 const size_t numHists = ws->getNumberHistograms();
965 for (size_t i = 0; i < numHists; ++i) {
966 std::cout << "Histogram " << i << " = ";
967 const auto &e = ws->e(i);
968 for (size_t j = 0; j < e.size(); ++j) {
969 std::cout << e[j] << " ";
970 }
971 std::cout << '\n';
972 }
973}
974
975// =====================================================================================
982void addTSPEntry(Run &runInfo, const std::string &name, double val) {
985 tsp->addValue("2011-05-24T00:00:00", val);
986 runInfo.addProperty(tsp);
987}
988
989// =====================================================================================
998void setOrientedLattice(const Mantid::API::MatrixWorkspace_sptr &ws, double a, double b, double c) {
999 ws->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>(a, b, c, 90., 90., 90.));
1000}
1001
1002// =====================================================================================
1010void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &ws, double phi, double chi, double omega) {
1011 addTSPEntry(ws->mutableRun(), "phi", phi);
1012 addTSPEntry(ws->mutableRun(), "chi", chi);
1013 addTSPEntry(ws->mutableRun(), "omega", omega);
1016 ws->mutableRun().setGoniometer(gm, true);
1017}
1018
1019//
1021 bool has_oriented_lattice) {
1022 auto rHist = static_cast<size_t>(std::sqrt(static_cast<double>(numPixels)));
1023 while (rHist * rHist < numPixels)
1024 rHist++;
1025
1027 auto pAxis0 = std::make_unique<NumericAxis>(numBins);
1028 for (size_t i = 0; i < numBins; i++) {
1029 double dE = -1.0 + static_cast<double>(i) * 0.8;
1030 pAxis0->setValue(i, dE);
1031 }
1032 pAxis0->setUnit("DeltaE");
1033 ws->replaceAxis(0, std::move(pAxis0));
1034 if (has_oriented_lattice) {
1035 ws->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>(1, 1, 1, 90., 90., 90.));
1036
1037 addTSPEntry(ws->mutableRun(), "phi", 0);
1038 addTSPEntry(ws->mutableRun(), "chi", 0);
1039 addTSPEntry(ws->mutableRun(), "omega", 0);
1042 ws->mutableRun().setGoniometer(gm, true);
1043 }
1044
1045 return ws;
1046}
1047
1058 const std::vector<double> &polar,
1059 const std::vector<double> &azimutal, size_t numBins,
1060 double Emin, double Emax, double Ei) {
1061 // not used but interface needs it
1062 std::set<int64_t> maskedWorkspaceIndices;
1063 size_t numPixels = L2.size();
1064
1066 create2DWorkspaceWithValues(uint64_t(numPixels), uint64_t(numBins), true, maskedWorkspaceIndices, 0, 1, 0.1);
1067
1068 // detectors at L2, sample at 0 and source at -L2_min
1069 ws->setInstrument(ComponentCreationHelper::createCylInstrumentWithDetInGivenPositions(L2, polar, azimutal));
1070
1071 for (int g = 0; g < static_cast<int>(numPixels); g++) {
1072 auto &spec = ws->getSpectrum(g);
1073 // we just made (in createCylInstrumentWithDetInGivenPosisions) det ID-s to
1074 // start from 1
1075 spec.setDetectorID(g + 1);
1076 // and this is absolutely different nummer, corresponding to det ID just by
1077 // chance ? -- some uncertainties remain
1078 spec.setSpectrumNo(g + 1);
1079 // spec->setSpectrumNo(g+1);
1080 // spec->addDetectorID(g*9);
1081 // spec->setSpectrumNo(g+1); // Match detector ID and spec NO
1082 }
1083
1084 const double dE = (Emax - Emin) / static_cast<double>(numBins);
1085 for (size_t j = 0; j < numPixels; j++) {
1086 std::vector<double> E_transfer;
1087 E_transfer.reserve(numBins);
1088 for (size_t i = 0; i <= numBins; i++) {
1089 E_transfer.emplace_back(Emin + static_cast<double>(i) * dE);
1090 }
1091 ws->mutableX(j) = E_transfer;
1092 }
1093
1094 // set axis, correspondent to the X-values
1095 auto pAxis0 = std::make_unique<NumericAxis>(numBins);
1096 const auto &E_transfer = ws->x(0);
1097 for (size_t i = 0; i < numBins; i++) {
1098 double E = 0.5 * (E_transfer[i] + E_transfer[i + 1]);
1099 pAxis0->setValue(i, E);
1100 }
1101
1102 pAxis0->setUnit("DeltaE");
1103
1104 ws->replaceAxis(0, std::move(pAxis0));
1105
1106 // define oriented lattice which requested for processed ws
1107 ws->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>(1, 1, 1, 90., 90., 90.));
1108
1109 ws->mutableRun().addProperty(new PropertyWithValue<std::string>("deltaE-mode", "Direct"), true);
1110 ws->mutableRun().addProperty(new PropertyWithValue<double>("Ei", Ei), true);
1111 // these properties have to be different -> specific for processed ws, as time
1112 // now should be reconciled
1113 addTSPEntry(ws->mutableRun(), "phi", 0);
1114 addTSPEntry(ws->mutableRun(), "chi", 0);
1115 addTSPEntry(ws->mutableRun(), "omega", 0);
1118 ws->mutableRun().setGoniometer(gm, true);
1119
1120 return ws;
1121}
1122
1123/*
1124 * Create an EventWorkspace from a source EventWorkspace.
1125 * The new workspace should be exactly the same as the source workspace but
1126 * without any events
1127 */
1130 API::Algorithm *alg) {
1131 UNUSED_ARG(wsname);
1132 // 1. Initialize:use dummy numbers for arguments, for event workspace it
1133 // doesn't matter
1136 outputWS->initialize(sourceWS->getInstrument()->getDetectorIDs(true).size(), 1, 1);
1137
1138 // 2. Set the units
1139 outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("TOF");
1140 outputWS->setYUnit("Counts");
1141 outputWS->setTitle("Empty_Title");
1142
1143 // 3. Add the run_start property:
1144 int runnumber = sourceWS->getRunNumber();
1145 outputWS->mutableRun().addProperty("run_number", runnumber);
1146
1147 std::string runstartstr = sourceWS->run().getProperty("run_start")->value();
1148 outputWS->mutableRun().addProperty("run_start", runstartstr);
1149
1150 // 4. Instrument
1151 Mantid::API::Algorithm_sptr loadInst = alg->createChildAlgorithm("LoadInstrument");
1152 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
1153 loadInst->setPropertyValue("InstrumentName", sourceWS->getInstrument()->getName());
1154 loadInst->setProperty<MatrixWorkspace_sptr>("Workspace", outputWS);
1155 loadInst->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(true));
1156 loadInst->executeAsChildAlg();
1157 // Populate the instrument parameters in this workspace - this works around a
1158 // bug
1159 outputWS->populateInstrumentParameters();
1160
1161 // 6. Build spectrum and event list
1162 // a) We want to pad out empty pixels.
1163 detid2det_map detector_map;
1164 outputWS->getInstrument()->getDetectors(detector_map);
1165
1166 // b) Pad all the pixels and Set to zero
1167 size_t workspaceIndex = 0;
1168 const auto &detectorInfo = outputWS->detectorInfo();
1169 for (auto it = detector_map.begin(); it != detector_map.end(); ++it) {
1170 if (!detectorInfo.isMonitor(detectorInfo.indexOf(it->first))) {
1171 auto &spec = outputWS->getSpectrum(workspaceIndex);
1172 spec.addDetectorID(it->first);
1173 // Start the spectrum number at 1
1174 spec.setSpectrumNo(specnum_t(workspaceIndex + 1));
1175 workspaceIndex += 1;
1176 }
1177 }
1178
1179 return outputWS;
1180}
1181
1184 // outputWS->setName("rebinTest");
1185 Mantid::API::AnalysisDataService::Instance().add("rebinTest", outputWS);
1186
1187 // Set Q ('y') axis binning
1188 std::vector<double> qbins{0.0, 1.0, 4.0};
1189 std::vector<double> qaxis;
1190 const auto numY = static_cast<int>(VectorHelper::createAxisFromRebinParams(qbins, qaxis));
1191
1192 // Initialize the workspace
1193 const int numHist = numY - 1;
1194 const int numX = 7;
1195 outputWS->initialize(numHist, numX, numX - 1);
1196
1197 // Set the normal units
1198 outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("DeltaE");
1199 outputWS->setYUnit("Counts");
1200 outputWS->setTitle("Empty_Title");
1201
1202 // Create the i-axis for histogramming.
1203 HistogramData::BinEdges x1{-3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0};
1204
1205 // Create a numeric axis to replace the default vertical one
1206 auto verticalAxis = std::make_unique<NumericAxis>(numY);
1207
1208 // Now set the axis values
1209 for (int i = 0; i < numHist; ++i) {
1210 outputWS->setBinEdges(i, x1);
1211 verticalAxis->setValue(i, qaxis[i]);
1212 }
1213 // One more to set on the 'y' axis
1214 verticalAxis->setValue(numHist, qaxis[numHist]);
1215
1216 // Set the 'y' axis units
1217 verticalAxis->unit() = UnitFactory::Instance().create("MomentumTransfer");
1218 verticalAxis->title() = "|Q|";
1219 outputWS->replaceAxis(1, std::move(verticalAxis));
1220
1221 // Set the X axis title (for conversion to MD)
1222 outputWS->getAxis(0)->title() = "Energy transfer";
1223
1224 // Now, setup the data
1225 // Q bin #1
1226
1227 // Populates destination starting at index 1 with the following data
1228 // e.g. y(0)[1] = 2.0, y(0)[2] = 3.0 ..etc. as the starting index is 1
1229 // if you change the values in the line below please update this comment!
1230 populateWsWithInitList(outputWS->mutableY(0), 1, {2.0, 3.0, 3.0, 2.0});
1231 populateWsWithInitList(outputWS->mutableE(0), 1, {2.0, 3.0, 3.0, 2.0});
1232 populateWsWithInitList(outputWS->dataF(0), 1, {2.0, 3.0, 3.0, 1.0});
1233
1234 // Q bin #2
1235 populateWsWithInitList(outputWS->mutableY(1), 1, {1.0, 3.0, 3.0, 2.0, 2.0});
1236 populateWsWithInitList(outputWS->mutableE(1), 1, {1.0, 3.0, 3.0, 2.0, 2.0});
1237 populateWsWithInitList(outputWS->dataF(1), 1, {1.0, 3.0, 3.0, 1.0, 2.0});
1238
1239 // Q bin #3
1240 populateWsWithInitList(outputWS->mutableY(2), 1, {1.0, 2.0, 3.0, 1.0});
1241 populateWsWithInitList(outputWS->mutableE(2), 1, {1.0, 2.0, 3.0, 1.0});
1242 populateWsWithInitList(outputWS->dataF(2), 1, {1.0, 2.0, 2.0, 1.0});
1243
1244 // Q bin #4
1245 populateWsWithInitList(outputWS->mutableY(3), 0, {1.0, 2.0, 3.0, 2.0, 1.0});
1246 populateWsWithInitList(outputWS->mutableE(3), 0, {1.0, 2.0, 3.0, 2.0, 1.0});
1247 populateWsWithInitList(outputWS->dataF(3), 0, {1.0, 2.0, 3.0, 2.0, 1.0, 1.0});
1248
1249 // Set representation
1250 outputWS->finalize();
1251
1252 // Make errors squared rooted and set sqrd err flag
1253 for (int i = 0; i < numHist; ++i) {
1254 auto &mutableE = outputWS->mutableE(i);
1255 for (int j = 0; j < numX - 1; ++j) {
1256 mutableE[j] = std::sqrt(mutableE[j]);
1257 }
1258 }
1259 outputWS->setSqrdErrors(false);
1260
1261 return outputWS;
1262}
1263
1276template <typename T>
1277void populateWsWithInitList(T &destination, size_t startingIndex, const std::initializer_list<double> &values) {
1278 size_t index = 0;
1279 for (const double val : values) {
1280 destination[startingIndex + index] = val;
1281 index++;
1282 }
1283}
1284
1285Mantid::DataObjects::PeaksWorkspace_sptr createPeaksWorkspace(const int numPeaks, const bool createOrientedLattice) {
1286 auto peaksWS = std::make_shared<PeaksWorkspace>();
1288 peaksWS->setInstrument(inst);
1289
1290 for (int i = 0; i < numPeaks; ++i) {
1291 Peak peak(inst, i, i + 0.5);
1292 peaksWS->addPeak(peak);
1293 }
1294
1295 if (createOrientedLattice) {
1296 peaksWS->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>());
1297 }
1298 return peaksWS;
1299}
1300
1302 const Mantid::Kernel::DblMatrix &ubMat) {
1303 if (ubMat.numRows() != 3 || ubMat.numCols() != 3) {
1304 throw std::invalid_argument("UB matrix is not 3x3");
1305 }
1306
1307 auto peaksWS = createPeaksWorkspace(numPeaks, true);
1308 peaksWS->mutableSample().getOrientedLattice().setUB(ubMat);
1309 return peaksWS;
1310}
1311
1313 const bool createOrientedLattice) {
1314 auto peaksWS = std::make_shared<LeanElasticPeaksWorkspace>();
1316 for (int i = 0; i < numPeaks; ++i) {
1317 Peak peak(inst, i, i + 0.5);
1318 LeanElasticPeak lpeak(peak);
1319 peaksWS->addPeak(lpeak);
1320 }
1321
1322 if (createOrientedLattice) {
1323 peaksWS->mutableSample().setOrientedLattice(std::make_unique<OrientedLattice>());
1324 }
1325 return peaksWS;
1326}
1327
1329 const Mantid::Kernel::DblMatrix &ubMat) {
1330 if (ubMat.numRows() != 3 || ubMat.numCols() != 3) {
1331 throw std::invalid_argument("UB matrix is not 3x3");
1332 }
1333
1334 auto peaksWS = createLeanPeaksWorkspace(numPeaks, true);
1335 peaksWS->mutableSample().getOrientedLattice().setUB(ubMat);
1336 return peaksWS;
1337}
1338
1339void create2DAngles(std::vector<double> &L2, std::vector<double> &polar, std::vector<double> &azim, size_t nPolar,
1340 size_t nAzim, double polStart, double polEnd, double azimStart, double azimEnd) {
1341 size_t nDet = nPolar * nAzim;
1342 L2.resize(nDet, 10);
1343 polar.resize(nDet);
1344 azim.resize(nDet);
1345
1346 double dPolar = (polEnd - polStart) / static_cast<double>(nDet - 1);
1347 double dAzim = (azimEnd - azimEnd) / static_cast<double>(nDet - 1);
1348 for (size_t i = 0; i < nPolar; i++) {
1349 for (size_t j = 0; j < nAzim; j++) {
1350 polar[i * nPolar + j] = polStart + dPolar * static_cast<double>(i);
1351 azim[i * nPolar + j] = azimStart + dAzim * static_cast<double>(j);
1352 }
1353 }
1354}
1355
1356ITableWorkspace_sptr createEPPTableWorkspace(const std::vector<EPPTableRow> &rows) {
1357 ITableWorkspace_sptr ws = std::make_shared<TableWorkspace>(rows.size());
1358 auto wsIndexColumn = ws->addColumn("int", "WorkspaceIndex");
1359 auto centreColumn = ws->addColumn("double", "PeakCentre");
1360 auto centreErrorColumn = ws->addColumn("double", "PeakCentreError");
1361 auto sigmaColumn = ws->addColumn("double", "Sigma");
1362 auto sigmaErrorColumn = ws->addColumn("double", "SigmaError");
1363 auto heightColumn = ws->addColumn("double", "Height");
1364 auto heightErrorColumn = ws->addColumn("double", "HeightError");
1365 auto chiSqColumn = ws->addColumn("double", "chiSq");
1366 auto statusColumn = ws->addColumn("str", "FitStatus");
1367 for (size_t i = 0; i != rows.size(); ++i) {
1368 const auto &row = rows[i];
1369 if (row.workspaceIndex < 0) {
1370 wsIndexColumn->cell<int>(i) = static_cast<int>(i);
1371 } else {
1372 wsIndexColumn->cell<int>(i) = row.workspaceIndex;
1373 }
1374 centreColumn->cell<double>(i) = row.peakCentre;
1375 centreErrorColumn->cell<double>(i) = row.peakCentreError;
1376 sigmaColumn->cell<double>(i) = row.sigma;
1377 sigmaErrorColumn->cell<double>(i) = row.sigmaError;
1378 heightColumn->cell<double>(i) = row.height;
1379 heightErrorColumn->cell<double>(i) = row.heightError;
1380 chiSqColumn->cell<double>(i) = row.chiSq;
1381 statusColumn->cell<std::string>(i) = row.fitStatus == EPPTableRow::FitStatus::SUCCESS ? "success" : "failed";
1382 }
1383 return ws;
1384}
1386 int maskedWorkspaceIndex, int maskedBinIndex) {
1387 auto ws = create2DWorkspace123(numHist, numBins);
1388 ws->flagMasked(maskedWorkspaceIndex, maskedBinIndex);
1389 return ws;
1390}
1391
1392MatrixWorkspace_sptr createSNAPLiteInstrument(const std::string &wkspName, const double ang1, const double ang2) {
1393 // Use lite instrument based on one valid starting 2018-05-01
1394 const std::string IDF_FILE("SNAPLite_Definition.xml");
1395
1396 // Create empty instrument
1397 auto loadEmptyInstr = AlgorithmManager::Instance().createUnmanaged("LoadEmptyInstrument");
1398 loadEmptyInstr->initialize();
1399 loadEmptyInstr->setProperty("Filename", IDF_FILE);
1400 loadEmptyInstr->setProperty("OutputWorkspace", wkspName);
1401
1402 loadEmptyInstr->execute();
1403 if (!loadEmptyInstr->isExecuted())
1404 throw std::runtime_error("Failed to execute LoadEmptyInstrument");
1405
1406 // add logs
1407 // for some reason, the units aren't in the logs
1408 TimeSeriesProperty<double> *ang1Prop = new TimeSeriesProperty<double>("det_arc1");
1409 ang1Prop->addValue(DateAndTime(0), ang1);
1410 TimeSeriesProperty<double> *ang2Prop = new TimeSeriesProperty<double>("det_arc2");
1411 ang2Prop->addValue(DateAndTime(0), ang2);
1412 TimeSeriesProperty<double> *len1Prop = new TimeSeriesProperty<double>("det_lin1");
1413 len1Prop->addValue(DateAndTime(0), 0.045);
1414 TimeSeriesProperty<double> *len2Prop = new TimeSeriesProperty<double>("det_lin2");
1415 len2Prop->addValue(DateAndTime(0), 0.043);
1416
1418 std::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(wkspName));
1419 wsIn->mutableRun().addProperty(ang1Prop);
1420 wsIn->mutableRun().addProperty(ang2Prop);
1421 wsIn->mutableRun().addProperty(len1Prop);
1422 wsIn->mutableRun().addProperty(len2Prop);
1423
1424 // reload instrument so the logs are used
1425 auto loadInstr = AlgorithmManager::Instance().createUnmanaged("LoadInstrument");
1426 loadInstr->initialize();
1427 loadInstr->setProperty("Workspace", wkspName);
1428 loadInstr->setProperty("Filename", IDF_FILE);
1429 loadInstr->setProperty("RewriteSpectraMap", "False");
1430 loadInstr->execute();
1431 if (!loadInstr->isExecuted())
1432 throw std::runtime_error("Failed to execute LoadInstrument");
1433
1434 // set the units so DiffractionFocussing will do its job
1435 auto xAxis = wsIn->getAxis(0);
1436 xAxis->unit() = Mantid::Kernel::UnitFactory::Instance().create("dSpacing");
1437 return wsIn;
1438}
1439
1440MatrixWorkspace_sptr createFocusedSNAPLiteInstrument(const std::string &wkspName, const std::string &groupingAlg,
1441 const std::string &groupingDescr, const double ang1,
1442 const double ang2) {
1443 const std::string GROUP_WS_NAME = "tmpGroupingWorkspace_" + groupingAlg + "_" + groupingDescr;
1444
1445 // create the full instrument
1447
1448 // create the groupingworkspace
1449 auto createGroupingAlg = AlgorithmManager::Instance().createUnmanaged(groupingAlg);
1450 createGroupingAlg->initialize();
1451 createGroupingAlg->setProperty("OutputWorkspace", GROUP_WS_NAME);
1452 if (groupingAlg == "CreateGroupingWorkspace") {
1453 createGroupingAlg->setProperty("InputWorkspace", ws);
1454 createGroupingAlg->setProperty("GroupDetectorsBy", groupingDescr);
1455 } else if (groupingAlg == "LoadDetectorsGroupingFile") {
1456 createGroupingAlg->setProperty("InputWorkspace", ws);
1457 createGroupingAlg->setProperty("InputFile", groupingDescr);
1458 } else {
1459 throw std::runtime_error("Do not know how to create grouping using \"" + groupingAlg + "\" algorithm");
1460 }
1461 createGroupingAlg->execute();
1462 if (!createGroupingAlg->isExecuted())
1463 throw std::runtime_error("Failed to execute CreateGroupingWorkspace");
1464
1465 // focus the data
1466 auto focusAlg = AlgorithmManager::Instance().createUnmanaged("DiffractionFocussing");
1467 focusAlg->initialize();
1468 focusAlg->setProperty("InputWorkspace", wkspName);
1469 focusAlg->setProperty("OutputWorkspace", wkspName);
1470 focusAlg->setProperty("GroupingWorkspace", GROUP_WS_NAME);
1471 focusAlg->execute();
1472 AnalysisDataService::Instance().remove(GROUP_WS_NAME); // delete the grouping workspace no matter what happened
1473 if (!focusAlg->isExecuted())
1474 throw std::runtime_error("Failed to execute DiffractionFocussing");
1475
1476 return std::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(wkspName));
1477}
1478
1479} // namespace WorkspaceCreationHelper
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
double sigma
Definition GetAllEi.cpp:156
double height
Definition GetAllEi.cpp:155
double error
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
int64_t nSpectra
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition System.h:48
double lower
lower and upper bounds on the multiplier, if known
double upper
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
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.
void addDetectorID(const detid_t detID)
Add a detector ID to the set of detector IDs.
Definition ISpectrum.cpp:51
void setDetectorID(const detid_t detID)
Clear the list of detector IDs, then add one.
Definition ISpectrum.cpp:84
void setSpectrumNo(specnum_t num)
Sets the spectrum number of this spectrum.
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Definition LogManager.h:91
Helper class for reporting progress from algorithms.
Definition Progress.h:25
This class stores information regarding an experimental run as a series of log entries.
Definition Run.h:35
A class for holding :
Definition EventList.h:57
This class is intended to fulfill the design specified in <https://github.com/mantidproject/documents...
Structure describing a single-crystal peak.
Structure describing a single-crystal peak.
Definition Peak.h:34
ScanningWorkspaceBuilder : This is a helper class to make it easy to build a scanning workspace (a wo...
void setPos(double, double, double) override
Set the IComponent position, x, y, z respective to parent (if present)
This class represents a detector - i.e.
Definition Detector.h:30
Class to represent a particular goniometer setting, which is described by the rotation matrix.
Definition Goniometer.h:55
void makeUniversalGoniometer()
Make a default universal goniometer with phi,chi,omega angles according to SNS convention.
Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.
std::shared_ptr< CSGObject > createShape(Poco::XML::Element *pElem)
Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain t...
size_t numRows() const
Return the number of rows in the matrix.
Definition Matrix.h:144
size_t numCols() const
Return the number of columns in the matrix.
Definition Matrix.h:147
This implements the Mersenne Twister 19937 pseudo-random number generator algorithm as a specialzatio...
double nextValue() override
Generate the next random number in the sequence within the given range default range.
OptionalBool : Tri-state bool.
The concrete, templated class for properties.
A specialised Property class for holding a series of time-value pairs.
void addValue(const Types::Core::DateAndTime &time, const TYPE &value)
Add a value to the map using a DateAndTime object.
Class for 3D vectors.
Definition V3D.h:34
constexpr double X() const noexcept
Get x.
Definition V3D.h:238
constexpr double Y() const noexcept
Get y.
Definition V3D.h:239
constexpr double Z() const noexcept
Get z.
Definition V3D.h:240
Implements a copy on write data template.
Definition cow_ptr.h:41
Mantid::Geometry::Instrument_sptr createCylInstrumentWithDetInGivenPositions(const std::vector< double > &L2, const std::vector< double > &polar, const std::vector< double > &azim)
create instrument with cylindrical detectors located in specific angular positions
Mantid::Geometry::Instrument_sptr createTestInstrumentCylindrical(int num_banks, const Mantid::Kernel::V3D &sourcePos=Mantid::Kernel::V3D(0.0, 0.0, -10.), const Mantid::Kernel::V3D &samplePos=Mantid::Kernel::V3D(), const double cylRadius=0.004, const double cylHeight=0.0002)
Create an test instrument with n panels of 9 cylindrical detectors, a source and a sample position.
Mantid::Geometry::Instrument_sptr createTestInstrumentRectangular2(int num_banks, int pixels, double pixelSpacing=0.008)
Create an test instrument with n panels of rectangular detectors, pixels*pixels in size,...
Mantid::Geometry::Instrument_sptr createTestInstrumentRectangular(int num_banks, int pixels, double pixelSpacing=0.008, double bankDistanceFromSample=5.0, bool addMonitor=false, const std::string &instrumentName="basic_rect")
Create a test instrument with n panels of rectangular detectors, pixels*pixels in size,...
void addMonitor(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const int ID, const std::string &name)
Adds a monitor to an instrument.
void addSource(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const std::string &name)
Adds a source to an instrument.
void addFullInstrumentToWorkspace(Mantid::API::MatrixWorkspace &workspace, bool includeMonitors, bool startYNegative, const std::string &instrumentName)
void addInstrumentWithGeographicalDetectorsToWorkspace(Mantid::API::MatrixWorkspace &workspace, const int nlat, const int nlong, const double anginc, const std::string &instrumentName)
void addSample(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const std::string &name)
Adds a sample to an instrument.
Mantid::Geometry::Component * addComponent(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const std::string &name)
Adds a component to an instrument.
void addDetector(Mantid::Geometry::Instrument_sptr &instrument, const Mantid::Kernel::V3D &position, const int ID, const std::string &name, Mantid::Geometry::ObjCompAssembly *compAss=nullptr)
Adds a detector to an instrument.
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
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< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition Algorithm.h:52
static MatrixWorkspace_sptr createWorkspaceSingleValue(const double &rhsValue)
Creates a temporary single value workspace the error is set to zero.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::size_t numEvents(Nexus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix, const Nexus::NexusDescriptor &descriptor)
Get the number of events in the currently opened group.
std::shared_ptr< LeanElasticPeaksWorkspace > LeanElasticPeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< WorkspaceSingleValue > WorkspaceSingleValue_sptr
shared pointer to the WorkspaceSingleValue class
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
std::shared_ptr< RebinnedOutput > RebinnedOutput_sptr
shared pointer to the RebinnedOutput class
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
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.
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
std::map< detid_t, Geometry::IDetector_const_sptr > detid2det_map
Typedef of a map from detector ID to detector shared pointer.
Definition Instrument.h:27
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition cow_ptr.h:172
int32_t specnum_t
Typedef for a spectrum Number.
Definition IDTypes.h:14
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWhereYIsWorkspaceIndex(int nhist, int numBoundaries)
Create a Workspace2D where the Y value at each bin is == to the workspace index.
Mantid::DataObjects::Workspace2D_sptr create1DWorkspaceConstant(int size, double value, double error, bool isHisto)
void setOrientedLattice(const Mantid::API::MatrixWorkspace_sptr &ws, double a, double b, double c)
Sets the OrientedLattice in the crystal as an crystal with given lattice lengths, angles of 90 deg.
void createInstrumentForWorkspaceWithDistances(const Mantid::API::MatrixWorkspace_sptr &workspace, const Mantid::Kernel::V3D &samplePosition, const Mantid::Kernel::V3D &sourcePosition, const std::vector< Mantid::Kernel::V3D > &detectorPositions)
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWithGeographicalDetectors(const int nlat, const int nlong, const double anginc, int nbins, const double x0=0.5, const double deltax=1.0, const std::string &instrumentName=std::string("testInst"), const std::string &xunit=std::string("Momentum"))
Create an Workspace2D with an instrument that contains detectors arranged at even latitude/longitude ...
Mantid::API::MatrixWorkspace_sptr create2DWorkspaceWithReflectometryInstrumentMultiDetector(const double startX=0.0, const double detSize=0.0, const Mantid::Kernel::V3D &slit1Pos=Mantid::Kernel::V3D(0, 0, 0), const Mantid::Kernel::V3D &slit2Pos=Mantid::Kernel::V3D(0, 0, 1), const double vg1=0.5, const double vg2=1.0, const Mantid::Kernel::V3D &sourcePos=Mantid::Kernel::V3D(0, 0, 0), const Mantid::Kernel::V3D &monitorPos=Mantid::Kernel::V3D(14, 0, 0), const Mantid::Kernel::V3D &samplePos=Mantid::Kernel::V3D(15, 0, 0), const Mantid::Kernel::V3D &detectorCenterPos=Mantid::Kernel::V3D(20,(20 - 15), 0), const int nSpectra=4, const int nBins=20, const double deltaX=5000.0)
Create a 2D workspace with one monitor and three detectors based around a virtual reflectometry instr...
void displayData(const Mantid::API::MatrixWorkspace_const_sptr &ws)
Mantid::API::MatrixWorkspace_sptr createProcessedInelasticWS(const std::vector< double > &L2, const std::vector< double > &polar, const std::vector< double > &azimutal, size_t numBins=4, double Emin=-10, double Emax=10, double Ei=11)
Create a workspace with all components needed for inelastic analysis and 3 detectors in specific plac...
Mantid::API::ITableWorkspace_sptr createEPPTableWorkspace(const std::vector< EPPTableRow > &rows={})
Create a table workspace corresponding to what the FindEPP algorithm gives.
void displayDataY(const Mantid::API::MatrixWorkspace_const_sptr &ws)
Mantid::DataObjects::WorkspaceSingleValue_sptr createWorkspaceSingleValueWithError(double value, double error)
void create2DAngles(std::vector< double > &L2, std::vector< double > &polar, std::vector< double > &azim, size_t nPolar=10, size_t nAzim=10, double polStart=0, double polEnd=90, double azimStart=-30, double azimEnd=30)
Mantid::DataObjects::Workspace2D_sptr create1DWorkspaceConstantWithXerror(int size, double value, double error, double xError, bool isHisto=true)
Mantid::API::MatrixWorkspace_sptr create2DWorkspaceRagged(int version=0)
Create a 2D ragged workspace.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceBinned(size_t nhist, size_t numVals, double x0=0.0, double deltax=1.0)
Create a 2D workspace with this many histograms and bins.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWithRectangularInstrument(int numBanks, int numPixels, int numBins, const std::string &instrumentName="basic_rect")
Create an Workspace2D with an instrument that contains RectangularDetector's.
void populateWsWithInitList(T &destination, size_t startingIndex, const std::initializer_list< double > &values)
Populates a mutable reference from initializer list starting at user specified index.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceNonUniformlyBinned(int nhist, const int numBoundaries, const double xBoundaries[], bool hasDx=false)
Create a 2D workspace with this many histograms and bins.
Mantid::DataObjects::EventWorkspace_sptr createEventWorkspaceWithFullInstrument(int numBanks, int numPixels, bool clearEvents=true)
Create an Eventworkspace with an instrument that contains RectangularDetector's.
Mantid::DataObjects::Workspace2D_sptr create1DWorkspaceFib(int size, bool isHisto)
std::shared_ptr< Mantid::DataObjects::PeaksWorkspace > createPeaksWorkspace(const int numPeaks, const bool createOrientedLattice=false)
Create a simple peaks workspace containing the given number of peaks.
void addNoise(const Mantid::API::MatrixWorkspace_sptr &ws, double noise, const double lower=-0.5, const double upper=0.5)
Add random noise to a 2D workspace.
Mantid::DataObjects::EventWorkspace_sptr createGroupedEventWorkspace(std::vector< std::vector< int > > const &groups, int numBins, double binDelta=1., double xOffset=0.)
Create event workspace, with several detector IDs in one event list.
void removeWS(const std::string &name)
Deletes a workspace.
void displayDataE(const Mantid::API::MatrixWorkspace_const_sptr &ws)
Mantid::HistogramData::Histogram createHisto(bool isHistogram, YType &&yAxis, EType &&eAxis)
Creates and returns point or bin based histograms with the data specified in parameters.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWithValuesAndXerror(int64_t nHist, int64_t nBins, bool isHist, double xVal, double yVal, double eVal, double dxVal, const std::set< int64_t > &maskedWorkspaceIndices=std::set< int64_t >())
Mantid::API::WorkspaceGroup_sptr createWorkspaceGroup(int nEntries, int nHist, int nBins, const std::string &stem)
Create a WorkspaceGroup with N workspaces and the specified parameters.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspace154(int64_t nHist, int64_t nBins, bool isHist=false, const std::set< int64_t > &maskedWorkspaceIndices=std::set< int64_t >(), bool hasDx=false)
std::shared_ptr< Mantid::DataObjects::LeanElasticPeaksWorkspace > createLeanPeaksWorkspace(const int numPeaks, const bool createOrientedLattice=false)
Create a simple lean peaks workspace containing the given number of peaks.
Mantid::DataObjects::EventWorkspace_sptr createRandomEventWorkspace(size_t numbins, size_t numpixels, double bin_delta=1.0)
Create an event workspace with randomized TOF and pulsetimes.
Mantid::API::MatrixWorkspace_sptr create2DWorkspaceWithReflectometryInstrument(const double startX=0.0, const Mantid::Kernel::V3D &slit1Pos=Mantid::Kernel::V3D(0, 0, 0), const Mantid::Kernel::V3D &slit2Pos=Mantid::Kernel::V3D(0, 0, 1), const double vg1=0.5, const double vg2=1.0, const Mantid::Kernel::V3D &sourcePos=Mantid::Kernel::V3D(0, 0, 0), const Mantid::Kernel::V3D &monitorPos=Mantid::Kernel::V3D(14, 0, 0), const Mantid::Kernel::V3D &samplePos=Mantid::Kernel::V3D(15, 0, 0), const Mantid::Kernel::V3D &detectorPos=Mantid::Kernel::V3D(20,(20 - 15), 0), const int nBins=100, const double deltaX=2000.0)
Create a 2D workspace with one detector and one monitor based around a virtual reflectometry instrume...
Mantid::DataObjects::EventWorkspace_sptr createEventWorkspaceWithStartTime(int numPixels, int numBins, int numEvents=100, double x0=0.0, double binDelta=1.0, int eventPattern=1, int start_at_pixelID=0, Mantid::Types::Core::DateAndTime run_start=Mantid::Types::Core::DateAndTime("2010-01-01T00:00:00"))
void addTSPEntry(Mantid::API::Run &runInfo, const std::string &name, double val)
Utility function to add a TimeSeriesProperty with a name and value.
Mantid::DataObjects::EventWorkspace_sptr createEventWorkspace()
Create event workspace with: 500 pixels 1000 histogrammed bins.
Mantid::API::MatrixWorkspace_sptr createFocusedSNAPLiteInstrument(const std::string &wkspName, const std::string &groupingAlg, const std::string &groupingDescr, const double ang1=-65.3, const double ang2=104.95)
Mantid::DataObjects::EventWorkspace_sptr createEventWorkspace3(const Mantid::DataObjects::EventWorkspace_const_sptr &sourceWS, const std::string &wsname, Mantid::API::Algorithm *alg)
Mantid::API::MatrixWorkspace_sptr create2DDetectorScanWorkspaceWithFullInstrument(int nhist, int nbins, size_t nTimeIndexes, size_t startTime=0, size_t firstInterval=1, bool includeMonitors=false, bool startYNegative=false, bool isHistogram=true, const std::string &instrumentName=std::string("testInst"))
Create a workspace as for create2DWorkspaceWithFullInstrument, but including time indexing,...
Mantid::API::MatrixWorkspace_sptr createSNAPLiteInstrument(const std::string &wkspName, const double ang1=-65.3, const double ang2=104.95)
Create a copy of the SNAP "lite" instrument.
Mantid::API::MatrixWorkspace_sptr createProcessedWorkspaceWithCylComplexInstrument(size_t numPixels=100, size_t numBins=20, bool has_oriented_lattice=true)
Mantid::DataObjects::Workspace2D_sptr create2DWorkspace123(int64_t nHist, int64_t nBins, bool isHist=false, const std::set< int64_t > &maskedWorkspaceIndices=std::set< int64_t >(), bool hasDx=false)
Mantid::DataObjects::Workspace2D_sptr maskSpectra(Mantid::DataObjects::Workspace2D_sptr workspace, const std::set< int64_t > &maskedWorkspaceIndices)
Workspace2D_sptr create2DWorkspaceWithValues(int64_t nHist, int64_t nBins, bool isHist, const std::set< int64_t > &maskedWorkspaceIndices, double xVal, double yVal, double eVal, bool hasDx=false)
create2DWorkspaceWithValues
DataObjects::Workspace2D_sptr reflectometryWorkspace(const double startX, const int nSpectra, const int nBins, const double deltaX)
Creates a binned 2DWorkspace with title and TOF x-axis and counts y-axis.
Mantid::DataObjects::RebinnedOutput_sptr createRebinnedOutputWorkspace()
Function to create a fixed RebinnedOutput workspace.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceThetaVsTOF(int nHist, int nBins)
Create a test workspace with a Theta numeric axis instead of a spectrum axis the values run from 1 to...
void displayDataX(const Mantid::API::MatrixWorkspace_const_sptr &ws)
Mantid::DataObjects::Workspace2D_sptr create1DWorkspaceRand(int size, bool isHisto)
Mantid::API::MatrixWorkspace_sptr createGroupedWorkspace2DWithRingsAndBoxes(size_t RootOfNumHist=10, int numBins=10, double binDelta=1.0)
Mantid::DataObjects::Workspace2D_sptr create2DWorkspace123WithMaskedBin(int numHist, int numBins, int maskedWorkspaceIndex, int maskedBinIndex)
void setGoniometer(const Mantid::API::MatrixWorkspace_sptr &ws, double phi, double chi, double omega)
Create a default universal goniometer and set its angles.
Mantid::DataObjects::EventWorkspace_sptr createEventWorkspaceWithNonUniformInstrument(int numBanks, bool clearEvents)
Creates an event workspace with instrument which consists of cylindrical detectors.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWithFullInstrument(int nhist, int nbins, bool includeMonitors=false, bool startYNegative=false, bool isHistogram=true, const std::string &instrumentName=std::string("testInst"), bool hasDx=false)
Create a test workspace with a fully defined instrument.
Mantid::DataObjects::EventWorkspace_sptr createEventWorkspaceWithFullInstrument2(int numBanks, int numPixels, bool clearEvents=true)
Create an Eventworkspace with instrument 2.0 that contains RectangularDetector's.
Mantid::DataObjects::EventWorkspace_sptr createEventWorkspace2(int numPixels=50, int numBins=100)
Create event workspace with: 50 pixels 100 histogrammed bins from 0.0 in steps of 1....
Mantid::DataObjects::Workspace2D_sptr create2DWorkspace(size_t nhist, size_t numBoundaries)
Mantid::API::MatrixWorkspace_sptr createGroupedWorkspace2D(size_t numHist, int numBins, double binDelta)
Create Workspace2d, with numHist spectra, each with 9 detectors, with IDs 1-9, 10-18,...
void eventWorkspace_Finalize(const Mantid::DataObjects::EventWorkspace_sptr &ew)
Perform some finalization on event workspace stuff.
Mantid::DataObjects::Workspace2D_sptr create2DWorkspacePoints(size_t nhist, size_t numVals, double x0=0.0, double deltax=1.0)
Create a 2D workspace with this many point-histograms and bins.
Generate a tableworkspace to store the calibration results.
STL namespace.
EPPTableRow()=default
Construct a row with the default values.
FitStatus
FindEPP algorithm fitting success status.