-
Notifications
You must be signed in to change notification settings - Fork 122
/
LoadMask.h
108 lines (89 loc) · 3.57 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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2011 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
#include "MantidAPI/MatrixWorkspace_fwd.h"
#include "MantidAPI/ParallelAlgorithm.h"
#include "MantidDataObjects/MaskWorkspace.h"
#include "MantidGeometry/IDTypes.h"
#include "MantidKernel/System.h"
#include <Poco/AutoPtr.h>
#include <Poco/DOM/Document.h>
namespace Poco {
namespace XML {
class Document;
class Element;
} // namespace XML
} // namespace Poco
namespace Mantid {
namespace DataHandling {
/** LoadMask : Load masking file to generate a SpecialWorkspace2D object
(masking workspace).
@author
@date 2011-11-02
*/
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; };
const std::vector<std::string> seeAlso() const override { return {"ExportSpectraMask", "LoadMask"}; }
/// 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