Large diffs are not rendered by default.

@@ -38,8 +38,7 @@ int is_member(const std::vector<std::string> &group,const std::string &candidate
*@param out_dim_units [out] -- vector of units for target workspace
*@param nQ_dims [out] -- number of Q or other dimensions. When converting into Q, it is 1 or 3 dimensions, if NoQ -- workspace dimensions are copied.
*/
std::string
ConvertToMDEventsParams::parseQMode(const std::string &Q_mode_req,const Strings &ws_dim_names,const Strings &ws_dim_units,Strings &out_dim_ID,Strings &out_dim_units,
std::string ConvertToMDEventsParams::parseQMode(const std::string &Q_mode_req,const Strings &ws_dim_names,const Strings &ws_dim_units,Strings &out_dim_ID,Strings &out_dim_units,
int &nQ_dims)const
{
std::string Q_MODE_ID("Unknown");
@@ -88,8 +87,7 @@ ConvertToMDEventsParams::parseQMode(const std::string &Q_mode_req,const Strings
*@param ndE_dims [out] -- number of additional dimensions, if inelastic, it would be one dimension more.
*@param natural_units [out] -- name of the units, the algorithm expects to work with.
*/
std::string
ConvertToMDEventsParams::parseDEMode(const std::string &Q_MODE_ID,const std::string &dE_mode_req,const Strings &ws_dim_units,
std::string ConvertToMDEventsParams::parseDEMode(const std::string &Q_MODE_ID,const std::string &dE_mode_req,const Strings &ws_dim_units,
Strings &out_dim_IDs,Strings &out_dim_units,int &ndE_dims,std::string &natural_units)const
{
if(is_member(dE_modes,dE_mode_req)<0){
@@ -133,8 +131,7 @@ ConvertToMDEventsParams::parseDEMode(const std::string &Q_MODE_ID,const std::str
*
*@returns CONV_MODE_ID -- the string identifier, which says what energy mode is deployed.
*/
std::string
ConvertToMDEventsParams::parseConvMode(const std::string &Q_MODE_ID,const std::string &UnitsToConvert2,const std::vector<std::string> &ws_dim_units)const
std::string ConvertToMDEventsParams::parseConvMode(const std::string &Q_MODE_ID,const std::string &UnitsToConvert2,const std::vector<std::string> &ws_dim_units)const
{
std::string CONV_MODE_ID("Unknown");
// IDENTIFY UNITS CONVERSION MODE
@@ -175,13 +172,21 @@ ConvertToMDEventsParams::parseConvMode(const std::string &Q_MODE_ID,const std::s

/** identify what kind of input workspace is provided as input argument
*
*@param inMatrixWS a pointer to the workspace, obtained from analysis data service
*@param inMatrixWS a pointer to the workspace, obtained from the analysis data service
*
*@returns -- the ID of the workspace of one of the supported types. Throws if can not dynamiucally cast the pointer to the workspace:
*@returns -- sets oriented lattice if the input workspace has one
*/
std::string
ConvertToMDEventsParams::parseWSType(API::MatrixWorkspace_const_sptr inMatrixWS)const
std::string ConvertToMDEventsParams::parseWSType(API::MatrixWorkspace_const_sptr inMatrixWS,MDEvents::MDWSDescription &TargWSDescription)const
{
// try to get the oriented lattice
if(inMatrixWS->sample().hasOrientedLattice()){
TargWSDescription.pLatt = std::auto_ptr<Geometry::OrientedLattice>(new Geometry::OrientedLattice(inMatrixWS->sample().getOrientedLattice()));
}else{
TargWSDescription.pLatt.reset();
}


const DataObjects::EventWorkspace *pWSEv= dynamic_cast<const DataObjects::EventWorkspace *>(inMatrixWS.get());
if(pWSEv){
return SupportedWS[EventWSType];
@@ -214,13 +219,11 @@ ConvertToMDEventsParams::parseWSType(API::MatrixWorkspace_const_sptr inMatrixWS)
*
* @return out_dim_IDs -- the vector of strings, with each string identify the dimensions ID-s, derived from current workspace by the algorithm
* @return out_dim_units -- vector of units for target workspace, if inelastic, one of the dimension units have to be DeltaE
* @return is_det_info_lost -- if Y axis of matix workspace contains some meaningful info, the detector information is certainly lost.
* @return algo_id -- the string, which describes the algorithm, which should be deployed on ws.
*/
std::string
ConvertToMDEventsParams::identifyMatrixAlg(API::MatrixWorkspace_const_sptr inMatrixWS, const std::string &Q_mode_req, const std::string &dE_mode_req,
Strings &out_dim_IDs,Strings &out_dim_units, bool &is_detector_information_lost)
std::string ConvertToMDEventsParams::identifyMatrixAlg(API::MatrixWorkspace_const_sptr inMatrixWS, const std::string &Q_mode_req, const std::string &dE_mode_req,
Strings &out_dim_IDs,Strings &out_dim_units, MDEvents::MDWSDescription &TargWSDescription)
{
// the key which would describe the algorithm to deploy on the matrix
std::string algo_id;
@@ -242,7 +245,7 @@ ConvertToMDEventsParams::identifyMatrixAlg(API::MatrixWorkspace_const_sptr inMat
ws_dim_units.push_back(Dim1Unit);
}
// get optional Y axis which can be used in NoQ-kind of algorithms
is_detector_information_lost= false;
bool is_detector_information_lost= false;
API::NumericAxis *pYAxis = dynamic_cast<API::NumericAxis *>(inMatrixWS->getAxis(1));
if(pYAxis){
std::string Dim2Unit = pYAxis->unit()->unitID();
@@ -251,12 +254,13 @@ ConvertToMDEventsParams::identifyMatrixAlg(API::MatrixWorkspace_const_sptr inMat
// if this is numeric axis, then the detector's information has been lost:
is_detector_information_lost=true;
}

//if Y axis of matix workspace contains some meaningful info, the detector information is certainly lost.
TargWSDescription.detInfoLost = is_detector_information_lost;

std::string Q_MODE_ID,DE_MODE_ID,CONV_MODE_ID,WS_ID;
int nQ_dims(0),ndE_dims(0);
// identify, what kind of input workspace is there:
WS_ID = parseWSType(inMatrixWS);
// identify, what kind of input workspace is there and if it has oriented lattice:
WS_ID = parseWSType(inMatrixWS,TargWSDescription);
algo_id =WS_ID;
// identify Q_mode
Q_MODE_ID = parseQMode (Q_mode_req,ws_dim_names,ws_dim_units,out_dim_IDs,out_dim_units,nQ_dims);
@@ -277,11 +281,74 @@ ConvertToMDEventsParams::identifyMatrixAlg(API::MatrixWorkspace_const_sptr inMat
/** function returns the algorithm ID as function of different integer conversion modes.
* This ID should coinside with the ID, obtained by identifyTheAlg method.
*/
std::string
ConvertToMDEventsParams::getAlgoID(Q_state Q,AnalMode Mode,CnvrtUnits Conv,InputWSType WS)const
std::string ConvertToMDEventsParams::getAlgoID(Q_state Q,AnalMode Mode,CnvrtUnits Conv,InputWSType WS)const
{
return SupportedWS[WS]+Q_modes[Q]+dE_modes[Mode]+ConvModes[Conv];

}
/** auxiliary function working opposite to getAlgoID and returns conversion modes given the algorithm ID
*@param AlgoID -- string wich specifies the algorithm ID
*
*@return Q -- momentum conversion mode
*@return Mode -- energy analysis mode
*@return Conv -- unit conversion mode
*@return WS -- processed workspace type
*/
void ConvertToMDEventsParams::getAlgoModes(const std::string &AlgoID, Q_state &Q,AnalMode &Mode,CnvrtUnits &Conv,InputWSType &WS)
{
int i;

// Q_mode
Q = NQStates;
for(i=0;i<NQStates;i++){
if(AlgoID.find(Q_modes[i])!=std::string::npos){
Q=static_cast<Q_state>(i);
break;
}
}
if(Q==NQStates){
std::string ERR(" Algorithm with ID: "+AlgoID+" does not defines recognized Momentum conversion mode");
throw(std::invalid_argument(ERR));
}
//dE mode;
Mode = NAnalModes;
for(i=0;i<NAnalModes;i++){
if(AlgoID.find(dE_modes[i])!=std::string::npos){
Mode=static_cast<AnalMode>(i);
break;
}
}
if(Mode==NAnalModes){
std::string ERR(" Algorithm with ID: "+AlgoID+" does not defines recognized Energy conversion mode");
throw(std::invalid_argument(ERR));
}

// Unit conversion mode:
Conv = NConvUintsStates;
for(i=0;i<NConvUintsStates;i++){
if(AlgoID.find(ConvModes[i])!=std::string::npos){
Conv=static_cast<CnvrtUnits>(i);
break;
}
}
if(Conv == NConvUintsStates){
std::string ERR(" Algorithm with ID: "+AlgoID+" does not defines recognized Units conversion mode");
throw(std::invalid_argument(ERR));
}
// workspace processing algorithm
WS = NInWSTypes;
for(i=0;i<NInWSTypes;i++){
if(AlgoID.find(SupportedWS[i])!=std::string::npos){
WS=static_cast<InputWSType>(i);
break;
}
}
if( WS == NInWSTypes){
std::string ERR(" Algorithm with ID: "+AlgoID+" does not defines recognized WS conversion mode");
throw(std::invalid_argument(ERR));
}


}


@@ -305,10 +372,9 @@ ConvertToMDEventsParams::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,con
Strings dim_IDs_requested,dim_units_requested;
Strings ws_dim_IDs,ws_dim_units;
std::string the_algID;
bool is_detector_info_lost;


// identify the matrix conversion part of subalgorithm as function of user input and workspace Matrix parameters (axis)
the_algID = identifyMatrixAlg(inWS, Q_mode_req, dE_mode_req,ws_dim_IDs,ws_dim_units,is_detector_info_lost);
the_algID = identifyMatrixAlg(inWS, Q_mode_req, dE_mode_req,ws_dim_IDs,ws_dim_units,TargWSDescription);
if(the_algID.find("Unknown")!=std::string::npos){
convert_log.error()<<" Input parameters indentify uncomplete algorithm ID: "<<the_algID<<std::endl;
throw(std::logic_error("can not parse input parameters propertly"));
@@ -340,10 +406,17 @@ ConvertToMDEventsParams::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,con
size_t nDims = dim_IDs_requested.size();

// Sanity checks:
if(nDims<3&&(the_algID.find(Q_modes[Q3D])!=std::string::npos)){
Q_state QMode;
AnalMode EMode;
CnvrtUnits ConvU;
InputWSType WS;
this->getAlgoModes(the_algID, QMode,EMode,ConvU,WS);

if((nDims<3)&&(QMode==Q3D))
{
convert_log.error()<<"Algorithm with ID:"<<the_algID<<" should produce at least 3 dimensions and it requested to provie just:"<<nDims<<" dims \n";
throw(std::logic_error("can not parse input parameters propertly"));
}
}
// we have can currenlty instanciate only N input dimensions. See the wsWrapper constructor to change that.
if(nDims>maxNdim){
convert_log.error()<<"Can not currently deal with more then: "<<maxNdim<< " dimesnions, but requested: "<<nDims<<std::endl;
@@ -352,7 +425,7 @@ ConvertToMDEventsParams::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,con
// get emode
int emode;
// if not found NoQ mode, then dE should be availible
if (Q_mode_req.find(Q_modes[NoQ])==std::string::npos){
if (QMode!=NoQ){
emode = getEMode(the_algID);
}else{
emode = -1; // no coordinate conversion
@@ -368,7 +441,7 @@ ConvertToMDEventsParams::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,con
TargWSDescription.Ei = getEi(inWS);
}
// detector information can be currently lost in NoQ mode only, when no conversion from detectors position to Q occurs
if(is_detector_info_lost && emode!=-1){
if(TargWSDescription.detInfoLost && emode!=-1){
convert_log.error()<<" Algorithm with ID: "<<the_algID<<" emode: "<<emode<<" request workspace with isntrument and full detectord information attached\n"
<<" but the detector information on input workspace has been lost\n";
throw(std::invalid_argument(" input workspace do not have full detector information attached to it"));
@@ -378,7 +451,6 @@ ConvertToMDEventsParams::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,con
// set up the target workspace description;
TargWSDescription.nDims = nDims;
TargWSDescription.emode = emode;
TargWSDescription.detInfoLost = is_detector_info_lost;
TargWSDescription.convert_to_hkl = convert_to_hkl;
TargWSDescription.dimNames = dim_IDs_requested;
TargWSDescription.dimIDs = dim_IDs_requested;
@@ -396,8 +468,7 @@ ConvertToMDEventsParams::identifyTheAlg(API::MatrixWorkspace_const_sptr inWS,con
* @param add_dim_names [out] -- the ID-s for the dimension names, which can be obtained from the workspace
* @param add_dim_units [out] -- the Units ID-s (if any) existing dimensions
*/
void
ConvertToMDEventsParams::getAddDimensionNames(API::MatrixWorkspace_const_sptr inMatrixWS,std::vector<std::string> &add_dim_names,std::vector<std::string> &add_dim_units)const
void ConvertToMDEventsParams::getAddDimensionNames(API::MatrixWorkspace_const_sptr inMatrixWS,std::vector<std::string> &add_dim_names,std::vector<std::string> &add_dim_units)const
{
// get dimension names from properties
// TODO: this should be only special processed properties, not all of them, as it is at the moment
@@ -457,8 +528,7 @@ ConvertToMDEventsParams::getEMode(const std::string &AlgID)const{
*@returns the incident energy of the neutrons.
* Throws if the energy property is not defined or can not be retrieved from the workspace
*/
double
ConvertToMDEventsParams::getEi(API::MatrixWorkspace_const_sptr inWS2D)const
double ConvertToMDEventsParams::getEi(API::MatrixWorkspace_const_sptr inWS2D)const
{
if(!inWS2D.get()){
convert_log.error()<<"getEi: invoked on empty input workspace \n";
@@ -477,7 +547,43 @@ ConvertToMDEventsParams::getEi(API::MatrixWorkspace_const_sptr inWS2D)const
return (*pProp);
}


Strings ConvertToMDEventsParams::getDefaultQNames(Q_state Qmode,AnalMode Mode)const
{
Strings rez;
// in noQ mode no default dimension names are availible. The dimension names shoudl be copied from the source WS
if(Qmode==NoQ)
{
rez.clear();
return rez;
}
// 1 or 2 defauld dimension names in modQ mode
if(Qmode==modQ)
{
if(Mode==Elastic){
rez.resize(1);
}else{
rez.resize(2);
rez[1]=default_dim_ID[dE_ID];
}
rez[0]=default_dim_ID[modQ_ID];
return rez;
}
// 3 or 4 defauld dimension names in Q3D mode
if(Qmode==Q3D)
{
if(Mode==Elastic){
rez.resize(3);
}else{
rez.resize(4);
rez[4]=default_dim_ID[dE_ID];
}
rez[0]=default_dim_ID[Q1_ID];
rez[1]=default_dim_ID[Q2_ID];
rez[2]=default_dim_ID[Q3_ID];
return rez;
}
throw(std::invalid_argument("Unknown Q mode provided"));
}

/// Constructor:
ConvertToMDEventsParams::ConvertToMDEventsParams():
@@ -493,7 +599,7 @@ default_dim_ID(nDefaultID)
{
// strings to indentify possible momentum analysis modes
Q_modes[modQ] = "|Q|";
Q_modes[Q3D] = "QhQkQl";
Q_modes[Q3D] = "Q3D";
Q_modes[NoQ] = "CopyToMD"; // no Q dimension;
// strings to indentify possible energy conversion modes
dE_modes[ANY_Mode] = "NoDE"; // no Q uses it to run without conversion.
@@ -43,7 +43,7 @@ void testEventWS()
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("InputWorkspace","testEvWS"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("OutputWorkspace","testMDEvWorkspace"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("OtherDimensions",""));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions", "QhQkQl"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions", "Q3D"));
pAlg->setPropertyValue("UsePreprocessedDetectors","0");
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("dEAnalysisMode", "Elastic"));
pAlg->setPropertyValue("MinValues","-10,-10,-10");
@@ -73,9 +73,9 @@ void testParseQMode_Q3D()
int nQ_dims;
std::string MODE;
ConvertToMDEventsParams params;
TS_ASSERT_THROWS_NOTHING(MODE=params.parseQMode("QhQkQl",ws_dim_names,ws_dim_units,out_dim_names,out_dim_units, nQ_dims));
TS_ASSERT_THROWS_NOTHING(MODE=params.parseQMode("Q3D",ws_dim_names,ws_dim_units,out_dim_names,out_dim_units, nQ_dims));
TS_ASSERT_EQUALS(3,nQ_dims);
TS_ASSERT_EQUALS("QhQkQl",MODE);
TS_ASSERT_EQUALS("Q3D",MODE);
TS_ASSERT_EQUALS("Q1",out_dim_names[0]);
TS_ASSERT_EQUALS("Q2",out_dim_names[1]);
TS_ASSERT_EQUALS("Q3",out_dim_names[2]);
@@ -253,31 +253,31 @@ void testParseConv_ByTOF()
// --> GET DIMENSIONS FROM WS MATRIX:
void testNeedsNumericAxis()
{
MDEvents::MDWSDescription TWS;
Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::Create2DWorkspace(4,10);
ws2D->replaceAxis(0,new API::TextAxis(3));
std::vector<std::string> dim_ID;
std::vector<std::string> dim_units;
ConvertToMDEventsParams params;

bool is_detInfoLost;
TS_ASSERT_THROWS(params.identifyMatrixAlg(ws2D,"QhQkQl","CopyToMD",dim_ID,dim_units,is_detInfoLost),std::invalid_argument);
TS_ASSERT_THROWS(params.identifyMatrixAlg(ws2D,"Q3D","CopyToMD",dim_ID,dim_units,TWS),std::invalid_argument);
}
void testGetWS4DimIDFine()
{
Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::createProcessedWorkspaceWithCylComplexInstrument(4,10,true);
MDEvents::MDWSDescription TWS;

std::vector<std::string> dim_ID;
std::vector<std::string> dim_units;
std::string Alg_ID;
bool is_detInfoLost;
ConvertToMDEventsParams params;

TS_ASSERT_THROWS_NOTHING(Alg_ID=params.identifyMatrixAlg(ws2D,"QhQkQl","Direct",dim_ID,dim_units,is_detInfoLost));
TS_ASSERT_THROWS_NOTHING(Alg_ID=params.identifyMatrixAlg(ws2D,"Q3D","Direct",dim_ID,dim_units,TWS));

TSM_ASSERT_EQUALS("Inelastic workspace will produce 4 dimensions",4,dim_ID.size());
TSM_ASSERT_EQUALS("Last dimension of Inelastic transformation should be DeltaE","DeltaE",dim_units[3]);
TSM_ASSERT_EQUALS("Alg ID would be: ","WS2DHistoQhQkQlDirectCnvNo",Alg_ID);
TS_ASSERT(!is_detInfoLost);
TSM_ASSERT_EQUALS("Alg ID would be: ","WS2DHistoQ3DDirectCnvNo",Alg_ID);
TS_ASSERT(!TWS.detInfoLost);
}
void testGetWS3DimIDFine()
{
@@ -286,24 +286,24 @@ void testGetWS3DimIDFine()
pAx->title() = "Dim1";
pAx->setUnit("dSpacing");
ws2D->replaceAxis(0,pAx);

MDEvents::MDWSDescription TWS;

std::vector<std::string> dim_ID;
std::vector<std::string> dim_units;
std::string Alg_ID;
bool is_detInfoLost;
std::string Alg_ID;
ConvertToMDEventsParams params;

TS_ASSERT_THROWS_NOTHING(Alg_ID=params.identifyMatrixAlg(ws2D,"QhQkQl","Elastic",dim_ID,dim_units, is_detInfoLost));
TS_ASSERT_THROWS_NOTHING(Alg_ID=params.identifyMatrixAlg(ws2D,"Q3D","Elastic",dim_ID,dim_units, TWS));

TSM_ASSERT_EQUALS("Inelastic workspace will produce 3 dimensions",3,dim_ID.size());
TSM_ASSERT_EQUALS("Last dimension of Elastic transformation should be ","Momentum",dim_units[2]);
TSM_ASSERT_EQUALS("Alg ID would be: ","WS2DHistoQhQkQlElasticCnvByTOF",Alg_ID);
TS_ASSERT(!is_detInfoLost);
TSM_ASSERT_EQUALS("Alg ID would be: ","WS2DHistoQ3DElasticCnvByTOF",Alg_ID);
TS_ASSERT(!TWS.detInfoLost);
}
void testGetWSDimNames2AxisNoQ()
{
Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::Create2DWorkspace(4,10);
MDEvents::MDWSDescription TWS;

API::NumericAxis *pAx = new API::NumericAxis(3);
pAx->title() = "Dim1";
@@ -318,12 +318,11 @@ void testGetWSDimNames2AxisNoQ()
std::vector<std::string> dim_ID;
std::vector<std::string> dim_units;
std::string AlgID;
bool is_detInfoLost;
ConvertToMDEventsParams params;

TS_ASSERT_THROWS_NOTHING(AlgID=params.identifyMatrixAlg(ws2D,"CopyToMD","NoDE",dim_ID,dim_units, is_detInfoLost));
TS_ASSERT_THROWS_NOTHING(AlgID=params.identifyMatrixAlg(ws2D,"CopyToMD","NoDE",dim_ID,dim_units,TWS));

TSM_ASSERT("Det info should be undefined an an numeric axis is along axis 2",is_detInfoLost);
TSM_ASSERT("Det info should be undefined an an numeric axis is along axis 2",TWS.detInfoLost);

TS_ASSERT_EQUALS(2,dim_ID.size());
TS_ASSERT_EQUALS("Dim1",dim_ID[0]);
@@ -338,6 +337,7 @@ void testGetWSDimNames2AxisNoQ()
void testIdentifyMatrixAlg_1()
{
Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::Create2DWorkspace(4,10);
MDEvents::MDWSDescription TWS;

std::vector<std::string> ws_dim_names(2);
std::vector<std::string> dim_names,dim_units;
@@ -352,13 +352,12 @@ void testIdentifyMatrixAlg_1()
pAx->title() = ws_dim_names[1];
pAx->setUnit("QSquared");
ws2D->replaceAxis(1,pAx);
bool is_detInfoLost;
ConvertToMDEventsParams params;

TS_ASSERT_EQUALS("WS2DHistoCopyToMDNoDECnvNo",params.identifyMatrixAlg(ws2D,"CopyToMD","NoDE",dim_names,dim_units,is_detInfoLost));
TS_ASSERT_EQUALS("WS2DHistoCopyToMDNoDECnvNo",params.identifyMatrixAlg(ws2D,"CopyToMD","NoDE",dim_names,dim_units,TWS));
TS_ASSERT_EQUALS(ws_dim_names[0],dim_names[0]);
TS_ASSERT_EQUALS(ws_dim_names[1],dim_names[1]);
TSM_ASSERT("Det info should be undefined an an numeric axis is along axis 2",is_detInfoLost);
TSM_ASSERT("Det info should be undefined an an numeric axis is along axis 2",TWS.detInfoLost);

}

@@ -369,44 +368,44 @@ void testIdentifyMatrixAlg_2()

Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::Create2DWorkspace(4,10);
std::vector<std::string> dim_names,dim_units;
bool is_detInfoLost;
MDEvents::MDWSDescription TWS;

API::NumericAxis *
pAx = new API::NumericAxis(3);
pAx->setUnit("TOF");
ws2D->replaceAxis(0,pAx);

TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,is_detInfoLost));
TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,TWS));
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);

pAx = new API::NumericAxis(3);
pAx->setUnit("Wavelength");
ws2D->replaceAxis(0,pAx);
// This is probably bug in conversion --> does not work in elastic mode
TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,is_detInfoLost));
TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,TWS));
//TSM_ASSERT_THROWS("Can not convert wavelength to momentum transfer in elastic mode ",pAlg->identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units),std::invalid_argument);
TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);

pAx = new API::NumericAxis(3);
pAx->setUnit("Energy");
ws2D->replaceAxis(0,pAx);
// This is probably bug in conversion --> does not work in elastic mode
TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,is_detInfoLost));
TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,TWS));
// TSM_ASSERT_THROWS("Can not convert Energy to momentum transfer in elastic mode ",pAlg->identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units),std::invalid_argument);
TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);

pAx = new API::NumericAxis(3);
pAx->setUnit("dSpacing");
ws2D->replaceAxis(0,pAx);
TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,is_detInfoLost));
TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT_THROWS_NOTHING("Elastic conversion needs X-axis to be in an Energy-related units",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,TWS));
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);

pAx = new API::NumericAxis(3);
pAx->setUnit("TOF");
ws2D->replaceAxis(0,pAx);
TS_ASSERT_EQUALS("WS2DHisto|Q|ElasticCnvFromTOF",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,is_detInfoLost));
TS_ASSERT_EQUALS("WS2DHisto|Q|ElasticCnvFromTOF",params.identifyMatrixAlg(ws2D,"|Q|","Elastic",dim_names,dim_units,TWS));

TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);
TSM_ASSERT_EQUALS("One dim name came from Q (this can be logically wrong)",1,dim_names.size());
TS_ASSERT_EQUALS(dim_names[0],"|Q|");

@@ -418,18 +417,18 @@ void testIdentifyMatrixAlg_3()

Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::Create2DWorkspace(4,10);
std::vector<std::string> dim_names,dim_units;
bool is_detInfoLost;
MDEvents::MDWSDescription TWS;

API::NumericAxis *pAx = new API::NumericAxis(3);
pAx->title()="A";
pAx->setUnit("DeltaE");
ws2D->replaceAxis(0,pAx);

TS_ASSERT_EQUALS("WS2DHisto|Q|DirectCnvNo",params.identifyMatrixAlg(ws2D,"|Q|","Direct",dim_names,dim_units,is_detInfoLost));
TS_ASSERT_EQUALS("WS2DHisto|Q|DirectCnvNo",params.identifyMatrixAlg(ws2D,"|Q|","Direct",dim_names,dim_units,TWS));
TSM_ASSERT_EQUALS("One dimension comes from Q",2,dim_names.size());
TS_ASSERT_EQUALS(dim_names[0],"|Q|");
TS_ASSERT_EQUALS(dim_names[1],"DeltaE");
TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);
}

void testIdentifyMatrixAlg_4()
@@ -438,39 +437,40 @@ void testIdentifyMatrixAlg_4()

std::vector<std::string> dim_names,dim_units;
Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::Create2DWorkspace(4,10);
bool is_detInfoLost;
MDEvents::MDWSDescription TWS;


API::NumericAxis *pAx = new API::NumericAxis(3);
pAx->title()="A";
pAx->setUnit("DeltaE");
ws2D->replaceAxis(0,pAx);

TS_ASSERT_EQUALS("WS2DHisto|Q|IndirectCnvNo",params.identifyMatrixAlg(ws2D,"|Q|","Indirect",dim_names,dim_units,is_detInfoLost));
TS_ASSERT_EQUALS("WS2DHisto|Q|IndirectCnvNo",params.identifyMatrixAlg(ws2D,"|Q|","Indirect",dim_names,dim_units,TWS));
TSM_ASSERT_EQUALS("One dim name came from Q (this can be wrong)",2,dim_names.size());
TS_ASSERT_EQUALS(dim_names[0],"|Q|");
TS_ASSERT_EQUALS(dim_names[1],"DeltaE");
TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);
}
void testIdentifyMatrixAlg_5()
{
ConvertToMDEventsParams params;

std::vector<std::string> dim_names,dim_units;
Mantid::API::MatrixWorkspace_sptr ws2D =WorkspaceCreationHelper::Create2DWorkspace(4,10);
bool is_detInfoLost;
MDEvents::MDWSDescription TWS;

API::NumericAxis *pAx = new API::NumericAxis(3);
pAx->title()="A";
pAx->setUnit("DeltaE");
ws2D->replaceAxis(0,pAx);

TS_ASSERT_EQUALS("WS2DHistoQhQkQlIndirectCnvNo",params.identifyMatrixAlg(ws2D,"QhQkQl","Indirect",dim_names,dim_units,is_detInfoLost));
TS_ASSERT_EQUALS("WS2DHistoQ3DIndirectCnvNo",params.identifyMatrixAlg(ws2D,"Q3D","Indirect",dim_names,dim_units,TWS));
TSM_ASSERT_EQUALS("One dim name came from Q (this can be wrong)",4,dim_names.size());
TS_ASSERT_EQUALS(dim_names[0],"Q1");
TS_ASSERT_EQUALS(dim_names[1],"Q2");
TS_ASSERT_EQUALS(dim_names[2],"Q3");
TS_ASSERT_EQUALS(dim_names[3],"DeltaE");
TSM_ASSERT("Det info should be defined for conversion",!is_detInfoLost);
TSM_ASSERT("Det info should be defined for conversion",!TWS.detInfoLost);
}

};
@@ -27,7 +27,7 @@ class Convert2AnyTestHelper: public ConvertToMDEvents
Convert2AnyTestHelper(){};
//
void buildDimNames(MDEvents::MDWSDescription &TargWSDescription){
this->ConvertToMDEvents::buildDimNames(TargWSDescription);
this->ConvertToMDEvents::buildDimensions(TargWSDescription);
}


