BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DetectorContext.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/Detector/DetectorContext.h
6 //! @brief Define DetectorContext class.
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_DETECTOR_DETECTORCONTEXT_H
21 #define BORNAGAIN_DEVICE_DETECTOR_DETECTORCONTEXT_H
22 
23 #include "Base/Pixel/IPixel.h"
24 #include "Base/Vector/EigenCore.h"
25 #include <memory>
26 #include <vector>
27 
28 class IDetector2D;
29 
30 //! Holds precalculated information for faster SimulationElement generation.
31 //! @ingroup detector
32 
34 public:
35  DetectorContext(const IDetector2D* detector);
36 
37  DetectorContext(const DetectorContext& other) = delete;
38  DetectorContext& operator=(const DetectorContext& other) = delete;
39 
40  size_t numberOfSimulationElements() const;
41 
42  std::unique_ptr<IPixel> createPixel(size_t element_index) const;
43 
44  size_t detectorIndex(size_t element_index) const;
45 
46 private:
47  void setup_context(const IDetector2D* detector);
48 
49  Eigen::Matrix2cd analyzer_operator;
50  std::vector<std::unique_ptr<IPixel>> pixels; //! All unmasked pixels inside ROI.
51  std::vector<size_t> active_indices; //! The sequence of detector bin indices (unmasked, in ROI)
52 };
53 
54 #endif // BORNAGAIN_DEVICE_DETECTOR_DETECTORCONTEXT_H
55 #endif // USER_API
Include to deal with Eigen alignment centrally.
Defines and implements interface IPixel.
Holds precalculated information for faster SimulationElement generation.
DetectorContext(const IDetector2D *detector)
DetectorContext & operator=(const DetectorContext &other)=delete
std::vector< size_t > active_indices
All unmasked pixels inside ROI.
std::vector< std::unique_ptr< IPixel > > pixels
void setup_context(const IDetector2D *detector)
size_t detectorIndex(size_t element_index) const
std::unique_ptr< IPixel > createPixel(size_t element_index) const
Creates pixel for given element index.
size_t numberOfSimulationElements() const
DetectorContext(const DetectorContext &other)=delete
Eigen::Matrix2cd analyzer_operator
Abstract 2D detector interface.
Definition: IDetector2D.h:31