33 : m_loadAlg(
"Load"), m_accumulateAlg(
"Plus"), m_loadAlgFileProp(
"Filename"),
34 m_propertyManagerPropertyName(
"ReductionProperties") {
35 Base::enableHistoryRecordingForChild(
true);
60std::shared_ptr<Algorithm>
62 const double endProgress,
const bool enableLogging,
66 alg->enableHistoryRecordingForChild(this->isRecordingHistoryForChild());
67 if (this->isRecordingHistoryForChild()) {
69 alg->trackAlgorithmHistory(Base::m_history);
76 throw std::invalid_argument(
"Cannot set load algorithm to empty string");
81 if (filePropName.empty()) {
82 throw std::invalid_argument(
"Cannot set the load algorithm file property name");
84 m_loadAlgFileProp = filePropName;
89 throw std::invalid_argument(
"Cannot set accumulate algorithm to empty string");
90 m_accumulateAlg = alg;
94 m_propertyManagerPropertyName = propName;
107 const std::string &nameInPropManager) {
108 m_nameToPMName[nameInProp] = nameInPropManager;
124 if (!alg->existsProperty(
name)) {
125 std::stringstream msg;
126 msg <<
"Algorithm \"" << alg->name() <<
"\" does not have property \"" <<
name <<
"\"";
127 throw std::runtime_error(msg.str());
130 auto prop = alg->getPointerToProperty(
name);
131 Base::declareProperty(std::unique_ptr<Property>(prop->clone()), prop->documentation());
144 if (!Base::isDefault(
name)) {
149 auto mapping = m_nameToPMName.find(
name);
150 if (mapping != m_nameToPMName.end()) {
151 auto pm = this->getProcessProperties();
152 if (pm->existsProperty(mapping->second)) {
153 return pm->getPropertyValue(mapping->second);
171 if (!Base::isDefault(
name)) {
172 return Base::getProperty(
name);
176 auto mapping = m_nameToPMName.find(
name);
177 if (mapping != m_nameToPMName.end()) {
178 auto pm = this->getProcessProperties();
179 if (pm->existsProperty(mapping->second)) {
180 return pm->getProperty(mapping->second);
192 throw std::runtime_error(
"DataProcessorAlgorithm::determineChunk is not implemented");
198 throw std::runtime_error(
"DataProcessorAlgorithm::loadChunk is not implemented");
209 if (!outputFile.empty()) {
210 auto saveAlg = createChildAlgorithm(
"SaveNexus");
211 saveAlg->setPropertyValue(
"Filename", outputFile);
212 saveAlg->setPropertyValue(
"InputWorkspace", outputWSName);
227 if (AnalysisDataService::Instance().doesExist(inputData)) {
228 inputWS = AnalysisDataService::Instance().retrieve(inputData);
230 std::string foundFile = FileFinder::Instance().getFullPath(inputData);
231 if (foundFile.empty()) {
233 FacilityInfo facilityInfo = ConfigService::Instance().getFacility();
234 const std::vector<std::string> facilityExts = facilityInfo.
extensions();
235 foundFile = FileFinder::Instance().findRun(inputData, facilityExts).result();
238 if (!foundFile.empty()) {
239 Poco::Path p(foundFile);
240 const std::string outputWSName = p.getBaseName();
242 auto loadAlg = createChildAlgorithm(m_loadAlg);
243 loadAlg->setProperty(m_loadAlgFileProp, foundFile);
245 loadAlg->setAlwaysStoreInADS(
true);
251 inputWS = loadAlg->getProperty(
"OutputWorkspace");
253 inputWS = AnalysisDataService::Instance().retrieve(outputWSName);
256 throw std::runtime_error(
"DataProcessorAlgorithm::load could process any data");
270std::shared_ptr<PropertyManager>
272 std::string propertyManagerName(propertyManager);
273 if (propertyManager.empty() && (!m_propertyManagerPropertyName.empty())) {
274 if (!Base::existsProperty(m_propertyManagerPropertyName)) {
275 std::stringstream msg;
276 msg <<
"Failed to find property \"" << m_propertyManagerPropertyName <<
"\"";
279 propertyManagerName = this->getPropertyValue(m_propertyManagerPropertyName);
282 std::shared_ptr<PropertyManager> processProperties;
283 if (PropertyManagerDataService::Instance().doesExist(propertyManagerName)) {
284 processProperties = PropertyManagerDataService::Instance().retrieve(propertyManagerName);
286 Base::getLogger().notice() <<
"Could not find property manager\n";
287 processProperties = std::make_shared<PropertyManager>();
288 PropertyManagerDataService::Instance().addOrReplace(propertyManagerName, processProperties);
290 return processProperties;
296 throw std::runtime_error(
"DataProcessorAlgorithm::splitInput is not implemented");
300 throw std::runtime_error(
"DataProcessorAlgorithm::forwardProperties is not implemented");
316 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
"Divide", lhs,
328 const double &rhsValue) {
329 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
344 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
"Divide", lhs,
358 const double &rhsValue) {
359 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
372 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
"Plus", lhs,
384 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
397 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
"Minus", lhs,
410 const double &rhsValue) {
411 return this->executeBinaryAlgorithm<MatrixWorkspace_sptr, MatrixWorkspace_sptr, MatrixWorkspace_sptr>(
423 retVal->dataY(0)[0] = rhsValue;
const std::vector< double > & rhs
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
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.
Data processor algorithm to be used as a parent to workflow algorithms.
std::shared_ptr< Kernel::PropertyManager > getProcessProperties(const std::string &propertyManager=std::string()) const
Get the property manager object of a given name from the property manager data service,...
MatrixWorkspace_sptr createWorkspaceSingleValue(const double &rhsValue)
Create a matrix workspace from a single number.
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) override
Create a Child Algorithm.
virtual ITableWorkspace_sptr determineChunk(const std::string &filename)
void saveNexus(const std::string &outputWSName, const std::string &outputFile)
Save a workspace as a nexus file, with check for which thread we are executing in.
void copyProperty(const API::Algorithm_sptr &alg, const std::string &name)
Copy a property from an existing algorithm.
Kernel::IPropertyManager::TypedValue getProperty(const std::string &name) const override
Get the property held by this object.
std::vector< std::string > splitInput(const std::string &input)
std::string getPropertyValue(const std::string &name) const override
Get the property held by this object.
void setAccumAlg(const std::string &alg)
void visualStudioC4661Workaround()
void setLoadAlgFileProp(const std::string &filePropName)
GenericDataProcessorAlgorithm()
Constructor.
void setLoadAlg(const std::string &alg)
MatrixWorkspace_sptr plus(const MatrixWorkspace_sptr lhs, const MatrixWorkspace_sptr rhs)
Add a matrix workspace to another matrix workspace.
MatrixWorkspace_sptr minus(const MatrixWorkspace_sptr lhs, const MatrixWorkspace_sptr rhs)
Subract a matrix workspace by another matrix workspace.
MatrixWorkspace_sptr multiply(const MatrixWorkspace_sptr lhs, const MatrixWorkspace_sptr rhs)
Multiply a matrix workspace by another matrix workspace.
virtual MatrixWorkspace_sptr loadChunk(const size_t rowIndex)
void setPropManagerPropName(const std::string &propName)
Workspace_sptr load(const std::string &inputData, const bool loadQuiet=false)
Determine what kind of input data we have and load it.
void mapPropertyName(const std::string &nameInProp, const std::string &nameInPropManager)
Declare mapping of property name to name in the PropertyManager.
MatrixWorkspace_sptr divide(const MatrixWorkspace_sptr lhs, const MatrixWorkspace_sptr rhs)
Divide a matrix workspace by another matrix workspace.
Exception for when an item is not found in a collection.
A class that holds information about a facility.
const std::vector< std::string > & extensions() const
Returns a list of file extensions.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
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
Utility class that enables the getProperty() method to effectively be templated on the return type.