Skip to content

Commit

Permalink
refs #6865 merge with develop and resolve conflicts (again)
Browse files Browse the repository at this point in the history
Merge branch 'feature/6856_ConvertToDiffractionMDWS_v2' into develop

Conflicts:
	Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp
  • Loading branch information
abuts committed May 30, 2013
2 parents 06ac1d2 + 27045d9 commit 1d94c2c
Show file tree
Hide file tree
Showing 13 changed files with 672 additions and 69 deletions.
11 changes: 6 additions & 5 deletions Code/Mantid/Framework/API/src/FrameworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,17 @@ IAlgorithm* FrameworkManagerImpl::exec(const std::string& algName, const std::st
*/
IAlgorithm_sptr FrameworkManagerImpl::exec(const std::string& algorithmName, int count, ...)
{
// Create the algorithm
if (count % 2 == 1)
{
throw std::runtime_error("Must have an even number of parameter/value string arguments");
}

// Create the algorithm
IAlgorithm_sptr alg = AlgorithmManager::Instance().createUnmanaged(algorithmName, -1);
alg->initialize();
if (!alg->isInitialized())
throw std::runtime_error(algorithmName + " was not initialized.");

if (count % 2 == 1)
{
throw std::runtime_error("Must have an even number of parameter/value string arguments");
}

va_list Params;
va_start(Params, count);
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ set ( SRC_FILES
src/CloneMDWorkspace.cpp
src/CompareMDWorkspaces.cpp
src/ConvertToDetectorFaceMD.cpp
src/ConvertToDiffractionMDWorkspace.cpp
src/ConvertToDiffractionMDWorkspace2.cpp
src/ConvertToMD.cpp
src/CreateMDHistoWorkspace.cpp
src/CreateMDWorkspace.cpp
Expand Down Expand Up @@ -79,6 +81,8 @@ set ( INC_FILES
inc/MantidMDAlgorithms/CloneMDWorkspace.h
inc/MantidMDAlgorithms/CompareMDWorkspaces.h
inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h
inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace.h
inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace2.h
inc/MantidMDAlgorithms/ConvertToMD.h
inc/MantidMDAlgorithms/CreateMDHistoWorkspace.h
inc/MantidMDAlgorithms/CreateMDWorkspace.h
Expand Down Expand Up @@ -148,6 +152,8 @@ set ( TEST_FILES
CompareMDWorkspacesTest.h
ConvertEventsToMDTest.h
ConvertToDetectorFaceMDTest.h
ConvertToDiffractionMDWorkspaceTest.h
ConvertToDiffractionMDWorkspace2Test.h
ConvertToMDComponentsTest.h
ConvertToMDTest.h
ConvertToQ3DdETest.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
#include "MantidKernel/System.h"
#include "MantidKernel/V3D.h"
#include "MantidMDEvents/BoxControllerSettingsAlgorithm.h"
#include "MantidMDEvents/ConvertToDiffractionMDWorkspace.h"
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidMDEvents/MDEventWorkspace.h"

namespace Mantid
{
namespace MDEvents
namespace MDAlgorithms
{

/** ConvertToDiffractionMDWorkspace :
Expand All @@ -26,11 +25,11 @@ namespace MDEvents
* @author Janik Zikovsky, SNS
* @date 2011-03-01 13:14:48.236513
*/
class DLLExport ConvertToDiffractionMDWorkspace : public BoxControllerSettingsAlgorithm
class DLLExport ConvertToDiffractionMDWorkspace : public MDEvents::BoxControllerSettingsAlgorithm
{
public:
ConvertToDiffractionMDWorkspace();
~ConvertToDiffractionMDWorkspace();
~ConvertToDiffractionMDWorkspace(){};

/// Algorithm's name for identification
virtual const std::string name() const { return "ConvertToDiffractionMDWorkspace";};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#ifndef MANTID_MDEVENTS_CONVERTTODIFFRACTIONMDWORKSPACE2_H_
#define MANTID_MDEVENTS_CONVERTTODIFFRACTIONMDWORKSPACE2_H_

#include "MantidAPI/Algorithm.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/Progress.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidKernel/PhysicalConstants.h"
#include "MantidKernel/ProgressBase.h"
#include "MantidKernel/ProgressText.h"
#include "MantidKernel/System.h"
#include "MantidKernel/V3D.h"
#include "MantidMDEvents/BoxControllerSettingsAlgorithm.h"
#include "MantidMDAlgorithms/ConvertToMD.h"
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidMDEvents/MDEventWorkspace.h"

namespace Mantid
{
namespace MDAlgorithms
{

/** ConvertToDiffractionMDWorkspace2 :
* Create a MDEventWorkspace with events in reciprocal space (Qx, Qy, Qz) from an input EventWorkspace.
*
* This is the wrapper for ConvertToMD algorithm transferring the properties of the old ConvertToDiffractionMDWorkspace into ConvertToMD properties
* and running ConvertToMD as a subalgorithm.
*
* @date 2013-05-20
*/
class DLLExport ConvertToDiffractionMDWorkspace2 : public MDEvents::BoxControllerSettingsAlgorithm
{
public:
/** Constructor */
ConvertToDiffractionMDWorkspace2(){};
/** Destructor */
virtual ~ConvertToDiffractionMDWorkspace2(){};

/// Algorithm's name for identification
virtual const std::string name() const { return "ConvertToDiffractionMDWorkspace";};
/// Algorithm's version for identification
virtual int version() const { return 2;};
/// Algorithm's category for identification
virtual const std::string category() const { return "MDAlgorithms";}

private:
/// Sets documentation strings for this algorithm
virtual void initDocs();
void init();
void exec();

// the target frame names exposed as the algorithm properties and recognized by old convertToDiffractionWorkspace algorithm.
std::vector<std::string> frameOptions;
protected: // for testing
// method to convert the value of the target frame specified for the ConvertToDiffractionMDWorksapce into the properties names of the ConvertToMD
void convertFramePropertyNames(const std::string &ConvToDifrWSPropName,std::string &TargFrameName,std::string & ScalingName);
// method to convert the extents specified for the ConvertToDiffractionMDWorksapce into the min-max properties names of the ConvertToMD
void convertExtents(const std::vector<double> &Extents,std::vector<double> &minVal,std::vector<double> &maxVal)const;
};


} // namespace Mantid
} // namespace MDEvents

#endif /* MANTID_MDEVENTS_CONVERTTODIFFRACTIONMDWORKSPACE_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ to an [[EventWorkspace]] but with no events for empty bins.
#include "MantidKernel/ProgressText.h"
#include "MantidKernel/System.h"
#include "MantidKernel/Timer.h"
#include "MantidMDEvents/ConvertToDiffractionMDWorkspace.h"
#include "MantidMDAlgorithms/ConvertToDiffractionMDWorkspace.h"
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MantidAPI/MemoryManager.h"
Expand All @@ -85,7 +85,7 @@ using namespace Mantid::Geometry;

namespace Mantid
{
namespace MDEvents
namespace MDAlgorithms
{

bool DODEBUG = true;
Expand All @@ -109,11 +109,7 @@ namespace MDEvents
}

//----------------------------------------------------------------------------------------------
/** Destructor
*/
ConvertToDiffractionMDWorkspace::~ConvertToDiffractionMDWorkspace()
{
}



//----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -174,7 +170,7 @@ namespace MDEvents


/// Our MDLeanEvent dimension
typedef MDLeanEvent<3> MDE;
typedef MDEvents::MDLeanEvent<3> MDE;

//----------------------------------------------------------------------------------------------
/** Convert one spectrum to MDEvents.
Expand Down Expand Up @@ -237,7 +233,7 @@ namespace MDEvents
void ConvertToDiffractionMDWorkspace::convertEventList(int workspaceIndex, EventList & el)
{
size_t numEvents = el.getNumberEvents();
MDBoxBase<MDLeanEvent<3>,3> * box = ws->getBox();
MDEvents::MDBoxBase<MDEvents::MDLeanEvent<3>,3> * box = ws->getBox();

// Get the position of the detector there.
const std::set<detid_t>& detectors = el.getDetectorIDs();
Expand Down Expand Up @@ -392,7 +388,7 @@ namespace MDEvents

// Try to get the output workspace
IMDEventWorkspace_sptr i_out = getProperty("OutputWorkspace");
ws = boost::dynamic_pointer_cast<MDEventWorkspace<MDLeanEvent<3>,3> >( i_out );
ws = boost::dynamic_pointer_cast<MDEvents::MDEventWorkspace<MDEvents::MDLeanEvent<3>,3> >( i_out );

// Initalize the matrix to 3x3 identity
mat = Kernel::Matrix<double>(3,3, true);
Expand Down Expand Up @@ -447,8 +443,8 @@ namespace MDEvents
{
// Create an output workspace with 3 dimensions.
size_t nd = 3;
i_out = MDEventFactory::CreateMDWorkspace(nd, "MDLeanEvent");
ws = boost::dynamic_pointer_cast<MDEventWorkspace3Lean>(i_out);
i_out = MDEvents::MDEventFactory::CreateMDWorkspace(nd, "MDLeanEvent");
ws = boost::dynamic_pointer_cast<MDEvents::MDEventWorkspace3Lean>(i_out);

// ---------------- Get the extents -------------
std::vector<double> extents = getProperty("Extents");
Expand Down

0 comments on commit 1d94c2c

Please sign in to comment.