Skip to content

Commit

Permalink
refs #4401 preprecessed detectors are prepared to refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 25, 2012
1 parent f9c4c33 commit 2dc8c40
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
12 changes: 6 additions & 6 deletions Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ set ( SRC_FILES
# src/ConvertToMDEvents.cpp
# src/ConvertToMDEventsParams.cpp
# src/ConvertToMDEventsSubalgFactory.cpp
src/IConvertToMDEventsMethods.cpp
src/ConvToMDPreprocDetectors.cpp
src/DivideMD.cpp
src/EqualToMD.cpp
src/ExponentialMD.cpp
src/GreaterThanMD.cpp
# src/IConvertToMDEventsMethods.cpp
src/IDynamicRebinning.cpp
src/InvalidParameter.cpp
src/InvalidParameterParser.cpp
Expand Down Expand Up @@ -45,7 +46,6 @@ set ( SRC_FILES
src/UnaryOperationMD.cpp
src/Vector3DParameterParser.cpp
src/XorMD.cpp
src/processDetectorsPositions.cpp
)

#set ( SRC_UNITY_IGNORE_FILES src/IDynamicRebinning.cpp
Expand All @@ -63,7 +63,6 @@ set ( INC_FILES
inc/MantidMDAlgorithms/CompositeImplicitFunctionParser.h
inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h
# inc/MantidMDAlgorithms/ConvertToMDEvents.h
# inc/MantidMDAlgorithms/ConvertToMDEventsDetInfo.h
# inc/MantidMDAlgorithms/ConvertToMDEventsEventWS.h
# inc/MantidMDAlgorithms/ConvertToMDEventsHistoWS.h
# inc/MantidMDAlgorithms/ConvertToMDEventsParams.h
Expand All @@ -72,12 +71,13 @@ set ( INC_FILES
# inc/MantidMDAlgorithms/ConvertToMDEventsTransfModQ.h
# inc/MantidMDAlgorithms/ConvertToMDEventsTransfNoQ.h
# inc/MantidMDAlgorithms/ConvertToMDEventsTransfQ3D.h
# inc/MantidMDAlgorithms/ConvertToMDEventsUnitsConv.h
inc/MantidMDAlgorithms/ConvToMDPreprocDetectors.h
inc/MantidMDAlgorithms/ConvertToMDEventsUnitsConv.h
inc/MantidMDAlgorithms/IConvertToMDEventsMethods.h
inc/MantidMDAlgorithms/DivideMD.h
inc/MantidMDAlgorithms/EqualToMD.h
inc/MantidMDAlgorithms/ExponentialMD.h
inc/MantidMDAlgorithms/GreaterThanMD.h
# inc/MantidMDAlgorithms/IConvertToMDEventsMethods.h
inc/MantidMDAlgorithms/IDynamicRebinning.h
inc/MantidMDAlgorithms/InvalidParameter.h
inc/MantidMDAlgorithms/InvalidParameterParser.h
Expand Down Expand Up @@ -123,7 +123,7 @@ set ( TEST_FILES
# test/ConvertToMDEventsParamsTest.h
# test/ConvertToMDEventsSubalgFactoryTest.h
# test/ConvertToMDEventsTest.h
# test/ConvertToMDEventsUnitsConvTest.h
test/ConvertToMDEventsUnitsConvTest.h
# test/ConvertToQ3DdETest.h
# test/ConvertToMDEventsTestPerformance.h
test/DivideMDTest.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Mantid
namespace MDAlgorithms
{

struct PreprocessedDetectors{
struct ConvToMDPreprocDetectors{
double L1; //< source-sample distance;
Kernel::V3D minDetPosition; //< minimal and
Kernel::V3D maxDetPosition; //< maxinal position for the detectors
Expand Down Expand Up @@ -70,9 +70,9 @@ struct PreprocessedDetectors{

/** helper function, does preliminary calculations of the detectors positions to convert results into k-dE space ;
and places the resutls into static cash to be used in subsequent calls to this algorithm */
void DLLExport processDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,PreprocessedDetectors &det,Kernel::Logger& convert_log,API::Progress *pProg);
void DLLExport processDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,ConvToMDPreprocDetectors &det,Kernel::Logger& convert_log,API::Progress *pProg);
/** function builds fake cpectra-detector map and all other detectors position for the case when detector information has been lost */
void DLLExport buildFakeDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,PreprocessedDetectors &det);
void DLLExport buildFakeDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,ConvToMDPreprocDetectors &det);
} // end MDAlgorithms
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef H_ICONVERT_TO_MDEVENTS_METHODS
#define H_ICONVERT_TO_MDEVENTS_METHODS

#define NO_CONVERSION

#include "MantidKernel/Logger.h"
#include "MantidKernel/TimeSeriesProperty.h"

Expand All @@ -11,8 +13,11 @@
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidMDEvents/MDWSDescription.h"
#include "MantidMDEvents/MDEventWSWrapper.h"
#include "MantidMDAlgorithms/ConvertToMDEventsDetInfo.h"
#include "MantidMDAlgorithms/ConvToMDPreprocDetectors.h"

#ifdef NO_CONVERSION
#include "MantidMDAlgorithms/ConvertToMDEventsParams.h"
#endif

namespace Mantid
{
Expand Down Expand Up @@ -65,24 +70,26 @@ namespace MDAlgorithms
protected:
/// shalow class which is invoked from processQND procedure and describes the transformation from workspace coordinates to target coordinates
/// presumably will be completely inlined

#ifdef NO_CONVERSION
template<ConvertToMD::QMode Q,ConvertToMD::AnalMode MODE,ConvertToMD::CnvrtUnits CONV,ConvertToMD::XCoordType Type,ConvertToMD::SampleType Sample>
friend struct CoordTransformer;
#endif
public:
// constructor;
IConvertToMDEventsMethods();

///method which initates all main class variables
virtual size_t setUPConversion(Mantid::API::MatrixWorkspace_sptr pWS2D, const PreprocessedDetectors &detLoc,const MDEvents::MDWSDescription &WSD, boost::shared_ptr<MDEvents::MDEventWSWrapper> inWSWrapper);
virtual size_t setUPConversion(Mantid::API::MatrixWorkspace_sptr pWS2D, const ConvToMDPreprocDetectors &detLoc,const MDEvents::MDWSDescription &WSD, boost::shared_ptr<MDEvents::MDEventWSWrapper> inWSWrapper);
/// method which starts the conversion procedure
virtual void runConversion(API::Progress *)=0;
/// virtual destructor
virtual ~IConvertToMDEventsMethods(){};
/**> helper functions: To assist with units conversion done by separate class and get access to some important internal states of the subalgorithm */
Kernel::Unit_sptr getAxisUnits()const;
PreprocessedDetectors const * pPrepDetectors()const{return pDetLoc;}
double getEi()const{return TWS.Ei;}
int getEMode()const{return TWS.emode;}
ConvToMDPreprocDetectors const * pPrepDetectors()const{return pDetLoc;}

API::NumericAxis *getPAxis(int nAaxis)const{return dynamic_cast<API::NumericAxis *>(this->inWS2D->getAxis(nAaxis));}
std::vector<double> getTransfMatrix()const{return TWS.rotMatrix;}
//<------------------
Expand All @@ -97,7 +104,7 @@ namespace MDAlgorithms
//
boost::shared_ptr<MDEvents::MDEventWSWrapper> pWSWrapper ;
// pointer to the array of detector's directions in reciprocal space
PreprocessedDetectors const * pDetLoc;
ConvToMDPreprocDetectors const * pDetLoc;
/// number of target ws dimesnions
size_t n_dims;
/// array of variables which describe min limits for the target variables;
Expand All @@ -119,7 +126,7 @@ namespace MDAlgorithms

};


#ifdef NO_CONVERSION
/// Templated interface to the workspace conversion algorithm. Every template parameter refers to different conversion possibilities
template<ConvertToMD::InputWSType WS,ConvertToMD::QMode Q, ConvertToMD::AnalMode MODE, ConvertToMD::CnvrtUnits CONV,ConvertToMD::SampleType Sample>
class ConvertToMDEventsWS: public IConvertToMDEventsMethods
Expand All @@ -135,7 +142,7 @@ class ConvertToMDEventsWS: public IConvertToMDEventsMethods
/**templated virtual function to run conversion chunk */
virtual size_t conversionChunk(size_t job_ID){return 0;}
};

#endif

} // end namespace MDAlgorithms
} // end namespace Mantid
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "MantidMDAlgorithms/ConvertToMDEventsDetInfo.h"
#include "MantidMDAlgorithms/ConvToMDPreprocDetectors.h"
#include "MantidKernel/Exception.h"

