本文整理汇总了C++中Algorithm_sptr::getPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Algorithm_sptr::getPropertyValue方法的具体用法?C++ Algorithm_sptr::getPropertyValue怎么用?C++ Algorithm_sptr::getPropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Algorithm_sptr
的用法示例。
在下文中一共展示了Algorithm_sptr::getPropertyValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPropertyValue
/** Process groups. Groups are processed differently depending on transmission
* runs and polarization analysis. If transmission run is a matrix workspace, it
* will be applied to each of the members in the input workspace group. If
* transmission run is a workspace group, the behaviour is different depending
* on polarization analysis. If polarization analysis is off (i.e.
* 'PolarizationAnalysis' is set to 'None') each item in the transmission group
* is associated with the corresponding item in the input workspace group. If
* polarization analysis is on (i.e. 'PolarizationAnalysis' is 'PA' or 'PNR')
* items in the transmission group will be summed to produce a matrix workspace
* that will be applied to each of the items in the input workspace group. See
* documentation of this algorithm for more details.
*/
bool ReflectometryReductionOneAuto2::processGroups() {
// this algorithm effectively behaves as MultiPeriodGroupAlgorithm
m_usingBaseProcessGroups = true;
// Get our input workspace group
auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
getPropertyValue("InputWorkspace"));
// Get name of IvsQ workspace (native binning)
const std::string outputIvsQ = getPropertyValue("OutputWorkspace");
// Get name of IvsQ (native binning) workspace
const std::string outputIvsQBinned =
getPropertyValue("OutputWorkspaceBinned");
// Get name of IvsLam workspace
const std::string outputIvsLam =
getPropertyValue("OutputWorkspaceWavelength");
// Create a copy of ourselves
Algorithm_sptr alg =
createChildAlgorithm(name(), -1, -1, isLogging(), version());
alg->setChild(false);
alg->setRethrows(true);
// Copy all the non-workspace properties over
const std::vector<Property *> props = getProperties();
for (auto &prop : props) {
if (prop) {
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (!wsProp)
alg->setPropertyValue(prop->name(), prop->value());
}
}
const bool polarizationAnalysisOn =
getPropertyValue("PolarizationAnalysis") != "None";
// Check if the transmission runs are groups or not
const std::string firstTrans = getPropertyValue("FirstTransmissionRun");
WorkspaceGroup_sptr firstTransG;
MatrixWorkspace_sptr firstTransSum;
if (!firstTrans.empty()) {
auto firstTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans);
firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS);
if (!firstTransG) {
alg->setProperty("FirstTransmissionRun", firstTrans);
} else if (polarizationAnalysisOn) {
firstTransSum = sumTransmissionWorkspaces(firstTransG);
}
}
const std::string secondTrans = getPropertyValue("SecondTransmissionRun");
WorkspaceGroup_sptr secondTransG;
MatrixWorkspace_sptr secondTransSum;
if (!secondTrans.empty()) {
auto secondTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans);
secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS);
if (!secondTransG) {
alg->setProperty("SecondTransmissionRun", secondTrans);
} else if (polarizationAnalysisOn) {
secondTransSum = sumTransmissionWorkspaces(secondTransG);
}
}
std::vector<std::string> IvsQGroup, IvsQUnbinnedGroup, IvsLamGroup;
// Execute algorithm over each group member
for (size_t i = 0; i < group->size(); ++i) {
const std::string IvsQName = outputIvsQ + "_" + std::to_string(i + 1);
const std::string IvsQBinnedName =
outputIvsQBinned + "_" + std::to_string(i + 1);
const std::string IvsLamName = outputIvsLam + "_" + std::to_string(i + 1);
if (firstTransG) {
if (!polarizationAnalysisOn)
alg->setProperty("FirstTransmissionRun",
firstTransG->getItem(i)->getName());
else
alg->setProperty("FirstTransmissionRun", firstTransSum);
}
if (secondTransG) {
if (!polarizationAnalysisOn)
alg->setProperty("SecondTransmissionRun",
secondTransG->getItem(i)->getName());
else
alg->setProperty("SecondTransmissionRun", secondTransSum);
}
//.........这里部分代码省略.........
示例2: processGroups
bool ReflectometryReductionOneAuto::processGroups() {
auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
getPropertyValue("InputWorkspace"));
const std::string outputIvsQ = this->getPropertyValue("OutputWorkspace");
const std::string outputIvsLam =
this->getPropertyValue("OutputWorkspaceWavelength");
// Create a copy of ourselves
Algorithm_sptr alg = this->createChildAlgorithm(
this->name(), -1, -1, this->isLogging(), this->version());
alg->setChild(false);
alg->setRethrows(true);
// Copy all the non-workspace properties over
std::vector<Property *> props = this->getProperties();
for (auto prop = props.begin(); prop != props.end(); ++prop) {
if (*prop) {
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(*prop);
if (!wsProp)
alg->setPropertyValue((*prop)->name(), (*prop)->value());
}
}
// Check if the transmission runs are groups or not
const std::string firstTrans = this->getPropertyValue("FirstTransmissionRun");
WorkspaceGroup_sptr firstTransG;
if (!firstTrans.empty()) {
auto firstTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans);
firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS);
if (!firstTransG)
alg->setProperty("FirstTransmissionRun", firstTrans);
else if (group->size() != firstTransG->size())
throw std::runtime_error("FirstTransmissionRun WorkspaceGroup must be "
"the same size as the InputWorkspace "
"WorkspaceGroup");
}
const std::string secondTrans =
this->getPropertyValue("SecondTransmissionRun");
WorkspaceGroup_sptr secondTransG;
if (!secondTrans.empty()) {
auto secondTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans);
secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS);
if (!secondTransG)
alg->setProperty("SecondTransmissionRun", secondTrans);
else if (group->size() != secondTransG->size())
throw std::runtime_error("SecondTransmissionRun WorkspaceGroup must be "
"the same size as the InputWorkspace "
"WorkspaceGroup");
}
std::vector<std::string> IvsQGroup, IvsLamGroup;
// Execute algorithm over each group member (or period, if this is
// multiperiod)
size_t numMembers = group->size();
for (size_t i = 0; i < numMembers; ++i) {
const std::string IvsQName =
outputIvsQ + "_" + boost::lexical_cast<std::string>(i + 1);
const std::string IvsLamName =
outputIvsLam + "_" + boost::lexical_cast<std::string>(i + 1);
alg->setProperty("InputWorkspace", group->getItem(i)->name());
alg->setProperty("OutputWorkspace", IvsQName);
alg->setProperty("OutputWorkspaceWavelength", IvsLamName);
// Handle transmission runs
if (firstTransG)
alg->setProperty("FirstTransmissionRun", firstTransG->getItem(i)->name());
if (secondTransG)
alg->setProperty("SecondTransmissionRun",
secondTransG->getItem(i)->name());
alg->execute();
IvsQGroup.push_back(IvsQName);
IvsLamGroup.push_back(IvsLamName);
// We use the first group member for our thetaout value
if (i == 0)
this->setPropertyValue("ThetaOut", alg->getPropertyValue("ThetaOut"));
}
// Group the IvsQ and IvsLam workspaces
Algorithm_sptr groupAlg = this->createChildAlgorithm("GroupWorkspaces");
groupAlg->setChild(false);
groupAlg->setRethrows(true);
groupAlg->setProperty("InputWorkspaces", IvsLamGroup);
groupAlg->setProperty("OutputWorkspace", outputIvsLam);
groupAlg->execute();
groupAlg->setProperty("InputWorkspaces", IvsQGroup);
groupAlg->setProperty("OutputWorkspace", outputIvsQ);
groupAlg->execute();
//.........这里部分代码省略.........
示例3: processGroups
bool ReflectometryReductionOneAuto::processGroups() {
// isPolarizationCorrectionOn is used to decide whether
// we should process our Transmission WorkspaceGroup members
// as individuals (not multiperiod) when PolarizationCorrection is off,
// or sum over all of the workspaces in the group
// and used that sum as our TransmissionWorkspace when PolarizationCorrection
// is on.
const bool isPolarizationCorrectionOn =
this->getPropertyValue("PolarizationAnalysis") !=
noPolarizationCorrectionMode();
// Get our input workspace group
auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(
getPropertyValue("InputWorkspace"));
// Get name of IvsQ workspace
const std::string outputIvsQ = this->getPropertyValue("OutputWorkspace");
// Get name of IvsLam workspace
const std::string outputIvsLam =
this->getPropertyValue("OutputWorkspaceWavelength");
// Create a copy of ourselves
Algorithm_sptr alg = this->createChildAlgorithm(
this->name(), -1, -1, this->isLogging(), this->version());
alg->setChild(false);
alg->setRethrows(true);
// Copy all the non-workspace properties over
std::vector<Property *> props = this->getProperties();
for (auto &prop : props) {
if (prop) {
IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop);
if (!wsProp)
alg->setPropertyValue(prop->name(), prop->value());
}
}
// Check if the transmission runs are groups or not
const std::string firstTrans = this->getPropertyValue("FirstTransmissionRun");
WorkspaceGroup_sptr firstTransG;
if (!firstTrans.empty()) {
auto firstTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans);
firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS);
if (!firstTransG) {
// we only have one transmission workspace, so we use it as it is.
alg->setProperty("FirstTransmissionRun", firstTrans);
} else if (group->size() != firstTransG->size() &&
!isPolarizationCorrectionOn) {
// if they are not the same size then we cannot associate a transmission
// group workspace member with every input group workpspace member.
throw std::runtime_error("FirstTransmissionRun WorkspaceGroup must be "
"the same size as the InputWorkspace "
"WorkspaceGroup");
}
}
const std::string secondTrans =
this->getPropertyValue("SecondTransmissionRun");
WorkspaceGroup_sptr secondTransG;
if (!secondTrans.empty()) {
auto secondTransWS =
AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans);
secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS);
if (!secondTransG)
// we only have one transmission workspace, so we use it as it is.
alg->setProperty("SecondTransmissionRun", secondTrans);
else if (group->size() != secondTransG->size() &&
!isPolarizationCorrectionOn) {
// if they are not the same size then we cannot associate a transmission
// group workspace member with every input group workpspace member.
throw std::runtime_error("SecondTransmissionRun WorkspaceGroup must be "
"the same size as the InputWorkspace "
"WorkspaceGroup");
}
}
std::vector<std::string> IvsQGroup, IvsLamGroup;
// Execute algorithm over each group member (or period, if this is
// multiperiod)
size_t numMembers = group->size();
for (size_t i = 0; i < numMembers; ++i) {
const std::string IvsQName =
outputIvsQ + "_" + boost::lexical_cast<std::string>(i + 1);
const std::string IvsLamName =
outputIvsLam + "_" + boost::lexical_cast<std::string>(i + 1);
// If our transmission run is a group and PolarizationCorrection is on
// then we sum our transmission group members.
//
// This is done inside of the for loop to avoid the wrong workspace being
// used when these arguments are passed through to the exec() method.
// If this is not set in the loop, exec() will fetch the first workspace
// from the specified Transmission Group workspace that the user entered.
if (firstTransG && isPolarizationCorrectionOn) {
auto firstTransmissionSum = sumOverTransmissionGroup(firstTransG);
alg->setProperty("FirstTransmissionRun", firstTransmissionSum);
}
if (secondTransG && isPolarizationCorrectionOn) {
//.........这里部分代码省略.........