33#include <gmock/gmock.h>
42namespace DataObjects {
44class LeanElasticPeaksWorkspace;
77 const std::string
name()
const override {
return "MockAlgorithm"; }
79 int version()
const override {
return 1; }
81 const std::string
category()
const override {
return "Test"; }
83 const std::string
summary()
const override {
return "Test summary."; }
127template <
typename WSType>
void storeWS(
const std::string &
name, WSType &ws) {
128 Mantid::API::AnalysisDataService::Instance().add(
name, ws);
133template <
typename T> std::shared_ptr<T>
getWS(
const std::string &
name) {
134 return Mantid::API::AnalysisDataService::Instance().retrieveWS<T>(
name);
139template <
typename YType,
typename EType>
140Mantid::HistogramData::Histogram
createHisto(
bool isHistogram, YType &&yAxis, EType &&eAxis);
145 double xError,
bool isHisto =
true);
150 const std::set<int64_t> &maskedWorkspaceIndices = std::set<int64_t>(),
bool hasDx =
false);
153 const std::set<int64_t> &maskedWorkspaceIndices = std::set<int64_t>(),
bool hasDx =
false);
157 const std::set<int64_t> &maskedWorkspaceIndices = std::set<int64_t>());
159 const std::set<int64_t> &maskedWorkspaceIndices);
168 double deltax = 1.0);
179 double deltax = 1.0);
189 double operator()(
const double, std::size_t) {
return 1.0; };
204template <
typename fT,
typename gT = ReturnOne>
206 double dx,
bool isHist =
false,
208 int nX = int((x1 - x0) / dx) + 1;
209 int nY = nX - (isHist ? 1 : 0);
211 throw std::invalid_argument(
"Number of bins <=0. Cannot create an empty workspace");
213 auto ws = std::dynamic_pointer_cast<Mantid::DataObjects::Workspace2D>(
216 for (
int iSpec = 0; iSpec < nSpec; iSpec++) {
217 auto &
X = ws->mutableX(iSpec);
218 auto &
Y = ws->mutableY(iSpec);
219 auto &E = ws->mutableE(iSpec);
220 for (
int i = 0; i < nY; i++) {
221 double x = x0 + dx * i;
223 Y[i] = yFunc(
x, iSpec);
224 E[i] = eFunc(
x, iSpec);
227 X.back() =
X[nY - 1] + dx;
234 const double upper = 0.5);
239 bool isHistogram =
true,
240 const std::string &instrumentName = std::string(
"testInst"),
bool hasDx =
false);
251 size_t firstInterval = 1,
bool includeMonitors =
false,
252 bool startYNegative =
false,
bool isHistogram =
true,
253 const std::string &instrumentName = std::string(
"testInst"));
256 const int nlat,
const int nlong,
const double anginc,
int nbins,
const double x0 = 0.5,
const double deltax = 1.0,
257 const std::string &instrumentName = std::string(
"testInst"),
const std::string &xunit = std::string(
"Momentum"));
268 const std::string &instrumentName =
"basic_rect");
271 int maskedWorkspaceIndex,
int maskedBinIndex);
276 bool clearEvents =
true);
281 bool clearEvents =
true);
316 double x0 = 0.0,
double binDelta = 1.0,
317 int eventPattern = 1,
int start_at_pixelID = 0);
320 int numPixels,
int numBins,
int numEvents = 100,
double x0 = 0.0,
double binDelta = 1.0,
int eventPattern = 1,
321 int start_at_pixelID = 0,
322 Mantid::Types::Core::DateAndTime run_start = Mantid::Types::Core::DateAndTime(
"2010-01-01T00:00:00"));
325 int numBins,
double binDelta = 1.,
326 double xOffset = 0.);
329 double bin_delta = 1.0);
335 double binDelta = 1.0);
357 bool has_oriented_lattice =
true);
361 const std::vector<double> &polar,
362 const std::vector<double> &azimutal,
size_t numBins = 4,
363 double Emin = -10,
double Emax = 10,
double Ei = 11);
375void populateWsWithInitList(T &destination,
size_t startingIndex,
const std::initializer_list<double> &values);
379 const bool createOrientedLattice =
false);
386std::shared_ptr<Mantid::DataObjects::LeanElasticPeaksWorkspace>
390std::shared_ptr<Mantid::DataObjects::LeanElasticPeaksWorkspace>
395std::shared_ptr<Mantid::DataObjects::TableWorkspace>
398void create2DAngles(std::vector<double> &L2, std::vector<double> &polar, std::vector<double> &azim,
size_t nPolar = 10,
399 size_t nAzim = 10,
double polStart = 0,
double polEnd = 90,
double azimStart = -30,
400 double azimEnd = 30);
411 const double deltaX = 2000.0);
416 const double startX = 0.0,
const double detSize = 0.0,
423 const int nBins = 20,
const double deltaX = 5000.0);
428 const std::vector<Mantid::Kernel::V3D> &detectorPositions);
438 const double ang2 = 104.95);
440 const std::string &groupingAlg,
441 const std::string &groupingDescr,
442 const double ang1 = -65.3,
443 const double ang2 = 104.95);
double value
The value of the point.
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
double lower
lower and upper bounds on the multiplier, if known
Base class from which all concrete algorithm classes should be derived.
This class is shared by a few Workspace types and holds information related to a particular experimen...
Helper class for reporting progress from algorithms.
This class stores information regarding an experimental run as a series of log entries.
base class for Geometric IComponent
The Logger class is in charge of the publishing messages from the framework through various channels.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Stub algorithm for doing logging/progress reporting.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
std::unique_ptr< Mantid::API::Progress > m_Progress
Mantid::API::Progress * getProgress()
const std::string summary() const override
Algorithm's summary.
Mantid::Kernel::Logger & getLogger()
const std::string name() const override
Algorithm's name for identification.
void init() override
Virtual method - must be overridden by concrete algorithm.
void exec() override
Virtual method - must be overridden by concrete algorithm.
static Mantid::Kernel::Logger & g_log
logger -> to provide logging,
void resetProgress(size_t nSteps)
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)
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)
Get the number of events in the currently opened group.
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< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
Helper class which provides the Collimation Length for SANS instruments.
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)
void storeWS(const std::string &name, WSType &ws)
Adds a workspace to the ADS.
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::Workspace2D_sptr create2DWorkspaceFromFunction(fT yFunc, int nSpec, double x0, double x1, double dx, bool isHist=false, gT eFunc=ReturnOne())
Creates a 2D workspace from taking the function values from the input function.
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,...
std::shared_ptr< T > getWS(const std::string &name)
Returns a workspace of a given type.
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)
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.
std::shared_ptr< Mantid::DataObjects::TableWorkspace > buildPreprocessedDetectorsWorkspace(const Mantid::API::MatrixWorkspace_sptr &ws)
Build table workspace with preprocessed detectors for existing workspace with instrument.
const Mantid::Geometry::IComponent * baseInstrumentID(const Mantid::API::ExperimentInfo &expInfo)
The base instrument a workspace was built from, as identified by the root of its base ComponentInfo.
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.
A struct containing the cells of an EPP table row.
EPPTableRow()=default
Construct a row with the default values.
FitStatus
FindEPP algorithm fitting success status.
Create a Fibonacci series.
FibSeries()
Initial value 2;.
double operator()(const double, std::size_t)