Skip to content

Commit

Permalink
refs #5626. Should fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jul 19, 2012
1 parent 0198138 commit e377769
Showing 1 changed file with 55 additions and 49 deletions.
104 changes: 55 additions & 49 deletions Code/Mantid/Framework/Algorithms/test/NormaliseByDetectorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,58 +523,64 @@ class NormaliseByDetectorTestPerformance : public CxxTest::TestSuite

public:

NormaliseByDetectorTestPerformance()
{
// Load some data
IAlgorithm* loadalg = FrameworkManager::Instance().createAlgorithm("Load");
loadalg->setRethrows(true);
loadalg->initialize();
loadalg->setPropertyValue("Filename", "POLREF00004699.nxs");
loadalg->setPropertyValue("OutputWorkspace", "testws");
loadalg->execute();

// Convert units to wavelength
IAlgorithm* unitsalg = FrameworkManager::Instance().createAlgorithm("ConvertUnits");
unitsalg->initialize();
unitsalg->setPropertyValue("InputWorkspace", "testws");
unitsalg->setPropertyValue("OutputWorkspace", "testws");
unitsalg->setPropertyValue("Target", "Wavelength");
unitsalg->execute();

// Convert the specturm axis ot signed_theta
IAlgorithm* specaxisalg = FrameworkManager::Instance().createAlgorithm("ConvertSpectrumAxis");
specaxisalg->initialize();
specaxisalg->setPropertyValue("InputWorkspace", "testws");
specaxisalg->setPropertyValue("OutputWorkspace", "testws");
specaxisalg->setPropertyValue("Target", "signed_theta");
specaxisalg->execute();

WorkspaceGroup_sptr wsGroup = API::AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("testws");
ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(0));
static NormaliseByDetectorTestPerformance *createSuite() { return new NormaliseByDetectorTestPerformance(); }
static void destroySuite( NormaliseByDetectorTestPerformance *suite ) { delete suite; }

const std::string instrumentName = ws->getInstrument()->getName();

// Create a parameter file, with a root equation that will apply to all detectors.
const std::string parameterFileContents = boost::str(boost::format(
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\
<parameter-file instrument = \"%1%\" date = \"2012-01-31T00:00:00\">\n\
<component-link name=\"%1%\">\n\
<parameter name=\"LinearBackground:A0\" type=\"fitting\">\n\
<formula eq=\"1\" result-unit=\"Wavelength\"/>\n\
<fixed />\n\
</parameter>\n\
<parameter name=\"LinearBackground:A1\" type=\"fitting\">\n\
<formula eq=\"2\" result-unit=\"Wavelength\"/>\n\
<fixed />\n\
</parameter>\n\
</component-link>\n\
void setUp()
{
if(!ws)
{
// Load some data
IAlgorithm* loadalg = FrameworkManager::Instance().createAlgorithm("Load");
loadalg->setRethrows(true);
loadalg->initialize();
loadalg->setPropertyValue("Filename", "POLREF00004699.nxs");
loadalg->setPropertyValue("OutputWorkspace", "testws");
loadalg->execute();

// Convert units to wavelength
IAlgorithm* unitsalg = FrameworkManager::Instance().createAlgorithm("ConvertUnits");
unitsalg->initialize();
unitsalg->setPropertyValue("InputWorkspace", "testws");
unitsalg->setPropertyValue("OutputWorkspace", "testws");
unitsalg->setPropertyValue("Target", "Wavelength");
unitsalg->execute();

// Convert the specturm axis ot signed_theta
IAlgorithm* specaxisalg = FrameworkManager::Instance().createAlgorithm("ConvertSpectrumAxis");
specaxisalg->initialize();
specaxisalg->setPropertyValue("InputWorkspace", "testws");
specaxisalg->setPropertyValue("OutputWorkspace", "testws");
specaxisalg->setPropertyValue("Target", "signed_theta");
specaxisalg->execute();

WorkspaceGroup_sptr wsGroup = API::AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>("testws");
ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsGroup->getItem(0));

const std::string instrumentName = ws->getInstrument()->getName();

// Create a parameter file, with a root equation that will apply to all detectors.
const std::string parameterFileContents = boost::str(boost::format(
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n\
<parameter-file instrument = \"%1%\" date = \"2012-01-31T00:00:00\">\n\
<component-link name=\"%1%\">\n\
<parameter name=\"LinearBackground:A0\" type=\"fitting\">\n\
<formula eq=\"1\" result-unit=\"Wavelength\"/>\n\
<fixed />\n\
</parameter>\n\
<parameter name=\"LinearBackground:A1\" type=\"fitting\">\n\
<formula eq=\"2\" result-unit=\"Wavelength\"/>\n\
<fixed />\n\
</parameter>\n\
</component-link>\n\
</parameter-file>\n") % instrumentName);

// Create a temporary Instrument Parameter file.
FileObject file(parameterFileContents, instrumentName + "_Parameters.xml");

// Apply parameter file to workspace.
apply_instrument_parameter_file_to_workspace(ws, file);
// Create a temporary Instrument Parameter file.
FileObject file(parameterFileContents, instrumentName + "_Parameters.xml");

// Apply parameter file to workspace.
apply_instrument_parameter_file_to_workspace(ws, file);
}
}

void testSequential()
Expand Down

0 comments on commit e377769

Please sign in to comment.