Skip to content

Commit

Permalink
refs #6053 This should fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Dec 4, 2012
1 parent 0c64450 commit 4df6eaa
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Mantid
void setMin(double min);
void setMax(double max);
void setNumBins(size_t nbins);

size_t getNumBins()const{return m_nbins;}
MDHistoDimension* createRaw();
IMDDimension_sptr create();
MDHistoDimensionBuilder(const MDHistoDimensionBuilder&);
Expand Down
50 changes: 31 additions & 19 deletions Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/Progress.h"
#include "MantidMDEvents/MDEventFactory.h"
#include "MantidGeometry/MDGeometry/MDHistoDimensionBuilder.h"
#include <fstream>
#include <string>

Expand Down Expand Up @@ -38,14 +39,16 @@ namespace MDAlgorithms
std::streamoff npax_start;
std::streamoff s_start;
std::streamoff err_start;
std::streamoff n_cell_pix_start;
std::streamoff n_cell_pix_start; // where data.npix array starts
std::streamoff min_max_start; // data range positions (uRange -- this is the data which describe the extents of the MDPixesl (events))
std::streamoff pix_start; //< event data positions
size_t mdImageSize; //< the variable describes the size of Horace MD image (number of pixels in Horace DND object or number of bins in Mantid Histo workspace)

/// Default Constructor
dataPositions():if_sqw_start(18),n_dims_start(22),sqw_header_start(26),
detectors_start(0),data_start(0),geom_start(0),s_start(0), // the following values have to be identified from the file itself
err_start(0),
n_cell_pix_start(0),min_max_start(0),pix_start(0){}; // the following values have to be identified from the file itself
n_cell_pix_start(0),min_max_start(0),pix_start(0),mdImageSize(0){}; // the following values have to be identified from the file itself

// the helper methods
///Block 1: Main_header: Parse SQW main data header
Expand All @@ -56,7 +59,7 @@ namespace MDAlgorithms
std::streamoff parse_sqw_detpar(std::ifstream &stream,std::streamoff start_location); //Legacy - candidate for removal
///Block 4: Data: parse positions of the data fields
void parse_data_locations(std::ifstream &stream,std::streamoff data_start,
std::vector<size_t> &nBins,size_t &nDims,size_t &mdImageSize,uint64_t &nDataPoints); //Legacy - candidate for removal
std::vector<size_t> &nBins,size_t &nDims,uint64_t &nDataPoints); //Legacy - candidate for removal

};
}
Expand All @@ -73,24 +76,38 @@ namespace MDAlgorithms
virtual int version() const { return 1;};
/// Algorithm's category for identification
virtual const std::string category() const { return "DataHandling;MDAlgorithms";}

protected:

private:
/// Sets documentation strings for this algorithm
virtual void initDocs();
void init();
void exec();

protected: // for testing

/// Read events onto the workspace.
virtual void readEvents(Mantid::MDEvents::MDEventWorkspace<MDEvents::MDEvent<4>,4>* ws);

/// Read dimensions onto the workspace.
virtual void readDNDDimensions(Mantid::MDEvents::MDEventWorkspace<MDEvents::MDEvent<4>,4>* ws);

/// Read dimensions onto the workspace.
virtual void readSQWDimensions(Mantid::MDEvents::MDEventWorkspace<MDEvents::MDEvent<4>,4>* ws);
/// Read DND dimensions.
void readDNDDimensions(std::vector<Mantid::Geometry::MDHistoDimensionBuilder> &DimVectorOut,bool arrangeByMDImage=true);
/// Read SQW dimensions
void readSQWDimensions(std::vector<Mantid::Geometry::MDHistoDimensionBuilder> &DimVectorOut);

/// Extract lattice information
virtual void addLattice(Mantid::MDEvents::MDEventWorkspace<MDEvents::MDEvent<4>,4>* ws);

/// Parse metadata from file.
void parseMetadata(); // New controlling function over legacy ones.

void parseMetadata(const std::string &fileName); // New controlling function over legacy ones.
/// build an initial range of 4 dimensions
void buildMDDimsBase(std::vector<Mantid::Geometry::MDHistoDimensionBuilder> &DimVector);
/// add range of dimensions to the workspace;
void addDimsToWs(Mantid::MDEvents::MDEventWorkspace<MDEvents::MDEvent<4>,4>* ws,std::vector<Mantid::Geometry::MDHistoDimensionBuilder> &DimVector);

/// read real box sizes for all Horace Boxes;
void readBoxSizes();

/// the name of the file to work with
std::string m_fileName;
/// File stream containing binary file data.
std::ifstream m_fileStream;

Expand All @@ -99,16 +116,11 @@ namespace MDAlgorithms

/// OutputFilename param
std::string m_outputFile;

private:
/// Sets documentation strings for this algorithm
virtual void initDocs();
void init();
void exec();

protected: // for testing
/// Instance of helper type, which describes the positions of the data within binary Horace file
LoadSQWHelper::dataPositions m_dataPositions;
// the array of horace boxe sizes;
std::vector<uint64_t> m_boxSizes;

uint64_t m_nDataPoints;
size_t m_mdImageSize;
Expand Down

0 comments on commit 4df6eaa

Please sign in to comment.