BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
Instrument.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/Instrument/Instrument.h
6 //! @brief Defines class Instrument.
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_INSTRUMENT_INSTRUMENT_H
16 #define BORNAGAIN_CORE_INSTRUMENT_INSTRUMENT_H
17 
18 #include "Device/Beam/Beam.h"
19 #include <memory>
20 
21 template <class T> class OutputData;
22 class Histogram2D;
23 class DetectorMask;
24 class IAxis;
25 class IDetector;
26 class IDetector2D;
28 class SimulationElement;
29 
30 //! Assembles beam, detector and their relative positions with respect to the sample.
31 //! @ingroup simulation_internal
32 
33 class Instrument : public INode
34 {
35 public:
36  Instrument();
37  Instrument(const Instrument& other);
38  Instrument& operator=(const Instrument& other);
39 
40  virtual ~Instrument();
41 
42  void accept(INodeVisitor* visitor) const final { visitor->visit(this); }
43 
44  Beam& getBeam() { return m_beam; }
45  const Beam& getBeam() const { return m_beam; }
46  void setBeam(const Beam& beam);
47 
48  //! Sets the beam wavelength and incoming angles
49  void setBeamParameters(double wavelength, double alpha_i, double phi_i);
50 
51  void setBeamIntensity(double intensity);
52 
53  //! Sets the beam's polarization according to the given Bloch vector
54  void setBeamPolarization(const kvector_t bloch_vector);
55 
56  double getBeamIntensity() const;
57 
58  const IDetector* getDetector() const;
60  const IDetector& detector() const;
61 
63  const IDetector2D& detector2D() const;
64 
65  const DetectorMask* getDetectorMask() const;
66 
67  const IAxis& getDetectorAxis(size_t index) const;
68 
69  size_t getDetectorDimension() const;
70 
71  //! Sets the detector (axes can be overwritten later)
72  void setDetector(const IDetector& detector);
73 
74  //! Sets detector resolution function
75  void setDetectorResolutionFunction(const IResolutionFunction2D& p_resolution_function);
76 
77  //! Removes detector resolution function.
79 
80  //! Sets the polarization analyzer characteristics of the detector
81  void setAnalyzerProperties(const kvector_t direction, double efficiency,
82  double total_transmission);
83 
84  //! apply the detector resolution to the given intensity map
85  void applyDetectorResolution(OutputData<double>* p_intensity_map) const;
86 
87  //! init detector with beam settings
88  void initDetector();
89 
90  std::vector<const INode*> getChildren() const;
91 
92 protected:
93  std::unique_ptr<IDetector> m_detector;
95 };
96 
97 #endif // BORNAGAIN_CORE_INSTRUMENT_INSTRUMENT_H
Defines class Beam.
Beam defined by wavelength, direction and intensity.
Definition: Beam.h:27
Collection of detector masks.
Definition: DetectorMask.h:29
Two dimensional histogram.
Definition: Histogram2D.h:25
Interface for one-dimensional axes.
Definition: IAxis.h:25
Abstract 2D detector interface.
Definition: IDetector2D.h:31
Abstract detector interface.
Definition: IDetector.h:36
Visitor interface to visit ISample objects.
Definition: INodeVisitor.h:149
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
Interface providing two-dimensional resolution function.
Assembles beam, detector and their relative positions with respect to the sample.
Definition: Instrument.h:34
Beam & getBeam()
Definition: Instrument.h:44
void applyDetectorResolution(OutputData< double > *p_intensity_map) const
apply the detector resolution to the given intensity map
Definition: Instrument.cpp:82
void setAnalyzerProperties(const kvector_t direction, double efficiency, double total_transmission)
Sets the polarization analyzer characteristics of the detector.
Definition: Instrument.cpp:167
const Beam & getBeam() const
Definition: Instrument.h:45
void setBeamIntensity(double intensity)
Definition: Instrument.cpp:106
const IAxis & getDetectorAxis(size_t index) const
Definition: Instrument.cpp:157
double getBeamIntensity() const
Definition: Instrument.cpp:116
const DetectorMask * getDetectorMask() const
Definition: Instrument.cpp:94
virtual ~Instrument()
void setBeamParameters(double wavelength, double alpha_i, double phi_i)
Sets the beam wavelength and incoming angles.
Definition: Instrument.cpp:87
void setDetector(const IDetector &detector)
Sets the detector (axes can be overwritten later)
Definition: Instrument.cpp:48
void accept(INodeVisitor *visitor) const final
Calls the INodeVisitor's visit method.
Definition: Instrument.h:42
IDetector & detector()
Definition: Instrument.cpp:133
void setDetectorResolutionFunction(const IResolutionFunction2D &p_resolution_function)
Sets detector resolution function.
Definition: Instrument.cpp:72
void initDetector()
init detector with beam settings
Definition: Instrument.cpp:55
void removeDetectorResolution()
Removes detector resolution function.
Definition: Instrument.cpp:77
const IDetector * getDetector() const
Definition: Instrument.cpp:121
std::vector< const INode * > getChildren() const
Returns a vector of children (const).
Definition: Instrument.cpp:63
void setBeam(const Beam &beam)
Definition: Instrument.cpp:99
size_t getDetectorDimension() const
Definition: Instrument.cpp:162
void setBeamPolarization(const kvector_t bloch_vector)
Sets the beam's polarization according to the given Bloch vector.
Definition: Instrument.cpp:111
IDetector2D & detector2D()
Definition: Instrument.cpp:139
Instrument & operator=(const Instrument &other)
Definition: Instrument.cpp:37
std::unique_ptr< IDetector > m_detector
Definition: Instrument.h:93
Beam m_beam
Definition: Instrument.h:94
Template class to store data of any type in multi-dimensional space.
Definition: OutputData.h:33
Data stucture containing both input and output of a single detector cell.