Skip to content

Commit

Permalink
Refs #5549 don't reload cal file for chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
VickieLynch committed Aug 4, 2012
1 parent 8300748 commit d0272fc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataObjects/GroupingWorkspace.h"
#include "MantidDataObjects/MaskWorkspace.h"
#include "MantidDataObjects/OffsetsWorkspace.h"

namespace Mantid
{
Expand Down Expand Up @@ -75,6 +78,9 @@ namespace Mantid
API::MatrixWorkspace_sptr m_inputW;
API::MatrixWorkspace_sptr m_outputW;
DataObjects::EventWorkspace_sptr m_eventW;
DataObjects::OffsetsWorkspace_sptr offsetsWS;
API::MatrixWorkspace_sptr maskWS;
DataObjects::GroupingWorkspace_sptr groupWS;
void doSortEvents(Mantid::API::Workspace_sptr ws);

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,28 +101,20 @@ void AlignAndFocusPowder::exec()
// retrieve the properties
m_inputW = getProperty("InputWorkspace");
m_eventW = boost::dynamic_pointer_cast<EventWorkspace>( m_inputW );
if ((m_eventW != NULL))
{
//Input workspace is an event workspace. Use the other exec method
this->execEvent();
return;
}
std::string instName = m_inputW->getInstrument()->getName();
std::string calFileName=getProperty("CalFileName");
OffsetsWorkspace_sptr offsetsWS = getProperty("OffsetsWorkspace");
MatrixWorkspace_sptr maskWS = getProperty("MaskWorkspace");
GroupingWorkspace_sptr groupWS = getProperty("GroupingWorkspace");
std::vector<double> params=getProperty("Params");
bool dspace = getProperty("DSpacing");
double xmin = getProperty("CropMin");
double xmax = getProperty("CropMax");
double LRef = getProperty("UnwrapRef");
double DIFCref = getProperty("LowResRef");
double minwl = getProperty("CropWavelengthMin");
double tmin = getProperty("TMin");
double tmax = getProperty("TMax");
offsetsWS = getProperty("OffsetsWorkspace");
maskWS = getProperty("MaskWorkspace");
groupWS = getProperty("GroupingWorkspace");

try {
if (!offsetsWS) offsetsWS = AnalysisDataService::Instance().retrieveWS<OffsetsWorkspace>(instName+"_offsets");
if (!maskWS) maskWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(instName+"_mask");
if (!groupWS) groupWS = AnalysisDataService::Instance().retrieveWS<GroupingWorkspace>(instName+"_group");
} catch (Exception::NotFoundError&) {
// Just checking if these files exist so they are not reloaded for chunks
}

// Get the input workspace
if ((!offsetsWS || !maskWS || !groupWS) && !calFileName.empty())
{
// Load the .cal file
Expand All @@ -138,6 +130,22 @@ void AlignAndFocusPowder::exec()
AnalysisDataService::Instance().addOrReplace(instName+"_offsets", offsetsWS);
AnalysisDataService::Instance().addOrReplace(instName+"_mask", maskWS);
}
if ((m_eventW != NULL))
{
//Input workspace is an event workspace. Use the other exec method
this->execEvent();
return;
}
std::vector<double> params=getProperty("Params");
bool dspace = getProperty("DSpacing");
double xmin = getProperty("CropMin");
double xmax = getProperty("CropMax");
double LRef = getProperty("UnwrapRef");
double DIFCref = getProperty("LowResRef");
double minwl = getProperty("CropWavelengthMin");
double tmin = getProperty("TMin");
double tmax = getProperty("TMax");

// Now create the output workspace
m_outputW = getProperty("OutputWorkspace");
if ( m_outputW != m_inputW )
Expand Down Expand Up @@ -272,9 +280,6 @@ void AlignAndFocusPowder::execEvent()
// retrieve the properties
std::string instName = m_inputW->getInstrument()->getName();
std::string calFileName=getProperty("CalFileName");
OffsetsWorkspace_sptr offsetsWS = getProperty("OffsetsWorkspace");
MatrixWorkspace_sptr maskWS = getProperty("MaskWorkspace");
GroupingWorkspace_sptr groupWS = getProperty("GroupingWorkspace");
std::vector<double> params=getProperty("Params");
bool dspace = getProperty("DSpacing");
double xmin = getProperty("CropMin");
Expand All @@ -292,24 +297,6 @@ void AlignAndFocusPowder::execEvent()
double filterMin = getProperty("FilterLogMinimumValue");
double filterMax = getProperty("FilterLogMaximumValue");

// Get the input workspace
if ((!offsetsWS || !maskWS || !groupWS) && !calFileName.empty())
{
// Load the .cal file
IAlgorithm_sptr alg = createSubAlgorithm("LoadCalFile");
alg->setPropertyValue("CalFilename", calFileName);
alg->setProperty("InputWorkspace", m_inputW);
alg->setProperty<std::string>("WorkspaceName", instName);
alg->executeAsSubAlg();
groupWS = alg->getProperty("OutputGroupingWorkspace");
offsetsWS = alg->getProperty("OutputOffsetsWorkspace");
maskWS = alg->getProperty("OutputMaskWorkspace");
AnalysisDataService::Instance().addOrReplace(instName+"_group", groupWS);
AnalysisDataService::Instance().addOrReplace(instName+"_offsets", offsetsWS);
AnalysisDataService::Instance().addOrReplace(instName+"_mask", maskWS);
}
Progress progress(this,0.0,1.0,m_eventW->getNumberHistograms());

// generate the output workspace pointer
m_outputW = getProperty("OutputWorkspace");
EventWorkspace_sptr m_outputEventW;
Expand Down

0 comments on commit d0272fc

Please sign in to comment.