Commit 731948d0 authored by Russell Taylor's avatar Russell Taylor
Browse files

Re #7778. Eliminate erroneous use of AnalysisDataService.

In general, algorithms shouldn't be dealing directly with the ADS,
the Algorithm base class takes care of these interactions.
parent c87ea1b6
......@@ -69,8 +69,7 @@ namespace Crystal
OrientedLattice o(a,b,c,alpha,beta,gamma);
Matrix<double> B=o.getB();
PeaksWorkspace_sptr ws;
ws = AnalysisDataService::Instance().retrieveWS<PeaksWorkspace>(this->getProperty("PeaksWorkspace") );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws) throw std::runtime_error("Problems reading the peaks workspace");
size_t nIndexedpeaks=0;
......
......@@ -52,10 +52,7 @@ namespace Crystal
*/
void FindUBUsingIndexedPeaks::exec()
{
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws)
{
throw std::runtime_error("Could not read the peaks workspace");
......
......@@ -79,10 +79,7 @@ namespace Crystal
int base_index = -1; // these "could" be properties if need be
double degrees_per_step = 1.5;
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws) throw std::runtime_error("Could not read the peaks workspace");
std::vector<Peak> &peaks = ws->getPeaks();
......
......@@ -93,10 +93,7 @@ namespace Crystal
int base_index = -1; // these "could" be properties if need be
double degrees_per_step = 1;
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws) throw std::runtime_error("Could not read the peaks workspace");
std::vector<Peak> &peaks = ws->getPeaks();
......
......@@ -62,11 +62,7 @@ namespace Crystal
*/
void IndexPeaks::exec()
{
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws)
{
throw std::runtime_error("Could not read the peaks workspace");
......
......@@ -130,8 +130,7 @@ namespace Mantid
using namespace Mantid::DataObjects;
std::vector<int> peakindices = getProperty("PeakIndices");
PeaksWorkspace_sptr ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
// Need a least two peaks
std::size_t npeaks=peakindices.size();
......
......@@ -414,14 +414,12 @@ namespace Mantid
//------------------ Fix up Covariance output --------------------
declareProperty( new WorkspaceProperty< ITableWorkspace>(
"OutputNormalisedCovarianceMatrixOptX" , "" , Direction::Output ) ,
"OutputNormalisedCovarianceMatrixOptX" , "CovarianceInfo" , Direction::Output ) ,
"The name of the TableWorkspace in which to store the final covariance matrix" );
ITableWorkspace_sptr NormCov = fit_alg->getProperty( "OutputNormalisedCovarianceMatrix" );
AnalysisDataService::Instance().addOrReplace( std::string( "CovarianceInfo" ) , NormCov );
setPropertyValue( "OutputNormalisedCovarianceMatrixOptX" , std::string( "CovarianceInfo" ) );//What if 2 instances are run
setProperty( "OutputNormalisedCovarianceMatrixOptX" , NormCov );//What if 2 instances are run
if ( chisq < 0 || chisq != chisq )
sigma = -1;
......@@ -448,10 +446,7 @@ namespace Mantid
//-----------Fix up Resultant workspace return info -------------------
std::string ResultWorkspaceName = getPropertyValue( "FitInfoTable" );
AnalysisDataService::Instance().addOrReplace( ResultWorkspaceName , RRes );
setPropertyValue( "FitInfoTable" , ResultWorkspaceName );
setProperty( "FitInfoTable" , RRes );
//----------- update instrument -------------------------
......
......@@ -845,14 +845,12 @@ namespace Mantid
declareProperty(
new API::WorkspaceProperty<API::ITableWorkspace>
("OutputNormalisedCovarianceMatrix","",Kernel::Direction::Output),
("OutputNormalisedCovarianceMatrix","CovarianceInfo",Kernel::Direction::Output),
"The name of the TableWorkspace in which to store the final covariance matrix" );
ITableWorkspace_sptr NormCov= fit_alg->getProperty("OutputNormalisedCovarianceMatrix");
// setProperty("OutputNormalisedCovarianceMatrix", NormCov);
AnalysisDataService::Instance().addOrReplace( string("CovarianceInfo"), NormCov);
setPropertyValue("OutputNormalisedCovarianceMatrix", string("CovarianceInfo"));
setProperty("OutputNormalisedCovarianceMatrix", NormCov);
//--------------------- Get and Process Results -----------------------
double chisq = fit_alg->getProperty( "OutputChi2overDoF");
......
......@@ -88,10 +88,7 @@ namespace Crystal
*/
void SelectCellOfType::exec()
{
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws)
{
throw std::runtime_error("Could not read the peaks workspace");
......
......@@ -125,10 +125,7 @@ namespace Crystal
*/
void SelectCellWithForm::exec()
{
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws)
{
throw std::runtime_error("Could not read the peaks workspace");
......
......@@ -6,7 +6,6 @@
#include "MantidKernel/Matrix.h"
#include "MantidDataObjects/Peak.h"
#include "MantidKernel/V3D.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Sample.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "../../API/inc/MantidAPI/WorkspaceFactory.h"
......@@ -119,9 +118,6 @@ namespace Mantid
}
std::string output= getProperty("HKLIntegerOffsets");
API::AnalysisDataService::Instance().addOrReplace( output, Res );
setPropertyValue( "HKLIntegerOffsets",output);
setProperty("HKLIntegerOffsets", Res);
}
......
......@@ -40,7 +40,7 @@ namespace Crystal
void ShowPossibleCells::init()
{
this->declareProperty(new WorkspaceProperty<PeaksWorkspace>(
"PeaksWorkspace","",Direction::InOut), "Input Peaks Workspace");
"PeaksWorkspace","",Direction::Input), "Input Peaks Workspace");
auto mustBePositive = boost::make_shared<BoundedValidator<double> >();
mustBePositive->setLower(0.0);
......@@ -64,16 +64,13 @@ namespace Crystal
*/
void ShowPossibleCells::exec()
{
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_const_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws)
{
throw std::runtime_error("Could not read the peaks workspace");
}
OrientedLattice o_lattice = ws->mutableSample().getOrientedLattice();
OrientedLattice o_lattice = ws->sample().getOrientedLattice();
Matrix<double> UB = o_lattice.getUB();
if ( ! IndexingUtils::CheckUB( UB ) )
......
......@@ -91,10 +91,7 @@ namespace Crystal
*/
void TransformHKL::exec()
{
PeaksWorkspace_sptr ws;
ws = boost::dynamic_pointer_cast<PeaksWorkspace>(
AnalysisDataService::Instance().retrieve(this->getProperty("PeaksWorkspace")) );
PeaksWorkspace_sptr ws = this->getProperty("PeaksWorkspace");
if (!ws)
{
throw std::runtime_error("Could not read the peaks workspace");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment