-
Notifications
You must be signed in to change notification settings - Fork 122
/
ReadGroupsFromFile.h
109 lines (102 loc) · 4.61 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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2009 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Algorithm.h"
#include "MantidAlgorithms/DllConfig.h"
#include "MantidDataObjects/Workspace2D.h"
#include <unordered_map>
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
*/
class MANTID_ALGORITHMS_DLL 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); }
const std::vector<std::string> seeAlso() const override {
return {"CreateDummyCalFile", "CreateCalFileByNames", "AlignDetectors", "DiffractionFocussing",
"LoadCalFile", "SaveCalFile", "MergeCalFiles"};
}
/// 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>.
using calmap = std::unordered_map<int, std::pair<int, int>>;
/// 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