Newer
Older
#include "MantidKernel/Exception.h"
#include "LoadRaw/isisraw.h"
#include "MantidAPI/AlgorithmFactory.h"
#include "MantidAPI/WorkspaceProperty.h"
Russell Taylor
committed
#include "MantidAPI/SpectraDetectorMap.h"
#include "MantidDataHandling/LoadMappingTable.h"
namespace Mantid
{
namespace DataHandling
{
using namespace Kernel;
using namespace API;
DECLARE_ALGORITHM(LoadMappingTable)
Logger& LoadMappingTable::g_log = Logger::get("LoadMappingTable");
LoadMappingTable::LoadMappingTable()
{
}
Russell Taylor
committed
Russell Taylor
committed
declareProperty("Filename","",new MandatoryValidator<std::string>); // Filename for RAW file
Roman Tolchenov
committed
declareProperty(new WorkspaceProperty<MatrixWorkspace>("Workspace","Anonymous",Direction::InOut)); // Associated workspace
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");
Russell Taylor
committed
ISISRAW iraw(NULL);
if (iraw.readFromFile(m_filename.c_str(),0) != 0) // ReadFrom File with no data
{
g_log.error("Unable to open file " + m_filename);
throw Kernel::Exception::FileError("Unable to open File:" , m_filename);
}
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);
Russell Taylor
committed
return;