From e8af97c97e5e86f4f9c1053fb9d2f1c36c93487b Mon Sep 17 00:00:00 2001
From: Ricardo Leal <ricardo.leal@ill.fr>
Date: Wed, 17 Apr 2013 16:33:48 +0200
Subject: [PATCH] New Algorithm to correct detector efficiency at ILL Refs
 #6850

---
 .../Framework/Algorithms/CMakeLists.txt       |  5 +++-
 Code/Mantid/instrument/IN4_Parameters.xml     | 23 ++++++++++++-------
 Code/Mantid/instrument/IN5_Parameters.xml     | 19 ++++++++++-----
 Code/Mantid/instrument/IN6_Parameters.xml     | 19 ++++++++++-----
 4 files changed, 45 insertions(+), 21 deletions(-)

diff --git a/Code/Mantid/Framework/Algorithms/CMakeLists.txt b/Code/Mantid/Framework/Algorithms/CMakeLists.txt
index a38f7517ead..16b2f04fee1 100644
--- a/Code/Mantid/Framework/Algorithms/CMakeLists.txt
+++ b/Code/Mantid/Framework/Algorithms/CMakeLists.txt
@@ -64,6 +64,7 @@ set ( SRC_FILES
 	src/DeleteWorkspace.cpp
 	src/DetectorDiagnostic.cpp
 	src/DetectorEfficiencyCor.cpp
+	src/DetectorEfficiencyCorUser.cpp
 	src/DetectorEfficiencyVariation.cpp
 	src/DiffractionEventCalibrateDetectors.cpp
 	src/DiffractionFocussing.cpp
@@ -75,8 +76,8 @@ set ( SRC_FILES
 	src/EditInstrumentGeometry.cpp
 	src/ElasticWindow.cpp
 	src/Exponential.cpp
-	src/ExportTimeSeriesLog.cpp
 	src/ExponentialCorrection.cpp
+	src/ExportTimeSeriesLog.cpp
 	src/ExtractFFTSpectrum.cpp
 	src/ExtractMask.cpp
 	src/ExtractMasking.cpp
@@ -275,6 +276,7 @@ set ( INC_FILES
 	inc/MantidAlgorithms/DeleteWorkspace.h
 	inc/MantidAlgorithms/DetectorDiagnostic.h
 	inc/MantidAlgorithms/DetectorEfficiencyCor.h
+	inc/MantidAlgorithms/DetectorEfficiencyCorUser.h
 	inc/MantidAlgorithms/DetectorEfficiencyVariation.h
 	inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h
 	inc/MantidAlgorithms/DiffractionFocussing.h
@@ -494,6 +496,7 @@ set ( TEST_FILES
 	CylinderAbsorptionTest.h
 	DeleteWorkspaceTest.h
 	DetectorEfficiencyCorTest.h
+	DetectorEfficiencyCorUserTest.h
 	DetectorEfficiencyVariationTest.h
 	DiffractionEventCalibrateDetectorsTest.h
 	DiffractionFocussing2Test.h
diff --git a/Code/Mantid/instrument/IN4_Parameters.xml b/Code/Mantid/instrument/IN4_Parameters.xml
index c910b9dc493..99b580ec6f0 100644
--- a/Code/Mantid/instrument/IN4_Parameters.xml
+++ b/Code/Mantid/instrument/IN4_Parameters.xml
@@ -1,21 +1,28 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<parameter-file instrument="IN5" date="2012-10-01T00:00:00">
+<parameter-file instrument="IN4" date="2012-10-01T00:00:00">
 
-	<component-link name="IN5">
+	<component-link name="IN4">
 
 		<parameter name="deltaE-mode" type="string">
 			<value val="direct" />
 		</parameter>
-		
-		<!--  
-		Distance between sample and equatorial line
-		of the detector. Mandatory if you want to correct
-		the flight paths.
-		-->
+
+		<!-- Distance between sample and equatorial line of the detector. Mandatory 
+			if you want to correct the flight paths. -->
 		<parameter name="l2" type="string">
 			<value val="2.0" />
 		</parameter>
 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+			operators -->
+		<parameter name="formula_eff0" type="string">
+			<value val="0.951*exp(-0.0887/sqrt(e0))*(1.0-exp(-5.597/sqrt(e0)))" />
+		</parameter>
+		<parameter name="formula_eff" type="string">
+			<value val="0.951/eff0*exp(-0.0887/sqrt(e))*(1.0-exp(-5.597/sqrt(e)))" />
+		</parameter>
+
 	</component-link>
 
 </parameter-file>
diff --git a/Code/Mantid/instrument/IN5_Parameters.xml b/Code/Mantid/instrument/IN5_Parameters.xml
index 39d17413f4c..3cdcdb81c08 100644
--- a/Code/Mantid/instrument/IN5_Parameters.xml
+++ b/Code/Mantid/instrument/IN5_Parameters.xml
@@ -6,16 +6,23 @@
 		<parameter name="deltaE-mode" type="string">
 			<value val="direct" />
 		</parameter>
-		
-		<!--  
-		Distance between sample and equatorial line
-		of the detector. Mandatory if you want to correct
-		the flight paths.
-		-->
+
+		<!-- Distance between sample and equatorial line of the detector. Mandatory 
+			if you want to correct the flight paths. -->
 		<parameter name="l2" type="string">
 			<value val="4.0" />
 		</parameter>
 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+			operators -->
+		<parameter name="formula_eff0" type="string">
+			<value val="exp(-0.0565/sqrt(e0))*(1.-exp(-3.284/sqrt(e0)))" />
+		</parameter>
+		<parameter name="formula_eff" type="string">
+			<value val="1.0/eff0*exp(-0.0565/sqrt(e))*(1.0-exp(-3.284/sqrt(e)))" />
+		</parameter>
+
 	</component-link>
 
 </parameter-file>
diff --git a/Code/Mantid/instrument/IN6_Parameters.xml b/Code/Mantid/instrument/IN6_Parameters.xml
index e09c28720ab..1739477d081 100644
--- a/Code/Mantid/instrument/IN6_Parameters.xml
+++ b/Code/Mantid/instrument/IN6_Parameters.xml
@@ -6,16 +6,23 @@
 		<parameter name="deltaE-mode" type="string">
 			<value val="direct" />
 		</parameter>
-		
-		<!--  
-		Distance between sample and equatorial line
-		of the detector. Mandatory if you want to correct
-		the flight paths.
-		-->
+
+		<!-- Distance between sample and equatorial line of the detector. Mandatory 
+			if you want to correct the flight paths. -->
 		<parameter name="l2" type="string">
 			<value val="2.48" />
 		</parameter>
 
+		<!-- formula for Detector efficiency calculation. Algorithm: DetectorEfficiencyCorUser 
+			See http://muparser.sourceforge.net/mup_features.html#idDef2 for available 
+			operators -->
+		<parameter name="formula_eff0" type="string">
+			<value val="exp(-0.0565/sqrt(e0))*(1.0-exp(-3.284/sqrt(e0)))" />
+		</parameter>
+		<parameter name="formula_eff" type="string">
+			<value val="1.0/eff0*exp(-0.0565/sqrt(e))*(1.0-exp(-3.284/sqrt(e)))" />
+		</parameter>
+
 	</component-link>
 
 </parameter-file>
-- 
GitLab