BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
DetectorMask.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Mask/DetectorMask.h
6 //! @brief Defines class DetectorMask.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_DEVICE_MASK_DETECTORMASK_H
16 #define BORNAGAIN_DEVICE_MASK_DETECTORMASK_H
17 
18 #include <memory>
19 
20 #ifndef SWIG
22 #endif
23 
24 class IAxis;
25 class IShape2D;
26 
27 class Datafield;
28 
29 class MaskPattern {
30 public:
31  MaskPattern(IShape2D* shape_, bool doMask_);
32  MaskPattern(const MaskPattern&) = delete;
33  ~MaskPattern();
34  MaskPattern* clone() const;
35  IShape2D* shape; // owning
36  bool doMask;
37 };
38 
39 //! Collection of detector masks.
40 //! @ingroup detector
41 
42 class DetectorMask {
43 public:
44  DetectorMask(const IAxis& xAxis, const IAxis& yAxis);
46  DetectorMask(const DetectorMask& other);
47  DetectorMask& operator=(const DetectorMask& other);
48 
49  //! Add mask to the stack of detector masks.
50  //! The value "true" means that the area will be excluded from the analysis.
51  //! @param shape The shape of mask.
52  //! @param mask_value The value of mask
53  void addMask(const IShape2D& shape, bool mask_value);
54 
55  bool isMasked(size_t index) const;
56 
57  //! Returns true if has masks
58  bool hasMasks() const;
59 
61 
62  size_t numberOfMasks() const;
63 
64  const MaskPattern* patternAt(size_t iMask) const;
65 
66 private:
67  void process_masks();
68 
69  // primary data:
70 #ifndef SWIG
71  const IAxis* m_xAxis;
72  const IAxis* m_yAxis;
74 #endif
75 
76  // cached secondary data:
77  std::vector<bool> m_masked;
79 };
80 
81 #endif // BORNAGAIN_DEVICE_MASK_DETECTORMASK_H
Defines and implements templated class OwningVector.
Stores radiation power per bin.
Definition: Datafield.h:30
Collection of detector masks.
Definition: DetectorMask.h:42
void process_masks()
const MaskPattern * patternAt(size_t iMask) const
int numberOfMaskedChannels() const
Definition: DetectorMask.h:60
const IAxis * m_yAxis
Definition: DetectorMask.h:72
int m_number_of_masked_channels
Definition: DetectorMask.h:78
bool isMasked(size_t index) const
bool hasMasks() const
Returns true if has masks.
size_t numberOfMasks() const
const IAxis * m_xAxis
Definition: DetectorMask.h:71
DetectorMask(const IAxis &xAxis, const IAxis &yAxis)
DetectorMask & operator=(const DetectorMask &other)
OwningVector< MaskPattern > m_stack
Definition: DetectorMask.h:73
std::vector< bool > m_masked
Definition: DetectorMask.h:77
void addMask(const IShape2D &shape, bool mask_value)
Add mask to the stack of detector masks. The value "true" means that the area will be excluded from t...
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27
Basic class for all shapes in 2D.
Definition: IShape2D.h:26
MaskPattern(IShape2D *shape_, bool doMask_)
MaskPattern * clone() const
IShape2D * shape
Definition: DetectorMask.h:35
MaskPattern(const MaskPattern &)=delete