예제 #1
0
/** method to build the Q-coordinates transformation.
 *
 * @param TargWSDescription -- the class which describes target MD workspace. In
 Q3D case this description is modified by the method
                               with default Q-axis labels and Q-axis units
 * @param FrameRequested    -- the string which describes the target
 transformation frame in Q3D case. If the string value is '''Auto'''
 *   the frame is selected depending on the presence of UB matrix and goniometer
 settings, namely it can be:
 * a) the laboratory -- (no UB matrix, goniometer angles set to 0)
   b) Q (sample frame)''': the goniometer rotation of the sample is taken out,
 to give Q in the frame of the sample. See [[SetGoniometer]] to specify the
 goniometer used in the experiment.
   c) Crystal or crystal Cartesian (C)- Busing, Levi 1967 coordinate system --
 depending on Q-scale requested
 *  one of the target frames above can be requested explicitly. In this case the
 method throws invalid argument if necessary parameters (UB matrix) is not
 attached to the workspace

 * @param QScaleRequested   -- Q-transformation needed
 *
 * @return the linear representation for the transformation matrix, which
 translate momentums from laboratory to the requested
 *   coordinate system.
*/
std::vector<double>
MDWSTransform::getTransfMatrix(MDWSDescription &TargWSDescription,
                               const std::string &FrameRequested,
                               const std::string &QScaleRequested) const {
  CoordScaling ScaleID = getQScaling(QScaleRequested);
  TargetFrame FrameID = getTargetFrame(FrameRequested);
  std::vector<double> transf =
      getTransfMatrix(TargWSDescription, FrameID, ScaleID);

  if (TargWSDescription.isQ3DMode()) {
    this->setQ3DDimensionsNames(TargWSDescription, FrameID, ScaleID);
  }

  return transf;
}
예제 #2
0
void MDEventWSWrapper::createEmptyEventWS(const MDWSDescription &description) {

    boost::shared_ptr<DataObjects::MDEventWorkspace<DataObjects::MDEvent<nd>, nd>>
            ws = boost::shared_ptr<
                 DataObjects::MDEventWorkspace<DataObjects::MDEvent<nd>, nd>>(
                     new DataObjects::MDEventWorkspace<DataObjects::MDEvent<nd>, nd>());

    auto numBins = description.getNBins();
    size_t nBins(10); // HACK. this means we have 10 bins artificially. This can't
    // be right.
    // Give all the dimensions
    for (size_t d = 0; d < nd; d++) {
        if (!numBins.empty())
            nBins = numBins[d];

        Geometry::MDHistoDimension *dim = NULL;
        if (d < 3 && description.isQ3DMode()) {
            // We should have frame and scale information that we can use correctly
            // for our Q dimensions.
            auto mdFrame = description.getFrame(d);

            dim = new Geometry::MDHistoDimension(
                description.getDimNames()[d], description.getDimIDs()[d], *mdFrame,
                Mantid::coord_t(description.getDimMin()[d]),
                Mantid::coord_t(description.getDimMax()[d]), nBins);

        } else {
            Mantid::Geometry::GeneralFrame frame(description.getDimNames()[d],
                                                 description.getDimUnits()[d]);
            dim = new Geometry::MDHistoDimension(
                description.getDimNames()[d], description.getDimIDs()[d], frame,
                Mantid::coord_t(description.getDimMin()[d]),
                Mantid::coord_t(description.getDimMax()[d]), nBins);
        }

        ws->addDimension(Geometry::MDHistoDimension_sptr(dim));
    }
    ws->initialize();

    m_Workspace = ws;
}