Skip to content

Commit

Permalink
refs #7351 This should fix it
Browse files Browse the repository at this point in the history
Added the piece of code, which processes Ei log value in a way similar to SofQ3 does
  • Loading branch information
abuts committed Jul 8, 2013
1 parent 6b16ed8 commit ca33d17
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions Code/Mantid/Framework/Algorithms/src/SofQW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ void SofQW::createInputProperties(API::Algorithm & alg)
void SofQW::exec()
{
using namespace Geometry;

double efixed;

MatrixWorkspace_const_sptr inputWorkspace = getProperty("InputWorkspace");
// Do the full check for common binning
if ( ! WorkspaceHelpers::commonBoundaries(inputWorkspace) )
Expand All @@ -113,7 +114,35 @@ void SofQW::exec()
int emode = 0;
if (emodeStr == "Direct") emode=1;
else if (emodeStr == "Indirect") emode=2;

// Retrieve the emode & efixed properties

// Check whether they should have supplied an EFixed value
if(emode == 1 ) // Direct
{

// If GetEi was run then it will have been stored in the workspace, if not the user will need to enter one
if ( inputWorkspace->run().hasProperty("Ei") )
{
Kernel::Property *p = inputWorkspace->run().getProperty("Ei");
Kernel::PropertyWithValue<double> *eiProp = dynamic_cast<Kernel::PropertyWithValue<double>*>(p);
if( !eiProp )
{
throw std::runtime_error("Input workspace contains Ei but its property type is not a double.");
}
efixed = (*eiProp)();
}
else
{
efixed = getProperty("EFixed");
if (efixed == 0)
{
throw std::invalid_argument("Input workspace does not contain an EFixed value. Please provide one or run GetEi.");
}
}

}


// Get a pointer to the instrument contained in the workspace
Instrument_const_sptr instrument = inputWorkspace->getInstrument();
// Get the parameter map
Expand Down Expand Up @@ -151,9 +180,9 @@ void SofQW::exec()
IDetector_const_sptr spectrumDet = inputWorkspace->getDetector(i);
if( spectrumDet->isMonitor() ) continue;
// If an indirect instrument, try getting Efixed from the geometry
double efixed = getProperty("EFixed");
if (emode==2)
{
efixed = getProperty("EFixed");
try {
Parameter_sptr par = pmap.get(spectrumDet.get(),"EFixed");
if (par)
Expand Down Expand Up @@ -202,6 +231,13 @@ void SofQW::exec()
{
ei = efixed;
ef = efixed - deltaE;
if (ef<0)
{
std::string mess = "Energy transfer requested in Indirect mode exceeds incident energy.\n Found for det ID: "+boost::lexical_cast<std::string>(idet)+
" bin No "+boost::lexical_cast<std::string>(j)+" with Ei="+boost::lexical_cast<std::string>(efixed)+" and energy transfer: "+
boost::lexical_cast<std::string>(deltaE);
throw std::runtime_error(mess);
}
}
else
{
Expand Down

0 comments on commit ca33d17

Please sign in to comment.