/
LoadFullprofResolution.h
176 lines (137 loc) · 6.84 KB
/
LoadFullprofResolution.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#ifndef MANTID_DATAHANDLING_LOADFULLPROFRESOLUTION_H_
#define MANTID_DATAHANDLING_LOADFULLPROFRESOLUTION_H_
#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/TableWorkspace.h"
namespace Poco {
namespace XML {
class Document;
class Element;
}
}
namespace Mantid {
namespace DataHandling {
/** LoadFullprofResolution : Load Fullprof resolution (.irf) file to
TableWorkspace(s)
Copyright © 2013 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
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 LoadFullprofResolution : public API::Algorithm {
public:
LoadFullprofResolution();
~LoadFullprofResolution() override;
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "LoadFullprofResolution"; }
/// Algorithm's version for identification overriding a virtual method
int version() const override { return 1; }
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override {
return "Diffraction\\DataHandling";
}
/// Summary of algorithms purpose
const std::string summary() const override {
return "Load Fullprof's resolution (.irf) file to one or multiple "
"TableWorkspace(s) and/or where this is supported."
" See description section, translate fullprof resolution fitting "
"parameter into Mantid equivalent fitting parameters.";
}
/// Get row numbers of the parameters in the table workspace
static void getTableRowNumbers(const API::ITableWorkspace_sptr &tablews,
std::map<std::string, size_t> ¶mmap);
/// Put parameters into a matrix workspace
static void putParametersIntoWorkspace(const API::Column_const_sptr,
API::MatrixWorkspace_sptr ws,
int nProf,
std::string ¶meterXMLString);
/// Add an Ikeda-Carpenter PV ALFBE parameter
static void addALFBEParameter(const API::Column_const_sptr,
Poco::XML::Document *mDoc,
Poco::XML::Element *parent,
const std::string ¶mName);
/// Add set of Ikeda-Carpenter PV Sigma parameters
static void addSigmaParameters(const API::Column_const_sptr,
Poco::XML::Document *mDoc,
Poco::XML::Element *parent);
/// Add set of Ikeda-Carpenter PV Gamma parameters
static void addGammaParameters(const API::Column_const_sptr,
Poco::XML::Document *mDoc,
Poco::XML::Element *parent);
/// Add set of BackToBackExponential S parameters
static void addBBX_S_Parameters(const API::Column_const_sptr,
Poco::XML::Document *mDoc,
Poco::XML::Element *parent);
/// Add set of BackToBackExponential A parameters
static void addBBX_A_Parameters(const API::Column_const_sptr,
Poco::XML::Document *mDoc,
Poco::XML::Element *parent);
/// Add set of BackToBackExponential B parameters
static void addBBX_B_Parameters(const API::Column_const_sptr,
Poco::XML::Document *mDoc,
Poco::XML::Element *parent);
/// Get value for XML eq attribute for parameter
static std::string getXMLEqValue(const API::Column_const_sptr,
const std::string &name);
/// Get value for XML eq attribute for squared parameter
static std::string getXMLSquaredEqValue(const API::Column_const_sptr column,
const std::string &name);
// Translate a parameter name from as it appears in the table workspace to its
// name in the XML file
static std::string getXMLParameterName(const std::string &name);
/// Create Bank to Workspace Correspondence
static void createBankToWorkspaceMap(const std::vector<int> &banks,
const std::vector<int> &workspaces,
std::map<int, size_t> &workspaceOfBank);
/// Place to store the row numbers
static std::map<std::string, size_t> m_rowNumbers;
private:
/// Implement abstract Algorithm methods
void init() override;
/// Implement abstract Algorithm methods
void exec() override;
/// Load file to a vector of strings
void loadFile(std::string filename, std::vector<std::string> &lines);
/// Get the NPROF number
int getProfNumber(const std::vector<std::string> &lines);
/// Scan imported file for bank information
void scanBanks(const std::vector<std::string> &lines,
const bool useFileBankIDs, std::vector<int> &banks,
std::map<int, int> &bankstartindexmap,
std::map<int, int> &bankendindexmap);
/// Parse .irf file to a map
void parseResolutionStrings(std::map<std::string, double> ¶mmap,
const std::vector<std::string> &lines,
const bool useFileBankIDs, int bankid,
int startlineindex, int endlineindex,
int profNumber);
void parseBankLine(std::string line, double &cwl, int &bankid);
/// Search token for profile number
int searchProfile();
/// Parse 1 bank of lines of profile 9
void parseProfile9();
/// Parse 1 bank of lines of profile 10
void parseProfile10();
/// Generate output workspace
DataObjects::TableWorkspace_sptr
genTableWorkspace(std::map<int, std::map<std::string, double>> bankparammap);
///// Generate bank information workspace
// DataObjects::TableWorkspace_sptr
// genInfoTableWorkspace(std::vector<int> banks);
// const std::vector<int> &workspaces,
// std::map<int, size_t> &WorkpsaceOfBank);
};
} // namespace DataHandling
} // namespace Mantid
#endif /* MANTID_DATAHANDLING_LOADFULLPROFRESOLUTION_H_ */