31 "An optional input workspace containing the default instrument for peaks "
32 "in this workspace.");
33 declareProperty(
"NumberOfPeaks", 1,
"Number of dummy peaks to initially create.");
35 "An output workspace.");
39 const std::vector<std::string> peakworkspaceTypes{
"Peak",
"LeanElasticPeak"};
40 declareProperty(
"OutputType",
"Peak", std::make_shared<StringListValidator>(peakworkspaceTypes),
41 "Output peak workspace type, default to full peak workspace.");
48 const std::string outputType =
getProperty(
"OutputType");
58 if (outputType ==
"Peak") {
59 out = std::make_shared<PeaksWorkspace>();
62 if (instMDWS !=
nullptr) {
63 if (instMDWS->getNumExperimentInfo() > 0) {
64 out->setInstrument(instMDWS->getExperimentInfo(0)->getInstrument());
65 out->mutableRun().setGoniometer(instMDWS->getExperimentInfo(0)->run().getGoniometer().getR(),
false);
67 throw std::invalid_argument(
"InstrumentWorkspace has no ExperimentInfo");
70 ei = std::dynamic_pointer_cast<ExperimentInfo>(instWS);
72 out->setInstrument(ei->getInstrument());
73 out->mutableRun().setGoniometer(ei->run().getGoniometer().getR(),
false);
79 for (
int i = 0; i < NumberOfPeaks; i++) {
80 out->addPeak(
Peak(out->getInstrument(), out->getInstrument()->getDetectorIDs(
true)[0], 1.0));
84 }
else if (outputType ==
"LeanElasticPeak") {
86 out = std::make_shared<LeanElasticPeaksWorkspace>();
90 if (instMDWS->getNumExperimentInfo() > 0) {
91 ei = std::dynamic_pointer_cast<ExperimentInfo>(instMDWS->getExperimentInfo(0));
94 ei = std::dynamic_pointer_cast<ExperimentInfo>(instWS);
98 out->copyExperimentInfoFrom(ei.get());
101 for (
int i = 0; i < NumberOfPeaks; i++) {
106 throw std::invalid_argument(
"OutputType MUST be either Peak or LeanElasticPeak!");
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void exec() override
Run the algorithm.
void init() override
Initialise the properties.
Structure describing a single-crystal peak.
Structure describing a single-crystal peak.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< MultipleExperimentInfos > MultipleExperimentInfos_sptr
@ Input
An input workspace.
@ Output
An output workspace.