Skip to content

Commit

Permalink
refs #4401 modified the sub-algorithms to obey code conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 24, 2012
1 parent 166493d commit be39953
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 123 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ set ( INC_FILES
inc/MantidMDAlgorithms/ConvertToMDEventsHistoWS.h
inc/MantidMDAlgorithms/ConvertToMDEventsParams.h
inc/MantidMDAlgorithms/ConvertToMDEventsSubalgFactory.h
inc/MantidMDAlgorithms/ConvertToMDEventsTransfGeneric.h
inc/MantidMDAlgorithms/ConvertToMDEventsTransfInterface.h
inc/MantidMDAlgorithms/ConvertToMDEventsTransfModQ.h
inc/MantidMDAlgorithms/ConvertToMDEventsTransfNoQ.h
inc/MantidMDAlgorithms/ConvertToMDEventsTransfQ3D.h
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef H_CONV2_MDEVENTS_DET_INFO
#define H_CONV2_MDEVENTS_DET_INFO
/** This structure is the basis and temporary replacement for future subalgorithm, which calculates
* matrix worrkspace with various precprocessed detectors parameters
* matrix workspace with various precprocessed detectors parameters
*
* @date 22-12-2011
Expand Down Expand Up @@ -46,7 +46,7 @@ struct PreprocessedDetectors{
Kernel::V3D maxDetPosition; //< maxinal position for the detectors
/** shared pointer to the base instrument, which was source of the detector's information. If the instrument changed,
* the detectors positions should be recalculated.
* IT IS USER's RECPONCIBLITY TO RECALCULATE THE DETECTOR's PARAMETERS
* IT IS USER's RESPONSIBLITY TO RECALCULATE THE DETECTOR's PARAMETERS
* if the derived instrument have changed in a way, which affects the detectors positions and TOF calculations */
boost::shared_ptr< const Geometry::Instrument > pBaseInstr;
std::vector<Kernel::V3D> det_dir; //< unit vector pointing from the sample to the detector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class ConvertToMDEventsWS<EventWSType,Q,MODE,CONV,Sample>: public IConvertToMDEv
/// shalow class which is invoked from processQND procedure and describes the transformation from workspace coordinates to target coordinates
/// presumably will be completely inlined
template<QMode QX, AnalMode MODEX, CnvrtUnits CONVX,XCoordType XTYPE,SampleType XSample>
friend struct COORD_TRANSFORMER;
friend struct CoordTransformer;
// the instanciation of the class which does the transformation itself
COORD_TRANSFORMER<Q,MODE,CONV,Centered,Sample> trn;
CoordTransformer<Q,MODE,CONV,Centered,Sample> trn;
// the pointer to underlying event workspace
DataObjects::EventWorkspace_sptr pEventWS;
// vector to keep generic part of event coordinates
Expand Down Expand Up @@ -189,7 +189,7 @@ class ConvertToMDEventsWS<EventWSType,Q,MODE,CONV,Sample>: public IConvertToMDEv
for (; it != it_end; it++)
{
double tof=it->tof();
if(!trn.ConvertAndCalcMatrixCoord(tof,locCoord))continue; // skip ND outside the range
if(!trn.convertAndCalcMatrixCoord(tof,locCoord))continue; // skip ND outside the range

sig_err.push_back(float(it->weight()));
sig_err.push_back(float(it->errorSquared()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class ConvertToMDEventsWS<Ws2DHistoType,Q,MODE,CONV,Sample>: public IConvertToMD
/// shalow class which is invoked from processQND procedure and describes the transformation from workspace coordinates to target coordinates
/// presumably will be completely inlined
template<QMode XQ,AnalMode XMODE,CnvrtUnits XCONV,XCoordType Type,SampleType XSample>
friend struct COORD_TRANSFORMER;
friend struct CoordTransformer;
// the instanciation of the class which does the transformation itself
COORD_TRANSFORMER<Q,MODE,CONV,Histogram,Sample> trn;
CoordTransformer<Q,MODE,CONV,Histogram,Sample> trn;
// not yet parallel
virtual size_t conversionChunk(size_t job_ID){UNUSED_ARG(job_ID); return 0;}
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef H_CONVERT_TO_MDEVENTS_TRANSF_GENERIC
#define H_CONVERT_TO_MDEVENTS_TRANSF_GENERIC
#ifndef H_CONVERT_TO_MDEVENTS_TRANSF_INTERFACE
#define H_CONVERT_TO_MDEVENTS_TRANSF_INTERFACE
//
#include "MantidMDAlgorithms/IConvertToMDEventsMethods.h"
#include "MantidMDAlgorithms/ConvertToMDEventsUnitsConv.h"
Expand All @@ -8,10 +8,21 @@ namespace Mantid
{
namespace MDAlgorithms
{
/** Set of internal classes used by ConvertToMDEvents algorithm and responsible for conversion of input workspace
/** Interface to set of internal classes used by ConvertToMDEvents algorithm and responsible for conversion of input workspace
* data into from 1 to 4 output dimensions as function of input parameters
*
* @date 11-10-2011
*
** The template below describes general ingerface to coordinate transformation:
*
* Usual transformation constis of 4 steps
* 1) Initiate the transformation itself.
* 2) set-up, calculation and copying generic multidimensional variables which are not depenent on data
* 3) set-up, calculation and copying the multidimensional variables which dependent on detectors id only
* 4) calculation of the multidimensional variables which depend on the data along x-axis of the workspace
* and possibly on detectors parameters.
*
* Generic template defines interface to 4 functions which perform these four steps.
*
* @date 11-10-2011
Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
Expand All @@ -34,20 +45,8 @@ namespace MDAlgorithms
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/

/** The template below describes general ingerface to coordinate transformation:
*
* Usual transformation constis of 3 steps
* 1) set-up, calculation and copying generic multidimensional variables which are not depenent on data
* 2) set-up, calculation and copying the multidimensional variables which dependent on detectors id only
* 3) calculation of the multidimensional variables which depend on the data along x-axis of the workspace
* and possibly on detectors parameters.
*
* Generic template defines interface to 3 functions which perform these three steps.
*/


template<QMode Q,AnalMode MODE,CnvrtUnits CONV,XCoordType Type,SampleType Sample>
struct COORD_TRANSFORMER
struct CoordTramsformer
{

/**Template defines common interface to common part of the algorithm, where all variables
Expand All @@ -62,9 +61,7 @@ struct COORD_TRANSFORMER
*
* has to be specialized
*/
inline bool calcGenericVariables(std::vector<coord_t> &Coord, size_t n_ws_variabes){
UNUSED_ARG(Coord); UNUSED_ARG(n_ws_variabes);throw(Kernel::Exception::NotImplementedError(""));
return false;}
bool calcGenericVariables(std::vector<coord_t> &Coord, size_t n_ws_variabes);


/** template generalizes the code to calculate Y-variables within the detector's loop of processQND workspace
Expand All @@ -75,8 +72,7 @@ struct COORD_TRANSFORMER
*
* some default implementations possible (e.g mode Q3D,ragged Any_Mode( Direct, indirect,elastic),
*/
inline bool calcYDepCoordinatese(std::vector<coord_t> &Coord,size_t i){
UNUSED_ARG(Coord); UNUSED_ARG(i); return true;}
bool calcYDepCoordinatese(std::vector<coord_t> &Coord,size_t i);

/** template generalizes the code to calculate all remaining coordinates, defined within the inner loop
* @param X -- vector of X workspace values
Expand All @@ -88,36 +84,32 @@ struct COORD_TRANSFORMER
*
* has to be specialized
*/
inline bool calcMatrixCoord(const MantidVec& X,size_t i,size_t j,std::vector<coord_t> &Coord)const
{
UNUSED_ARG(X); UNUSED_ARG(i); UNUSED_ARG(j); UNUSED_ARG(Coord);throw(Kernel::Exception::NotImplementedError(""));
return false;
}
bool calcMatrixCoord(const MantidVec& X,size_t i,size_t j,std::vector<coord_t> &Coord)const;

/** template generalizes the code to calculate all remaining coordinates, defined within the inner loop
* given that the input described by sinble value only
* @param X -- X workspace value
*
* @param Coord -- subalgorithm specific number of coordinates, placed in the proper position of the Coordinate vector
* @return true -- if all Coord are within the range requested by algorithm. false otherwise
*
* has to be specialized
*/

inline bool calc1MatrixCoord(const double & X,std::vector<coord_t> &Coord)const
{
UNUSED_ARG(X); UNUSED_ARG(Coord);throw(Kernel::Exception::NotImplementedError(""));
}
inline bool ConvertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const
{
UNUSED_ARG(X); UNUSED_ARG(Coord);throw(Kernel::Exception::NotImplementedError(""));
}

inline void setUpTransf(IConvertToMDEventsMethods *){};
* has to be specialized */
bool calc1MatrixCoord(const double & X,std::vector<coord_t> &Coord)const;
/** template generalizes the conversion of single x-variable using unit conversion as the first step
* @param X -- X workspace value
*
* @param Coord -- subalgorithm specific number of coordinates, placed in the proper position of the Coordinate vector
* @return true -- if all Coord are within the range requested by algorithm. false otherwise
*
* has to be specialized */
bool convertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const;
/** set up transformation and retrieve the pointer to the incorporating class, which runs the transformation and provides
* necessary variables */
void setUpTransf(IConvertToMDEventsMethods *);

private:

private:

}; // end COORD_TRANSFORMER structure:
}; // end CoordTransformer structure:

////----------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef H_CONVERT_TO_MDEVENTS_MODQ_TRANSF
#define H_CONVERT_TO_MDEVENTS_MODQ_TRANSF
//
#include "MantidMDAlgorithms/ConvertToMDEventsTransfGeneric.h"
#include "MantidMDAlgorithms/ConvertToMDEventsTransfInterface.h"
//
namespace Mantid
{
Expand All @@ -10,7 +10,7 @@ namespace MDAlgorithms
/** Set of internal classes used by ConvertToMDEvents algorithm and responsible for conversion of input workspace
* data into from 1 to 4 output dimensions as function of input parameters
*
* This file defines specializations of generic coordinate transformation templated to the ModQ case
* This particular file defines specializations of generic coordinate transformation templated to the ModQ case
*
* @date 11-10-2011
Expand Down Expand Up @@ -38,7 +38,7 @@ namespace MDAlgorithms

// ModQ,Inelastic
template<AnalMode MODE,CnvrtUnits CONV,XCoordType Type,SampleType Sample>
struct COORD_TRANSFORMER<ModQ,MODE,CONV,Type,Sample>
struct CoordTransformer<ModQ,MODE,CONV,Type,Sample>
{
inline bool calcGenericVariables(std::vector<coord_t> &Coord, size_t nd)
{
Expand Down Expand Up @@ -100,21 +100,21 @@ struct COORD_TRANSFORMER<ModQ,MODE,CONV,Type,Sample>
return true;

}
// should be actually on ICOORD_TRANSFORMER but there is problem with template-overloaded functions
// should be actually on ICoordTransformer but there is problem with template-overloaded functions
inline bool calcMatrixCoord(const MantidVec& X,size_t i,size_t j,std::vector<coord_t> &Coord)const
{
UNUSED_ARG(i);
double X_ev = CONV_UNITS_FROM.getXConverted(X,j);
return calc1MatrixCoord(X_ev,Coord);
}

inline bool ConvertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const
inline bool convertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const
{
double X_ev = CONV_UNITS_FROM.getXConverted(X);
return calc1MatrixCoord(X_ev,Coord);
}
// constructor;
COORD_TRANSFORMER():pDet(NULL),pHost(NULL){}
CoordTransformer():pDet(NULL),pHost(NULL){}
void setUpTransf(IConvertToMDEventsMethods *pConv){
pHost = pConv;
}
Expand All @@ -134,12 +134,12 @@ struct COORD_TRANSFORMER<ModQ,MODE,CONV,Type,Sample>
// Calling Mantid algorithm
IConvertToMDEventsMethods *pHost;
// class which would convert units
UNITS_CONVERSION<CONV,Type> CONV_UNITS_FROM;
UnitsConverter<CONV,Type> CONV_UNITS_FROM;

};
// ModQ,Elastic
template<CnvrtUnits CONV,XCoordType Type,SampleType Sample>
struct COORD_TRANSFORMER<ModQ,Elastic,CONV,Type,Sample>
struct CoordTransformer<ModQ,Elastic,CONV,Type,Sample>
{
inline bool calcGenericVariables(std::vector<coord_t> &Coord, size_t nd)
{
Expand Down Expand Up @@ -191,22 +191,22 @@ struct COORD_TRANSFORMER<ModQ,Elastic,CONV,Type,Sample>

}

// should be actually on ICOORD_TRANSFORMER
// should be actually on ICoordTransformer
inline bool calcMatrixCoord(const MantidVec& X,size_t i,size_t j,std::vector<coord_t> &Coord)const
{
UNUSED_ARG(i);
double X_ev = CONV_UNITS_FROM.getXConverted(X,j);

return calc1MatrixCoord(X_ev,Coord);
}
inline bool ConvertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const
inline bool convertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const
{
double X_ev = CONV_UNITS_FROM.getXConverted(X);
return calc1MatrixCoord(X_ev,Coord);
}

// constructor;
COORD_TRANSFORMER():pDet(NULL),pHost(NULL){}
CoordTransformer():pDet(NULL),pHost(NULL){}
void setUpTransf(IConvertToMDEventsMethods *pConv){
pHost = pConv;
}
Expand All @@ -226,7 +226,7 @@ struct COORD_TRANSFORMER<ModQ,Elastic,CONV,Type,Sample>
// Calling Mantid algorithm
IConvertToMDEventsMethods *pHost;
// class which would convert units
UNITS_CONVERSION<CONV,Type> CONV_UNITS_FROM;
UnitsConverter<CONV,Type> CONV_UNITS_FROM;

};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef H_CONVERT_TO_MDEVENTS_TRANSF_NOQ
#define H_CONVERT_TO_MDEVENTS_TRANSF_NOQ
//
#include "MantidMDAlgorithms/ConvertToMDEventsTransfGeneric.h"
#include "MantidMDAlgorithms/ConvertToMDEventsTransfInterface.h"
//
namespace Mantid
{
Expand Down Expand Up @@ -43,7 +43,7 @@ namespace MDAlgorithms
// NoQ,ANY_Mode -- no units conversion. This templates just copies the data into MD events and not doing any momentum transformations
//
template<AnalMode MODE,CnvrtUnits CONV,XCoordType Type,SampleType Sample>
struct COORD_TRANSFORMER<NoQ,MODE,CONV,Type,Sample>
struct CoordTransformer<NoQ,MODE,CONV,Type,Sample>
{
inline bool calcGenericVariables(std::vector<coord_t> &Coord, size_t nd)
{
Expand Down Expand Up @@ -76,22 +76,22 @@ struct COORD_TRANSFORMER<NoQ,MODE,CONV,Type,Sample>
Coord[0]=(coord_t)X;
return true;
}
// should be actually on ICOORD_TRANSFORMER but there is problem with template-overloaded functions
// should be actually on ICoordTransformer but there is problem with template-overloaded functions
inline bool calcMatrixCoord(const MantidVec& X,size_t i,size_t j,std::vector<coord_t> &Coord)const
{
UNUSED_ARG(i);
double X_ev = CONV_UNITS_FROM.getXConverted(X,j);

return calc1MatrixCoord(X_ev,Coord);
}
inline bool ConvertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const
inline bool convertAndCalcMatrixCoord(const double & X,std::vector<coord_t> &Coord)const
{
double X_ev = CONV_UNITS_FROM.getXConverted(X);
return calc1MatrixCoord(X_ev,Coord);
}

// constructor;
COORD_TRANSFORMER():pYAxis(NULL),pHost(NULL){}
CoordTransformer():pYAxis(NULL),pHost(NULL){}

inline void setUpTransf(IConvertToMDEventsMethods *pConv){
pHost = pConv;
Expand All @@ -103,7 +103,7 @@ struct COORD_TRANSFORMER<NoQ,MODE,CONV,Type,Sample>
// pointer to MD workspace convertor
IConvertToMDEventsMethods *pHost;
// class which would convert units
UNITS_CONVERSION<CONV,Type> CONV_UNITS_FROM;
UnitsConverter<CONV,Type> CONV_UNITS_FROM;
};
//
} // End MDAlgorighms namespace
Expand Down

0 comments on commit be39953

Please sign in to comment.