From dc8cd875b35f4e44f0f5b5898c7f236537b655ba Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Mon, 9 May 2011 14:09:54 +0000
Subject: [PATCH] Refs #2945. Add a parameter into the MARI, MAPS, MERLIN and
 LET files that tells the loader (currently only LoadRaw) to take detector
 positions from the RAW file not from the IDF. Swapped UpdateInstrumentFromRaw
 for UpdateInstrumentFromFile and will add ISIS NeXus support soon.

---
 .../Framework/DataHandling/CMakeLists.txt     |   6 +-
 ...ntFromRaw.h => UpdateInstrumentFromFile.h} |  40 +++----
 .../DataHandling/src/LoadRawHelper.cpp        |  28 +++--
 ...omRaw.cpp => UpdateInstrumentFromFile.cpp} | 107 ++++++++++--------
 ...wTest.h => UpdateInstrumentFromFileTest.h} |  27 ++---
 Code/Mantid/instrument/LET_Parameters.xml     |   5 +
 Code/Mantid/instrument/MAPS_Parameters.xml    |   6 +
 Code/Mantid/instrument/MARI_Parameters.xml    |   6 +-
 Code/Mantid/instrument/MERLIN_Parameters.xml  |   6 +
 9 files changed, 135 insertions(+), 96 deletions(-)
 rename Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/{UpdateInstrumentFromRaw.h => UpdateInstrumentFromFile.h} (65%)
 rename Code/Mantid/Framework/DataHandling/src/{UpdateInstrumentFromRaw.cpp => UpdateInstrumentFromFile.cpp} (51%)
 rename Code/Mantid/Framework/DataHandling/test/{UpdateInstrumentFromRawTest.h => UpdateInstrumentFromFileTest.h} (74%)

