BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DetectorMask.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Detector/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_DETECTOR_DETECTORMASK_H
16 #define BORNAGAIN_DEVICE_DETECTOR_DETECTORMASK_H
17 
18 #include "Device/Data/OutputData.h"
19 #include "Device/Mask/IShape2D.h"
20 
21 class IDetector2D;
22 template <class T> class OutputData;
23 class Histogram2D;
24 
25 //! Collection of detector masks.
26 //! @ingroup detector
27 
28 class DetectorMask {
29 public:
30  DetectorMask();
31  DetectorMask(const DetectorMask& other);
32  DetectorMask& operator=(const DetectorMask& other);
33 
34  //! Add mask to the stack of detector masks.
35  //! The value "true" means that the area will be excluded from the analysis.
36  //! @param shape The shape of mask.
37  //! @param mask_value The value of mask
38  void addMask(const IShape2D& shape, bool mask_value);
39 
40  //! Init the map of masks for the given detector plane
41  void initMaskData(const IDetector2D& detector);
42 
43  void initMaskData(const OutputData<double>& data);
44 
45  bool isMasked(size_t index) const;
46 
47  const OutputData<bool>* getMaskData() const { return &m_mask_data; }
48 
50 
51  //! returns true if has masks
52  bool hasMasks() const { return !m_shapes.empty(); }
53 
55 
56  size_t numberOfMasks() const;
57 
58  const IShape2D* getMaskShape(size_t mask_index, bool& mask_value) const;
59 
60 private:
61  void process_masks();
62 
64  std::vector<bool> m_mask_of_shape;
67 };
68 
69 #endif // BORNAGAIN_DEVICE_DETECTOR_DETECTORMASK_H
Defines basic class for all 2D shapes.
Defines and implements templated class OutputData.
Collection of detector masks.
Definition: DetectorMask.h:28
void process_masks()
int numberOfMaskedChannels() const
Definition: DetectorMask.h:54
const OutputData< bool > * getMaskData() const
Definition: DetectorMask.h:47
const IShape2D * getMaskShape(size_t mask_index, bool &mask_value) const
int m_number_of_masked_channels
Definition: DetectorMask.h:66
bool isMasked(size_t index) const
bool hasMasks() const
returns true if has masks
Definition: DetectorMask.h:52
size_t numberOfMasks() const
Histogram2D * createHistogram() const
DetectorMask & operator=(const DetectorMask &other)
void addMask(const IShape2D &shape, bool mask_value)
Add mask to the stack of detector masks.
SafePointerVector< IShape2D > m_shapes
Definition: DetectorMask.h:63
void initMaskData(const IDetector2D &detector)
Init the map of masks for the given detector plane.
std::vector< bool > m_mask_of_shape
Definition: DetectorMask.h:64
OutputData< bool > m_mask_data
Definition: DetectorMask.h:65
Two dimensional histogram.
Definition: Histogram2D.h:24
Abstract 2D detector interface.
Definition: IDetector2D.h:31
Basic class for all shapes in 2D.
Definition: IShape2D.h:27
Templated class to store data of type double or CumulativeValue in multi-dimensional space.
Definition: OutputData.h:32