Skip to content

Commit

Permalink
Parameterize strings in CalculateResolution.
Browse files Browse the repository at this point in the history
Refs #10007.
  • Loading branch information
Harry Jeffery committed Aug 22, 2014
1 parent ab96893 commit 5bc6180
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
21 changes: 15 additions & 6 deletions Code/Mantid/Framework/Algorithms/src/CalculateResolution.cpp
Expand Up @@ -80,7 +80,12 @@ namespace Mantid
declareProperty(new WorkspaceProperty<>("Workspace","",Direction::Input,boost::make_shared<InstrumentValidator>()),
"Workspace to calculate the instrument resolution of.");

declareProperty("Theta", Mantid::EMPTY_DBL(), "Theta in degrees", Direction::Input);
declareProperty("Theta", Mantid::EMPTY_DBL(), "Theta in degrees");
declareProperty("FirstSlitName", "slit1", "Component name of the first slit.");
declareProperty("SecondSlitName", "slit2", "Component name of the second slit.");
declareProperty("VerticalGapParameter", "vertical gap", "Parameter the vertical gap of each slit can be found in.");
declareProperty("ThetaLogName", "THETA", "Name theta can be found in the run log as.");

declareProperty("Resolution", Mantid::EMPTY_DBL(), "Calculated resolution (dq/q).", Direction::Output);
}

Expand All @@ -91,10 +96,14 @@ namespace Mantid
{
const MatrixWorkspace_sptr ws = getProperty("Workspace");
double theta = getProperty("Theta");
const std::string slit1Name = getProperty("FirstSlitName");
const std::string slit2Name = getProperty("SecondSlitName");
const std::string vGapParam = getProperty("VerticalGapParameter");
const std::string thetaLogName = getProperty("ThetaLogName");

if(isEmpty(theta))
{
const Kernel::Property* logData = ws->mutableRun().getLogData("THETA");
const Kernel::Property* logData = ws->mutableRun().getLogData(thetaLogName);

if(!logData)
throw std::runtime_error("Value for theta could not be found in log. You must provide it.");
Expand All @@ -106,14 +115,14 @@ namespace Mantid
}

boost::shared_ptr<const IComponent> slit1, slit2;
slit1 = getComponent(ws, "slit1");
slit2 = getComponent(ws, "slit2");
slit1 = getComponent(ws, slit1Name);
slit2 = getComponent(ws, slit2Name);

const double slit1Z = slit1->getPos().Z() * 1000.0; //Converting from mm to m
const double slit2Z = slit2->getPos().Z() * 1000.0; //Converting from mm to m

const double slit1VG = slit1->getNumberParameter("vertical gap").front();
const double slit2VG = slit2->getNumberParameter("vertical gap").front();
const double slit1VG = slit1->getNumberParameter(vGapParam).front();
const double slit2VG = slit2->getNumberParameter(vGapParam).front();

const double vGap = slit1VG + slit2VG;
const double zDiff = slit2Z - slit1Z;
Expand Down
11 changes: 3 additions & 8 deletions Code/Mantid/docs/source/algorithms/CalculateResolution-v1.rst
Expand Up @@ -9,15 +9,10 @@
Description
-----------

This algorithm takes a workspaces and a value for theta, and attempts to calculate
This algorithm takes a workspace and a value for theta, and attempts to calculate
the reflectometry resolution (dq/q) from them. If no value is provided for theta
then CalculateResolution will attempt to fetch a value from the workspace's log.

This algorithm depends upon proper configuration of reflectometry instruments
passed to it. Specifically, it requires that two components, 'slit1', and 'slit2'
are properly defined and positioned, and that they both have their 'vertical gap'
parameter set correctly. If these requirements are not met, this algorithm will
not produce accurate results.
then CalculateResolution will attempt to fetch a value from the workspace's log
using the theta log name provided.

Usage
-----
Expand Down

0 comments on commit 5bc6180

Please sign in to comment.