Skip to content

Commit

Permalink
Refs #6473. Refactored dead time correction a bit.
Browse files Browse the repository at this point in the history
So it now uses the same routines as algorithm creation function.
  • Loading branch information
arturbekasov committed Dec 13, 2013
1 parent 88673f3 commit 697229c
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp
Expand Up @@ -1535,38 +1535,28 @@ void MuonAnalysis::inputFileChanged(const QStringList& files)
if (m_uiForm.instrSelector->currentText().toUpper() == "ARGUS")
throw std::runtime_error("Dead times are currently not implemented in ARGUS files.");

IAlgorithm_sptr applyCorrAlg = AlgorithmManager::Instance().create("ApplyDeadTimeCorr");

applyCorrAlg->setPropertyValue("InputWorkspace", m_workspace_name);
applyCorrAlg->setPropertyValue("OutputWorkspace", m_workspace_name);

ScopedWorkspace customDeadTimes;
ScopedWorkspace deadTimes;

if (m_uiForm.deadTimeType->currentIndex() == 1) // From Run Data
{
if( ! loadedDeadTimes )
throw std::runtime_error("Data file doesn't appear to contain dead time values");

applyCorrAlg->setPropertyValue("DeadTimeTable", loadedDeadTimes.name());

Workspace_sptr ws = loadedDeadTimes.retrieve();
loadedDeadTimes.remove();

deadTimes.set(ws);
}
else if (m_uiForm.deadTimeType->currentIndex() == 2) // From Specified File
{
if(!m_uiForm.mwRunDeadTimeFile->isValid())
throw std::runtime_error("Specified Dead Time file is not valid.");

std::string deadTimeFile = m_uiForm.mwRunDeadTimeFile->getFirstFilename().toStdString();

IAlgorithm_sptr loadDeadTimes = AlgorithmManager::Instance().create("LoadNexusProcessed");
loadDeadTimes->setPropertyValue("Filename", deadTimeFile);
loadDeadTimes->setPropertyValue("OutputWorkspace", customDeadTimes.name());
loadDeadTimes->execute();

if ( ! customDeadTimes )
throw std::runtime_error("Unable to load dead times from the spefied file");

applyCorrAlg->setPropertyValue("DeadTimeTable", customDeadTimes.name());
Workspace_sptr ws = loadDeadTimes( deadTimeFilename() );
deadTimes.set(ws);
}

IAlgorithm_sptr applyCorrAlg = AlgorithmManager::Instance().create("ApplyDeadTimeCorr");
applyCorrAlg->setPropertyValue("InputWorkspace", m_workspace_name);
applyCorrAlg->setPropertyValue("OutputWorkspace", m_workspace_name);
applyCorrAlg->setPropertyValue("DeadTimeTable", deadTimes.name());
applyCorrAlg->execute();
}
catch(std::exception& e)
Expand Down

0 comments on commit 697229c

Please sign in to comment.