BornAgain  1.18.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 scattering at grazing incidence
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_CORE_DETECTOR_DETECTORMASK_H
16 #define BORNAGAIN_CORE_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 
29 {
30 public:
31  DetectorMask();
32  DetectorMask(const DetectorMask& other);
33  DetectorMask& operator=(const DetectorMask& other);
34 
35  //! Add mask to the stack of detector masks.
36  //! The value "true" means that the area will be excluded from the analysis.
37  //! @param shape The shape of mask.
38  //! @param mask_value The value of mask
39  void addMask(const IShape2D& shape, bool mask_value);
40 
41  //! Init the map of masks for the given detector plane
42  void initMaskData(const IDetector2D& detector);
43 
44  void initMaskData(const OutputData<double>& data);
45 
46  bool isMasked(size_t index) const;
47 
48  const OutputData<bool>* getMaskData() const { return &m_mask_data; }
49 
51 
52  //! remove all masks and return object to initial state
53  void removeMasks();
54 
55  //! returns true if has masks
56  bool hasMasks() const { return !m_shapes.empty(); }
57 
59 
60  size_t numberOfMasks() const;
61 
62  const IShape2D* getMaskShape(size_t mask_index, bool& mask_value) const;
63 
64 private:
65  void process_masks();
66 
68  std::vector<bool> m_mask_of_shape;
71 };
72 
73 #endif // BORNAGAIN_CORE_DETECTOR_DETECTORMASK_H
Defines basic class for all 2D shapes.
Defines and implements template class OutputData.
Collection of detector masks.
Definition: DetectorMask.h:29
void process_masks()
int numberOfMaskedChannels() const
Definition: DetectorMask.h:58
const OutputData< bool > * getMaskData() const
Definition: DetectorMask.h:48
void removeMasks()
remove all masks and return object to initial state
const IShape2D * getMaskShape(size_t mask_index, bool &mask_value) const
int m_number_of_masked_channels
Definition: DetectorMask.h:70
bool isMasked(size_t index) const
bool hasMasks() const
returns true if has masks
Definition: DetectorMask.h:56
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:67
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:68
OutputData< bool > m_mask_data
Definition: DetectorMask.h:69
Two dimensional histogram.
Definition: Histogram2D.h:25
Abstract 2D detector interface.
Definition: IDetector2D.h:31
Basic class for all shapes in 2D.
Definition: IShape2D.h:27
Template class to store data of any type in multi-dimensional space.
Definition: OutputData.h:33