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::ParallelAlgorithm {
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 void initializeXMLParser(const std::string &filename);
58 void parseXML();
60 void intializeMaskWorkspace();
62 void componentToDetectors(const std::vector<std::string> &componentnames, std::vector<detid_t> &detectors);
64 void bankToDetectors(const std::vector<std::string> &singlebanks, std::vector<detid_t> &detectors);
65
66 void processMaskOnDetectors(const detid2index_map &indexmap, bool tomask, const std::vector<detid_t> &singledetids);
68 void processMaskOnWorkspaceIndex(bool mask, std::vector<specnum_t> &maskedSpecID, std::vector<detid_t> &singleDetIds);
69
70 void initDetectors();
71
72 std::map<std::string, std::string> validateInputs() override;
73
74 void convertSpMasksToDetIDs(const API::MatrixWorkspace &sourceWS, const std::vector<specnum_t> &maskedSpecID,
75 std::vector<detid_t> &singleDetIds);
76
77 void reset();
78
86 Poco::AutoPtr<Poco::XML::Document> m_pDoc;
88 Poco::XML::Element *m_pRootElem{nullptr};
89
91 bool m_defaultToUse{true};
92
93 // detector id-s to mask
94 std::vector<detid_t> m_maskDetID;
95 // spectrum id-s to unmask
96 std::vector<detid_t> m_unMaskDetID;
97
98 // spectra mask provided
99 std::vector<specnum_t> m_maskSpecID;
100 // spectra unmask provided NOT IMPLEMENTED
101 // std::vector<specnum_t> m_unMaskSpecID;
102
103 std::vector<std::string> m_maskCompIdSingle;
104 std::vector<std::string> m_uMaskCompIdSingle;
105};
106
107} // namespace DataHandling
108} // namespace Mantid
Base MatrixWorkspace Abstract Class.
Base class for algorithms that can run in parallel on all MPI ranks but not in a distributed fashion.
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:80
std::vector< std::string > m_uMaskCompIdSingle
Definition: LoadMask.h:104
std::string m_instrumentPropValue
Instrument name.
Definition: LoadMask.h:82
std::vector< std::string > m_maskCompIdSingle
Definition: LoadMask.h:103
std::vector< detid_t > m_maskDetID
Definition: LoadMask.h:94
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:86
std::vector< specnum_t > m_maskSpecID
Definition: LoadMask.h:99
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:96
API::MatrixWorkspace_sptr m_sourceMapWS
optional source workspace, containing spectra-detector mapping
Definition: LoadMask.h:84
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
Definition: MaskWorkspace.h:64
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.
Definition: Algorithm.h:30