Exemplo n.º 1
0
  /** Get set of spectra of the input table workspace
    * Spectra is set to the column named 'spectrum'.
    * Algorithm supports multiple peaks in multiple spectra
    */
  void GeneratePeaks::getSpectraSet(DataObjects::TableWorkspace_const_sptr peakParmsWS)
  {
    size_t numpeaks = peakParmsWS->rowCount();
    API::Column_const_sptr col = peakParmsWS->getColumn("spectrum");

    for (size_t ipk = 0; ipk < numpeaks; ipk ++)
    {
      // Spectrum
      specid_t specid = static_cast<specid_t>((*col)[ipk]);
      m_spectraSet.insert(specid);

      std::stringstream outss;
      outss << "Peak " << ipk << ": specid = " << specid;
      g_log.debug(outss.str());
    }

    std::set<specid_t>::iterator pit;
    specid_t icount = 0;
    for (pit = m_spectraSet.begin(); pit != m_spectraSet.end(); ++pit)
    {
      m_SpectrumMap.insert(std::make_pair(*pit, icount));
      ++ icount;
    }

    return;
  }
Exemplo n.º 2
0
void UnitsConversionHelper::initialize(
    const std::string &unitsFrom, const std::string &unitsTo,
    const DataObjects::TableWorkspace_const_sptr &DetWS, int Emode,
    bool forceViaTOF) {
  m_Emode = Emode;

  if (!DetWS)
    throw std::runtime_error("UnitsConversionHelper::initialize called with "
                             "empty preprocessed detectors table");

  // Check how the source units relate to the units requested and create source
  // units
  m_UnitCnvrsn = analyzeUnitsConversion(unitsFrom, unitsTo, forceViaTOF);

  // create target units class
  m_TargetUnit = Kernel::UnitFactory::Instance().create(unitsTo);
  if (!m_TargetUnit)
    throw(std::runtime_error(
        " Cannot retrieve target unit from the units factory"));

  // get access to all values used by unit conversion.
  m_pTwoThetas = &(DetWS->getColVector<double>("TwoTheta"));
  m_pL2s = &(DetWS->getColVector<double>("L2"));

  m_L1 = DetWS->getLogs()->getPropertyValueAsType<double>("L1");

  // get efix
  m_Efix = DetWS->getLogs()->getPropertyValueAsType<double>("Ei");
  m_pEfixedArray = NULL;
  if (m_Emode == (int)Kernel::DeltaEMode::Indirect)
    m_pEfixedArray = DetWS->getColDataArray<float>("eFixed");

  // set up conversion to working state -- in some tests it can be used straight
  // from the beginning.
  m_TwoTheta = (*m_pTwoThetas)[0];
  m_L2 = (*m_pL2s)[0];
  double Efix = m_Efix;
  if (m_pEfixedArray)
    Efix = (double)(*(m_pEfixedArray + 0));

  m_TargetUnit->initialize(m_L1, m_L2, m_TwoTheta, m_Emode, Efix, 0.);
  if (m_SourceWSUnit) {
    m_SourceWSUnit->initialize(m_L1, m_L2, m_TwoTheta, m_Emode, Efix, 0.);
  }
}
Exemplo n.º 3
0
/** Get set of spectra of the input table workspace
  * Spectra is set to the column named 'spectrum'.
  * Algorithm supports multiple peaks in multiple spectra
  */
void GeneratePeaks::getSpectraSet(
    DataObjects::TableWorkspace_const_sptr peakParmsWS) {
  size_t numpeaks = peakParmsWS->rowCount();
  API::Column_const_sptr col = peakParmsWS->getColumn("spectrum");

  for (size_t ipk = 0; ipk < numpeaks; ipk++) {
    // Spectrum
    specnum_t specid = static_cast<specnum_t>((*col)[ipk]);
    m_spectraSet.insert(specid);

    std::stringstream outss;
    outss << "Peak " << ipk << ": specid = " << specid;
    g_log.debug(outss.str());
  }

  specnum_t icount = 0;
  for (const auto specnum : m_spectraSet) {
    m_SpectrumMap.emplace(specnum, icount);
    ++icount;
  }
}