diff --git a/Code/Mantid/Framework/DataHandling/CMakeLists.txt b/Code/Mantid/Framework/DataHandling/CMakeLists.txt
index 34a7bd7e5c2..575f2db9344 100644
--- a/Code/Mantid/Framework/DataHandling/CMakeLists.txt
+++ b/Code/Mantid/Framework/DataHandling/CMakeLists.txt
@@ -71,7 +71,7 @@ set ( SRC_FILES
 	src/SaveSPE.cpp
 	src/SaveVTK.cpp
 	src/SetScalingPSD.cpp
-	src/UpdateInstrumentFromRaw.cpp
+	src/UpdateInstrumentFromFile.cpp
 )
 
 set ( SRC_UNITY_IGNORE_FILES src/LoadDAE/idc.cpp
@@ -136,7 +136,7 @@ set ( INC_FILES
 	inc/MantidDataHandling/SaveSPE.h
 	inc/MantidDataHandling/SaveVTK.h
 	inc/MantidDataHandling/SetScalingPSD.h
-	inc/MantidDataHandling/UpdateInstrumentFromRaw.h
+	inc/MantidDataHandling/UpdateInstrumentFromFile.h
 )
 
 set ( TEST_FILES
@@ -190,7 +190,7 @@ set ( TEST_FILES
 	test/SaveRKHTest.h
 	test/SaveSPETest.h
 	test/SetScalingPSDTest.h
-	test/UpdateInstrumentFromRawTest.h
+	test/UpdateInstrumentFromFileTest.h
 	test/XMLlogfileTest.h
 )
 
diff --git a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromRaw.h b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromFile.h
similarity index 65%
rename from Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromRaw.h
rename to Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromFile.h
index 5de517531c3..f436859ac7d 100644
--- a/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromRaw.h
+++ b/Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromFile.h
@@ -1,5 +1,5 @@
-#ifndef MANTID_DATAHANDLING_UPDATEINSTRUMENTFROMRAW_H_
-#define MANTID_DATAHANDLING_UPDATEINSTRUMENTFROMRAW_H_
+#ifndef MANTID_DATAHANDLING_UPDATEINSTRUMENTFROMFILE_H_
+#define MANTID_DATAHANDLING_UPDATEINSTRUMENTFROMFILE_H_
 
 //----------------------------------------------------------------------
 // Includes
@@ -8,20 +8,17 @@
 
 namespace Mantid
 {
-	
   namespace Geometry
   {
-    class CompAssembly;
-    class Component;
     class Instrument;
   }
 	
   namespace DataHandling
   {
-    /** @class UpdateInstrumentFromRaw UpdateInstrumentFromRaw.h DataHandling/UpdateInstrumentFromRaw.h
+    /**
 
-    Updating detector positions initially loaded in from Instrument Defintion File (IDF) from information in raw files. 
-    Note doing this will results in a slower performance (likely slightly slower performance) compared to specifying the 
+    Update detector positions initially loaded in from Instrument Defintion File (IDF) from information in the provided files. 
+    Note doing this will result in a slower performance (likely slightly slower performance) compared to specifying the 
     correct detector positions in the IDF in the first place. 
 
     Note that this algorithm moves the detectors without subsequent rotation, hence this means that detectors may not for 
@@ -33,10 +30,9 @@ namespace Mantid
     <LI> Filename - The name of and path to the input RAW file </LI>
     </UL>
 
-    @author Anders Markvardsen, ISIS, RAL
-    @date 6/5/2010
+    @author Martyn Gigg, Tessella plc
 
-    Copyright &copy; 2007-10 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
+    Copyright &copy; 2011 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
 
     This file is part of Mantid.
 
@@ -55,17 +51,19 @@ namespace Mantid
 
     File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>    
     */
-    class DLLExport UpdateInstrumentFromRaw : public API::Algorithm
+    class DLLExport UpdateInstrumentFromFile : public API::Algorithm
     {
     public:
       /// Default constructor
-      UpdateInstrumentFromRaw();
+      UpdateInstrumentFromFile();
 
       /// Destructor
-      ~UpdateInstrumentFromRaw() {}
+      ~UpdateInstrumentFromFile() {}
 
       /// Algorithm's name for identification overriding a virtual method
-      virtual const std::string name() const { return "UpdateInstrumentFromRaw";};
+      virtual const std::string name() const { return "UpdateInstrumentFromFile"; }
+      /// Algorithm's alias for the old UpdateInstrumentFromRaw
+      virtual const std::string alias() const { return "UpdateInstrumentFromRaw"; }
 
       /// Algorithm's version for identification overriding a virtual method
       virtual int version() const { return 1;};
@@ -76,19 +74,21 @@ namespace Mantid
     private:
       /// Sets documentation strings for this algorithm
       virtual void initDocs();
-
       /// Overwrites Algorithm method. Does nothing at present
       void init();
-
       /// Overwrites Algorithm method
       void exec();
 
-      /// The name and path of the input file
-      std::string m_filename;
+      /// Assumes the file is a raw file
+      void updateFromRaw(boost::shared_ptr<Geometry::Instrument> instrument, 
+                         const std::string & filename);
+      /// Assumes the file is an ISIS NeXus file
+      void updateFromIsisNeXus(boost::shared_ptr<Geometry::Instrument> instrument, 
+                               const std::string & filename);
     };
 
   } // namespace DataHandling
 } // namespace Mantid
 
-#endif /*MANTID_DATAHANDLING_UPDATEINSTRUMENTFROMRAW_H_*/
+#endif /*MANTID_DATAHANDLING_UPDATEINSTRUMENTFROMFILE_H_*/
 
diff --git a/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp b/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp
index 80f016f7356..d06f282cc7b 100644
--- a/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp
@@ -14,7 +14,6 @@
 #include "MantidKernel/TimeSeriesProperty.h"
 #include "LoadRaw/isisraw2.h"
 #include "MantidDataHandling/LoadLog.h"
-//#include "MantidDataHandling/LoadInstrumentHelper.h"
 #include "MantidAPI/LoadAlgorithmFactory.h"
 
 #include <boost/date_time/gregorian/gregorian.hpp>
@@ -553,11 +552,9 @@ namespace Mantid
 
       std::string instrumentID = isisRaw->i_inst; // get the instrument name
       size_t i = instrumentID.find_first_of(' '); // cut trailing spaces
-      if (i != std::string::npos)
-        instrumentID.erase(i);
+      if (i != std::string::npos) instrumentID.erase(i);
 
       IAlgorithm_sptr loadInst= createSubAlgorithm("LoadInstrument");
-
       // Now execute the sub-algorithm. Catch and log any error, but don't stop.
       bool executionSuccessful(true);
       try
@@ -585,6 +582,21 @@ namespace Mantid
       }
       else
       {
+        // If requested update the instrument to positions in the raw file
+        const Geometry::ParameterMap & pmap = localWorkspace->instrumentParameters();
+        if( pmap.contains(localWorkspace->getBaseInstrument().get(),"det-pos-source") )
+        {
+          boost::shared_ptr<Geometry::Parameter> updateDets = pmap.get(localWorkspace->getBaseInstrument().get(),"det-pos-source");
+          if( updateDets->value<std::string>() == "datafile" )
+          {
+            IAlgorithm_sptr updateInst = createSubAlgorithm("UpdateInstrumentFromFile");
+            updateInst->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
+            updateInst->setPropertyValue("Filename", fileName);
+            // We want this to throw if it fails to warn the user that the information is not correct.
+            updateInst->execute();
+          }
+        }
+        // Debugging code??
         m_monitordetectorList = loadInst->getProperty("MonitorList");
         std::vector<int>::const_iterator itr;
         for (itr = m_monitordetectorList.begin(); itr != m_monitordetectorList.end(); ++itr)
@@ -1048,11 +1060,11 @@ namespace Mantid
       bool braw = (!extn.compare("raw")||!extn.compare("add")||extn[0]=='s') ? true : false;
       if( isRawFileHeader(static_cast<int>(nread), header.full_hdr) || braw )
       {
-	return true;
+	      return true;
       }
       else
       {
-	return false;
+	      return false;
       }
     }
     /**Checks the file by opening it and reading few lines 
@@ -1068,7 +1080,7 @@ namespace Mantid
       FILE* fp = fopen(filePath.c_str(), "rb");
       if (fp == NULL)
       {
-	return bret;
+        return bret;
       }
       file_header header;
       int nread(static_cast<int>(fread(
@@ -1081,7 +1093,7 @@ namespace Mantid
       
       if( isRawFileHeader(nread, header.full_hdr) )
       {
-	bret=80;
+        bret=80;
       }
       return bret;
     }
diff --git a/Code/Mantid/Framework/DataHandling/src/UpdateInstrumentFromRaw.cpp b/Code/Mantid/Framework/DataHandling/src/UpdateInstrumentFromFile.cpp
similarity index 51%
rename from Code/Mantid/Framework/DataHandling/src/UpdateInstrumentFromRaw.cpp
rename to Code/Mantid/Framework/DataHandling/src/UpdateInstrumentFromFile.cpp
index 7e4daf06c73..a6d6d14d7cf 100644
--- a/Code/Mantid/Framework/DataHandling/src/UpdateInstrumentFromRaw.cpp
+++ b/Code/Mantid/Framework/DataHandling/src/UpdateInstrumentFromFile.cpp
@@ -1,56 +1,51 @@
 //----------------------------------------------------------------------
 // Includes
 //----------------------------------------------------------------------
-#include "MantidDataHandling/UpdateInstrumentFromRaw.h"
+#include "MantidDataHandling/UpdateInstrumentFromFile.h"
+#include "MantidDataHandling/LoadRawHelper.h"
 #include "MantidGeometry/Instrument/Instrument.h"
-#include "MantidGeometry/Instrument/Detector.h"
-#include "MantidGeometry/Instrument/CompAssembly.h"
-#include "MantidGeometry/Instrument/Component.h"
-#include "LoadRaw/isisraw.h"
-#include "MantidKernel/ArrayProperty.h"
-#include "MantidKernel/ConfigService.h"
 #include "MantidAPI/FileProperty.h"
-
-#include <fstream>
-
+#include "LoadRaw/isisraw2.h"
+#include <boost/scoped_ptr.hpp>
 
 namespace Mantid
 {
 namespace DataHandling
 {
 
-DECLARE_ALGORITHM(UpdateInstrumentFromRaw)
+DECLARE_ALGORITHM(UpdateInstrumentFromFile)
 
 /// Sets documentation strings for this algorithm
-void UpdateInstrumentFromRaw::initDocs()
+void UpdateInstrumentFromFile::initDocs()
 {
-  this->setWikiSummary(" Updating detector positions initially loaded in from Instrument Defintion File ([[InstrumentDefinitionFile|IDF]]) from information in raw files. Note doing this will results in a slower performance (likely slightly slower performance) compared to specifying the correct detector positions in the IDF in the first place. It is assumed that the positions specified in the raw file are all with respect to the a coordinate system defined with its origin at the sample position.  Note that this algorithm moves the detectors without subsequent rotation, hence this means that detectors may not for example face the sample perfectly after this algorithm has been applied. ");
-  this->setOptionalMessage("Updating detector positions initially loaded in from Instrument Defintion File (IDF) from information in raw files. Note doing this will results in a slower performance (likely slightly slower performance) compared to specifying the correct detector positions in the IDF in the first place. It is assumed that the positions specified in the raw file are all with respect to the a coordinate system defined with its origin at the sample position.  Note that this algorithm moves the detectors without subsequent rotation, hence this means that detectors may not for example face the sample perfectly after this algorithm has been applied.");
+  this->setWikiSummary("Update detector positions initially loaded in from Instrument Definition File ([[InstrumentDefinitionFile|IDF]]) from information the given file. Note doing this will results in a slower performance (likely slightly slower performance) compared to specifying the correct detector positions in the IDF in the first place. It is assumed that the positions specified in the raw file are all with respect to the a coordinate system defined with its origin at the sample position.  Note that this algorithm moves the detectors without subsequent rotation, hence this means that detectors may not for example face the sample perfectly after this algorithm has been applied. ");
+  this->setOptionalMessage("Updates detector positions initially loaded in from the Instrument Definition File (IDF) with information from the provided file. Currently supports RAW and ISIS NeXus.");
 }
 
 
 using namespace Kernel;
 using namespace API;
-using Geometry::Instrument;
+using Geometry::Instrument_sptr;
 
 /// Empty default constructor
-UpdateInstrumentFromRaw::UpdateInstrumentFromRaw()
+UpdateInstrumentFromFile::UpdateInstrumentFromFile()
 {}
 
 /// Initialisation method.
-void UpdateInstrumentFromRaw::init()
+void UpdateInstrumentFromFile::init()
 {
   // When used as a sub-algorithm the workspace name is not used - hence the "Anonymous" to satisfy the validator
   declareProperty(
     new WorkspaceProperty<MatrixWorkspace>("Workspace","Anonymous",Direction::InOut),
-    "The name of the workspace in which to store the imported instrument" );
+    "The name of the workspace in which to store the imported instrument");
   
   std::vector<std::string> exts;
   exts.push_back(".raw");
   exts.push_back(".s*");
   declareProperty(new FileProperty("Filename", "", FileProperty::Load, exts),
-		  "The filename (including its full or relative path) of an ISIS RAW file.\n"
-		  "The file extension must either be .raw or .s??" ); 
+		                               "The filename of the input file.\n"
+                                   "Currently supports RAW and ISIS NeXus."
+                 );
 }
 
 /** Executes the algorithm. Reading in the file and creating and populating
@@ -58,31 +53,46 @@ void UpdateInstrumentFromRaw::init()
  *
  *  @throw FileError Thrown if unable to parse XML file
  */
-void UpdateInstrumentFromRaw::exec()
+void UpdateInstrumentFromFile::exec()
 {
   // Retrieve the filename from the properties
-  m_filename = getPropertyValue("Filename");
-
-  // Get the input workspace
-  const MatrixWorkspace_sptr localWorkspace = getProperty("Workspace");
-
-  // open raw file
-  ISISRAW iraw(NULL);
-  if (iraw.readFromFile(m_filename.c_str(),false) != 0)
+  const std::string filename = getPropertyValue("Filename");
+  MatrixWorkspace_const_sptr localWorkspace = getProperty("Workspace");
+  Instrument_sptr instrument = localWorkspace->getBaseInstrument();
+  if (instrument.get() == 0)
   {
-    g_log.error("Unable to open file " + m_filename);
-    throw Exception::FileError("Unable to open File:" , m_filename);
+    throw std::runtime_error("Input workspace has no defined instrument");
   }
 
-  // Get reference to Instrument
-  boost::shared_ptr<Instrument> instrument = localWorkspace->getBaseInstrument();
-  if (instrument.get() == 0)
+  progress(0.5);
+    
+  // Check the file type
+  boost::scoped_ptr<LoadRawHelper> rawCheck(new LoadRawHelper()); 
+  if( rawCheck->fileCheck(filename) > 0 )
+  {
+    updateFromRaw(instrument, filename);
+  }
+  // Assume it is a NeXus file for now
+  else
   {
-      g_log.error("Trying to use ParInstrument as an Instrument.");
-      throw std::runtime_error("Trying to use ParInstrument as an Instrument.");
+    g_log.warning("Input file is not a RAW file.\n");
+    //updateFromIsisNeXus(instrument, filename);
   }
+}
 
-  progress(0.5);
+/**
+ * Update the detector information from a raw file
+ * @param instrument :: A shared pointer to the base instrument, it will throw if a parametrized one is given
+ * @param filename :: The input filename
+ */
+void UpdateInstrumentFromFile::updateFromRaw(Instrument_sptr instrument, const std::string & filename)
+{
+  ISISRAW2 iraw;
+  if (iraw.readFromFile(filename.c_str(),false) != 0)
+  {
+    g_log.error("Unable to open file " + filename);
+    throw Exception::FileError("Unable to open File:" , filename);
+  }
 
   // add detectors
   const int numDetector = iraw.i_det;    // number of detectors
@@ -93,39 +103,42 @@ void UpdateInstrumentFromRaw::exec()
   // Is ut01 (=phi) present? Sometimes an array is present but has wrong values e.g.all 1.0 or all 2.0
   bool phiPresent = iraw.i_use>0 && phi[0]!= 1.0 && phi[0] !=2.0; 
 
+  g_log.information() << "Setting detector postions from RAW file.\n";
   double prog=0.5;
   for (int i = 0; i < numDetector; ++i)
   {
-    // check if detID[i] is represented in IDF and if yes set position
     try
     {
       // throws exception if not found
       Geometry::IDetector_sptr det = instrument->getDetector(detID[i]);
-
       // get postion of parent
       Geometry::V3D parentPos = det->getPos() - det->getRelativePos();
-
       // Get position from raw file.
       Geometry::V3D pos;
-
-      if(phiPresent)
-        pos.spherical(r[i], angle[i], phi[i]);
-      else
-        pos.spherical(r[i], angle[i], 0.0 );
+      if(phiPresent) pos.spherical(r[i], angle[i], phi[i]);
+      else pos.spherical(r[i], angle[i], 0.0 );
 
       // sets new relative position to parent so that its absolute position
       // is where the raw file says it is.
       det->setPos(pos-parentPos);
     }
-    catch (...)
+    catch (Kernel::Exception::NotFoundError&)
     {
       // if detector was not found do nothing in this case
     }
  
     progress(prog);
   }  
+}
 
-  return;
+/**
+ * Update the detector information from a raw file
+ * @param instrument :: A shared pointer to the base instrument, it will throw if a parametrized one is given
+ * @param filename :: The input filename
+ */
+void UpdateInstrumentFromFile::updateFromIsisNeXus(Instrument_sptr instrument, const std::string & filename)
+{
+  throw Kernel::Exception::NotImplementedError("UpdateInstrumentFromFile::updateFromIsisNeXus");
 }
 
 } // namespace DataHandling