using namespace Mantid::Kernel;
Expand All @@ -9,17 +9,16 @@ namespace Mantid
{
namespace MDAlgorithms
{
bool
PreprocessedDetectors::isDefined(const API::MatrixWorkspace_const_sptr &inputWS)const

bool ConvToMDPreprocDetectors::isDefined(const API::MatrixWorkspace_const_sptr &inputWS)const
{
if(det_dir.empty())return false;

if(pBaseInstr !=inputWS->getInstrument()->baseInstrument())return false;
return true;
}

void
PreprocessedDetectors::allocDetMemory(size_t nHist)
void ConvToMDPreprocDetectors::allocDetMemory(size_t nHist)
{
this->det_dir.resize(nHist);
this->det_id.resize(nHist);
Expand All @@ -33,8 +32,7 @@ PreprocessedDetectors::allocDetMemory(size_t nHist)

/** helper function, does preliminary calculations of the detectors positions to convert results into k-dE space ;
and places the resutls into static cash to be used in subsequent calls to this algorithm */
void DLLExport
processDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,PreprocessedDetectors &det_loc,Kernel::Logger& convert_log,API::Progress *pProg)
void DLLExport processDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,ConvToMDPreprocDetectors &det_loc,Kernel::Logger& convert_log,API::Progress *pProg)
{
convert_log.information()<<" Preprocessing detectors locations in a target reciprocal space\n";
//
Expand Down Expand Up @@ -113,8 +111,7 @@ processDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,PreprocessedDe
pProg->report();
}

void DLLExport
buildFakeDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,PreprocessedDetectors &det_loc)
void DLLExport buildFakeDetectorsPositions(const API::MatrixWorkspace_sptr inputWS,ConvToMDPreprocDetectors &det_loc)
{

det_loc.L1 = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cxxtest/TestSuite.h>
#include "MantidMDAlgorithms/ConvertToMDEventsUnitsConv.h"
#include "MantidMDAlgorithms/ConvertToMDEventsDetInfo.h"
#include "MantidMDAlgorithms/ConvertToMDEvents.h"
//#include "MantidMDAlgorithms/ConvertToMDEvents.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"
#include "MantidAPI/Progress.h"

Expand Down Expand Up @@ -38,7 +38,7 @@ class TestConvertToMDEventsMethods :public IConvertToMDEventsMethods
};


