Skip to content

Commit

Permalink
refs #4401 Additional piece of code enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 25, 2012
1 parent 3264ec3 commit 7315ed7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 25 deletions.
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ set ( INC_FILES
inc/MantidMDAlgorithms/CompositeImplicitFunctionParser.h
inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h
# inc/MantidMDAlgorithms/ConvertToMDEvents.h
# inc/MantidMDAlgorithms/ConvertToMDEventsEventWS.h
# inc/MantidMDAlgorithms/ConvertToMDEventsHistoWS.h
inc/MantidMDAlgorithms/ConvertToMDEventsEventWS.h
inc/MantidMDAlgorithms/ConvertToMDEventsHistoWS.h
inc/MantidMDAlgorithms/ConvertToMDEventsParams.h
inc/MantidMDAlgorithms/ConvertToMDEventsSubalgFactory.h
inc/MantidMDAlgorithms/ConvertToMDEventsTransfInterface.h
Expand Down Expand Up @@ -119,7 +119,7 @@ set ( TEST_FILES
# test/ConvertToDetectorFaceMDTest.h
# test/ConvertEventsToMDEventsTest.h
# test/ConvertToMDEventsCoordTransfTest.h
# test/ConvertToMDEventsMethodsTest.h
# test/ConvertToMDEventsWSTest.h
test/ConvertToMDEventsParamsTest.h
test/ConvertToMDEventsSubalgFactoryTest.h
# test/ConvertToMDEventsTest.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ConvertToMDEventsWS<ConvertToMD::EventWSType,Q,MODE,CONV,Sample>: public I
size_t setUPConversion(Mantid::API::MatrixWorkspace_sptr pWS2D, const ConvToMDPreprocDetectors &detLoc,
const MDEvents::MDWSDescription &WSD, boost::shared_ptr<MDEvents::MDEventWSWrapper> inWSWrapper)
{
size_t numSpec=IConvertToMDEventsMethods::setUPConversion(pWS2D,detLoc,WSD,inWSWrapper);
size_t numSpec=IConvertToMDEventsWS::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 @@ -58,23 +58,26 @@ namespace MDAlgorithms
//-----------------------------------------------
// Method to process rugged Histogram workspace
template<ConvertToMD::QMode Q, ConvertToMD::AnalMode MODE, ConvertToMD::CnvrtUnits CONV,ConvertToMD::SampleType Sample>
class ConvertToMDEventsWS<ConvertToMD::Ws2DHistoType,Q,MODE,CONV,Sample>: public IConvertToMDEventsMethods
class ConvertToMDEventsWS<ConvertToMD::Ws2DHistoType,Q,MODE,CONV,Sample>: public IConvertToMDEventsWS
{
/// shalow class which is invoked from processQND procedure and describes the transformation from workspace coordinates to target coordinates
/// presumably will be completely inlined
template<ConvertToMD::QMode XQ,ConvertToMD::AnalMode XM,ConvertToMD::CnvrtUnits XC,ConvertToMD::XCoordType XT,ConvertToMD::SampleType XS>
friend struct CoordTransformer;
// the instanciation of the class which does the transformation itself
CoordTransformer<Q,MODE,CONV,ConvertToMD::Histogram,Sample> trn;

// the instanciation of the class which does the transformation itself
CoordTransformer<Q,MODE,CONV,ConvertToMD::Histogram,Sample> QE_TRANSF;
//

// not yet parallel
virtual size_t conversionChunk(size_t job_ID){UNUSED_ARG(job_ID); return 0;}
public:
size_t setUPConversion(Mantid::API::MatrixWorkspace_sptr pWS2D, const ConvToMDPreprocDetectors &detLoc,
const MDEvents::MDWSDescription &WSD, boost::shared_ptr<MDEvents::MDEventWSWrapper> inWSWrapper)
{
size_t numSpec=IConvertToMDEventsMethods::setUPConversion(pWS2D,detLoc,WSD,inWSWrapper);
size_t numSpec=IConvertToMDEventsWS::setUPConversion(pWS2D,detLoc,WSD,inWSWrapper);
// initiate the templated class which does the conversion of workspace data into MD WS coordinates;
trn.setUpTransf(this);
QE_TRANSF.setUpTransf(this);

return numSpec;
}
Expand All @@ -94,7 +97,7 @@ class ConvertToMDEventsWS<ConvertToMD::Ws2DHistoType,Q,MODE,CONV,Sample>: public
// number of dimesnions
std::vector<coord_t> Coord(n_dims); // coordinates for single event
// if any property dimension is outside of the data range requested, the job is done;
if(!trn.calcGenericVariables(Coord,n_dims))return;
if(!QE_TRANSF.calcGenericVariables(Coord,n_dims))return;

// take at least bufSize amout of data in one run for efficiency
size_t buf_size = ((specSize>SPLIT_LEVEL)?specSize:SPLIT_LEVEL);
Expand All @@ -119,15 +122,15 @@ class ConvertToMDEventsWS<ConvertToMD::Ws2DHistoType,Q,MODE,CONV,Sample>: public
const MantidVec& Error = inWS2D->readE(iSpctr);

// calculate the coordinates which depend on detector posision
if(!trn.calcYDepCoordinates(Coord,i))continue; // skip y outsize of the range;
if(!QE_TRANSF.calcYDepCoordinates(Coord,i))continue; // skip y outsize of the range;

//=> START INTERNAL LOOP OVER THE "TIME"
for (size_t j = 0; j < specSize; ++j)
{
// drop emtpy events
if(Signal[j]<FLT_EPSILON)continue;

if(!trn.calcMatrixCoord(X,i,j,Coord))continue; // skip ND outside the range
if(!QE_TRANSF.calcMatrixCoord(X,i,j,Coord))continue; // skip ND outside the range
// ADD RESULTING EVENTS TO THE BUFFER
float ErrSq = float(Error[j]*Error[j]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef H_CONVERT_TO_MDEVENTS_TRANSF_INTERFACE
#define H_CONVERT_TO_MDEVENTS_TRANSF_INTERFACE
//
#include "MantidMDAlgorithms/IConvertToMDEventsMethods.h"
#include "MantidMDAlgorithms/ConvertToMDEventsParams.h"
#include "MantidMDAlgorithms/ConvertToMDEventsUnitsConv.h"
//
namespace Mantid
Expand Down Expand Up @@ -46,7 +46,7 @@ namespace MDAlgorithms
*/

template<ConvertToMD::QMode Q,ConvertToMD::AnalMode MODE,ConvertToMD::CnvrtUnits CONV,ConvertToMD::XCoordType TYPE,ConvertToMD::SampleType Sample>
struct CoordTramsformer
struct CoordTransformer
{

/**Template defines common interface to common part of the algorithm, where all variables
Expand All @@ -60,7 +60,7 @@ struct CoordTramsformer
* @return true -- if all Coord are within the range requested by algorithm. false otherwise
*
* has to be specialized
*/
*/
bool calcGenericVariables(std::vector<coord_t> &Coord, size_t n_ws_variabes)
{
return false;
Expand All @@ -76,7 +76,8 @@ struct CoordTramsformer
*
* some default implementations possible (e.g mode Q3D,ragged Any_Mode( Direct, indirect,elastic),
*/
bool calcYDepCoordinatese(std::vector<coord_t> &Coord,size_t i)
//calcYDepCoordinates
bool calcYDepCoordinates(std::vector<coord_t> &Coord,size_t i)
{
return false;
}
Expand All @@ -90,6 +91,7 @@ struct CoordTramsformer
*
* has to be specialized
*/
//calcMatrixCoord(X,i,j,Coord)
bool calcMatrixCoord(const MantidVec& X,size_t i,size_t j,std::vector<coord_t> &Coord)const
{
return false;
Expand Down Expand Up @@ -120,7 +122,7 @@ struct CoordTramsformer
}
/** set up transformation and retrieve the pointer to the incorporating class, which runs the transformation and provides
* necessary variables */
void setUpTransf(IConvertToMDEventsMethods *){};
void setUpTransf(IConvertToMDEventsWS *){};

private:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "MantidMDAlgorithms/ConvertToMDEventsSubalgFactory.h"
//#include "MantidMDAlgorithms/ConvertToMDEventsHistoWS.h"
#include "MantidMDAlgorithms/ConvertToMDEventsHistoWS.h"
//#include "MantidMDAlgorithms/ConvertToMDEventsEventWS.h"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ using namespace Mantid::MDAlgorithms::ConvertToMD;
//};


class ConvertToMDEventsMethodsTest : public CxxTest::TestSuite, public ConvertToMDEvents
class ConvertToMDEventsWSTest : public CxxTest::TestSuite, public ConvertToMDEvents
{
Mantid::API::MatrixWorkspace_sptr ws2D;
Mantid::API::MatrixWorkspace_sptr ws_events;
Expand All @@ -70,17 +70,17 @@ class ConvertToMDEventsMethodsTest : public CxxTest::TestSuite, public ConvertTo
MDEvents::MDWSDescription TestWS;

public:
static ConvertToMDEventsMethodsTest *createSuite() {
return new ConvertToMDEventsMethodsTest();
static ConvertToMDEventsWSTest *createSuite() {
return new ConvertToMDEventsWSTest();
}
static void destroySuite(ConvertToMDEventsMethodsTest * suite) { delete suite; }
static void destroySuite(ConvertToMDEventsWSTest * suite) { delete suite; }

void testSetUp_and_PreprocessDetectors()
{
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(pConvMethods = std::auto_ptr<TestConvertToMDEventsMethods>(new TestConvertToMDEventsMethods()));
TS_ASSERT_THROWS_NOTHING(pConvMethods = std::auto_ptr<TestConvertToMDEventsWS>(new TestConvertToMDEventsWS()));
TS_ASSERT_THROWS_NOTHING(pConvMethods->setUPTestConversion(ws2D,det_loc));

}
Expand Down Expand Up @@ -211,7 +211,7 @@ void test_compareTwoBuilds()
}

// constructor:
ConvertToMDEventsMethodsTest ():TestWS(4){
ConvertToMDEventsWSTest ():TestWS(4){

std::vector<double> L2(5,5);
std::vector<double> polar(5,(30./180.)*3.1415926);
Expand Down Expand Up @@ -239,7 +239,7 @@ ConvertToMDEventsMethodsTest ():TestWS(4){

}
// function repeats convert to events algorithm which for some mysterious reasons do not work here as subalgorithm.
EventWorkspace_sptr convertToEvents(DataObjects::Workspace2D_const_sptr inWS,const IConvertToMDEventsMethods &conv,bool GenerateMultipleEvents=false,int MaxEventsPerBin=10){
EventWorkspace_sptr convertToEvents(DataObjects::Workspace2D_const_sptr inWS,const IConvertToMDEventsWS &conv,bool GenerateMultipleEvents=false,int MaxEventsPerBin=10){

// set up conversion to Time of flight
UnitsConverter<ConvByTOF,Centered> TOFCONV;
Expand Down

0 comments on commit 7315ed7

Please sign in to comment.