diff --git a/Code/Mantid/Framework/DataHandling/test/UpdateInstrumentFromRawTest.h b/Code/Mantid/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h
similarity index 74%
rename from Code/Mantid/Framework/DataHandling/test/UpdateInstrumentFromRawTest.h
rename to Code/Mantid/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h
index e9e6304cc59..e3e7b1e9869 100644
--- a/Code/Mantid/Framework/DataHandling/test/UpdateInstrumentFromRawTest.h
+++ b/Code/Mantid/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h
@@ -1,23 +1,16 @@
-#ifndef UPDATEINSTRUMENTTESTFROMRAW_H_
-#define UPDATEINSTRUMENTTESTFROMRAW_H_
+#ifndef UPDATEINSTRUMENTTESTFROMFILE_H_
+#define UPDATEINSTRUMENTTESTFROMFILE_H_
 
 #include <cxxtest/TestSuite.h>
 
-#include "MantidDataHandling/UpdateInstrumentFromRaw.h"
+#include "MantidDataHandling/UpdateInstrumentFromFile.h"
 #include "MantidDataHandling/LoadInstrumentFromRaw.h"
 #include "MantidDataHandling/LoadInstrument.h"
 #include "MantidAPI/InstrumentDataService.h"
 #include "MantidAPI/WorkspaceFactory.h"
 #include "MantidGeometry/Instrument/Instrument.h"
 #include "MantidDataObjects/Workspace2D.h"
