diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadILL.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadILL.h index 2a7ead842a01..8bc13a44b1a7 100644 --- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadILL.h +++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadILL.h @@ -70,6 +70,7 @@ namespace DataHandling { // Execution code void exec(); + int getEPPFromVanadium(const std::string &,Mantid::API::MatrixWorkspace_sptr); void loadInstrumentDetails(NeXus::NXEntry&); void initWorkSpace(NeXus::NXEntry& entry); void initInstrumentSpecific(); diff --git a/Code/Mantid/Framework/DataHandling/src/LoadILL.cpp b/Code/Mantid/Framework/DataHandling/src/LoadILL.cpp index 1e7ac2758a10..3aed02a0cc35 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadILL.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadILL.cpp @@ -105,20 +105,26 @@ namespace Mantid /** * Initialise the algorithm */ - void LoadILL::init() - { - declareProperty( - new FileProperty("Filename", "", FileProperty::Load, ".nxs"), - "File path of the Data file to load"); - declareProperty( - new FileProperty("FilenameVanadium", "", FileProperty::OptionalLoad, ".nxs"), - "File path of the Vanadium file to load (Optional)"); + void LoadILL::init() { + declareProperty( + new FileProperty("Filename", "", FileProperty::Load, ".nxs"), + "File path of the Data file to load"); - declareProperty( - new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output), - "The name to use for the output workspace"); + declareProperty( + new FileProperty("FilenameVanadium", "", FileProperty::OptionalLoad, + ".nxs"), + "File path of the Vanadium file to load (Optional)"); - } + declareProperty( + new WorkspaceProperty("WorkspaceVanadium", "", + Direction::Input, PropertyMode::Optional), + "Vanadium Workspace file to load (Optional)"); + + declareProperty( + new WorkspaceProperty<>("OutputWorkspace", "", Direction::Output), + "The name to use for the output workspace"); + + } /** @@ -129,6 +135,7 @@ namespace Mantid // Retrieve filename std::string filenameData = getPropertyValue("Filename"); std::string filenameVanadium = getPropertyValue("FilenameVanadium"); + MatrixWorkspace_sptr vanaWS = getProperty("WorkspaceVanadium"); // open the root node NeXus::NXRoot dataRoot(filenameData); @@ -141,11 +148,7 @@ namespace Mantid runLoadInstrument(); // just to get IDF contents initInstrumentSpecific(); - int calculatedDetectorElasticPeakPosition = -1; - if (filenameVanadium != "") { - g_log.information() << "Calculating the elastic peak position from the Vanadium." << std::endl; - calculatedDetectorElasticPeakPosition = validateVanadium(filenameVanadium); - } + int calculatedDetectorElasticPeakPosition = getEPPFromVanadium(filenameVanadium,vanaWS); loadDataIntoTheWorkSpace(dataFirstEntry,calculatedDetectorElasticPeakPosition); @@ -159,6 +162,38 @@ namespace Mantid setProperty("OutputWorkspace", m_localWorkspace); } + + int LoadILL::getEPPFromVanadium(const std::string &filenameVanadium, + MatrixWorkspace_sptr vanaWS) { + int calculatedDetectorElasticPeakPosition = -1; + + if (vanaWS != NULL) { + + // Check if it has been store on the run object for this workspace + if (vanaWS->run().hasProperty("EPP")) { + Kernel::Property* prop = vanaWS->run().getProperty("EPP"); + calculatedDetectorElasticPeakPosition = boost::lexical_cast( + prop->value()); + g_log.information() + << "Using EPP from Vanadium WorkSpace : value = " + << calculatedDetectorElasticPeakPosition << "\n"; + } else { + g_log.error( + "No EPP Property in the Vanadium Workspace. Following regular procedure..."); + //throw std::invalid_argument("No EPP value has been set or stored within the run information."); + } + } + if (calculatedDetectorElasticPeakPosition == -1 && filenameVanadium != "") { + g_log.information() + << "Calculating the elastic peak position from the Vanadium." + << std::endl; + calculatedDetectorElasticPeakPosition = validateVanadium( + filenameVanadium); + } + return calculatedDetectorElasticPeakPosition; + } + + /** * */ @@ -496,6 +531,9 @@ namespace Mantid else calculatedDetectorElasticPeakPosition = vanaCalculatedDetectorElasticPeakPosition; + //set it as a Property + API::Run & runDetails = m_localWorkspace->mutableRun(); + runDetails.addProperty("EPP", calculatedDetectorElasticPeakPosition); double theoreticalElasticTOF = (m_loader.calculateTOF(m_l1,m_wavelength) + m_loader.calculateTOF(m_l2,m_wavelength)) * 1e6; //microsecs diff --git a/Code/Mantid/instrument/Facilities.xml b/Code/Mantid/instrument/Facilities.xml index 1cfa025be8d2..9a9f11a4e65d 100644 --- a/Code/Mantid/instrument/Facilities.xml +++ b/Code/Mantid/instrument/Facilities.xml @@ -436,7 +436,7 @@ - + Neutron Spectroscopy