diff --git a/Core/Algorithms/inc/Instrument.h b/Core/Algorithms/inc/Instrument.h index 1b4f946e01bf1d251e3ff011acfcda85b79f6516..174299ed2a31ad317c0f864e1b281fbc87c660dd 100644 --- a/Core/Algorithms/inc/Instrument.h +++ b/Core/Algorithms/inc/Instrument.h @@ -119,15 +119,9 @@ inline Beam Instrument::getBeam() const return m_beam; } -inline void Instrument::setBeam(const Beam &beam) -{ - m_beam = beam; -} -inline void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i) -{ - m_beam.setCentralK(wavelength, alpha_i, phi_i); -} + + inline void Instrument::setBeamIntensity(double intensity) { diff --git a/Core/Algorithms/src/Instrument.cpp b/Core/Algorithms/src/Instrument.cpp index 2697f8e9e4dc0f935416c6366378babb98d1ae33..18584fdfe070a283b93a4b77d3775be06f224d6d 100644 --- a/Core/Algorithms/src/Instrument.cpp +++ b/Core/Algorithms/src/Instrument.cpp @@ -46,6 +46,7 @@ Instrument &Instrument::operator=(const Instrument &other) void Instrument::setDetector(const IDetector2D& detector) { mP_detector.reset(detector.clone()); + initDetector(); } void Instrument::matchDetectorAxes(const OutputData<double> &output_data) @@ -82,6 +83,9 @@ std::string Instrument::addParametersToExternalPool(std::string path, ParameterP void Instrument::initDetector() { + if(!mP_detector) { + throw RuntimeErrorException("Instrument::initDetector() -> Error. Detector is not initialized."); + } getDetector()->init(getBeam()); } @@ -140,3 +144,15 @@ void Instrument::print(std::ostream &ostr) const ostr << " " << m_beam << std::endl; ostr << " " << *mP_detector << std::endl; } + +void Instrument::setBeamParameters(double wavelength, double alpha_i, double phi_i) +{ + m_beam.setCentralK(wavelength, alpha_i, phi_i); + if(mP_detector) initDetector(); +} + +void Instrument::setBeam(const Beam &beam) +{ + m_beam = beam; + if(mP_detector) initDetector(); +}