-#include "MantidAPI/AnalysisDataService.h"
-#include "MantidKernel/Exception.h"
-#include "MantidAPI/FrameworkManager.h"
-#include "MantidAPI/Workspace.h"
 #include "MantidAPI/Algorithm.h"
-#include "MantidGeometry/Instrument/Component.h"
-#include "MantidGeometry/Instrument/FitParameter.h"
-#include <vector>
 
 using namespace Mantid::API;
 using namespace Mantid::Kernel;
@@ -25,13 +18,13 @@ using namespace Mantid::Geometry;
 using namespace Mantid::DataHandling;
 using namespace Mantid::DataObjects;
 
-class UpdateInstrumentFromRawTest : public CxxTest::TestSuite
+class UpdateInstrumentFromFileTest : public CxxTest::TestSuite
 {
 public:
-    static UpdateInstrumentFromRawTest *createSuite() { return new UpdateInstrumentFromRawTest(); }
-  static void destroySuite(UpdateInstrumentFromRawTest *suite) { delete suite; }
+    static UpdateInstrumentFromFileTest *createSuite() { return new UpdateInstrumentFromFileTest(); }
+  static void destroySuite(UpdateInstrumentFromFileTest *suite) { delete suite; }
 
-  UpdateInstrumentFromRawTest()
+  UpdateInstrumentFromFileTest()
   {
   }
 
@@ -55,7 +48,7 @@ public:
     TS_ASSERT( loaderHRP.isExecuted() );
 
     // now try to reload in detector positions from raw file
-    UpdateInstrumentFromRaw loadRawPos;
+    UpdateInstrumentFromFile loadRawPos;
     loadRawPos.initialize();
     loadRawPos.setPropertyValue("Filename", "HRP38692.raw");
     loadRawPos.setPropertyValue("Workspace", wsName);
@@ -80,10 +73,10 @@ public:
 
 
 private:
-  UpdateInstrumentFromRaw loader;
+  UpdateInstrumentFromFile loader;
   std::string inputFile;
   std::string wsName;
 
 };
 
