本文整理汇总了C++中mantid::api::MatrixWorkspace_const_sptr::getInstrument方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_const_sptr::getInstrument方法的具体用法?C++ MatrixWorkspace_const_sptr::getInstrument怎么用?C++ MatrixWorkspace_const_sptr::getInstrument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid::api::MatrixWorkspace_const_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_const_sptr::getInstrument方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setDefaultSampleLog
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);
}
}
}
示例2: getResolutionRangeFromWs
/**
* 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;
}
示例3: preprocessDetectorsPositions
/**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;
}