Commit 2fd3d78e authored by Anders Markvardsen's avatar Anders Markvardsen
Browse files

Fixed problem with 'value' attribute of <parameter> not being stored in...

Fixed problem with 'value' attribute of <parameter> not being stored in workspace. Added test to LoadRaw3test to test that parameters are read in from Tosca IDF. Refs #725.
parent 3eae4f6a
......@@ -556,7 +556,7 @@ namespace Mantid
std::multimap<std::string, boost::shared_ptr<DataHandling::XMLlogfile> > :: const_iterator it;
std::pair<std::multimap<std::string, boost::shared_ptr<DataHandling::XMLlogfile> >::iterator,
std::multimap<std::string, boost::shared_ptr<DataHandling::XMLlogfile> >::iterator> ret;
std::multimap<std::string, boost::shared_ptr<DataHandling::XMLlogfile> >::iterator> ret;
// loop over all logfiles and see if any of these are associated with parameters in the
......@@ -593,6 +593,27 @@ namespace Mantid
else
paramMap->addDouble(((*it).second)->m_component, paramN, value);
}
} // finished looping over logfiles
// Check if parameters have been specified using the 'value' attribute rather than the 'logfile-id' attribute
// All such parameters have been stored using the key = "".
ret = paramInfoFromIDF.equal_range("");
TimeSeriesProperty<double>* dummy = NULL;
for (it=ret.first; it!=ret.second; ++it)
{
double value = ((*it).second)->createParamValue(dummy);
// special case if parameter name is "x", "y" or "z" and "rot"
std::string paramN = ((*it).second)->m_paramName;
if ( paramN.compare("x")==0 || paramN.compare("y")==0 || paramN.compare("z")==0 )
paramMap->addPositionCoordinate(((*it).second)->m_component, paramN, value);
else if ( paramN.compare("rot")==0 )
paramMap->addRotationParam(((*it).second)->m_component,paramN, value);
else
paramMap->addDouble(((*it).second)->m_component, paramN, value);
}
}
......
......@@ -12,6 +12,7 @@
#include "MantidKernel/TimeSeriesProperty.h"
#include "MantidAPI/SpectraDetectorMap.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidAPI/Instrument.h"
using namespace Mantid::API;
using namespace Mantid::Kernel;
......@@ -308,6 +309,46 @@ public:
TS_ASSERT( dynamic_cast<ManagedWorkspace2D*>(output.get()) )
}
// test if parameters set in instrument definition file are loaded properly
void testIfParameterFromIDFLoaded()
{
LoadRaw3 loader4;
loader4.initialize();
loader4.setPropertyValue("Filename", "../../../../Test/Data/TSC10076.raw");
loader4.setPropertyValue("OutputWorkspace", "parameterIDF");
TS_ASSERT_THROWS_NOTHING( loader4.execute() )
TS_ASSERT( loader4.isExecuted() )
// Get back workspace and check it really is a ManagedWorkspace2D
Workspace_sptr output;
TS_ASSERT_THROWS_NOTHING( output = AnalysisDataService::Instance().retrieve("parameterIDF") );
Workspace2D_sptr output2D = boost::dynamic_pointer_cast<Workspace2D>(output);
// Check the total number of elements in the map for TOSCA
//TS_ASSERT_EQUALS(output2D->spectraMap().nElements(),141);
//boost::shared_ptr<IComponent> comp;
boost::shared_ptr<IInstrument> i = output2D->getInstrument();
Mantid::Geometry::IDetector_sptr ptrDet = i->getDetector(60);
TS_ASSERT_EQUALS( ptrDet->getID(), 60);
boost::shared_ptr<Mantid::Geometry::ParameterMap> pmap = output2D->instrumentParameters();
TS_ASSERT_EQUALS( pmap->size(), 140);
// Mantid::Geometry::IComponent* comp = static_cast<IComponent*>(ptrDet);
// Mantid::Geometry::Parameter_sptr par = pmap->get(ptrDet,"Efixed");
}
private:
LoadRaw3 loader,loader2,loader3;
std::string inputFile;
......
Supports Markdown
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