/** The procedure analyses emode and efixed properties provided to the algorithm *and identify the energy analysis mode and the way the properties are defined *@param workspace :: input workspace which may or may not have incident *energy property (Ei) attached to it as the run log *@param hostAlgorithm :: the pointer to SofQ algorithm hosting the base class. *This algorithm expects to have EMode and EFixed properties attached to it. */ void SofQCommon::initCachedValues(const API::MatrixWorkspace &workspace, API::Algorithm *const hostAlgorithm) { // Retrieve the emode & efixed properties const std::string emode = hostAlgorithm->getProperty("EMode"); // Convert back to an integer representation m_emode = 0; if (emode == "Direct") m_emode = 1; else if (emode == "Indirect") m_emode = 2; m_efixed = hostAlgorithm->getProperty("EFixed"); // Check whether they should have supplied an EFixed value if (m_emode == 1) // Direct { // If GetEi was run then it will have been stored in the workspace, if not // the user will need to enter one if (m_efixed == 0.0) { if (workspace.run().hasProperty("Ei")) { Kernel::Property *p = workspace.run().getProperty("Ei"); Kernel::PropertyWithValue<double> *eiProp = dynamic_cast<Kernel::PropertyWithValue<double> *>(p); if (!eiProp) throw std::runtime_error("Input workspace contains Ei but its " "property type is not a double."); m_efixed = (*eiProp)(); } else { throw std::invalid_argument("Input workspace does not contain an " "EFixed value. Please provide one or run " "GetEi."); } } else { m_efixedGiven = true; } } else { if (m_efixed != 0.0) { m_efixedGiven = true; } } }