@@ -158,7 +158,7 @@ void testExecQ3D()
pAlg->setPropertyValue("OtherDimensions","phi,chi");
pAlg->setPropertyValue("UsePreprocessedDetectors","0");

TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions", "QhQkQl"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions", "Q3D"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("dEAnalysisMode", "Direct"));
pAlg->setPropertyValue("MinValues","-10,-10,-10, 0,-10,-10");
pAlg->setPropertyValue("MaxValues"," 10, 10, 10, 20, 40, 20");
@@ -177,7 +177,7 @@ void test_buildDimNames(){
TargWSDescription.u=Kernel::V3D(1,0,0);
TargWSDescription.v=Kernel::V3D(0,1,0);
TargWSDescription.emode=1;
TargWSDescription.AlgID = "QhQkQl";
TargWSDescription.AlgID = "Q3D";
TargWSDescription.convert_to_hkl=true;
TargWSDescription.rotMatrix.assign(9,0);

@@ -219,7 +219,7 @@ void testAlgorithmProperties()
TSM_ASSERT_EQUALS("QDimensions property values have changed. This has broken Create MD Workspace GUI. Fix CreateMDWorkspaceGUI!", 3, QDimValues.size());
TSM_ASSERT("QDimensions property values have changed. This has broken Create MD Workspace GUI. Fix CreateMDWorkspaceGUI!", QDimValues.find("CopyToMD") != QDimValues.end());
TSM_ASSERT("QDimensions property values have changed. This has broken Create MD Workspace GUI. Fix CreateMDWorkspaceGUI!", QDimValues.find("|Q|") != QDimValues.end());
TSM_ASSERT("QDimensions property values have changed. This has broken Create MD Workspace GUI. Fix CreateMDWorkspaceGUI!", QDimValues.find("QhQkQl") != QDimValues.end());
TSM_ASSERT("QDimensions property values have changed. This has broken Create MD Workspace GUI. Fix CreateMDWorkspaceGUI!", QDimValues.find("Q3D") != QDimValues.end());

Mantid::Kernel::Property *dEAnalysisMode =alg.getProperty("dEAnalysisMode");
PropertyAllowedValues dEAnalysisModeValues = dEAnalysisMode->allowedValues();
@@ -29,11 +29,11 @@ class ConvertTo3DdETestHelper: public ConvertToMDEvents
// 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);
return ConvertToMDEvents::getTransfMatrix(inWS2D,TargWSDescription);
}
/// construct meaningful dimension names:
void buildDimNames(MDEvents::MDWSDescription &TargWSDescription){
ConvertToMDEvents::buildDimNames(TargWSDescription);
ConvertToMDEvents::buildDimensions(TargWSDescription);
}


