Mantid
Loading...
Searching...
No Matches
LoadMask.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
11#include "MantidDataHandling/DllConfig.h"
14
15#include <Poco/AutoPtr.h>
16#include <Poco/DOM/Document.h>
17
18namespace Poco {
19namespace XML {
20class Document;
21class Element;
22} // namespace XML
23} // namespace Poco
24
25namespace Mantid {
26namespace DataHandling {
27
34class MANTID_DATAHANDLING_DLL LoadMask : public API::Algorithm {
35public:
37 const std::string name() const override { return "LoadMask"; };
39 const std::string summary() const override {
40 return "Load file containing masking information to a SpecialWorkspace2D "
41 "(masking workspace).";
42 }
43
45 int version() const override { return 1; };
46 const std::vector<std::string> seeAlso() const override { return {"ExportSpectraMask", "LoadMask"}; }
48 const std::string category() const override { return "DataHandling\\Masking;Transforms\\Masking"; }
49
50private:
52 void init() override;
54 void exec() override;
56 std::vector<std::string> validExtensions() const { return {"xml", "msk"}; }
57 std::map<std::string, std::string> validateInputs() override;
59 void initializeXMLParser(const std::string &filename);
61 void parseXML();
63 void intializeMaskWorkspace();
65 void componentToDetectors(const std::vector<std::string> &componentnames, std::vector<detid_t> &detectors);
67 void bankToDetectors(const std::vector<std::string> &singlebanks, std::vector<detid_t> &detectors);
68
69 void processMaskOnDetectors(const detid2index_map &indexmap, bool tomask, const std::vector<detid_t> &singledetids);
71 void processMaskOnWorkspaceIndex(bool mask, std::vector<specnum_t> &maskedSpecID, std::vector<detid_t> &singleDetIds);
72
73 void initDetectors();
74
75 void convertSpMasksToDetIDs(const API::MatrixWorkspace &sourceWS, const std::vector<specnum_t> &maskedSpecID,
76 std::vector<detid_t> &singleDetIds);
77
78 void reset();
79
87 Poco::AutoPtr<Poco::XML::Document> m_pDoc;
89 Poco::XML::Element *m_pRootElem{nullptr};
90
92 bool m_defaultToUse{true};
93
94 // detector id-s to mask
95 std::vector<detid_t> m_maskDetID;
96 // spectrum id-s to unmask
97 std::vector<detid_t> m_unMaskDetID;
98
99 // spectra mask provided
100 std::vector<specnum_t> m_maskSpecID;
101 // spectra unmask provided NOT IMPLEMENTED
102 // std::vector<specnum_t> m_unMaskSpecID;
103
104 std::vector<std::string> m_maskCompIdSingle;
105 std::vector<std::string> m_uMaskCompIdSingle;
106};
107
108} // namespace DataHandling
109} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
Base MatrixWorkspace Abstract Class.
LoadMask : Load masking file to generate a SpecialWorkspace2D object (masking workspace).
Definition LoadMask.h:34
DataObjects::MaskWorkspace_sptr m_maskWS
Mask Workspace.
Definition LoadMask.h:81
std::vector< std::string > m_uMaskCompIdSingle
Definition LoadMask.h:105
std::string m_instrumentPropValue
Instrument name.
Definition LoadMask.h:83
std::vector< std::string > m_maskCompIdSingle
Definition LoadMask.h:104
std::vector< detid_t > m_maskDetID
Definition LoadMask.h:95
const std::string summary() const override
Summary of algorithms purpose.
Definition LoadMask.h:39
const std::string category() const override
Algorithm's category for identification.
Definition LoadMask.h:48
Poco::AutoPtr< Poco::XML::Document > m_pDoc
XML document loaded.
Definition LoadMask.h:87
std::vector< specnum_t > m_maskSpecID
Definition LoadMask.h:100
int version() const override
Algorithm's version for identification.
Definition LoadMask.h:45
const std::string name() const override
Algorithm's name for identification.
Definition LoadMask.h:37
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
Definition LoadMask.h:46
std::vector< detid_t > m_unMaskDetID
Definition LoadMask.h:97
std::vector< std::string > validExtensions() const
Valudate inputs.
Definition LoadMask.h:56
API::MatrixWorkspace_sptr m_sourceMapWS
optional source workspace, containing spectra-detector mapping
Definition LoadMask.h:85
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< MaskWorkspace > MaskWorkspace_sptr
shared pointer to the MaskWorkspace class
Helper class which provides the Collimation Length for SANS instruments.
std::unordered_map< detid_t, size_t > detid2index_map
Map with key = detector ID, value = workspace index.