/** * Set up starting values for cached variables */ void MDNormDirectSC::cacheInputs() { m_inputWS = getProperty("InputWorkspace"); bool skipCheck = getProperty("SkipSafetyCheck"); if (!skipCheck && (inputEnergyMode() != "Direct")) { throw std::invalid_argument("Invalid energy transfer mode. Algorithm only " "supports direct geometry spectrometers."); } // Min/max dimension values const auto hdim(m_inputWS->getDimension(0)), kdim(m_inputWS->getDimension(1)), ldim(m_inputWS->getDimension(2)), edim(m_inputWS->getDimension(3)); m_hmin = hdim->getMinimum(); m_kmin = kdim->getMinimum(); m_lmin = ldim->getMinimum(); m_dEmin = edim->getMinimum(); m_hmax = hdim->getMaximum(); m_kmax = kdim->getMaximum(); m_lmax = ldim->getMaximum(); m_dEmax = edim->getMaximum(); const auto &exptInfoZero = *(m_inputWS->getExperimentInfo(0)); auto source = exptInfoZero.getInstrument()->getSource(); auto sample = exptInfoZero.getInstrument()->getSample(); if (source == nullptr || sample == nullptr) { throw Kernel::Exception::InstrumentDefinitionError( "Instrument not sufficiently defined: failed to get source and/or " "sample"); } m_samplePos = sample->getPos(); m_beamDir = m_samplePos - source->getPos(); m_beamDir.normalize(); double originaldEmin = exptInfoZero.run().getBinBoundaries().front(); double originaldEmax = exptInfoZero.run().getBinBoundaries().back(); if (exptInfoZero.run().hasProperty("Ei")) { Kernel::Property *eiprop = exptInfoZero.run().getProperty("Ei"); m_Ei = boost::lexical_cast<double>(eiprop->value()); if (m_Ei <= 0) { throw std::invalid_argument("Ei stored in the workspace is not positive"); } } else { throw std::invalid_argument("Could not find Ei value in the workspace."); } double eps = 1e-7; if (m_Ei - originaldEmin < eps) { originaldEmin = m_Ei - eps; } if (m_Ei - originaldEmax < eps) { originaldEmax = m_Ei - 1e-7; } if (originaldEmin == originaldEmax) { throw std::runtime_error("The limits of the original workspace used in " "ConvertToMD are incorrect"); } const double energyToK = 8.0 * M_PI * M_PI * PhysicalConstants::NeutronMass * PhysicalConstants::meV * 1e-20 / (PhysicalConstants::h * PhysicalConstants::h); m_ki = std::sqrt(energyToK * m_Ei); m_kfmin = std::sqrt(energyToK * (m_Ei - originaldEmin)); m_kfmax = std::sqrt(energyToK * (m_Ei - originaldEmax)); }
/** * Set up starting values for cached variables */ void MDNormSCD::cacheInputs() { m_inputWS = getProperty("InputWorkspace"); if (inputEnergyMode() != "Elastic") { throw std::invalid_argument("Invalid energy transfer mode. Algorithm " "currently only supports elastic data."); } // Min/max dimension values const auto hdim(m_inputWS->getDimension(0)), kdim(m_inputWS->getDimension(1)), ldim(m_inputWS->getDimension(2)); m_hmin = hdim->getMinimum(); m_kmin = kdim->getMinimum(); m_lmin = ldim->getMinimum(); m_hmax = hdim->getMaximum(); m_kmax = kdim->getMaximum(); m_lmax = ldim->getMaximum(); const auto &exptInfoZero = *(m_inputWS->getExperimentInfo(0)); auto source = exptInfoZero.getInstrument()->getSource(); auto sample = exptInfoZero.getInstrument()->getSample(); if (source == nullptr || sample == nullptr) { throw Kernel::Exception::InstrumentDefinitionError( "Instrument not sufficiently defined: failed to get source and/or " "sample"); } m_samplePos = sample->getPos(); m_beamDir = m_samplePos - source->getPos(); m_beamDir.normalize(); }