-#endif /*UPDATEINSTRUMENTTESTFROMRAW_H_*/
+#endif /*UPDATEINSTRUMENTTESTFROMFILE_H_*/
diff --git a/Code/Mantid/instrument/LET_Parameters.xml b/Code/Mantid/instrument/LET_Parameters.xml
index af46eac0c61..024e82f5e59 100644
--- a/Code/Mantid/instrument/LET_Parameters.xml
+++ b/Code/Mantid/instrument/LET_Parameters.xml
@@ -3,6 +3,11 @@
 
 <component-link name = "LET">
 
+<!-- Specify that the detector positions should be taken from the data file -->
+<parameter name="det-pos-source" type="string">
+  <value val="datafile"/>
+</parameter>
+
 <parameter name="deltaE-mode" type="string">
   <value val="direct"/>
 </parameter>
diff --git a/Code/Mantid/instrument/MAPS_Parameters.xml b/Code/Mantid/instrument/MAPS_Parameters.xml
index 138868cfba1..2b4cc6ceab7 100644
--- a/Code/Mantid/instrument/MAPS_Parameters.xml
+++ b/Code/Mantid/instrument/MAPS_Parameters.xml
@@ -3,6 +3,12 @@
 
 <component-link name = "MAPS">
 
+<!-- Specify that the detector positions should be taken from the data file -->
+<parameter name="det-pos-source" type="string">
+  <value val="datafile"/>
+</parameter>
+
+
 <parameter name="deltaE-mode" type="string">
   <value val="direct"/>
 </parameter>
