Skip to content

Commit

Permalink
WIP Define LoadSQW2 as a file loader algorithm.
Browse files Browse the repository at this point in the history
Refs #11056
  • Loading branch information
martyngigg committed Dec 11, 2015
1 parent 0bf2d6b commit 4cf729a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef MANTID_MDALGORITHMS_LOADSQW2_H_
#define MANTID_MDALGORITHMS_LOADSQW2_H_

#include "MantidAPI/Algorithm.h"
#include "MantidAPI/IFileLoader.h"
#include "MantidDataObjects/MDEvent.h"
#include "MantidDataObjects/MDEventWorkspace.h"
#include "MantidKernel/BinaryStreamReader.h"
Expand Down Expand Up @@ -41,7 +41,7 @@ namespace MDAlgorithms {
* File change history is stored at: <https://github.com/mantidproject/mantid>
* Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadSQW2 : public API::Algorithm {
class DLLExport LoadSQW2 : public API::IFileLoader<Kernel::FileDescriptor> {
public:
LoadSQW2();
~LoadSQW2();
Expand All @@ -50,6 +50,7 @@ class DLLExport LoadSQW2 : public API::Algorithm {
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;
virtual int confidence(Kernel::FileDescriptor &descriptor) const;

private:
/// Local typedef for
Expand Down
27 changes: 24 additions & 3 deletions Framework/MDAlgorithms/src/LoadSQW2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "MantidAPI/FileProperty.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/RegisterFileLoader.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidGeometry/Instrument/Goniometer.h"
#include "MantidGeometry/MDGeometry/MDHistoDimension.h"
Expand Down Expand Up @@ -34,14 +35,15 @@ using Kernel::V3D;
constexpr int64_t NPIX_CHUNK = 150000;

// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(LoadSQW2)
DECLARE_FILELOADER_ALGORITHM(LoadSQW2)

//------------------------------------------------------------------------------
// Public methods
//------------------------------------------------------------------------------
/// Default constructor
LoadSQW2::LoadSQW2()
: API::Algorithm(), m_file(), m_reader(), m_outputWS(), m_progress() {}
: API::IFileLoader<Kernel::FileDescriptor>(), m_file(), m_reader(),
m_outputWS(), m_progress() {}

/// Default destructor
LoadSQW2::~LoadSQW2() {}
Expand All @@ -64,6 +66,26 @@ const std::string LoadSQW2::summary() const {
"Horace.";
}

/**
* Return the confidence with this algorithm can load the file
* @param descriptor A descriptor for the file
* @returns An integer specifying the confidence level. 0 indicates it will not
* be used
*/
int LoadSQW2::confidence(Kernel::FileDescriptor &descriptor) const {
// only .sqw can be considered
const std::string &extn = descriptor.extension();
if (extn.compare(".sqw") != 0)
return 0;

if (descriptor.isAscii()) {
// Low so that others may try
return 10;
}
// Beat v1
return 81;
}

//------------------------------------------------------------------------------
// Private methods
//------------------------------------------------------------------------------
Expand Down Expand Up @@ -441,7 +463,6 @@ void LoadSQW2::addEventFromBuffer(const float *pixel) {
m_outputWS->addEvent(MDEvent<4>(signal, error * error, irun, idet, centres));
}


/**
* Transform the given coordinates from U to the HKL frame
* using the transformation defined for the given run
Expand Down

0 comments on commit 4cf729a

Please sign in to comment.