/** 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; }
/** * Create new MD workspace and set up its box controller using algorithm's box * controllers properties * @param targWSDescr :: Description of workspace to create * @param filebackend :: true if the workspace will have a file back end * @param filename :: file to use for file back end of workspace * @return :: Shared pointer for the created workspace */ API::IMDEventWorkspace_sptr ConvertToMD::createNewMDWorkspace(const MDWSDescription &targWSDescr, const bool filebackend, const std::string &filename) { // create new md workspace and set internal shared pointer of m_OutWSWrapper // to this workspace API::IMDEventWorkspace_sptr spws = m_OutWSWrapper->createEmptyMDWS(targWSDescr); if (!spws) { g_log.error() << "can not create target event workspace with :" << targWSDescr.nDimensions() << " dimensions\n"; throw(std::invalid_argument("can not create target workspace")); } // Build up the box controller Mantid::API::BoxController_sptr bc = m_OutWSWrapper->pWorkspace()->getBoxController(); // Build up the box controller, using the properties in // BoxControllerSettingsAlgorithm this->setBoxController(bc, m_InWS2D->getInstrument()); if (filebackend) { setupFileBackend(filename, m_OutWSWrapper->pWorkspace()); } // Check if the user want sto force a top level split or not bool topLevelSplittingChecked = this->getProperty("TopLevelSplitting"); if (topLevelSplittingChecked) { // Perform initial split with the forced settings setupTopLevelSplitting(bc); } // split boxes; spws->splitBox(); // Do we split more due to MinRecursionDepth? int minDepth = this->getProperty("MinRecursionDepth"); int maxDepth = this->getProperty("MaxRecursionDepth"); if (minDepth > maxDepth) throw std::invalid_argument( "MinRecursionDepth must be >= MaxRecursionDepth "); spws->setMinRecursionDepth(size_t(minDepth)); return spws; }