-
Notifications
You must be signed in to change notification settings - Fork 122
/
LoadMask.h
133 lines (107 loc) · 4.32 KB
/
LoadMask.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
#ifndef MANTID_DATAHANDLING_LOADMASK_H_
#define MANTID_DATAHANDLING_LOADMASK_H_
#include "MantidKernel/System.h"
#include "MantidAPI/ParallelAlgorithm.h"
#include "MantidAPI/MatrixWorkspace_fwd.h"
#include "MantidDataObjects/MaskWorkspace.h"
#include "MantidGeometry/IDTypes.h"
#include <Poco/AutoPtr.h>
#include <Poco/DOM/Document.h>
namespace Poco {
namespace XML {
class Document;
class Element;
}
}
namespace Mantid {
namespace DataHandling {
/** LoadMask : Load masking file to generate a SpecialWorkspace2D object
(masking workspace).
@author
@date 2011-11-02
Copyright © 2011 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 LoadMask : public API::ParallelAlgorithm {
public:
/// Algorithm's name for identification
const std::string name() const override { return "LoadMask"; };
/// Summary of algorithms purpose
const std::string summary() const override {
return "Load file containing masking information to a SpecialWorkspace2D "
"(masking workspace).";
}
/// Algorithm's version for identification
int version() const override { return 1; };
/// Algorithm's category for identification
const std::string category() const override {
return "DataHandling\\Masking;Transforms\\Masking";
}
private:
/// Initialise the properties
void init() override;
/// Run the algorithm
void exec() override;
/// Initialize XML parser
void initializeXMLParser(const std::string &filename);
/// Parse XML
void parseXML();
/// Initialize a Mask Workspace
void intializeMaskWorkspace();
/// Convert component to detectors
void componentToDetectors(const std::vector<std::string> &componentnames,
std::vector<detid_t> &detectors);
/// Convert bank to detector
void bankToDetectors(const std::vector<std::string> &singlebanks,
std::vector<detid_t> &detectors);
void processMaskOnDetectors(const detid2index_map &indexmap, bool tomask,
const std::vector<detid_t> &singledetids);
/// Convert spectrum to detector
void processMaskOnWorkspaceIndex(bool mask,
std::vector<specnum_t> &maskedSpecID,
std::vector<detid_t> &singleDetIds);
void initDetectors();
std::map<std::string, std::string> validateInputs() override;
void convertSpMasksToDetIDs(const API::MatrixWorkspace &sourceWS,
const std::vector<specnum_t> &maskedSpecID,
std::vector<detid_t> &singleDetIds);
void reset();
/// Mask Workspace
DataObjects::MaskWorkspace_sptr m_maskWS;
/// Instrument name
std::string m_instrumentPropValue;
/// optional source workspace, containing spectra-detector mapping
API::MatrixWorkspace_sptr m_sourceMapWS;
/// XML document loaded
Poco::AutoPtr<Poco::XML::Document> m_pDoc;
/// Root element of the parsed XML
Poco::XML::Element *m_pRootElem{nullptr};
/// Default setup. If true, not masking, but use the pixel
bool m_defaultToUse{true};
// detector id-s to mask
std::vector<detid_t> m_maskDetID;
// spectrum id-s to unmask
std::vector<detid_t> m_unMaskDetID;
// spectra mask provided
std::vector<specnum_t> m_maskSpecID;
// spectra unmask provided NOT IMPLEMENTED
// std::vector<specnum_t> m_unMaskSpecID;
std::vector<std::string> m_maskCompIdSingle;
std::vector<std::string> m_uMaskCompIdSingle;
};
} // namespace DataHandling
} // namespace Mantid
#endif /* MANTID_DATAHANDLING_LOADMASK_H_ */