22 IDetector::IDetector()
24 registerChild(&m_detection_properties);
27 IDetector::IDetector(
const IDetector& other)
29 m_detection_properties(other.m_detection_properties)
31 if (other.mP_detector_resolution)
32 setDetectorResolution(*other.mP_detector_resolution);
33 setName(other.getName());
34 registerChild(&m_detection_properties);
37 IDetector::~IDetector() =
default;
39 void IDetector::addAxis(
const IAxis& axis)
41 m_axes.push_back(axis.
clone());
49 void IDetector::clear()
54 const IAxis& IDetector::getAxis(
size_t index)
const
57 return *m_axes[index];
58 throw std::runtime_error(
"Error in IDetector::getAxis: not so many axes in this detector.");
64 size_t remainder(index);
66 for (
size_t i = 0; i < dim; ++i) {
68 if (selected_axis == i_axis)
69 return remainder % m_axes[i_axis]->size();
70 remainder /= m_axes[i_axis]->size();
72 throw std::runtime_error(
"IDetector::getAxisBinIndex() -> "
73 "Error! No axis with given number");
83 "IDetector::createAxis() -> Error! Number n_bins can't be zero.");
84 return std::make_unique<FixedBinAxis>(
axisName(index), n_bins, min, max);
93 for (
size_t i_axis = 0; i_axis < dim; ++i_axis)
94 result *= m_axes[i_axis]->size();
99 double total_transmission)
106 mP_detector_resolution.reset(p_detector_resolution.clone());
107 registerChild(mP_detector_resolution.get());
119 if (!p_intensity_map)
120 throw std::runtime_error(
"IDetector::applyDetectorResolution() -> "
121 "Error! Null pointer to intensity map");
122 if (mP_detector_resolution) {
123 mP_detector_resolution->applyDetectorResolution(p_intensity_map);
127 buff->copyShapeFrom(*p_intensity_map);
130 (*buff)[it.roiIndex()] = (*p_intensity_map)[it.roiIndex()];
139 mP_detector_resolution.reset();
144 return mP_detector_resolution.get();
153 "can't create detector map.");
155 setDataToDetectorMap(*detectorMap, elements);
156 if (mP_detector_resolution)
159 return detectorMap.release();
166 throw std::runtime_error(
167 "Error in IDetector::createDetectorMap: dimensions of the detector are undefined");
170 for (
size_t i = 0; i < dim; ++i)
172 result->addAxis(*roi->clipAxisToRoi(i, getAxis(i)));
174 result->addAxis(getAxis(i));
180 const std::vector<SimulationElement>& elements)
const
182 if (elements.empty())
184 iterate([&](const_iterator it) {
185 detectorMap[it.roiIndex()] = elements[it.elementIndex()].getIntensity();
198 return std::vector<const INode*>() << &m_detection_properties << mP_detector_resolution;
Defines class ConvolutionDetectorResolution.
Defines class DetectorMask.
Defines common detector interface.
Defines class RegionOfInterest.
Defines class SimulationArea.
Defines class SimulationElement.
Convolutes the intensity in 1 or 2 dimensions with a resolution function.
void setAnalyzerProperties(const kvector_t direction, double efficiency, double total_transmission)
Sets the polarization analyzer characteristics of the detector.
Interface for one-dimensional axes.
virtual IAxis * clone() const =0
clone function
Interface for polymorphic classes that should not be copied, except by explicit cloning.
Interface for detector resolution algorithms.
Abstract detector interface.
void applyDetectorResolution(OutputData< double > *p_intensity_map) const
Applies the detector resolution to the given intensity maps.
virtual std::string axisName(size_t index) const =0
Returns the name for the axis with given index.
virtual const DetectorMask * detectorMask() const =0
Returns detector masks container.
size_t dimension() const
Returns actual dimensionality of the detector (number of defined axes)
size_t axisBinIndex(size_t index, size_t selected_axis) const
Calculate axis index for given global index.
virtual std::unique_ptr< IAxis > createAxis(size_t index, size_t n_bins, double min, double max) const
Generates an axis with correct name and default binning for given index.
std::vector< const INode * > getChildren() const override
Returns a vector of children (const).
size_t totalSize() const
Returns total number of pixels.
size_t numberOfSimulationElements() const
Returns number of simulation elements.
void setAnalyzerProperties(const kvector_t direction, double efficiency, double total_transmission)
Sets the polarization analyzer characteristics of the detector.
OutputData< double > * createDetectorIntensity(const std::vector< SimulationElement > &elements) const
Returns new intensity map with detector resolution applied.
void setDetectorResolution(const IDetectorResolution &p_detector_resolution)
Sets the detector resolution.
std::unique_ptr< OutputData< double > > createDetectorMap() const
Returns empty detector map in given axes units.
const IDetectorResolution * detectorResolution() const
Returns a pointer to detector resolution object.
void removeDetectorResolution()
Removes detector resolution function.
virtual const RegionOfInterest * regionOfInterest() const =0
Returns region of interest if exists.
Base class for tree-like structures containing parameterized objects.
Interface providing two-dimensional resolution function.
void setRawDataVector(const std::vector< T > &data_vector)
Sets new values to raw data vector.
An iterator for SimulationArea.
Holds iteration logic over active detector channels in the presence of masked areas and RegionOfInter...
Holds iteration logic over active detector channels in the presence of ROI.