/**
 * Cache some frequently used attributes
 * @param name :: The name of the attribute
 * @param value :: It's value
 */
void TobyFitResolutionModel::setAttribute(
    const std::string &name, const API::IFunction::Attribute &value) {
    MDResolutionConvolution::setAttribute(name, value);
    if (name == MC_MIN_NAME)
        m_mcLoopMin = value.asInt();
    else if (name == MC_MAX_NAME)
        m_mcLoopMax = value.asInt();
    else if (name == MC_LOOP_TOL)
        m_mcRelErrorTol = value.asDouble();
    else if (name == MC_TYPE) {
        m_mcType = value.asInt();
        if (m_mcType > 4 || m_mcType < 0) {
            throw std::invalid_argument("TobyFitResolutionModel: Invalid MCType "
                                        "argument, valid values are 0-4. Current "
                                        "value=" +
                                        boost::lexical_cast<std::string>(m_mcType));
        }
    } else if (name == CRYSTAL_MOSAIC) {
        m_mosaicActive = (value.asInt() != 0);
    } else if (name == FOREGROUNDONLY_NAME) {
        m_foregroundOnly = (value.asInt() != 0);
    } else {
        for (auto &iter : m_yvector) {
            iter.setAttribute(name, value);
        }
    }
}
예제 #2
0
/** Set Attribute
 * @param attName :: The attribute name. If it is not "eps" exception is thrown.
 * @param att :: A double attribute containing a new positive value.
 */
void DynamicKuboToyabe::setAttribute(const std::string &attName,
                                     const API::IFunction::Attribute &att) {
  if (attName == "BinWidth") {

    double newVal = att.asDouble();

    if (newVal < 0) {
      clearAllParameters();
      throw std::invalid_argument(
          "DKT: Attribute BinWidth cannot be negative.");

    } else if (newVal < m_minEps) {
      clearAllParameters();
      std::stringstream ss;
      ss << "DKT: Attribute BinWidth too small (BinWidth < "
         << std::setprecision(3) << m_minEps << ")";
      throw std::invalid_argument(ss.str());

    } else if (newVal > m_maxEps) {
      clearAllParameters();
      std::stringstream ss;
      ss << "DKT: Attribute BinWidth too large (BinWidth > "
         << std::setprecision(3) << m_maxEps << ")";
      throw std::invalid_argument(ss.str());
    }

    if (!nParams()) {
      init();
    }
    m_eps = newVal;

  } else {
    throw std::invalid_argument("DynamicKuboToyabe: Unknown attribute " +
                                attName);
  }
}