本文整理汇总了C++中IAlgorithm_sptr::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::setProperty方法的具体用法?C++ IAlgorithm_sptr::setProperty怎么用?C++ IAlgorithm_sptr::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void StripVanadiumPeaks2::exec(){
// 1. Process input/output
API::MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");
std::string outputWSName = getPropertyValue("OutputWorkspace");
int singleIndex = getProperty("WorkspaceIndex");
int param_fwhm = getProperty("FWHM");
int param_tolerance = getProperty("Tolerance");
bool singleSpectrum = !isEmpty(singleIndex);
// 2. Call StripPeaks
std::string peakpositions;
std::string unit = inputWS->getAxis(0)->unit()->unitID();
if (unit == "dSpacing")
{
peakpositions = "0.5044,0.5191,0.5350,0.5526,0.5936,0.6178,0.6453,0.6768,0.7134,0.7566,0.8089,0.8737,0.9571,1.0701,1.2356,1.5133,2.1401";
}
else if (unit == "MomentumTransfer")
{
g_log.error() << "Unit MomentumTransfer (Q-space) is NOT supported by StripVanadiumPeaks now.\n";
throw std::invalid_argument("Q-space is not supported");
// Comment out next line as it won't be reached.
//peakpositions = "2.9359, 4.1520, 5.0851, 5.8716, 6.5648, 7.1915, 7.7676, 8.3045, 8.8074, 9.2837, 9.7368, 10.1703, 10.5849, 11.3702, 11.7443, 12.1040, 12.4568";
} else {
g_log.error() << "Unit " << unit << " Is NOT supported by StripVanadiumPeaks, which only supports d-spacing" << std::endl;
throw std::invalid_argument("Not supported unit");
}
// Call StripPeak
double pro0 = 0.0;
double prof = 1.0;
bool sublog = true;
IAlgorithm_sptr stripPeaks = createChildAlgorithm("StripPeaks", pro0, prof, sublog);
stripPeaks->setProperty("InputWorkspace", inputWS);
stripPeaks->setPropertyValue("OutputWorkspace", outputWSName);
stripPeaks->setProperty("FWHM", param_fwhm);
stripPeaks->setProperty("Tolerance", param_tolerance);
stripPeaks->setPropertyValue("PeakPositions", peakpositions);
stripPeaks->setProperty<std::string>("BackgroundType", getProperty("BackgroundType"));
stripPeaks->setProperty<bool>("HighBackground", getProperty("HighBackground"));
if (singleSpectrum){
stripPeaks->setProperty("WorkspaceIndex", singleIndex);
}
stripPeaks->setProperty<double>("PeakPositionTolerance", getProperty("PeakPositionTolerance"));
stripPeaks->executeAsChildAlg();
// 3. Get and set output workspace
// API::MatrixWorkspace_sptr outputWS = AnalysisDataService::Instance().retrieveWS<API::MatrixWorkspace_sptr>(outputWSName);
// boost::shared_ptr<API::Workspace> outputWS = AnalysisDataService::Instance().retrieve(outputWSName);
API::MatrixWorkspace_sptr outputWS = stripPeaks->getProperty("OutputWorkspace");
this->setProperty("OutputWorkspace", outputWS);
return;
}
示例2: exec
/** Executes the algorithm */
void FilterBadPulses::exec()
{
// the input workspace into the event workspace we already know it is
EventWorkspace_sptr inputWS = this->getProperty("InputWorkspace");
// get the proton charge exists in the run object
const API::Run& runlogs = inputWS->run();
if (!runlogs.hasProperty("proton_charge"))
{
throw std::runtime_error("Failed to find \"proton_charge\" in sample logs");
}
Kernel::TimeSeriesProperty<double> * pcharge_log
= dynamic_cast<Kernel::TimeSeriesProperty<double> *>( runlogs.getLogData("proton_charge") );
Kernel::TimeSeriesPropertyStatistics stats = pcharge_log->getStatistics();
// set the range
double min_percent = this->getProperty("LowerCutoff");
min_percent *= .01; // convert it to a percentage (0<x<1)
double min_pcharge = stats.mean * min_percent;
double max_pcharge = stats.maximum * 1.1; // make sure everything high is in
if (min_pcharge >= max_pcharge) {
throw std::runtime_error("proton_charge window filters out all of the data");
}
this->g_log.information() << "Filtering pcharge outside of " << min_pcharge
<< " to " << max_pcharge << std::endl;
size_t inputNumEvents = inputWS->getNumberEvents();
// sub-algorithme does all of the actual work - do not set the output workspace
IAlgorithm_sptr filterAlgo = createSubAlgorithm("FilterByLogValue", 0., 1.);
filterAlgo->setProperty("InputWorkspace", inputWS);
filterAlgo->setProperty("LogName", "proton_charge");
filterAlgo->setProperty("MinimumValue", min_pcharge);
filterAlgo->setProperty("MaximumValue", max_pcharge);
filterAlgo->execute();
// just grab the child's output workspace
EventWorkspace_sptr outputWS = filterAlgo->getProperty("OutputWorkspace");
size_t outputNumEvents = outputWS->getNumberEvents();
this->setProperty("OutputWorkspace", outputWS);
// log the number of events deleted
double percent = static_cast<double>(inputNumEvents - outputNumEvents)
/ static_cast<double>(inputNumEvents);
percent *= 100.;
if (percent > 10.)
{
this->g_log.warning() << "Deleted " << (inputNumEvents - outputNumEvents)
<< " of " << inputNumEvents
<< " events (" << static_cast<int>(percent) << "%)\n";
}
else
{
this->g_log.information() << "Deleted " << (inputNumEvents - outputNumEvents)
<< " of " << inputNumEvents
<< " events (" << static_cast<int>(percent) << "%)\n";
}
}
示例3: integration
MatrixWorkspace_sptr CalculateIqt::integration(MatrixWorkspace_sptr workspace) {
IAlgorithm_sptr integrationAlgorithm =
this->createChildAlgorithm("Integration");
integrationAlgorithm->initialize();
integrationAlgorithm->setProperty("InputWorkspace", workspace);
integrationAlgorithm->setProperty("OutputWorkspace", "_");
integrationAlgorithm->execute();
return integrationAlgorithm->getProperty("OutputWorkspace");
}
示例4: applyDTC
/**
* Applies dead time correction to the workspace.
* @param ws :: Workspace to apply correction
* @param dt :: Dead time table to use
* @return Corrected workspace
*/
MatrixWorkspace_sptr MuonLoad::applyDTC(MatrixWorkspace_sptr ws,
TableWorkspace_sptr dt) {
IAlgorithm_sptr dtc = createChildAlgorithm("ApplyDeadTimeCorr");
dtc->setProperty("InputWorkspace", ws);
dtc->setProperty("DeadTimeTable", dt);
dtc->execute();
return dtc->getProperty("OutputWorkspace");
}
示例5: groupWorkspace
/**
* Groups specified workspace according to specified DetectorGroupingTable.
* @param ws :: Workspace to group
* @param grouping :: Detector grouping table to use
* @return Grouped workspace
*/
MatrixWorkspace_sptr MuonLoad::groupWorkspace(MatrixWorkspace_sptr ws,
TableWorkspace_sptr grouping) {
IAlgorithm_sptr group = createChildAlgorithm("MuonGroupDetectors");
group->setProperty("InputWorkspace", ws);
group->setProperty("DetectorGroupingTable", grouping);
group->execute();
return group->getProperty("OutputWorkspace");
}
示例6: applyMask
/**
* Function to apply a given mask to a workspace.
* @param inputWS : the workspace to mask
* @param maskWS : the workspace containing the masking information
*/
void DetectorDiagnostic::applyMask(API::MatrixWorkspace_sptr inputWS,
API::MatrixWorkspace_sptr maskWS)
{
IAlgorithm_sptr maskAlg = createChildAlgorithm("MaskDetectors"); // should set progress bar
maskAlg->setProperty("Workspace", inputWS);
maskAlg->setProperty("MaskedWorkspace", maskWS);
maskAlg->setProperty("StartWorkspaceIndex", m_minIndex);
maskAlg->setProperty("EndWorkspaceIndex", m_maxIndex);
maskAlg->executeAsChildAlg();
}
示例7: divide
MatrixWorkspace_sptr CalculateIqt::divide(MatrixWorkspace_sptr lhsWorkspace,
MatrixWorkspace_sptr rhsWorkspace) {
IAlgorithm_sptr divideAlgorithm = this->createChildAlgorithm("Divide");
divideAlgorithm->initialize();
divideAlgorithm->setProperty("LHSWorkspace", lhsWorkspace);
divideAlgorithm->setProperty("RHSWorkspace", rhsWorkspace);
divideAlgorithm->setProperty("OutputWorkspace", "_");
divideAlgorithm->execute();
return divideAlgorithm->getProperty("OutputWorkspace");
}
示例8:
MatrixWorkspace_sptr
CalculateIqt::convertToPointData(MatrixWorkspace_sptr workspace) {
IAlgorithm_sptr pointDataAlgorithm =
this->createChildAlgorithm("ConvertToPointData");
pointDataAlgorithm->initialize();
pointDataAlgorithm->setProperty("InputWorkspace", workspace);
pointDataAlgorithm->setProperty("OutputWorkspace", "_");
pointDataAlgorithm->execute();
return pointDataAlgorithm->getProperty("OutputWorkspace");
}
示例9: rebin
MatrixWorkspace_sptr CalculateIqt::rebin(MatrixWorkspace_sptr workspace,
const std::string ¶ms) {
IAlgorithm_sptr rebinAlgorithm = this->createChildAlgorithm("Rebin");
rebinAlgorithm->initialize();
rebinAlgorithm->setProperty("InputWorkspace", workspace);
rebinAlgorithm->setProperty("OutputWorkspace", "_");
rebinAlgorithm->setProperty("Params", params);
rebinAlgorithm->execute();
return rebinAlgorithm->getProperty("OutputWorkspace");
}
示例10: createChildAlgorithm
/** Calls the Rebin algorithm as a ChildAlgorithm.
* @param workspace The workspace to use as input to the Rebin algorithms
* @param params The rebin parameters
* @return A shared pointer to the output (rebinned) workspace
* @throw std::runtime_error If the Rebin algorithm fails
*/
API::MatrixWorkspace_sptr
MergeRuns::rebinInput(const API::MatrixWorkspace_sptr &workspace,
const std::vector<double> ¶ms) {
// Create a Rebin child algorithm
IAlgorithm_sptr rebin = createChildAlgorithm("Rebin");
rebin->setProperty("InputWorkspace", workspace);
rebin->setProperty("Params", params);
rebin->executeAsChildAlg();
return rebin->getProperty("OutputWorkspace");
}
示例11: cropWorkspace
MatrixWorkspace_sptr CalculateIqt::cropWorkspace(MatrixWorkspace_sptr workspace,
const double xMax) {
IAlgorithm_sptr cropAlgorithm = this->createChildAlgorithm("CropWorkspace");
cropAlgorithm->initialize();
cropAlgorithm->setProperty("InputWorkspace", workspace);
cropAlgorithm->setProperty("OutputWorkspace", "_");
cropAlgorithm->setProperty("XMax", xMax);
cropAlgorithm->execute();
return cropAlgorithm->getProperty("OutputWorkspace");
}
示例12: 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;
}
示例13: plotGuess
void IqtFit::plotGuess(QtProperty *) {
// Do nothing if there is no sample data curve
if (!m_uiForm.ppPlot->hasCurve("Sample"))
return;
CompositeFunction_sptr function = createFunction(true);
// Create the double* array from the input workspace
const size_t binIndxLow =
m_ffInputWS->binIndexOf(m_ffRangeManager->value(m_properties["StartX"]));
const size_t binIndxHigh =
m_ffInputWS->binIndexOf(m_ffRangeManager->value(m_properties["EndX"]));
const size_t nData = binIndxHigh - binIndxLow;
std::vector<double> inputXData(nData);
const Mantid::MantidVec &XValues = m_ffInputWS->readX(0);
const bool isHistogram = m_ffInputWS->isHistogramData();
for (size_t i = 0; i < nData; i++) {
if (isHistogram)
inputXData[i] =
0.5 * (XValues[binIndxLow + i] + XValues[binIndxLow + i + 1]);
else
inputXData[i] = XValues[binIndxLow + i];
}
FunctionDomain1DVector domain(inputXData);
FunctionValues outputData(domain);
function->function(domain, outputData);
QVector<double> dataX;
QVector<double> dataY;
for (size_t i = 0; i < nData; i++) {
dataX.append(inputXData[i]);
dataY.append(outputData.getCalculated(i));
}
IAlgorithm_sptr createWsAlg =
AlgorithmManager::Instance().create("CreateWorkspace");
createWsAlg->initialize();
createWsAlg->setChild(true);
createWsAlg->setLogging(false);
createWsAlg->setProperty("OutputWorkspace", "__GuessAnon");
createWsAlg->setProperty("NSpec", 1);
createWsAlg->setProperty("DataX", dataX.toStdVector());
createWsAlg->setProperty("DataY", dataY.toStdVector());
createWsAlg->execute();
MatrixWorkspace_sptr guessWs = createWsAlg->getProperty("OutputWorkspace");
m_uiForm.ppPlot->addSpectrum("Guess", guessWs, 0, Qt::green);
}
示例14:
MatrixWorkspace_sptr
MuonPairingAsymmetry::appendSpectra(MatrixWorkspace_sptr inputWS1,
MatrixWorkspace_sptr inputWS2) {
IAlgorithm_sptr alg = this->createChildAlgorithm("AppendSpectra");
alg->setProperty("InputWorkspace1", inputWS1);
alg->setProperty("InputWorkspace2", inputWS2);
alg->setProperty("ValidateInputs", true);
alg->execute();
MatrixWorkspace_sptr ws = alg->getProperty("OutputWorkspace");
return ws;
}
示例15: executionSuccessful
/// Run the Child Algorithm LoadInstrument (or LoadInstrumentFromNexus)
void LoadISISNexus2::runLoadInstrument(DataObjects::Workspace2D_sptr localWorkspace)
{
IAlgorithm_sptr loadInst = createChildAlgorithm("LoadInstrument");
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
bool executionSuccessful(true);
try
{
loadInst->setPropertyValue("InstrumentName", m_instrument_name);
loadInst->setProperty<MatrixWorkspace_sptr> ("Workspace", localWorkspace);
loadInst->setProperty("RewriteSpectraMap", false);
loadInst->execute();
}
catch( std::invalid_argument&)
{
g_log.information("Invalid argument to LoadInstrument Child Algorithm");
executionSuccessful = false;
}
catch (std::runtime_error&)
{
g_log.information("Unable to successfully run LoadInstrument Child Algorithm");
executionSuccessful = false;
}
if( executionSuccessful )
{
// If requested update the instrument to positions in the data file
const Geometry::ParameterMap & pmap = localWorkspace->instrumentParameters();
if( pmap.contains(localWorkspace->getInstrument()->getComponentID(),"det-pos-source") )
{
boost::shared_ptr<Geometry::Parameter> updateDets = pmap.get(localWorkspace->getInstrument()->getComponentID(),"det-pos-source");
std::string value = updateDets->value<std::string>();
if(value.substr(0,8) == "datafile" )
{
IAlgorithm_sptr updateInst = createChildAlgorithm("UpdateInstrumentFromFile");
updateInst->setProperty<MatrixWorkspace_sptr>("Workspace", localWorkspace);
updateInst->setPropertyValue("Filename", m_filename);
if(value == "datafile-ignore-phi" )
{
updateInst->setProperty("IgnorePhi", true);
g_log.information("Detector positions in IDF updated with positions in the data file except for the phi values");
}
else
{
g_log.information("Detector positions in IDF updated with positions in the data file");
}
// We want this to throw if it fails to warn the user that the information is not correct.
updateInst->execute();
}
}
}
}