class ConvertToMDEventsUnitsConvTest : public CxxTest::TestSuite, public ConvertToMDEvents
class ConvertToMDEventsUnitsConvTest : public CxxTest::TestSuite
{
Mantid::API::MatrixWorkspace_sptr ws2D;
// static Mantid::Kernel::Logger &g_log;
Expand Down Expand Up @@ -80,9 +80,9 @@ void testTOFConversionFails()

void testSetUp_and_PreprocessDetectors()
{
pProg = std::auto_ptr<API::Progress >(new API::Progress(dynamic_cast<ConvertToMDEvents *>(this),0.0,1.0,4));
// pProg = std::auto_ptr<API::Progress >(new API::Progress(dynamic_cast<ConvertToMDEvents *>(this),0.0,1.0,4));

TS_ASSERT_THROWS_NOTHING(processDetectorsPositions(ws2D,det_loc,ConvertToMDEvents::getLogger(),pProg.get()));
// TS_ASSERT_THROWS_NOTHING(processDetectorsPositions(ws2D,det_loc,ConvertToMDEvents::getLogger(),pProg.get()));
TS_ASSERT_THROWS_NOTHING(pConvMethods = std::auto_ptr<TestConvertToMDEventsMethods>(new TestConvertToMDEventsMethods()));
TS_ASSERT_THROWS_NOTHING(pConvMethods->setUPTestConversion(ws2D,det_loc));

Expand Down

0 comments on commit 2dc8c40

Please sign in to comment.