예제 #1
0
/** function creates empty MD event workspace with given parameters (workspace factory) and stores internal pointer to this workspace for further usage.
*  IT ASLO SETS UP W-TRANSFORMATON. TODO: reconsile w-transfo with MD geometry. 
*
*@param WSD the class which describes an MD workspace
*
*@returns shared pointer to the created workspace
*/
API::IMDEventWorkspace_sptr MDEventWSWrapper::createEmptyMDWS(const MDWSDescription &WSD)
{

  if(WSD.nDimensions()<1||WSD.nDimensions()>MAX_N_DIM)
  {
    std::string ERR=" Number of requested MD dimensions: "+boost::lexical_cast<std::string>(WSD.nDimensions())+
      " exceeds maximal number of MD dimensions: "+boost::lexical_cast<std::string>((int)MAX_N_DIM)+" instantiated during compilation\n";
    throw(std::invalid_argument(ERR));
  }

  m_NDimensions = (int)WSD.nDimensions();
  // call the particular function, which creates the workspace with n_dimensions
  (this->*(wsCreator[m_NDimensions]))(WSD.getDimNames(),WSD.getDimIDs(),WSD.getDimUnits(),WSD.getDimMin(),WSD.getDimMax(),WSD.getNBins());

  // set up the matrix, which convert momentums from Q in orthogonal crystal coordinate system and units of Angstrom^-1 to hkl or orthogonal hkl or whatevert
  m_Workspace->setWTransf(WSD.m_Wtransf);
  return m_Workspace;
}
예제 #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;
}