Skip to content

Commit

Permalink
refs #4401 further separating algorithm body from internal methods
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Mar 16, 2012
1 parent ea2fa1c commit 6878d92
Show file tree
Hide file tree
Showing 14 changed files with 327 additions and 148 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,11 @@ Desktop.ini
/Code/Mantid/Build/CMake/OutputBinaryTo.cmake

Code/Mantid/instrument/Grouping/tempMuonAnalysisGrouping.xml

/Code/Mantid/Framework/DataHandling/logs/.gitignore
/Code/Mantid/Framework/DataObjects/test/.gitignore
/Code/Mantid/Framework/MDAlgorithms/logs/.gitignore
/Code/Mantid/Framework/MDEvents/test/mantid.log
/Code/Mantid/Framework/CurveFitting/test/test_header.h
/Code/Mantid/Framework/CurveFitting/test/test_header.cpp
/Code/Mantid/Framework/Algorithms/test/mantid.log
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set ( SRC_FILES
src/ConvertToDetectorFaceMD.cpp
src/ConvertToMDEvents.cpp
src/ConvertToMDEventsParams.cpp
src/ConvertToMDEventsSubalgFactory.cpp
src/DivideMD.cpp
src/EqualToMD.cpp
src/ExponentialMD.cpp
Expand Down Expand Up @@ -67,6 +68,7 @@ set ( INC_FILES
inc/MantidMDAlgorithms/ConvertToMDEventsDetInfo.h
inc/MantidMDAlgorithms/ConvertToMDEventsEventWS.h
inc/MantidMDAlgorithms/ConvertToMDEventsHistoWS.h
inc/MantidMDAlgorithms/ConvertToMDEventsSubalgFactory.h
inc/MantidMDAlgorithms/ConvertToMDEventsUnitsConv.h
inc/MantidMDAlgorithms/DivideMD.h
inc/MantidMDAlgorithms/EqualToMD.h
Expand Down Expand Up @@ -118,6 +120,7 @@ set ( TEST_FILES
test/ConvertToMDEventsTest.h
test/ConvertToMDEventsParamsTest.h
test/ConvertToMDEventsUnitsConvTest.h
test/ConvertToMDEventsSubalgFactoryTest.h
test/ConvertToQ3DdETest.h
test/DivideMDTest.h
test/EqualToMDTest.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef MANTID_MD_CONVERT2_MDEVENTS
#define MANTID_MD_CONVERT2_MDEVENTS

#include "MantidMDAlgorithms/ConvertToMDEventsParams.h"
#include "MantidMDAlgorithms/IConvertToMDEventsMethods.h"

#include "MantidMDEvents/MDWSDescription.h"
#include "MantidMDEvents/BoxControllerSettingsAlgorithm.h"
#include "MantidMDAlgorithms/ConvertToMDEventsSubalgFactory.h"

namespace Mantid
{
Expand Down Expand Up @@ -75,11 +75,6 @@ namespace MDAlgorithms
/// logger -> to provide logging, for MD dataset file operations
static Mantid::Kernel::Logger& convert_log;
//------------------------------------------------------------------------------------------------------------------------------------------
ConvertToMDEventsParams ParamParser;
/// string -Key to identify the algorithm -- rather for testing and debugging, though may be reliet upon somewhere by bad practice
std::string algo_id;


/// the properties of the requested target MD workpsace:
MDEvents::MDWSDescription TWS;

Expand All @@ -99,15 +94,11 @@ namespace MDAlgorithms
/// construct meaningful dimension names:
void buildDimNames(MDEvents::MDWSDescription &TargWSDescription);

/// map to select an algorithm as function of the key, which describes it
std::map<std::string, IConvertToMDEventsMethods *> alg_selector;
private:
//--------------------------------------------------------------------------------------------------
/// helper class to orginize metaloop instantiating various subalgorithms
template<Q_state Q,size_t N_ALGORITHMS >
friend class LOOP_ALGS;


/// the class which generates alforithm ID as function of input parameters and knows about existing subalgorithms.
ConvertToMDEventsParams ParamParser;
/// The class which contains all existing subalgorithms to convert to MDEventWorkspace. Shoud be done through a singleton if used elsewhere, not only here.
ConvertToMDEventsSubalgFactory subAlgFactory;
/** helper function which verifies if projection vectors are specified and if their values are correct when present.
* sets default values u and v to [1,0,0] and [0,1,0] if not present or any error. */
void checkUVsettings(const std::vector<double> &ut,const std::vector<double> &vt,MDEvents::MDWSDescription &TargWSDescription)const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace MDAlgorithms

// Class to process event workspace by direct conversion:
template<Q_state Q, AnalMode MODE, CnvrtUnits CONV>
class ConvertToMDEvensEventWS: public IConvertToMDEventsMethods
class ConvertToMDEventsWS<EventWSType,Q,MODE,CONV>: public IConvertToMDEventsMethods
{
/// shalow class which is invoked from processQND procedure and describes the transformation from workspace coordinates to target coordinates
/// presumably will be completely inlined
Expand All @@ -63,7 +63,7 @@ class ConvertToMDEvensEventWS: public IConvertToMDEventsMethods
// the pointer to underlying event workspace
DataObjects::EventWorkspace_sptr pEventWS;
// vector to keep generic part of event coordinates
std::vector<coord_t> Coord;
std::vector<coord_t> Coord;
public:
size_t setUPConversion(Mantid::API::MatrixWorkspace_sptr pWS2D, const PreprocessedDetectors &detLoc,
const MDEvents::MDWSDescription &WSD, boost::shared_ptr<MDEvents::MDEventWSWrapper> inWSWrapper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ namespace MDAlgorithms
#define SPLIT_LEVEL 2048

//-----------------------------------------------
// Method to process histohram workspace
// Method to process rugged histohram workspace
template<Q_state Q, AnalMode MODE, CnvrtUnits CONV>
class ConvertToMDEvensHistoWS: public IConvertToMDEventsMethods
class ConvertToMDEventsWS<Ws2DRuggedType,Q,MODE,CONV>: public IConvertToMDEventsMethods
{
/// shalow class which is invoked from processQND procedure and describes the transformation from workspace coordinates to target coordinates
/// presumably will be completely inlined
Expand All @@ -70,7 +70,6 @@ class ConvertToMDEvensHistoWS: public IConvertToMDEventsMethods
const MDEvents::MDWSDescription &WSD, boost::shared_ptr<MDEvents::MDEventWSWrapper> inWSWrapper)
{
size_t numSpec=IConvertToMDEventsMethods::setUPConversion(pWS2D,detLoc,WSD,inWSWrapper);

// initiate the templated class which does the conversion of workspace data into MD WS coordinates;
trn.setUpTransf(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ namespace Mantid
{
namespace MDAlgorithms
{
/** Helper class describes the possible properties of the algorithm, which converts a workspace to MDEventWorkspace
/** Helper class describes the possible properties of the algorithm, converting a workspace to a MDEventWorkspace
*
* It is used to convert user input and input data into the key, which is responsible for calling appropriate
* subalgorithm, performing actual conversion.
* subalgorithm, performing the actual conversion.
*
* @date 14-03-2012
Expand Down Expand Up @@ -66,7 +66,8 @@ namespace MDAlgorithms
};
enum InputWSType // Algorithm recognizes 2 input workspace types with different interface.
{
Workspace2DType, //< 2D matirix workspace
Ws2DAlighnType, //< 2D matirix workspace with the same x-axis for each sign
Ws2DRuggedType, //<2D matirix workspace with own x-axis for every sign
EventWSType, //< Event worskapce
NInWSTypes
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#ifndef H_CONVERT_TO_MDEVENTS_SUBALG_FACTORY
#define H_CONVERT_TO_MDEVENTS_SUBALG_FACTORY


#include "MantidMDAlgorithms/ConvertToMDEventsParams.h"
#include "MantidMDAlgorithms/IConvertToMDEventsMethods.h"
#include "MantidMDAlgorithms/ConvertToMDEventsHistoWS.h"
#include "MantidMDAlgorithms/ConvertToMDEventsEventWS.h"

namespace Mantid
{
namespace MDAlgorithms
{

/** The helper class for ConvertToMDEvents, which instantiates various subalgorithms, availible to convert a workspace into MDEvent workspace
* and accessed on request:
*
* @date 16-03-2012
*
* Gateway for number of subalgorithms, some are very important, some are questionable
* Intended to cover wide range of cases;
Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ConvertToMDEventsSubalgFactory
{
/// map to select an algorithm as function of the key, which describes it
std::map<std::string, IConvertToMDEventsMethods *> alg_selector;
public:
/// constructor
ConvertToMDEventsSubalgFactory();
~ConvertToMDEventsSubalgFactory();
/// access to a subalgorithm
IConvertToMDEventsMethods * getAlg(const std::string &AlgName);
/// initiate the subalgorithm creation
void initSubalgorithms(const ConvertToMDEventsParams &SubAlgDescriptor);
private:
//--------------------------------------------------------------------------------------------------
/// helper class to orginize metaloop instantiating various subalgorithms
template<Q_state Q,size_t N_ALGORITHMS >
friend class LOOP_ALGS;
};
}
}



#endif
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,29 @@ namespace MDAlgorithms

};

/// Templated interface to the workspace conversion algorithm. Every template parameter refers to different conversion possibilities
template<InputWSType WS,Q_state Q, AnalMode MODE, CnvrtUnits CONV>
class ConvertToMDEventsWS: public IConvertToMDEventsMethods
{
public:
ConvertToMDEventsWS(){};
size_t setUPConversion(Mantid::API::MatrixWorkspace_sptr , const PreprocessedDetectors &,const MDEvents::MDWSDescription &, boost::shared_ptr<MDEvents::MDEventWSWrapper> )
{
throw(std::logic_error("Generic Conversion inot MD workspace can not be implemented"));
}

void runConversion(API::Progress *)
{
throw(std::logic_error("Generic Conversion inot MD workspace can not be implemented"));
}
private:
virtual size_t conversionChunk(size_t job_ID)
{
throw(std::logic_error("Generic Conversion inot MD workspace can not be implemented"));
}
};




} // end namespace MDAlgorithms
Expand Down

0 comments on commit 6878d92

Please sign in to comment.