Newer
Older
Russell Taylor
committed
#include "MantidDataHandling/LoadMappingTable.h"
Russell Taylor
committed
#include "MantidAPI/SpectraDetectorMap.h"
Gigg, Martyn Anthony
committed
#include "MantidAPI/FileProperty.h"
namespace Mantid
{
namespace DataHandling
{
using namespace Kernel;
using namespace API;
DECLARE_ALGORITHM(LoadMappingTable)
Russell Taylor
committed
LoadMappingTable::LoadMappingTable() : Algorithm()
Russell Taylor
committed
Janik Zikovsky
committed
//this->setWikiSummary("Builds up the mapping between spectrum number and the detector objects in the [[instrument]] [[Geometry]].");
//this->setOptionalMessage("Builds up the mapping between spectrum number and the detector objects in the instrument Geometry.");
Gigg, Martyn Anthony
committed
declareProperty(new FileProperty("Filename","", FileProperty::Load),
Russell Taylor
committed
"The name of the file from which to obtain the mapping information,\n"
"including its full or relative path" );
declareProperty(new WorkspaceProperty<>("Workspace","Anonymous",Direction::InOut),
"The name of the workspace to which the mapping information will be added");
Russell Taylor
committed
Russell Taylor
committed
//Get the raw file name
m_filename = getPropertyValue("Filename");
// Get the input workspace
Roman Tolchenov
committed
const MatrixWorkspace_sptr localWorkspace = getProperty("Workspace");
/// ISISRAW class instance which does raw file reading. Shared pointer to prevent memory leak when an exception is thrown.
boost::shared_ptr<ISISRAW2> iraw(new ISISRAW2);
if (iraw->readFromFile(m_filename.c_str(),0) != 0) // ReadFrom File with no data
Russell Taylor
committed
{
g_log.error("Unable to open file " + m_filename);
throw Kernel::Exception::FileError("Unable to open File:" , m_filename);
}
Sofia Antony
committed
progress(0.5);
const int number_spectra=iraw->i_det; // Number of entries in the spectra/udet table
if ( number_spectra == 0 )
{
g_log.warning("The spectra to detector mapping table is empty");
}
Russell Taylor
committed
//Populate the Spectra Map with parameters
localWorkspace->mutableSpectraMap().populate(iraw->spec,iraw->udet,number_spectra);
Sofia Antony
committed
progress(1);
Russell Taylor
committed
return;