本文整理汇总了C++中IAlgorithm_sptr::existsProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::existsProperty方法的具体用法?C++ IAlgorithm_sptr::existsProperty怎么用?C++ IAlgorithm_sptr::existsProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::existsProperty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p
Workspace_sptr
GenericDataProcessorAlgorithm<Base>::load(const std::string &inputData,
const bool loadQuiet) {
Workspace_sptr inputWS;
// First, check whether we have the name of an existing workspace
if (AnalysisDataService::Instance().doesExist(inputData)) {
inputWS = AnalysisDataService::Instance().retrieve(inputData);
} else {
std::string foundFile = FileFinder::Instance().getFullPath(inputData);
if (foundFile.empty()) {
// Get facility extensions
FacilityInfo facilityInfo = ConfigService::Instance().getFacility();
const std::vector<std::string> facilityExts = facilityInfo.extensions();
foundFile = FileFinder::Instance().findRun(inputData, facilityExts);
}
if (!foundFile.empty()) {
Poco::Path p(foundFile);
const std::string outputWSName = p.getBaseName();
IAlgorithm_sptr loadAlg = createChildAlgorithm(m_loadAlg);
loadAlg->setProperty(m_loadAlgFileProp, foundFile);
if (!loadQuiet) {
loadAlg->setAlwaysStoreInADS(true);
}
// Set up MPI if available
#ifdef MPI_BUILD
// First, check whether the loader allows use to chunk the data
if (loadAlg->existsProperty("ChunkNumber") &&
loadAlg->existsProperty("TotalChunks")) {
m_useMPI = true;
// The communicator containing all processes
boost::mpi::communicator world;
g_log.notice() << "Chunk/Total: " << world.rank() + 1 << "/"
<< world.size() << '\n';
loadAlg->setPropertyValue("OutputWorkspace", outputWSName);
loadAlg->setProperty("ChunkNumber", world.rank() + 1);
loadAlg->setProperty("TotalChunks", world.size());
}
#endif
loadAlg->execute();
if (loadQuiet) {
inputWS = loadAlg->getProperty("OutputWorkspace");
} else {
inputWS = AnalysisDataService::Instance().retrieve(outputWSName);
}
} else
throw std::runtime_error(
"DataProcessorAlgorithm::load could process any data");
}
return inputWS;
}
示例2: exec
void HFIRDarkCurrentSubtraction::exec()
{
std::string output_message = "";
// Reduction property manager
const std::string reductionManagerName = getProperty("ReductionProperties");
boost::shared_ptr<PropertyManager> reductionManager;
if (PropertyManagerDataService::Instance().doesExist(reductionManagerName))
{
reductionManager = PropertyManagerDataService::Instance().retrieve(reductionManagerName);
}
else
{
reductionManager = boost::make_shared<PropertyManager>();
PropertyManagerDataService::Instance().addOrReplace(reductionManagerName, reductionManager);
}
// If the load algorithm isn't in the reduction properties, add it
const bool persistent = getProperty("PersistentCorrection");
if (!reductionManager->existsProperty("DarkCurrentAlgorithm") && persistent)
{
AlgorithmProperty *algProp = new AlgorithmProperty("DarkCurrentAlgorithm");
algProp->setValue(toString());
reductionManager->declareProperty(algProp);
}
Progress progress(this,0.0,1.0,10);
MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");
const std::string fileName = getPropertyValue("Filename");
MatrixWorkspace_sptr darkWS;
std::string darkWSName = getPropertyValue("OutputDarkCurrentWorkspace");
progress.report("Subtracting dark current");
// Look for an entry for the dark current in the reduction table
Poco::Path path(fileName);
const std::string entryName = "DarkCurrent"+path.getBaseName();
if (reductionManager->existsProperty(entryName))
{
darkWS = reductionManager->getProperty(entryName);
darkWSName = reductionManager->getPropertyValue(entryName);
output_message += darkWSName + '\n';
} else {
// Load the dark current if we don't have it already
if (darkWSName.size()==0)
{
darkWSName = "__dark_current_"+path.getBaseName();
setPropertyValue("OutputDarkCurrentWorkspace", darkWSName);
}
IAlgorithm_sptr loadAlg;
if (!reductionManager->existsProperty("LoadAlgorithm"))
{
loadAlg = createChildAlgorithm("HFIRLoad", 0.1, 0.3);
loadAlg->setProperty("Filename", fileName);
loadAlg->setProperty("ReductionProperties", reductionManagerName);
loadAlg->executeAsChildAlg();
} else {
IAlgorithm_sptr loadAlg0 = reductionManager->getProperty("LoadAlgorithm");
const std::string loadString = loadAlg0->toString();
loadAlg = Algorithm::fromString(loadString);
loadAlg->setChild(true);
loadAlg->setProperty("Filename", fileName);
loadAlg->setProperty("ReductionProperties", reductionManagerName);
loadAlg->setPropertyValue("OutputWorkspace", darkWSName);
loadAlg->execute();
}
darkWS = loadAlg->getProperty("OutputWorkspace");
output_message += "\n Loaded " + fileName + "\n";
if (loadAlg->existsProperty("OutputMessage"))
{
std::string msg = loadAlg->getPropertyValue("OutputMessage");
output_message += " |" + Poco::replace(msg, "\n", "\n |") + "\n";
}
setProperty("OutputDarkCurrentWorkspace", darkWS);
reductionManager->declareProperty(new WorkspaceProperty<>(entryName,"",Direction::Output));
reductionManager->setPropertyValue(entryName, darkWSName);
reductionManager->setProperty(entryName, darkWS);
}
progress.report(3, "Loaded dark current");
// Perform subtraction
double darkTimer = getCountingTime(darkWS);
double dataTimer = getCountingTime(inputWS);
IAlgorithm_sptr scaleAlg = createChildAlgorithm("Scale", 0.3, 0.5);
scaleAlg->setProperty("InputWorkspace", darkWS);
scaleAlg->setProperty("Factor", dataTimer/darkTimer);
scaleAlg->setProperty("Operation", "Multiply");
scaleAlg->executeAsChildAlg();
MatrixWorkspace_sptr scaledDarkWS = scaleAlg->getProperty("OutputWorkspace");
// Zero out timer and monitor so that we don't subtract them out
for(size_t i=0; i<scaledDarkWS->dataY(0).size(); i++)
{
scaledDarkWS->dataY(DEFAULT_TIMER_ID)[i]=0.0;
scaledDarkWS->dataE(DEFAULT_TIMER_ID)[i]=0.0;
scaledDarkWS->dataY(DEFAULT_MONITOR_ID)[i]=0.0;
scaledDarkWS->dataE(DEFAULT_MONITOR_ID)[i]=0.0;
//.........这里部分代码省略.........
示例3: exec
void EQSANSLoad::exec() {
// Verify the validity of the inputs
// TODO: this should be done by the new data management algorithm used for
// live data reduction (when it's implemented...)
const std::string fileName = getPropertyValue("Filename");
EventWorkspace_sptr inputEventWS = getProperty("InputWorkspace");
if (fileName.size() == 0 && !inputEventWS) {
g_log.error() << "EQSANSLoad input error: Either a valid file path or an "
"input workspace must be provided\n";
throw std::runtime_error("EQSANSLoad input error: Either a valid file path "
"or an input workspace must be provided");
} else if (fileName.size() > 0 && inputEventWS) {
g_log.error() << "EQSANSLoad input error: Either a valid file path or an "
"input workspace must be provided, but not both\n";
throw std::runtime_error("EQSANSLoad input error: Either a valid file path "
"or an input workspace must be provided, but not "
"both");
}
// Read in default TOF cuts
const bool skipTOFCorrection = getProperty("SkipTOFCorrection");
m_low_TOF_cut = getProperty("LowTOFCut");
m_high_TOF_cut = getProperty("HighTOFCut");
// Read in default beam center
m_center_x = getProperty("BeamCenterX");
m_center_y = getProperty("BeamCenterY");
const bool noBeamCenter = getProperty("NoBeamCenter");
// Reduction property manager
const std::string reductionManagerName = getProperty("ReductionProperties");
boost::shared_ptr<PropertyManager> reductionManager;
if (PropertyManagerDataService::Instance().doesExist(reductionManagerName)) {
reductionManager =
PropertyManagerDataService::Instance().retrieve(reductionManagerName);
} else {
reductionManager = boost::make_shared<PropertyManager>();
PropertyManagerDataService::Instance().addOrReplace(reductionManagerName,
reductionManager);
}
if (!reductionManager->existsProperty("LoadAlgorithm")) {
auto loadProp = make_unique<AlgorithmProperty>("LoadAlgorithm");
setPropertyValue("InputWorkspace", "");
setProperty("NoBeamCenter", false);
loadProp->setValue(toString());
reductionManager->declareProperty(std::move(loadProp));
}
if (!reductionManager->existsProperty("InstrumentName")) {
reductionManager->declareProperty(
make_unique<PropertyWithValue<std::string>>("InstrumentName",
"EQSANS"));
}
// Output log
m_output_message = "";
// Check whether we need to load the data
if (!inputEventWS) {
const bool loadMonitors = getProperty("LoadMonitors");
IAlgorithm_sptr loadAlg = createChildAlgorithm("LoadEventNexus", 0, 0.2);
loadAlg->setProperty("LoadMonitors", loadMonitors);
loadAlg->setProperty("MonitorsAsEvents", false);
loadAlg->setProperty("Filename", fileName);
if (skipTOFCorrection) {
if (m_low_TOF_cut > 0.0)
loadAlg->setProperty("FilterByTofMin", m_low_TOF_cut);
if (m_high_TOF_cut > 0.0)
loadAlg->setProperty("FilterByTofMax", m_high_TOF_cut);
}
loadAlg->execute();
Workspace_sptr dataWS_asWks = loadAlg->getProperty("OutputWorkspace");
dataWS = boost::dynamic_pointer_cast<MatrixWorkspace>(dataWS_asWks);
// Get monitor workspace as necessary
std::string mon_wsname = getPropertyValue("OutputWorkspace") + "_monitors";
if (loadMonitors && loadAlg->existsProperty("MonitorWorkspace")) {
Workspace_sptr monWSOutput = loadAlg->getProperty("MonitorWorkspace");
MatrixWorkspace_sptr monWS =
boost::dynamic_pointer_cast<MatrixWorkspace>(monWSOutput);
if ((monWSOutput) && (!monWS)) {
// this was a group workspace - EQSansLoad does not support multi period
// data yet
throw Exception::NotImplementedError("The file contains multi period "
"data, support for this is not "
"implemented in EQSANSLoad yet");
}
declareProperty(Kernel::make_unique<WorkspaceProperty<>>(
"MonitorWorkspace", mon_wsname, Direction::Output),
"Monitors from the Event NeXus file");
setProperty("MonitorWorkspace", monWS);
}
} else {
MatrixWorkspace_sptr outputWS = getProperty("OutputWorkspace");
EventWorkspace_sptr outputEventWS =
boost::dynamic_pointer_cast<EventWorkspace>(outputWS);
if (inputEventWS != outputEventWS) {
IAlgorithm_sptr copyAlg = createChildAlgorithm("CloneWorkspace", 0, 0.2);
copyAlg->setProperty("InputWorkspace", inputEventWS);
//.........这里部分代码省略.........
示例4: exec
void SANSSensitivityCorrection::exec() {
// Output log
m_output_message = "";
Progress progress(this, 0.0, 1.0, 10);
// Reduction property manager
const std::string reductionManagerName = getProperty("ReductionProperties");
boost::shared_ptr<PropertyManager> reductionManager;
if (PropertyManagerDataService::Instance().doesExist(reductionManagerName)) {
reductionManager =
PropertyManagerDataService::Instance().retrieve(reductionManagerName);
} else {
reductionManager = boost::make_shared<PropertyManager>();
PropertyManagerDataService::Instance().addOrReplace(reductionManagerName,
reductionManager);
}
if (!reductionManager->existsProperty("SensitivityAlgorithm")) {
auto algProp = make_unique<AlgorithmProperty>("SensitivityAlgorithm");
algProp->setValue(toString());
reductionManager->declareProperty(std::move(algProp));
}
progress.report("Loading sensitivity file");
const std::string fileName = getPropertyValue("Filename");
// Look for an entry for the dark current in the reduction table
Poco::Path path(fileName);
const std::string entryName = "Sensitivity" + path.getBaseName();
MatrixWorkspace_sptr floodWS;
std::string floodWSName = "__sensitivity_" + path.getBaseName();
if (reductionManager->existsProperty(entryName)) {
std::string wsName = reductionManager->getPropertyValue(entryName);
floodWS = boost::dynamic_pointer_cast<MatrixWorkspace>(
AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName));
m_output_message += " |Using " + wsName + "\n";
g_log.debug()
<< "SANSSensitivityCorrection :: Using sensitivity workspace: "
<< wsName << "\n";
} else {
// Load the flood field if we don't have it already
// First, try to determine whether we need to load data or a sensitivity
// workspace...
if (!floodWS && fileCheck(fileName)) {
g_log.debug() << "SANSSensitivityCorrection :: Loading sensitivity file: "
<< fileName << "\n";
IAlgorithm_sptr loadAlg = createChildAlgorithm("Load", 0.1, 0.3);
loadAlg->setProperty("Filename", fileName);
loadAlg->executeAsChildAlg();
Workspace_sptr floodWS_ws = loadAlg->getProperty("OutputWorkspace");
floodWS = boost::dynamic_pointer_cast<MatrixWorkspace>(floodWS_ws);
// Check that it's really a sensitivity file
if (!floodWS->run().hasProperty("is_sensitivity")) {
// Reset pointer
floodWS.reset();
g_log.error() << "A processed Mantid workspace was loaded but it "
"wasn't a sensitivity file!\n";
}
}
// ... if we don't, just load the data and process it
if (!floodWS) {
// Read in default beam center
double center_x = getProperty("BeamCenterX");
double center_y = getProperty("BeamCenterY");
if (isEmpty(center_x) || isEmpty(center_y)) {
if (reductionManager->existsProperty("LatestBeamCenterX") &&
reductionManager->existsProperty("LatestBeamCenterY")) {
center_x = reductionManager->getProperty("LatestBeamCenterX");
center_y = reductionManager->getProperty("LatestBeamCenterY");
m_output_message +=
" |Setting beam center to [" +
Poco::NumberFormatter::format(center_x, 1) + ", " +
Poco::NumberFormatter::format(center_y, 1) + "]\n";
} else
m_output_message += " |No beam center provided: skipping!\n";
}
const std::string rawFloodWSName = "__flood_data_" + path.getBaseName();
MatrixWorkspace_sptr rawFloodWS;
if (!reductionManager->existsProperty("LoadAlgorithm")) {
IAlgorithm_sptr loadAlg = createChildAlgorithm("Load", 0.1, 0.3);
loadAlg->setProperty("Filename", fileName);
if (!isEmpty(center_x) && loadAlg->existsProperty("BeamCenterX"))
loadAlg->setProperty("BeamCenterX", center_x);
if (!isEmpty(center_y) && loadAlg->existsProperty("BeamCenterY"))
loadAlg->setProperty("BeamCenterY", center_y);
loadAlg->setPropertyValue("OutputWorkspace", rawFloodWSName);
loadAlg->executeAsChildAlg();
Workspace_sptr tmpWS = loadAlg->getProperty("OutputWorkspace");
rawFloodWS = boost::dynamic_pointer_cast<MatrixWorkspace>(tmpWS);
m_output_message += " | Loaded " + fileName + " (Load algorithm)\n";
} else {
// Get load algorithm as a string so that we can create a completely
// new proxy and ensure that we don't overwrite existing properties
IAlgorithm_sptr loadAlg0 =
reductionManager->getProperty("LoadAlgorithm");
//.........这里部分代码省略.........