@@ -74,7 +74,7 @@ void t__tWithExistingLatticeTrowsLowEnergy(){

AnalysisDataService::Instance().addOrReplace("testWSProcessed", ws2D);

TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","QhQkQl"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","Q3D"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("dEAnalysisMode", "Inelastic"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("InputWorkspace", ws2D->getName()));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("OutputWorkspace", "EnergyTransfer4DWS"));
@@ -112,7 +112,7 @@ void testExecFailsOnNewWorkspaceNoMaxLimits(){

AnalysisDataService::Instance().addOrReplace("testWSProcessed", ws2D);

TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","QhQkQl"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","Q3D"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("dEAnalysisMode", "Indirect"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("InputWorkspace", ws2D->getName()));

@@ -131,7 +131,7 @@ void testExecFailsLimits_MinGeMax(){
AnalysisDataService::Instance().addOrReplace("testWSProcessed", ws2D);


TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","QhQkQl"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","Q3D"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("dEAnalysisMode", "Indirect"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("InputWorkspace", ws2D->getName()));

@@ -152,7 +152,7 @@ void testExecFine(){

AnalysisDataService::Instance().addOrReplace("testWSProcessed", ws2D);

TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","QhQkQl"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","Q3D"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("dEAnalysisMode", "Indirect"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("InputWorkspace", ws2D->getName()));

@@ -176,7 +176,7 @@ void testExecAndAdd(){

AnalysisDataService::Instance().addOrReplace("testWSProcessed", ws2D);

TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","QhQkQl"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("QDimensions","Q3D"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("dEAnalysisMode", "Indirect"));
TS_ASSERT_THROWS_NOTHING(pAlg->setPropertyValue("InputWorkspace", ws2D->getName()));

@@ -221,7 +221,7 @@ void testTransfMat1()
TS_ASSERT_EQUALS(V3D(1,0,0),ex);

// to allow recalculate axis names specific for Q3D mode
TWS.AlgID="QhQkQl";
TWS.AlgID="Q3D";
pAlg->buildDimNames(TWS);
TS_ASSERT_EQUALS("[Qh,0,0]",TWS.dimNames[0]);
TS_ASSERT_EQUALS("[0,Qk,0]",TWS.dimNames[1]);
@@ -11,8 +11,9 @@ namespace Mantid
{
namespace MDEvents
{
/** Lighteweith class wrapping together all parameters, related to MDEventoWorkspace description used mainly to reduce number of parameters trasferred between
* an algorithm, creating MD workspace and UI.
/*** Lighteweith class wrapping together all parameters, related to conversion from a workspace to MDEventoWorkspace
* used mainly to reduce number of parameters trasferred between an algorithm, creating a MD workspace and the UI.
*
* It also defines some auxiliary functions, used for convenient description of MD workspace, see below.
*
@@ -42,14 +43,6 @@ namespace MDEvents
struct DLLExport MDWSDescription
{
public:
/// constructor
MDWSDescription():nDims(0),emode(-1),Ei(std::numeric_limits<double>::quiet_NaN()){};
/// mainly test constructor;
MDWSDescription(size_t nDimesnions);
/// function build MD Event description from existing workspace
void build_from_MDWS(const API::IMDEventWorkspace_const_sptr &pWS);
/// compare two descriptions and select the coplimentary result.
void compareDescriptions(MDEvents::MDWSDescription &NewMDWorkspaceD);
/// the variable which describes the number of the dimensions, in the target workspace.
/// Calculated from number of input properties and the operations, performed on input workspace;
size_t nDims;
@@ -65,27 +58,47 @@ namespace MDEvents
std::vector<std::string> dimIDs;
/// the units of target workspace dimensions and properties of input MD workspace dimensions
std::vector<std::string> dimUnits;
/// if defined, specifies number of bins in each dimension
std::vector<size_t> nBins;
/// the swich, specifying if the target Q3D -dimensions should be converted to hkl. Ignored in ModQ and NoQ mode and if no oriented lattice is found in input ws.
bool convert_to_hkl;
/** vectors, which describe the projection plain the target ws is based on (notional coordinate system). The transformation matrix below
/** vectors, which describe the projection plain the target ws is based on (notional or cryst cartezian coordinate system). The transformation matrix below
* should bring the momentums from lab coordinate system into orthogonal, related to u,v vectors, coordinate system */
Kernel::V3D u,v;
/// the matrix to transform momentums of the workspace into target coordinate system, it is constructed from UB matix and W-matrix;
std::vector<double> rotMatrix; // can be Quat if not for non-orthogonal lattices

/// the string which describes subalgorithm, used to convert source ws to target MD ws.
std::string AlgID;

/// the oriented lattice which should be picked up from source ws and be carryed out to target ws. Defined for transfromation from Matrix or Event WS
std::auto_ptr<Geometry::OrientedLattice> pLatt;
/// the matrix transforming Q-coodinates in crystal cartesian coordinate system into target coodinate system.
Kernel::DblMatrix Wtransf;
/// the indicator, informing if the uv plain has been set as a parameter. If they are not, the UB matrix from the source workspace is used uncnanged
bool is_uv_default;
/// the matrix to transform momentums of the workspace into target coordinate system
std::vector<double> rotMatrix; // should it be the Quat?
/// the oriented lattice which should be picked up from source ws and be carryed out to target ws as it can be modified by u,v on the way.
Geometry::OrientedLattice Latt;
/// helper function checks if min values are less them max values and are consistent between each other
void checkMinMaxNdimConsistent(Mantid::Kernel::Logger& log)const;
/// the vector of default names for Q-directrions in reciprocal space;
std::vector<std::string> defailtQNames;
/// the string which describes subalgorithm, used to convert source ws to target MD ws.
std::string AlgID;
/// parameter, which specify if the ws describes powder analysis
bool is_powder;
/// shows if source workspace still has information about detectors. Some ws (like rebinned one) do not have this information any more.
bool detInfoLost;
/// if defined, specifies number of bins in each dimension
std::vector<size_t> nBins;
//=======================
/// constructor
MDWSDescription():nDims(0),emode(-1),Ei(std::numeric_limits<double>::quiet_NaN()),is_powder(false),Wtransf(3,3,true){};
/// mainly test constructor;
MDWSDescription(size_t nDimesnions);
/// function build MD Event description from existing workspace
void build_from_MDWS(const API::IMDEventWorkspace_const_sptr &pWS);
/// compare two descriptions and select the coplimentary result.
void compareDescriptions(MDEvents::MDWSDescription &NewMDWorkspaceD);

/// helper function checks if min values are less them max values and are consistent between each other
void checkMinMaxNdimConsistent(Mantid::Kernel::Logger& log)const;
// default does not do any more;
MDWSDescription & operator=(const MDWSDescription &rhs);
private:
// let's hide copy constructor for the time being as defaults are incorrect and it is unclear if one is needed.
MDWSDescription(const MDWSDescription &);

};
/** function to build mslice-like axis name from the vector, which describes crystallographic direction along this axis*/
std::string DLLExport makeAxisName(const Kernel::V3D &vector,const std::vector<std::string> &Q1Names);
@@ -20,7 +20,8 @@ MDWSDescription::build_from_MDWS(const API::IMDEventWorkspace_const_sptr &pWS)
this->dimIDs.resize(nDims);
this->dimUnits.resize(nDims);
this->nBins.resize(nDims);
for(size_t i=0;i<nDims;i++){
for(size_t i=0;i<nDims;i++)
{
const Geometry::IMDDimension *pDim = pWS->getDimension(i).get();
dimMin[i] = pDim->getMinimum();
dimMax[i] = pDim->getMaximum();
@@ -29,6 +30,18 @@ MDWSDescription::build_from_MDWS(const API::IMDEventWorkspace_const_sptr &pWS)
dimUnits[i]= pDim->getUnits();
nBins[i] = pDim->getNBins();
}
uint16_t num_experiments = pWS->getNumExperimentInfo();

// target ws does not have experiment info, so this can be only powder.
if (num_experiments==0)
{
is_powder = true;
return;
}else{
is_powder=false;
this->Wtransf = Kernel::DblMatrix(pWS->getWTransf());
}


}
/**function compares old workspace description with the new workspace description, defined by the algorithm properties and
@@ -76,19 +89,19 @@ dimMax(nDimesnions,1),
dimNames(nDimesnions,"mdn"),
dimIDs(nDimesnions,"mdn_"),
dimUnits(nDimesnions,"Momentum"),
Wtransf(3,3,true),
convert_to_hkl(false),
u(1,0,0),
v(0,1,0),
is_uv_default(true),
defailtQNames(3),
is_powder(false),
detInfoLost(false)
{
for(size_t i=0;i<nDimesnions;i++){
dimIDs[i]= dimIDs[i]+boost::lexical_cast<std::string>(i);
for(size_t i=0;i<nDimesnions;i++)
{
dimIDs[i] = dimIDs[i]+boost::lexical_cast<std::string>(i);
dimNames[i]=dimNames[i]+boost::lexical_cast<std::string>(i);
}
defailtQNames[0]="Qh";
defailtQNames[1]="Qk";
defailtQNames[2]="Ql";

}
std::string DLLExport sprintfd(const double data, const double eps)
@@ -99,6 +112,36 @@ std::string DLLExport sprintfd(const double data, const double eps)

}

MDWSDescription & MDWSDescription::operator=(const MDWSDescription &rhs)
{
this->nDims = rhs.nDims;
// prepare all arrays:
this->dimMin = rhs.dimMin;
this->dimMax = rhs.dimMax;
this->dimNames=rhs.dimNames;
this->dimIDs =rhs.dimIDs;
this->dimUnits=rhs.dimUnits;
this->nBins =rhs.nBins;

this->convert_to_hkl= rhs.convert_to_hkl;
this->u = rhs.u;
this->v = rhs.v;
this->rotMatrix = rhs.rotMatrix;
this->AlgID = rhs.AlgID;
this->is_uv_default = rhs.is_uv_default;
this->is_powder = rhs.is_powder;
this->detInfoLost = rhs.detInfoLost;

if(rhs.pLatt.get()){
this->pLatt = std::auto_ptr<Geometry::OrientedLattice>(new Geometry::OrientedLattice(*(rhs.pLatt)));
}
this->Wtransf=rhs.Wtransf;

return *this;

}


std::string makeAxisName(const Kernel::V3D &Dir,const std::vector<std::string> &QNames)
{
double eps(1.e-3);
@@ -4,7 +4,6 @@
#include <cxxtest/TestSuite.h>
#include "MantidMDEvents/MDWSDescription.h"


using namespace Mantid::MDEvents;
using namespace Mantid::Kernel;

@@ -22,20 +21,25 @@ class MDWSDescriptionTest : public CxxTest::TestSuite
V3D dir1(1,0,0);
std::string name;

TS_ASSERT_THROWS_NOTHING(name=makeAxisName(dir1,descr.defailtQNames));
TS_ASSERT_EQUALS("[Qh,0,0]",name);
std::vector<std::string> Names(3,"");
Names[0]="Q1";
Names[1]="Q2";
Names[2]="Q3";

TS_ASSERT_THROWS_NOTHING(name=makeAxisName(dir1,Names));
TS_ASSERT_EQUALS("[Q1,0,0]",name);

TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(-1,0.99,-1.001),descr.defailtQNames));
TS_ASSERT_EQUALS("[-Qh,0.99Qk,-Ql]",name);
TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(-1,0.99,-1.001),Names));
TS_ASSERT_EQUALS("[-Q1,0.99Q2,-Q3]",name);

TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(-1,0.9999,-1.001),descr.defailtQNames));
TS_ASSERT_EQUALS("[-Qh,Qk,-Ql]",name);
TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(-1,0.9999,-1.001),Names));
TS_ASSERT_EQUALS("[-Q1,Q2,-Q3]",name);

TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(-1,0.999,-1.01),descr.defailtQNames));
TS_ASSERT_EQUALS("[-Qh,0.999Qk,-1.01Ql]",name);
TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(-1,0.999,-1.01),Names));
TS_ASSERT_EQUALS("[-Q1,0.999Q2,-1.01Q3]",name);

TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(2.01,0.9,-1.01),descr.defailtQNames));
TS_ASSERT_EQUALS("[2.01Qh,0.9Qk,-1.01Ql]",name);
TS_ASSERT_THROWS_NOTHING(name=makeAxisName(V3D(2.01,0.9,-1.01),Names));
TS_ASSERT_EQUALS("[2.01Q1,0.9Q2,-1.01Q3]",name);

}

@@ -96,6 +96,9 @@ include_directories ( ../MantidWidgets/inc )
include_directories ( ${CMAKE_CURRENT_BINARY_DIR}/../MantidWidgets )
include_directories ( ${CMAKE_CURRENT_BINARY_DIR}/../API )
include_directories ( ../../QtPropertyBrowser/src )
# the directory with the information about ConvertToMD interface definitions
include_directories (../../Framework/MDAlgorithms/inc)
include_directories (../../Framework/MDEvents/inc)

qt4_wrap_cpp ( MOCCED_FILES ${MOC_FILES} )

@@ -118,7 +121,7 @@ set_target_properties ( CustomInterfaces PROPERTIES OUTPUT_NAME MantidQtCustomIn

Find_Package(Threads)

target_link_libraries ( CustomInterfaces MantidQtAPI MantidWidgets QtPropertyBrowser ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries ( CustomInterfaces MantidQtAPI MantidWidgets QtPropertyBrowser MDAlgorithms ${CMAKE_THREAD_LIBS_INIT})

if ( CXXTEST_FOUND )

@@ -27,7 +27,7 @@
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>You can to transfer source workspace dimensions into target worskpace directly (NoQ) or transform into mod(Q) (1 dimension) or QxQyQz (3 dimensions) in Q space</string>
<string>You can to transfer source workspace dimensions into target worskpace directly (NoQ) or transform into mod(Q) (1 dimension) or Q3D (3 dimensions) in Q space</string>
</property>
<property name="text">
<string>Q Dimensions</string>
@@ -80,7 +80,7 @@

a) 1+N_OtherDimensions if the first dimension (QDimensions property) is equal to |Q| or

b) 3+N_OtherDimensions if the first (3) dimensions (QDimensions property) equal QxQyQz or
b) 3+N_OtherDimensions if the first (3) dimensions (QDimensions property) equal Q3D or

c) (1 or 2)+N_OtherDimesnions if QDimesnins property is empty.

@@ -1,10 +1,12 @@
#include "MantidQtCustomInterfaces/CreateMDWorkspaceAlgDialog.h"
#include "MantidKernel/ConfigService.h"
#include "MantidMDAlgorithms/ConvertToMDEventsParams.h"
#include <QComboBox>
#include <QLineEdit>
#include <QCheckBox>
#include <QFileDialog>

using namespace Mantid::MDAlgorithms;
/**
Constructor
*/
@@ -15,12 +17,23 @@ CreateMDWorkspaceAlgDialog::CreateMDWorkspaceAlgDialog()
connect(m_uiForm.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(m_uiForm.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

m_uiForm.combo_q_dimensions->addItem("|Q|");
m_uiForm.combo_q_dimensions->addItem("QhQkQl");
ConvertToMDEventsParams ConvParams;
std::vector<std::string> QModes = ConvParams.getQModes();
// based on noQ mode being first in the list
QString name1(QModes[modQ].c_str());
m_uiForm.combo_q_dimensions->addItem(name1);
QString name2(QModes[Q3D].c_str());
m_uiForm.combo_q_dimensions->addItem(name2);

m_uiForm.combo_analysis_mode->addItem("Direct");
m_uiForm.combo_analysis_mode->addItem("Elastic");
m_uiForm.combo_analysis_mode->addItem("Indirect");
std::vector<std::string> dEModes = ConvParams.getDEModes();
for(size_t i=0;i<ANY_Mode;i++)
{
QString name(dEModes[i].c_str());
m_uiForm.combo_analysis_mode->addItem(name);
}

//m_uiForm.combo_analysis_mode->addItem(dEModes[Elastic]);
// m_uiForm.combo_analysis_mode->addItem(dEModes[Indirect]);

this->setWindowTitle("Set MDWorkspace Creation Parameters");
}