コード例 #1
0
void SaveNexusProcessed::appendEventListData(std::vector<T> events,
                                             size_t offset, double *tofs,
                                             float *weights,
                                             float *errorSquareds,
                                             int64_t *pulsetimes) {
  // Do nothing if there are no events.
  if (events.empty())
    return;

  typename std::vector<T>::const_iterator it;
  typename std::vector<T>::const_iterator it_end = events.end();
  size_t i = offset;

  // Fill the C-arrays with the fields from all the events, as requested.
  for (it = events.begin(); it != it_end; it++) {
    if (tofs)
      tofs[i] = it->tof();
    if (weights)
      weights[i] = static_cast<float>(it->weight());
    if (errorSquareds)
      errorSquareds[i] = static_cast<float>(it->errorSquared());
    if (pulsetimes)
      pulsetimes[i] = it->pulseTime().totalNanoseconds();
    i++;
  }
}
コード例 #2
0
ファイル: NexusFileIO.cpp プロジェクト: BigShows/mantid
  void NexusFileIO::writeEventListData( std::vector<T> events, bool writeTOF, bool writePulsetime, bool writeWeight, bool writeError) const
  {
    // Do nothing if there are no events.
    if (events.empty())
      return;

    size_t num = events.size();
    double * tofs = new double[num];
    double * weights = new double[num];
    double * errorSquareds = new double[num];
    int64_t * pulsetimes = new int64_t[num];

    typename std::vector<T>::const_iterator it;
    typename std::vector<T>::const_iterator it_end = events.end();
    size_t i = 0;

    // Fill the C-arrays with the fields from all the events, as requested.
    for (it = events.begin(); it != it_end; it++)
    {
      if (writeTOF) tofs[i] = it->tof();
      if (writePulsetime) pulsetimes[i] = it->pulseTime().totalNanoseconds();
      if (writeWeight) weights[i] = it->weight();
      if (writeError) errorSquareds[i] = it->errorSquared();
      i++;
    }

    // Write out all the required arrays.
    int dims_array[1] = { static_cast<int>(num) };
    // In this mode, compressing makes things extremely slow! Not to be used for managed event workspaces.
    bool compress = true; //(num > 100);
    if (writeTOF)
      NXwritedata("tof", NX_FLOAT64, 1, dims_array, (void *)(tofs), compress);
    if (writePulsetime)
      NXwritedata("pulsetime", NX_INT64, 1, dims_array, (void *)(pulsetimes), compress);
    if (writeWeight)
      NXwritedata("weight", NX_FLOAT32, 1, dims_array, (void *)(weights), compress);
    if (writeError)
      NXwritedata("error_squared", NX_FLOAT32, 1, dims_array, (void *)(errorSquareds), compress);

    // Free mem.
    delete [] tofs;
    delete [] weights;
    delete [] errorSquareds;
    delete [] pulsetimes;
  }