Skip to content

Commit

Permalink
Methods for applying dead time correction.
Browse files Browse the repository at this point in the history
Refs #7229
  • Loading branch information
arturbekasov committed Oct 10, 2013
1 parent b2ada41 commit 01c5905
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Workspace2D.h"

namespace Mantid
{
Expand All @@ -19,6 +20,7 @@ namespace Mantid
namespace Algorithms
{
using namespace API;
using namespace DataObjects;
/**Takes a muon workspace as input and sums all the spectra into two spectra which represent
the two detector groupings. The resultant spectra are used to calculate (F-aB) / (F+aB) the results of which
are stored in the output workspace.
Expand Down Expand Up @@ -87,6 +89,14 @@ namespace Mantid
/// Get log value
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);

/// Applies DTC to a group of workspace using a group of tables
void 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);

/// Stores property "Int"
bool m_int;
Expand Down
70 changes: 70 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,76 @@ namespace Mantid
throw std::invalid_argument("Log "+logName+" cannot be converted to a double type.");
}

/**
* Applies a Dead Time Correction to a group of workspace using a single table.
*
* @param deadTimeTable :: Dead Time Table to be applied
* @param wsGroup :: Group of workspaces to apply correction to
*/
void PlotAsymmetryByLogValue::applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable,
WorkspaceGroup_sptr wsGroup)
{
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);
}
}

/**
* Applies Dead Time Correction to a group workspaces using a group of tables. Each table
* is applied to the corresponding ws from the group.
*
* @param deadTimeGroup :: Group of Dead Time Tables to be applied
* @param wsGroup :: Group of workspaces to apply correction to
*/
void 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");

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

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

ITableWorkspace_sptr deadTimeMember =
boost::dynamic_pointer_cast<ITableWorkspace>(deadTimeGroup->getItem(i));

if(!deadTimeMember)
throw std::invalid_argument("Dead Time Table group contains workspace which is not a table");

applyDeadTimeCorrection(deadTimeMember, wsMember);
}
}

/**
* 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
*/
void PlotAsymmetryByLogValue::applyDeadTimeCorrection(ITableWorkspace_sptr deadTimeTable,
Workspace2D_sptr ws)
{
IAlgorithm_sptr applyDtc = createChildAlgorithm("ApplyDeadTimeCorr");

applyDtc->setProperty<MatrixWorkspace_sptr>("InputWorkspace", ws);
applyDtc->setProperty<ITableWorkspace_sptr>("DeadTimeTable", deadTimeTable);
applyDtc->execute();

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

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

} // namespace Algorithm
} // namespace Mantid

Expand Down

0 comments on commit 01c5905

Please sign in to comment.