Skip to content

Commit

Permalink
refs #6856 Copied ConvertToDiffractionMDWorkspace.cpp
Browse files Browse the repository at this point in the history
into MD algorithms
  • Loading branch information
abuts committed May 24, 2013
1 parent 9a2b70e commit 4e34acb
Show file tree
Hide file tree
Showing 5 changed files with 957 additions and 7 deletions.
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
@@ -0,0 +1,100 @@
#ifndef MANTID_MDEVENTS_CONVERTTODIFFRACTIONMDWORKSPACE_H_
#define MANTID_MDEVENTS_CONVERTTODIFFRACTIONMDWORKSPACE_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 "MantidMDEvents/ConvertToDiffractionMDWorkspace.h"
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidMDEvents/MDEventWorkspace.h"

namespace Mantid
{
namespace MDAlgorithms
{

/** ConvertToDiffractionMDWorkspace :
* Create a MDEventWorkspace with events in reciprocal space (Qx, Qy, Qz) from an input EventWorkspace.
*
* @author Janik Zikovsky, SNS
* @date 2011-03-01 13:14:48.236513
*/
class DLLExport ConvertToDiffractionMDWorkspace : public BoxControllerSettingsAlgorithm
{
public:
ConvertToDiffractionMDWorkspace();
~ConvertToDiffractionMDWorkspace();

/// Algorithm's name for identification
virtual const std::string name() const { return "ConvertToDiffractionMDWorkspace";};
/// Algorithm's version for identification
virtual int version() const { return 1;};
/// 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();

template <class T>
void convertEventList(int workspaceIndex, DataObjects::EventList & el);

void convertSpectrum(int workspaceIndex);

/// The input MatrixWorkspace
API::MatrixWorkspace_sptr m_inWS;

/// The input event workspace
DataObjects::EventWorkspace_sptr m_inEventWS;

/// The output MDEventWorkspace<3>
MDEvents::MDEventWorkspace3Lean::sptr ws;
/// Do we clear events on the input during loading?
bool ClearInputWorkspace;
/// Use the histogram representation with one event per bin
bool OneEventPerBin;
/// Are we appending?
bool Append;
/// Perform LorentzCorrection on the fly.
bool LorentzCorrection;
/// Map of all the detectors in the instrument
detid2det_map allDetectors;
/// Primary flight path (source to sample)
double l1;
/// Beam direction and length
Kernel::V3D beamline;
/// Path length between source and sample
double beamline_norm;
/// Path length between source and sample
size_t failedDetectorLookupCount;
/// Beam direction (unit vector)
Kernel::V3D beamDir;
/// Sample position
Kernel::V3D samplePos;
/// Progress reporter (shared)
boost::shared_ptr<Kernel::ProgressBase> prog;
/// Matrix. Multiply this by the lab frame Qx, Qy, Qz to get the desired Q or HKL.
Kernel::Matrix<double> mat;

/// Minimum extents of the workspace. Cached for speed
coord_t * m_extentsMin;
/// Maximum extents of the workspace. Cached for speed
coord_t * m_extentsMax;


};


} // namespace Mantid
} // namespace MDEvents

#endif /* MANTID_MDEVENTS_CONVERTTODIFFRACTIONMDWORKSPACE_H_ */

0 comments on commit 4e34acb

Please sign in to comment.