Skip to content

Commit

Permalink
Make grouping functions to return output workspaces.
Browse files Browse the repository at this point in the history
Refs #7229
  • Loading branch information
arturbekasov committed Oct 11, 2013
1 parent 1f0d2ac commit e1e6635
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ namespace Mantid
double getLogValue(MatrixWorkspace& ws,const std::string& logName);

/// Applies DTC to a group of workspaces using a single table
void applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable, WorkspaceGroup_sptr wsGroup);
WorkspaceGroup_sptr applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable,
WorkspaceGroup_sptr wsGroup);

/// Applies DTC to a group of workspace using a group of tables
void applyDeadTimeCorrection(WorkspaceGroup_sptr deadTimeGroup, WorkspaceGroup_sptr wsGroup);
WorkspaceGroup_sptr applyDeadTimeCorrection(WorkspaceGroup_sptr deadTimeGroup,
WorkspaceGroup_sptr wsGroup);

/// Runs ApplyDeadTimeCorr to apply DTC to a workspace using a table
void applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable, Workspace2D_sptr ws);
Workspace2D_sptr applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable,
Workspace2D_sptr ws);

/// Stores property "Int"
bool m_int;
Expand Down
36 changes: 27 additions & 9 deletions Code/Mantid/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,19 +568,27 @@ namespace Mantid
*
* @param deadTimeTable :: Dead Time Table to be applied
* @param wsGroup :: Group of workspaces to apply correction to
*
* @return Group of workspaces with DTC applied
*/
void PlotAsymmetryByLogValue::applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable,
WorkspaceGroup_sptr wsGroup)
WorkspaceGroup_sptr PlotAsymmetryByLogValue::applyDeadTimeCorrection(
ITableWorkspace_sptr deadTimeTable, WorkspaceGroup_sptr wsGroup)
{
WorkspaceGroup_sptr outputGroup = boost::make_shared<WorkspaceGroup>();

for(size_t i = 0; i < wsGroup->size(); i++)
{
Workspace2D_sptr member = boost::dynamic_pointer_cast<Workspace2D>(wsGroup->getItem(i));

if(!member)
throw std::invalid_argument("Group contains unsupported type of workspace");

applyDeadTimeCorrection(deadTimeTable, member);
Workspace2D_sptr outputWs = applyDeadTimeCorrection(deadTimeTable, member);

outputGroup->addWorkspace(outputWs);
}

return outputGroup;
}

/**
Expand All @@ -589,13 +597,17 @@ namespace Mantid
*
* @param deadTimeGroup :: Group of Dead Time Tables to be applied
* @param wsGroup :: Group of workspaces to apply correction to
*
* @return Group of workspaces with DTC applied
*/
void PlotAsymmetryByLogValue::applyDeadTimeCorrection(WorkspaceGroup_sptr deadTimeGroup,
WorkspaceGroup_sptr wsGroup)
WorkspaceGroup_sptr PlotAsymmetryByLogValue::applyDeadTimeCorrection(
WorkspaceGroup_sptr deadTimeGroup, WorkspaceGroup_sptr wsGroup)
{
if(deadTimeGroup->size() != wsGroup->size())
throw std::invalid_argument("Dead Time Table group size is not equal to ws group sizes");

WorkspaceGroup_sptr outputGroup = boost::make_shared<WorkspaceGroup>();

for(size_t i = 0; i < wsGroup->size(); i++)
{
Workspace2D_sptr wsMember = boost::dynamic_pointer_cast<Workspace2D>(wsGroup->getItem(i));
Expand All @@ -609,18 +621,24 @@ namespace Mantid
if(!deadTimeMember)
throw std::invalid_argument("Dead Time Table group contains workspace which is not a table");

applyDeadTimeCorrection(deadTimeMember, wsMember);
Workspace2D_sptr outputWs = applyDeadTimeCorrection(deadTimeMember, wsMember);

outputGroup->addWorkspace(outputWs);
}

return outputGroup;
}

/**
* Runs ApplyDeadTimeCorr algorithm to apply Dead Time Correction to a ws using a given table.
*
* @param deadTimeTable :: Dead Time Table to be applied
* @param ws :: Workspace to apply correction to
*
* @return Workspace with DTC applied
*/
void PlotAsymmetryByLogValue::applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable,
Workspace2D_sptr ws)
Workspace2D_sptr PlotAsymmetryByLogValue::applyDeadTimeCorrection(
ITableWorkspace_sptr deadTimeTable, Workspace2D_sptr ws)
{
IAlgorithm_sptr applyDtc = createChildAlgorithm("ApplyDeadTimeCorr");

Expand All @@ -630,7 +648,7 @@ namespace Mantid

MatrixWorkspace_sptr output = applyDtc->getProperty("OutputWorkspace");

ws = boost::dynamic_pointer_cast<Workspace2D>(output);
return boost::dynamic_pointer_cast<Workspace2D>(output);
}

} // namespace Algorithm
Expand Down

0 comments on commit e1e6635

Please sign in to comment.