Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/8365_ILL_D2B'
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Jul 1, 2014
2 parents da00765 + f4f5f77 commit dd3ce04
Show file tree
Hide file tree
Showing 13 changed files with 13,018 additions and 1 deletion.
Expand Up @@ -70,6 +70,9 @@ class MANTID_GEOMETRY_DLL CompAssembly : public ICompAssembly, public Component
//! Add a component to the assembly
int add(IComponent*);
//! Add a copy (clone) of a component

void addChildren(IComponent* comp);

int addCopy(IComponent*);
//! Add a copy (clone) of a component and rename it
int addCopy(IComponent*, const std::string&);
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Geometry/src/Instrument/Component.cpp
Expand Up @@ -88,6 +88,9 @@ namespace Geometry
*/
IComponent* Component::clone() const
{
// TODO : overload to copy the new pmap
// Create a new one with pmap parameter
/// if pmap not present throw
return new Component(*this);
}

Expand Down
Expand Up @@ -243,7 +243,6 @@ class ParametrizedComponentTest : public CxxTest::TestSuite
m_paramMap->add("string", m_childTwoComp, m_strName + "_child2", m_strValue + "_child2");
}


void cleanUpComponent()
{
delete m_parentComp;
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/MDAlgorithms/CMakeLists.txt
Expand Up @@ -35,6 +35,8 @@ set ( SRC_FILES
src/LoadMD.cpp
src/LoadSQW.cpp
src/LogarithmMD.cpp
src/LoadILLAscii.cpp
src/LoadILLAsciiHelper.cpp
src/MaskMD.cpp
src/MergeMD.cpp
src/MergeMDFiles.cpp
Expand Down Expand Up @@ -113,6 +115,8 @@ set ( INC_FILES
inc/MantidMDAlgorithms/LoadMD.h
inc/MantidMDAlgorithms/LoadSQW.h
inc/MantidMDAlgorithms/LogarithmMD.h
inc/MantidMDAlgorithms/LoadILLAscii.h
inc/MantidMDAlgorithms/LoadILLAsciiHelper.h
inc/MantidMDAlgorithms/MaskMD.h
inc/MantidMDAlgorithms/MergeMD.h
inc/MantidMDAlgorithms/MergeMDFiles.h
Expand Down Expand Up @@ -192,6 +196,7 @@ set ( TEST_FILES
LoadMDTest.h
LoadSQWTest.h
LogarithmMDTest.h
LoadILLAsciiTest.h
MDResolutionConvolutionFactoryTest.h
MaskMDTest.h
MergeMDFilesTest.h
Expand Down
@@ -0,0 +1,72 @@
#ifndef MANTID_MDALGORITHMS_LOADILLASCII_H_
#define MANTID_MDALGORITHMS_LOADILLASCII_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"

#include "MantidMDAlgorithms/LoadILLAsciiHelper.h"
#include "MantidAPI/IFileLoader.h"
#include "MantidAPI/IMDEventWorkspace.h"

namespace Mantid {
namespace MDAlgorithms {

/** LoadILLAscii :
This loader loads ILL data in Ascii format.
For more details on data format, please see:
<http://www.ill.eu/instruments-support/computing-for-science/data-analysis/raw-data/>
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport LoadILLAscii: public API::IFileLoader<Kernel::FileDescriptor> {
public:
LoadILLAscii();
virtual ~LoadILLAscii();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;
/// Returns a confidence value that this algorithm can load a file
virtual int confidence(Kernel::FileDescriptor & descriptor) const;


private:
void init();
void exec();
void loadInstrumentName(ILLParser &);
void loadExperimentDetails(ILLParser &p);
void loadIDF(API::MatrixWorkspace_sptr &workspace);
void loadsDataIntoTheWS(API::MatrixWorkspace_sptr &, const std::vector<int> &);
API::IMDEventWorkspace_sptr mergeWorkspaces(std::vector<API::MatrixWorkspace_sptr> &);
void setWorkspaceRotationAngle(API::MatrixWorkspace_sptr, double rotationAngle);

//LoadHelper m_loader;
std::string m_instrumentName; ///< Name of the instrument
double m_wavelength;
std::vector<std::string> m_supportedInstruments;
};

} // namespace MDAlgorithms
} // namespace Mantid

#endif /* MANTID_MDALGORITHMS_LOADILLASCII_H_ */
@@ -0,0 +1,90 @@
#ifndef MANTID_MDALGORITHMS_LOADILLASCIIHELPER_H_
#define MANTID_MDALGORITHMS_LOADILLASCIIHELPER_H_

#include "MantidMDAlgorithms/DllConfig.h"

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>

namespace Mantid {
namespace MDAlgorithms {

/** LoadILLAsciiHelper :
This parses ILL data in Ascii format.
For more details on data format, please see:
<http://www.ill.eu/instruments-support/computing-for-science/data-analysis/raw-data/>
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/

class ILLParser {
public:
ILLParser(const std::string &filename);
virtual ~ILLParser();
void parse();
void showHeader();
std::string getInstrumentName();

// Those are large vectors: returning references => no copy constructors
// std::vector< std::vector<int> > & getSpectraList() {return spectraList;}
// std::vector<std::map<std::string, std::string> > & getSpectraHeaderList() {return spectraHeaders;}
// No difference in running times :(

std::vector< std::vector<int> > getSpectraList() const {return spectraList;}
std::vector<std::map<std::string, std::string> > getSpectraHeaderList() const {return spectraHeaders;}

template<typename T> T getValueFromHeader(const std::string &);
template<typename T> T getValue(const std::string &, const std::map<std::string, std::string> &);
private:
void parseFieldR();
void parseFieldA();
void parseFieldNumeric(std::map<std::string, std::string> &header,
int fieldWith);
std::vector<int> parseFieldISpec(int fieldWith = intWith);

void startParseSpectra();
std::vector<std::string> splitLineInFixedWithFields(const std::string &s,
int fieldWidth, int lineWitdh = lineWith);

template<typename T> T evaluate(std::string field);

static const int lineWith = 80;
static const int intWith = 8;
static const int floatWith = 16;

std::ifstream fin;
// Not great, but to date there's 3 containers:
std::map<std::string, std::string> header; // file global header
std::vector<std::map<std::string, std::string> > spectraHeaders; // list with every spectrum header
std::vector<std::vector<int> > spectraList; // same size list but with spectra contents

};

}
// namespace MDAlgorithms
}// namespace Mantid

#endif /* MANTID_MDALGORITHMS_LOADILLASCIIHELPER_H_ */

0 comments on commit dd3ce04

Please sign in to comment.