diff --git a/Code/Mantid/instrument/MARI_Parameters.xml b/Code/Mantid/instrument/MARI_Parameters.xml
index 006d04961ef..bc7e625cc8c 100644
--- a/Code/Mantid/instrument/MARI_Parameters.xml
+++ b/Code/Mantid/instrument/MARI_Parameters.xml
@@ -3,11 +3,15 @@
 
 <component-link name = "MARI">
 
+<!-- Specify that the detector positions should be taken from the data file -->
+<parameter name="det-pos-source" type="string">
+  <value val="datafile"/>
+</parameter>
+
 <parameter name="deltaE-mode" type="string">
   <value val="direct"/>
 </parameter>
 
-
 <parameter name="ei-mon1-spec">
   <value val="2"/>
 </parameter>
diff --git a/Code/Mantid/instrument/MERLIN_Parameters.xml b/Code/Mantid/instrument/MERLIN_Parameters.xml
index 2bb955ce1ae..6dd6064278f 100644
--- a/Code/Mantid/instrument/MERLIN_Parameters.xml
+++ b/Code/Mantid/instrument/MERLIN_Parameters.xml
@@ -3,6 +3,12 @@
 
 <component-link name = "MERLIN">
 
+<!-- Specify that the detector positions should be taken from the data file -->
+<parameter name="det-pos-source" type="string">
+  <value val="datafile"/>
+</parameter>
+
+
 <parameter name="deltaE-mode" type="string">
   <value val="direct"/>
 </parameter>
-- 
GitLab