Skip to content

Commit

Permalink
WIP Skip the detector paramter block
Browse files Browse the repository at this point in the history
Refs #11056
  • Loading branch information
martyngigg committed Dec 7, 2015
1 parent d8c64b0 commit df5e621
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DLLExport LoadSQW2 : public API::Algorithm {
virtual const std::string category() const;
virtual const std::string summary() const;

void skipDetectorData();
private:
/// Local typedef for
typedef DataObjects::MDEventWorkspace<DataObjects::MDEvent<4>, 4>
Expand All @@ -64,7 +65,7 @@ class DLLExport LoadSQW2 : public API::Algorithm {
void exec();
void initFileReader();
SQWHeader readMainHeader();
void readAllSPEHeaders(const int32_t nfiles);
void readAllSPEHeadersToWorkspace(const int32_t nfiles);
void readSingleSPEHeader(API::ExperimentInfo &experiment);
void createOutputWorkspace();

Expand Down
31 changes: 26 additions & 5 deletions Framework/MDAlgorithms/src/LoadSQW2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void LoadSQW2::exec() {
initFileReader();
auto mainHeader = readMainHeader();
createOutputWorkspace();
readAllSPEHeaders(mainHeader.nfiles);
readAllSPEHeadersToWorkspace(mainHeader.nfiles);
skipDetectorData();

setProperty("OutputWorkspace", m_outputWS);
}
Expand Down Expand Up @@ -112,12 +113,17 @@ LoadSQW2::SQWHeader LoadSQW2::readMainHeader() {
return header;
}

/// Create the output workspace object
void LoadSQW2::createOutputWorkspace() {
m_outputWS = boost::make_shared<SQWWorkspace>();
}

/**
* Read all of the SPE headers and fill in the experiment details on the
* output workspace
* @param nfiles The number of expected spe header sections
*/
void LoadSQW2::readAllSPEHeaders(const int32_t nfiles) {
void LoadSQW2::readAllSPEHeadersToWorkspace(const int32_t nfiles) {
for (int32_t i = 0; i < nfiles; ++i) {
auto expt = boost::make_shared<ExperimentInfo>();
readSingleSPEHeader(*expt);
Expand Down Expand Up @@ -201,12 +207,27 @@ void LoadSQW2::readSingleSPEHeader(API::ExperimentInfo &experiment) {
m_file->seekg(96, std::ios_base::cur);
std::vector<int32_t> ulabel_shape(2);
m_reader->read(ulabel_shape, 2);
// shape[0]*shape[1]*sizeof(char)
m_file->seekg(ulabel_shape[0] * ulabel_shape[1], std::ios_base::cur);
}

/// Create the output workspace object
void LoadSQW2::createOutputWorkspace() {
m_outputWS = boost::make_shared<SQWWorkspace>();
/**
* Skip the data in the detector section. The size is based on the number
* of contribution detector parameters
*/
void LoadSQW2::skipDetectorData() {
std::string filename, filepath;
*m_reader >> filename >> filepath;
int32_t ndet(0);
*m_reader >> ndet;
if (g_log.is(Logger::Priority::PRIO_DEBUG)) {
std::stringstream os;
os << "Skipping " << ndet << " detector parameters from '" << filename
<< "'\n";
g_log.debug(os.str());
}
// 6 float fields all ndet long - group, x2, phi, azim, width, height
m_file->seekg(6 * 4 * ndet);
}

} // namespace MDAlgorithms
Expand Down

0 comments on commit df5e621

Please sign in to comment.