Ejemplo n.º 1
0
void SliceMDHisto::cutData(Mantid::API::IMDHistoWorkspace_sptr inWS,
                           Mantid::API::IMDHistoWorkspace_sptr outWS,
                           Mantid::coord_t *sourceDim,
                           Mantid::coord_t *targetDim, std::vector<int> start,
                           std::vector<int> end, unsigned int dim) {
  int length;

  boost::shared_ptr<const IMDDimension> inDim = inWS->getDimension(dim);
  boost::shared_ptr<const IMDDimension> outDim = outWS->getDimension(dim);
  length = end[dim] - start[dim];
  if (dim == m_rank - 1) {
    MDHistoWorkspace_sptr outWSS =
        boost::dynamic_pointer_cast<MDHistoWorkspace>(outWS);
    for (int i = 0; i < length; i++) {
      sourceDim[dim] = inDim->getX(start[dim] + i);
      signal_t val = inWS->getSignalAtCoord(
          sourceDim, static_cast<Mantid::API::MDNormalization>(0));
      targetDim[dim] = outDim->getX(i);
      size_t idx = outWSS->getLinearIndexAtCoord(targetDim);
      outWS->setSignalAt(idx, val);
      outWS->setErrorSquaredAt(idx, val);
    }
  } else {
    for (int i = 0; i < length; i++) {
      sourceDim[dim] = inDim->getX(start[dim] + i);
      targetDim[dim] = outDim->getX(i);
      cutData(inWS, outWS, sourceDim, targetDim, start, end, dim + 1);
    }
  }
}
Ejemplo n.º 2
0
void SINQHMListener::recurseDim(int *data, IMDHistoWorkspace_sptr ws,
                                int currentDim, coord_t *idx) {
  if (currentDim == rank) {
    int Cindex = calculateCAddress(idx);
    int val = data[Cindex];
    MDHistoWorkspace_sptr mdws =
        boost::dynamic_pointer_cast<MDHistoWorkspace>(ws);
    size_t F77index = mdws->getLinearIndexAtCoord(idx);
    mdws->setSignalAt(F77index, signal_t(val));
    mdws->setErrorSquaredAt(F77index, signal_t(val));
  } else {
    for (int i = 0; i < dim[currentDim]; i++) {
      idx[currentDim] = static_cast<coord_t>(i);
      recurseDim(data, ws, currentDim + 1, idx);
    }
  }
}