From c269ce50ddf372c84c48c825a815fdb83e661796 Mon Sep 17 00:00:00 2001
From: Alex Buts <Alex.Buts@stfc.ac.uk>
Date: Thu, 26 Jan 2012 17:01:03 +0000
Subject: [PATCH] refs #4572 Creates dimID-s if they have not been copied

from source workspace (appears empty)
---
 .../inc/MantidGeometry/Crystal/AngleUnits.h   |  1 +
 .../MantidMDAlgorithms/ConvertToMDEvents.h    |  3 ++-
 .../MDAlgorithms/src/ConvertToMDEvents.cpp    | 10 ++++++++
 .../MDAlgorithms/test/ConvertToQ3DdETest.h    | 24 +++++++++++++++----
 4 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/AngleUnits.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/AngleUnits.h
index f2af003166c..550e7fb5b5e 100644
--- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/AngleUnits.h
+++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/Crystal/AngleUnits.h
@@ -2,6 +2,7 @@
 #define MANTID_GEOMETRY_ANGLEUNITS_H_
 
 #include "MantidGeometry/DllConfig.h"
+#include "MantidKernel/PhysicalConstants.h"
 #include <cmath>
 
 namespace Mantid
diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h
index dfca778b2f4..33744b7fb9b 100644
--- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h
+++ b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDEvents.h
@@ -128,7 +128,8 @@ namespace MDAlgorithms
 
  
 
-   /** function provides the linear representation for the transformation matrix, which translate momentums from laboratory to notional (fractional) coordinate system */
+   /** function provides the linear representation for the transformation matrix, which translate momentums from laboratory to crystal cartezian 
+       (C)- Busing, Levi 1967 coordinate system */
    std::vector<double> getTransfMatrix(API::MatrixWorkspace_sptr inWS2D,MDEvents::MDWSDescription &TargWSDescription, 
                                        bool is_powder=false)const;
    /// get transformation matrix currently defined for the algorithm
diff --git a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
index 31fbaa95796..6634cd13fb4 100644
--- a/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
+++ b/Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
@@ -852,6 +852,16 @@ void ConvertToMDEvents::buildDimNames(MDEvents::MDWSDescription &TargWSDescripti
 
         }
     }
+   // NoQ copies dimension names and may need dimension ID-s changed
+    if(TargWSDescription.AlgID.find(Q_modes[NoQ])!=std::string::npos){
+        for(size_t i=0;i<TargWSDescription.dim_IDs.size();i++){
+            if(TargWSDescription.dim_IDs[i].empty()){
+                  TargWSDescription.dim_IDs[i]="D"+boost::lexical_cast<std::string>(i);              
+            }
+        }
+
+    }
+
 }
 
 //
diff --git a/Code/Mantid/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h b/Code/Mantid/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h
index 861646849a3..0005cd591ff 100644
--- a/Code/Mantid/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h
+++ b/Code/Mantid/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h
@@ -9,6 +9,7 @@
 #include "MantidTestHelpers/ComponentCreationHelper.h"
 #include "MantidTestHelpers/MDEventsTestHelper.h"
 #include "MantidTestHelpers/WorkspaceCreationHelper.h"
+#include "MantidMDEvents/MDWSDescription.h"
 #include <cxxtest/TestSuite.h>
 #include <iomanip>
 #include <iostream>
@@ -21,17 +22,29 @@ using namespace Mantid::DataObjects;
 using namespace Mantid::MDAlgorithms;
 using namespace Mantid::MDEvents;
 
+class ConvertTo3DdETestHelper: public ConvertToMDEvents
+{
+public:
+    ConvertTo3DdETestHelper(){};
+   // private (PROTECTED) methods, exposed for testing:
+   std::vector<double> getTransfMatrix(API::MatrixWorkspace_sptr inWS2D,MDWSDescription &TargWSDescription, 
+                                       bool is_powder=false)const
+   {
+       return ConvertToMDEvents::getTransfMatrix(inWS2D,TargWSDescription,is_powder);
+   }
+ 
+};
+
 // Test is transformed from ConvetToQ3DdE but actually tests some aspects of ConvertToMDEvents algorithm. 
 class ConvertToQ3DdETest : public CxxTest::TestSuite
 {
- std::auto_ptr<ConvertToMDEvents> pAlg;
+ std::auto_ptr<ConvertTo3DdETestHelper> pAlg;
 public:
 static ConvertToQ3DdETest *createSuite() { return new ConvertToQ3DdETest(); }
 static void destroySuite(ConvertToQ3DdETest * suite) { delete suite; }    
 
 void testInit(){
-
-    TS_ASSERT_THROWS_NOTHING( pAlg->initialize() )
+  
     TS_ASSERT( pAlg->isInitialized() )
  
 }
@@ -180,6 +193,8 @@ void xtestTransfMat1()
      Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::createProcessedWorkspaceWithCylComplexInstrument(16,10,true);
      OrientedLattice * latt = new OrientedLattice(1,2,3, 90., 90., 90.);
      ws2D->mutableSample().setOrientedLattice(latt);
+     MDWSDescription TWS(4);
+
 
      std::vector<double> rot;
 //    std::vector<double> rot=pAlg->get_transf_matrix(ws2D,Kernel::V3D(1,0,0),Kernel::V3D(0,1,0));
@@ -332,7 +347,8 @@ void t__tResult(){
 
 
 ConvertToQ3DdETest(){
-    pAlg = std::auto_ptr<ConvertToMDEvents>(new ConvertToMDEvents());
+    pAlg = std::auto_ptr<ConvertTo3DdETestHelper>(new ConvertTo3DdETestHelper());
+    pAlg->initialize();
 }
 
 };
-- 
GitLab