Commit a141edfc authored by Steve Williams's avatar Steve Williams
Browse files

Fixes broken GetEi test refs #841

parent ac9292b1
......@@ -119,12 +119,24 @@ void GetEi::getGeometry(Workspace2D_const_sptr WS, int mon0Spec, int mon1Spec, d
const IObjComponent_sptr source = WS->getInstrument()->getSource();
// retrieve a pointer to the first detector and get its distance
IDetector_sptr dets = WS->getDetector(mon0Spec);
monitor0Dist = dets->getDistance(*(source.get()));
std::vector<int> dets = WS->spectraMap().getDetectors(mon0Spec);
if ( dets.size() != 1 )
{
g_log.error() << "The detector for spectrum number " << mon0Spec << " was either not found or is a group, grouped monitors are not supported by this algorithm" << std::endl;
throw std::bad_cast("Error retrieving data for the first monitor");
}
IDetector_sptr det = WS->getInstrument()->getDetector(dets[0]);
monitor0Dist = det->getDistance(*(source.get()));
// repeat for the second detector
dets = WS->getDetector(mon1Spec);
monitor1Dist = dets->getDistance(*(source.get()));
dets = WS->spectraMap().getDetectors(mon1Spec);
if ( dets.size() != 1 )
{
g_log.error() << "The detector for spectrum number " << mon1Spec << " was either not found or is a group, grouped monitors are not supported by this algorithm" << std::endl;
throw std::bad_cast("Error retrieving data for the second monitor");
}
det = WS->getInstrument()->getDetector(dets[0]);
monitor1Dist = det->getDistance(*(source.get()));
}
/** Converts detector IDs to spectra indexes
* @param WS the workspace on which the calculations are being performed
......
......@@ -30,27 +30,26 @@ public:
TS_ASSERT_EQUALS( grouper.category(), "CorrectionFunctions" )
TS_ASSERT_THROWS_NOTHING( grouper.initialize() )
TS_ASSERT( grouper.isInitialized() )
// the following is for a MARI workspace that is loaded in the constructor and the values I found from experimenting
grouper.setPropertyValue("InputWorkspace", m_WS);
grouper.setPropertyValue("Monitor1ID", "2");
grouper.setPropertyValue("Monitor2ID", "3");
grouper.setPropertyValue("Monitor1Spec", "2");
grouper.setPropertyValue("Monitor2Spec", "3");
grouper.setPropertyValue("EnergyEstimate", "14");
//MAPS one off test, takes to long to do it every time. To activate uncomment the code below and two sections below that
// when the MAP workspace that is load in the constructor
/* grouper.setPropertyValue("InputWorkspace", m_WS);
grouper.setPropertyValue("Monitor1ID", "1000002");
grouper.setPropertyValue("Monitor2ID", "1000003");
grouper.setPropertyValue("Monitor1Spec", "41474");
grouper.setPropertyValue("Monitor2Spec", "41475");
grouper.setPropertyValue("EnergyEstimate", "400");*/
//MERLIN one off test, takes 30 or more seconds. To activate uncomment the code below and two sections below that
/* grouper.setPropertyValue("InputWorkspace", m_WS);
grouper.setPropertyValue("Monitor1Spec", "69634");
grouper.setPropertyValue("Monitor2Spec", "69638");
grouper.setPropertyValue("EnergyEstimate", "15");
grouper.setPropertyValue("EnergyEstimate", "15");*/
TS_ASSERT_THROWS_NOTHING( grouper.execute());
TS_ASSERT( grouper.isExecuted() );*/
TS_ASSERT( grouper.isExecuted() );
double finalAnswer = grouper.getProperty("IncidentEnergy");
TS_ASSERT_DELTA( finalAnswer, 12.9462875, 1e-6 )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment