void Elwin::setDefaultSampleLog(Mantid::API::MatrixWorkspace_const_sptr ws) { auto inst = ws->getInstrument(); // Set sample environment log name auto log = inst->getStringParameter("Workflow.SE-log"); QString logName("sample"); if (log.size() > 0) { logName = QString::fromStdString(log[0]); } m_uiForm.leLogName->setText(logName); // Set sample environment log value auto logval = inst->getStringParameter("Workflow.SE-log-value"); if (logval.size() > 0) { auto logValue = QString::fromStdString(logval[0]); int index = m_uiForm.leLogValue->findText(logValue); if (index >= 0) { m_uiForm.leLogValue->setCurrentIndex(index); } } }
/** * Checks the workspace's intrument for a resolution parameter to use as * a default for the energy range on the mini plot * * @param ws :: Pointer to the workspace to use * @param res :: The retrieved values for the resolution parameter (if one was *found) */ bool IndirectTab::getResolutionRangeFromWs( Mantid::API::MatrixWorkspace_const_sptr ws, QPair<double, double> &res) { auto inst = ws->getInstrument(); auto analyser = inst->getStringParameter("analyser"); if (analyser.size() > 0) { auto comp = inst->getComponentByName(analyser[0]); if (comp) { auto params = comp->getNumberParameter("resolution", true); // set the default instrument resolution if (params.size() > 0) { res = qMakePair(-params[0], params[0]); return true; } } } return false; }
void Elwin::setDefaultResolution(Mantid::API::MatrixWorkspace_const_sptr ws) { auto inst = ws->getInstrument(); auto analyser = inst->getStringParameter("analyser"); if(analyser.size() > 0) { auto comp = inst->getComponentByName(analyser[0]); auto params = comp->getNumberParameter("resolution", true); //set the default instrument resolution if(params.size() > 0) { double res = params[0]; m_dblManager->setValue(m_properties["IntegrationStart"], -res); m_dblManager->setValue(m_properties["IntegrationEnd"], res); m_dblManager->setValue(m_properties["BackgroundStart"], -10*res); m_dblManager->setValue(m_properties["BackgroundEnd"], -9*res); } } }
/**The method responsible for analyzing input workspace parameters and preprocessing detectors positions into reciprocal space * * @param InWS2D -- input Matrix workspace with defined instrument * @param dEModeRequested -- energy conversion mode (direct/indirect/elastic) * @param updateMasks -- if full detector positions calculations or just update masking requested * @param OutWSName -- the name for the preprocessed detectors workspace to have in the analysis data service * * @return shared pointer to the workspace with preprocessed detectors information. */ DataObjects::TableWorkspace_const_sptr ConvertToMDParent::preprocessDetectorsPositions( Mantid::API::MatrixWorkspace_const_sptr InWS2D,const std::string &dEModeRequested, bool updateMasks, const std::string & OutWSName) { DataObjects::TableWorkspace_sptr TargTableWS; Kernel::DeltaEMode::Type Emode; // Do we need to reuse output workspace bool storeInDataService(true); std::string tOutWSName(OutWSName); if(tOutWSName=="-"||tOutWSName.empty()) // TargTableWS is recalculated each time; { storeInDataService = false; tOutWSName = "ServiceTableWS"; // TODO: should be hidden? } else { storeInDataService = true; } // if output workspace exists in dataservice, we may try to use it if(storeInDataService && API::AnalysisDataService::Instance().doesExist(tOutWSName) ) { TargTableWS = API::AnalysisDataService::Instance().retrieveWS<DataObjects::TableWorkspace>(tOutWSName); // get number of all histograms (may be masked or invalid) size_t nHist = InWS2D->getNumberHistograms(); size_t nDetMap=TargTableWS->rowCount(); if(nHist==nDetMap) { // let's take at least some precaution to ensure that instrument have not changed std::string currentWSInstrumentName = InWS2D->getInstrument()->getName(); std::string oldInstrName = TargTableWS->getLogs()->getPropertyValueAsType<std::string>("InstrumentName"); if(oldInstrName==currentWSInstrumentName) { if(!updateMasks) return TargTableWS; //Target workspace with preprocessed detectors exists and seems is correct one. // We still need to update masked detectors information TargTableWS = this->runPreprocessDetectorsToMDChildUpdatingMasks(InWS2D,tOutWSName,dEModeRequested,Emode); return TargTableWS; } } else // there is a workspace in the data service with the same name but this ws is not suitable as target for this algorithm. { // Should delete this WS from the dataservice API::AnalysisDataService::Instance().remove(tOutWSName); } } // No result found in analysis data service or the result is unsatisfactory. Try to calculate target workspace. TargTableWS =this->runPreprocessDetectorsToMDChildUpdatingMasks(InWS2D,tOutWSName,dEModeRequested,Emode); if(storeInDataService) API::AnalysisDataService::Instance().addOrReplace(tOutWSName,TargTableWS); // else // TargTableWS->setName(OutWSName); // check if we got what we wanted: // in direct or indirect mode input ws has to have input energy if(Emode==Kernel::DeltaEMode::Direct||Emode==Kernel::DeltaEMode::Indirect) { double m_Ei = TargTableWS->getLogs()->getPropertyValueAsType<double>("Ei"); if(isNaN(m_Ei)) { // Direct mode needs Ei if(Emode==Kernel::DeltaEMode::Direct)throw(std::invalid_argument("Input neutron's energy has to be defined in inelastic mode ")); // Do we have at least something for Indirect? float *eFixed = TargTableWS->getColDataArray<float>("eFixed"); if(!eFixed) throw(std::invalid_argument("Input neutron's energy has to be defined in inelastic mode ")); uint32_t NDetectors = TargTableWS->getLogs()->getPropertyValueAsType<uint32_t>("ActualDetectorsNum"); for(uint32_t i=0;i<NDetectors;i++) if(isNaN(*(eFixed+i)))throw(std::invalid_argument("Undefined eFixed energy for detector N: "+boost::lexical_cast<std::string>(i))); } } return TargTableWS; }