18#include "MantidHistogramData/BinEdges.h"
19#include "MantidHistogramData/Histogram.h"
20#include "MantidHistogramData/LinearGenerator.h"
26using namespace DataHandling;
27using namespace DataObjects;
28using namespace HistogramData;
29using namespace Kernel;
31namespace FrameworkTestHelpers {
34 std::string
const &unitX =
"TOF") {
35 double const dX = (endX - startX) /
double(nBins);
36 BinEdges xVals(nBins + 1, LinearGenerator(startX,
dX));
37 size_t nSpec = values.size();
38 std::vector<double> yVals(nSpec * nBins);
39 for (
size_t i = 0; i < nSpec; ++i) {
40 std::fill(yVals.begin() + i * nBins, yVals.begin() + (i + 1) * nBins, values[i]);
44 creator->setChild(
true);
45 creator->initialize();
46 creator->setProperty(
"DataX", xVals.rawData());
47 creator->setProperty(
"DataY", yVals);
48 creator->setProperty(
"NSpec",
int(nSpec));
49 creator->setProperty(
"UnitX", unitX);
50 creator->setPropertyValue(
"OutputWorkspace",
"dummy");
57 std::string
const ¶msType, std::string
const &instrumentSuffix) {
60 auto filePrefix = std::string(
"unit_testing/REFL") + instrumentSuffix;
62 instrumentLoader->initialize();
63 instrumentLoader->setPropertyValue(
"Filename", filePrefix + std::string(
"_Definition.xml"));
64 instrumentLoader->setProperty(
"Workspace",
workspace);
65 instrumentLoader->setProperty(
"RewriteSpectraMap",
OptionalBool(
true));
66 instrumentLoader->execute();
68 if (!paramsType.empty()) {
70 paramLoader->initialize();
71 paramLoader->setPropertyValue(
"Filename", filePrefix + std::string(
"_Parameters_") + paramsType +
".xml");
72 paramLoader->setProperty(
"Workspace",
workspace);
73 paramLoader->execute();
79void prepareInputGroup(std::string
const &name, std::string
const ¶msType,
size_t size,
double const startX,
80 double const endX,
size_t const nBins) {
81 double monitorValue = 99.0;
82 double detectorValue = 0.9;
87 for (
size_t i = 0; i < size; ++i) {
88 std::vector<double> values(257, detectorValue);
89 values[0] = monitorValue;
92 ADS.addOrReplace(name1, ws);
101 mkGroup->initialize();
102 mkGroup->setProperty(
"InputWorkspaces", names);
103 mkGroup->setProperty(
"OutputWorkspace", name);
108 std::vector<MatrixWorkspace_sptr> out;
109 for (
size_t i = 0; i < group->size(); ++i) {
110 out.emplace_back(std::dynamic_pointer_cast<MatrixWorkspace>(group->getItem(i)));
128 auto nBins = Rpp->blocksize();
129 auto startX = Rpp->x(0).front();
130 auto endX = Rpp->x(0).back();
137 auto Ipp = (Rpp * (Pp + 1.0) * (Ap + 1.0) + Raa * (Pp * (-1.0) + 1.0) * (Ap * (-1.0) + 1.0) +
138 Rpa * (Pp + 1.0) * (Ap * (-1.0) + 1.0) + Rap * (Pp * (-1.0) + 1.0) * (Ap + 1.0)) /
140 auto Iaa = (Raa * (Pa + 1.0) * (Aa + 1.0) + Rpp * (Pa * (-1.0) + 1.0) * (Aa * (-1.0) + 1.0) +
141 Rap * (Pa + 1.0) * (Aa * (-1.0) + 1.0) + Rpa * (Pa * (-1.0) + 1.0) * (Aa + 1.0)) /
143 auto Ipa = (Rpa * (Pp + 1.0) * (Aa + 1.0) + Rap * (Pp * (-1.0) + 1.0) * (Aa * (-1.0) + 1.0) +
144 Rpp * (Pp + 1.0) * (Aa * (-1.0) + 1.0) + Raa * (Pp * (-1.0) + 1.0) * (Aa + 1.0)) /
146 auto Iap = (Rap * (Pa + 1.0) * (Ap + 1.0) + Rpa * (Pa * (-1.0) + 1.0) * (Ap * (-1.0) + 1.0) +
147 Raa * (Pa + 1.0) * (Ap * (-1.0) + 1.0) + Rpp * (Pa * (-1.0) + 1.0) * (Ap + 1.0)) /
151 ADS.addOrReplace(Rpp->getName(), Ipp);
152 ADS.addOrReplace(Rpa->getName(), Ipa);
153 ADS.addOrReplace(Rap->getName(), Iap);
154 ADS.addOrReplace(Raa->getName(), Iaa);
156 auto instrument = Rpp->getInstrument();
157 Ipp->setInstrument(instrument);
158 Ipa->setInstrument(instrument);
159 Iap->setInstrument(instrument);
160 Iaa->setInstrument(instrument);
169 const std::vector<double> &yValues) {
171 startX, 0.0,
Mantid::Kernel::V3D(0, 0, 0),
Mantid::Kernel::V3D(0, 0, 1), 0.5, 1.0,
Mantid::Kernel::V3D(0, 0, 0),
172 Mantid::Kernel::V3D(14, 0, 0),
Mantid::Kernel::V3D(15, 0, 0),
Mantid::Kernel::V3D(20, (20 - 15), 0), 2, nBins,
175 for (
auto i = 0u; i < ws->y(0).size(); ++i) {
176 ws->mutableY(0)[i] = yValues[i];
179 ws->mutableRun().addProperty<std::string>(
"run_number",
"1234");
186 startX, 0.0,
Mantid::Kernel::V3D(0, 0, 0),
Mantid::Kernel::V3D(0, 0, 1), 0.5, 1.0,
Mantid::Kernel::V3D(0, 0, 0),
187 Mantid::Kernel::V3D(14, 0, 0),
Mantid::Kernel::V3D(15, 0, 0),
Mantid::Kernel::V3D(20, (20 - 15), 0), 2, nBins,
190 ws->mutableRun().addProperty<std::string>(
"run_number",
"1234");
IPeaksWorkspace_sptr workspace
Class to hold a set of workspaces.
OptionalBool : Tri-state bool.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
void prepareInputGroup(std::string const &name, std::string const ¶msType="", size_t size=4, double const startX=5000.0, double const endX=100000.0, size_t const nBins=10)
MatrixWorkspace_sptr createWorkspaceSingle(const double startX, const int nBins, const double deltaX, const std::vector< double > &yValues)
MatrixWorkspace_sptr createREFL_WS(size_t nBins, double startX, double endX, std::vector< double > const &values, std::string const ¶msType="", std::string const &instrumentSuffix="")
MatrixWorkspace_sptr createHistoWS(size_t nBins, double startX, double endX, std::vector< double > const &values, std::string const &unitX="TOF")
void applyPolarizationEfficiencies(std::string const &name)
std::vector< MatrixWorkspace_sptr > retrieveOutWS(std::string const &name)
std::vector< MatrixWorkspace_sptr > groupToVector(const WorkspaceGroup_sptr &group)
Helper class which provides the Collimation Length for SANS instruments.
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...
std::string to_string(const wide_integer< Bits, Signed > &n)