-
Notifications
You must be signed in to change notification settings - Fork 122
/
ReadGroupsFromFile.h
125 lines (111 loc) · 5.08 KB
/
ReadGroupsFromFile.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
#ifndef MANTID_ALGORITHMS_READGROUPSFROMFILE_H_
#define MANTID_ALGORITHMS_READGROUPSFROMFILE_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include <unordered_map>
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/Workspace2D.h"
namespace Mantid {
namespace Algorithms {
/** Read a diffraction calibration file (*.cal) and an instrument name, and
output a 2D workspace
* containing on the Y-axis the values of the Group each detector belongs to.
* This is used to visualise the grouping scheme for powder diffractometers,
where a large number of detectors
* are grouped together. The output 2D workspace can be visualize using the show
instrument method.
* The format of the *.cal file is as follows:
*
* # Format:
* number UDET offset select group
* 0 611 0.0000000 1 0
* 1 612 0.0000000 1 0
* 2 601 0.0000000 0 0
* 3 602 0.0000000 0 0
* 4 621 0.0000000 1 0
* The first column is simply an index, the second is a UDET identifier for
the detector,
* the third column corresponds to an offset in Deltad/d (not applied, usually
applied using
* the AlignDetectors algorithm). The forth column is a flag to indicate
whether the detector
* is selected. The fifth column indicates the group this detector belongs to
(number >=1),
* zero is not considered as a group.
* Required Properties:
* <UL>
* <LI> InstrumentName - The name of the instrument. Needs to be present in
the store </LI>
* <LI> GroupingFilename - The name of the output file (*.cal extension) </LI>
* <LI> ShowUnselected - Option (true or false) to consider unselected
detectors in the cal file </LI>
* <LI> OuputWorkspace - The name of the output 2D Workspace containing the
group information </LI>
* </UL>
@author Laurent Chapon, ISIS Facility, Rutherford Appleton Laboratory
@date 09/03/2009
Copyright © 2009 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 ReadGroupsFromFile : public API::Algorithm {
public:
/// (Empty) Constructor
ReadGroupsFromFile();
/// Algorithm's name
const std::string name() const override { return "ReadGroupsFromFile"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Read a diffraction calibration file (*.cal) or an XML grouping "
"file (*.xml) and an instrument name, and output a 2D workspace "
"containing on the Y-axis the values of the Group each detector "
"belongs to. This is used to visualise the grouping scheme for "
"powder diffractometers, where a large number of detectors are "
"grouped together. The output 2D workspace can be visualize using "
"the show instrument method.";
}
/// Algorithm's version
int version() const override { return (1); }
/// Algorithm's category for identification
const std::string category() const override {
return "Diffraction\\DataHandling\\CalFiles";
}
private:
/// Map containing the detector entries found in the *.cal file. The key is
/// the udet number, the value of is a pair of <group,selected>.
typedef std::unordered_map<int, std::pair<int, int>> calmap;
/// Initialisation code
void init() override;
/// Execution code
void exec() override;
/// Read a grouping file and construct the calibration map
void readGroupingFile(const std::string &filename);
/// Read an XML Grouping File
void readXMLGroupingFile(const std::string &filename);
/// Child Algorithm to Load the associated empty instrument
/// @param instrument_xml_name :: The instrument xml name including
/// extension(.xml or .XML) but no path
/// this is determine by the mantid instrument.directory
/// @return Shared pointer to the 2D workspace
DataObjects::Workspace2D_sptr
loadEmptyInstrument(const std::string &instrument_xml_name);
/// Calibration map containing the detector entries found in the *.cal file.
/// The key is the udet number, the value of is a pair of <group,selected>.
calmap calibration;
};
} // namespace Algorithms
} // namespace Mantid
#endif /*MANTID_ALGORITHMS_READGROUPFROMFILES*/