本文整理汇总了C++中api::IAlgorithm_sptr::getPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::getPropertyValue方法的具体用法?C++ IAlgorithm_sptr::getPropertyValue怎么用?C++ IAlgorithm_sptr::getPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::getPropertyValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOutputWorkspace
/**
* Set the output workspace(s) if the load's return workspace has type
* API::Workspace
* @param loader :: Shared pointer to load algorithm
*/
void Load::setOutputWorkspace(const API::IAlgorithm_sptr &loader) {
// Go through each OutputWorkspace property and check whether we need to make
// a counterpart here
const std::vector<Property *> &loaderProps = loader->getProperties();
const size_t count = loader->propertyCount();
for (size_t i = 0; i < count; ++i) {
Property *prop = loaderProps[i];
if (dynamic_cast<IWorkspaceProperty *>(prop) &&
prop->direction() == Direction::Output) {
const std::string &name = prop->name();
if (!this->existsProperty(name)) {
declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>(
name, loader->getPropertyValue(name), Direction::Output));
}
Workspace_sptr wkspace = getOutputWorkspace(name, loader);
setProperty(name, wkspace);
}
}
}
示例2: exec
/**
* Executes the algorithm
*/
void PlotPeakByLogValue::exec()
{
// Create a list of the input workspace
const std::vector<InputData> wsNames = makeNames();
std::string fun = getPropertyValue("Function");
//int wi = getProperty("WorkspaceIndex");
std::string logName = getProperty("LogValue");
bool sequential = getPropertyValue("FitType") == "Sequential";
bool isDataName = false; // if true first output column is of type string and is the data source name
ITableWorkspace_sptr result = WorkspaceFactory::Instance().createTable("TableWorkspace");
if (logName == "SourceName")
{
result->addColumn("str","Source name");
isDataName = true;
}
else if (logName.empty())
{
result->addColumn("double","axis-1");
}
else
{
result->addColumn("double",logName);
}
// Create an instance of the fitting function to obtain the names of fitting parameters
IFitFunction* ifun = FunctionFactory::Instance().createInitialized(fun);
if (!ifun)
{
throw std::invalid_argument("Fitting function failed to initialize");
}
for(size_t iPar=0;iPar<ifun->nParams();++iPar)
{
result->addColumn("double",ifun->parameterName(iPar));
result->addColumn("double",ifun->parameterName(iPar)+"_Err");
}
result->addColumn("double","Chi_squared");
delete ifun;
setProperty("OutputWorkspace",result);
double dProg = 1./static_cast<double>(wsNames.size());
double Prog = 0.;
for(int i=0;i<static_cast<int>(wsNames.size());++i)
{
InputData data = getWorkspace(wsNames[i]);
if (!data.ws)
{
g_log.warning() << "Cannot access workspace " << wsNames[i].name << '\n';
continue;
}
if (data.i < 0 && data.indx.empty())
{
g_log.warning() << "Zero spectra selected for fitting in workspace " << wsNames[i].name << '\n';
continue;
}
int j,jend;
if (data.i >= 0)
{
j = data.i;
jend = j + 1;
}
else
{// no need to check data.indx.empty()
j = data.indx.front();
jend = data.indx.back() + 1;
}
dProg /= abs(jend - j);
for(;j < jend;++j)
{
// Find the log value: it is either a log-file value or simply the workspace number
double logValue;
if (logName.empty())
{
API::Axis* axis = data.ws->getAxis(1);
logValue = (*axis)(j);
}
else if (logName != "SourceName")
{
Kernel::Property* prop = data.ws->run().getLogData(logName);
if (!prop)
{
throw std::invalid_argument("Log value "+logName+" does not exist");
}
TimeSeriesProperty<double>* logp =
dynamic_cast<TimeSeriesProperty<double>*>(prop);
logValue = logp->lastValue();
}
std::string resFun = fun;
std::vector<double> errors;
double chi2;
//.........这里部分代码省略.........