Skip to content

Commit

Permalink
refs #4572 Creates dimID-s if they have not been copied
Browse files Browse the repository at this point in the history
from source workspace (appears empty)
  • Loading branch information
abuts committed Jan 26, 2012
1 parent 635347f commit c269ce5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define MANTID_GEOMETRY_ANGLEUNITS_H_

#include "MantidGeometry/DllConfig.h"
#include "MantidKernel/PhysicalConstants.h"
#include <cmath>

namespace Mantid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

}

}

//
Expand Down
24 changes: 20 additions & 4 deletions Code/Mantid/Framework/MDAlgorithms/test/ConvertToQ3DdETest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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() )

}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -332,7 +347,8 @@ void t__tResult(){


ConvertToQ3DdETest(){
pAlg = std::auto_ptr<ConvertToMDEvents>(new ConvertToMDEvents());
pAlg = std::auto_ptr<ConvertTo3DdETestHelper>(new ConvertTo3DdETestHelper());
pAlg->initialize();
}

};
Expand Down

0 comments on commit c269ce5

Please sign in to comment.