Skip to content

Commit

Permalink
Refs #10648 Fetch polarization parameters from instrument if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Jeffery committed Nov 27, 2014
1 parent a5bd790 commit f4b4035
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions Code/Mantid/Framework/Algorithms/src/PolarizationCorrection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidKernel/Unit.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidGeometry/Instrument.h"
#include "MantidKernel/ListValidator.h"
#include "MantidDataObjects/WorkspaceSingleValue.h"
Expand Down Expand Up @@ -215,16 +214,13 @@ namespace Mantid
"PNR: Polarized Neutron Reflectivity mode\n"
"PA: Full Polarization Analysis PNR-PA");

VecDouble emptyVec;
auto mandatoryArray = boost::make_shared<MandatoryValidator<VecDouble> >();

declareProperty(new ArrayProperty<double>(cppLabel(), mandatoryArray, Direction::Input),
declareProperty(new ArrayProperty<double>(cppLabel(), Direction::Input),
"Effective polarizing power of the polarizing system. Expressed as a ratio 0 < Pp < 1");

declareProperty(new ArrayProperty<double>(cApLabel(), Direction::Input),
"Effective polarizing power of the analyzing system. Expressed as a ratio 0 < Ap < 1");

declareProperty(new ArrayProperty<double>(crhoLabel(), mandatoryArray, Direction::Input),
declareProperty(new ArrayProperty<double>(crhoLabel(), Direction::Input),
"Ratio of efficiencies of polarizer spin-down to polarizer spin-up. This is characteristic of the polarizer flipper. Values are constants for each term in a polynomial expression.");

declareProperty(new ArrayProperty<double>(cAlphaLabel(), Direction::Input),
Expand Down Expand Up @@ -366,6 +362,29 @@ namespace Mantid

Instrument_const_sptr instrument = fetchInstrument(inWS.get());

//Check if we need to fetch polarization parameters from the instrument's parameters
std::map<std::string,std::string> loadableProperties;
loadableProperties[ crhoLabel()] = "crho";
loadableProperties[cAlphaLabel()] = "calpha";
loadableProperties[ cApLabel()] = "cAp";
loadableProperties[ cppLabel()] = "cPp";

for(auto propName = loadableProperties.begin(); propName != loadableProperties.end(); ++propName)
{
Property* prop = getProperty(propName->first);

if(!prop)
continue;

if(prop->isDefault())
{
auto vals = instrument->getStringParameter(propName->second);
if(vals.empty())
throw std::runtime_error("Cannot find value for " + propName->first + " in parameter file. Please specify this property manually.");
prop->setValue(vals[0]);
}
}

WorkspaceGroup_sptr outWS;
if (analysisMode == pALabel())
{
Expand Down

0 comments on commit f4b4035

Please sign in to comment.