本文整理汇总了C++中Algorithm_sptr::executeAsSubAlg方法的典型用法代码示例。如果您正苦于以下问题:C++ Algorithm_sptr::executeAsSubAlg方法的具体用法?C++ Algorithm_sptr::executeAsSubAlg怎么用?C++ Algorithm_sptr::executeAsSubAlg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Algorithm_sptr
的用法示例。
在下文中一共展示了Algorithm_sptr::executeAsSubAlg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
/** Execute the algorithm.
*/
void OneStepMDEW::exec()
{
std::string tempWsName = getPropertyValue("OutputWorkspace") + "_nxs";
Algorithm_sptr childAlg;
// -------- First we load the event nexus file -------------
childAlg = AlgorithmFactory::Instance().create("LoadEventNexus", 1); // new Mantid::NeXus::LoadEventNexus();
childAlg->initialize();
childAlg->setPropertyValue("Filename", getPropertyValue("Filename"));
childAlg->setPropertyValue("OutputWorkspace", tempWsName);
childAlg->executeAsSubAlg();
// Workspace_sptr tempWS = childAlg->getProperty<Workspace>("OutputWorkspace");
// IEventWorkspace_sptr tempEventWS = boost::dynamic_pointer_cast<IEventWorkspace>(AnalysisDataService::Instance().retrieve(tempWsName));
// IEventWorkspace_sptr tempEventWS = boost::dynamic_pointer_cast<IEventWorkspace>(AnalysisDataService::Instance().retrieve(tempWsName));
// --------- Now Convert -------------------------------
//childAlg = createSubAlgorithm("ConvertToDiffractionMDWorkspace");
childAlg = AlgorithmFactory::Instance().create("ConvertToDiffractionMDWorkspace", 1); // new ConvertToDiffractionMDWorkspace();
childAlg->initialize();
childAlg->setPropertyValue("InputWorkspace", tempWsName);
childAlg->setProperty<bool>("ClearInputWorkspace", false);
childAlg->setProperty<bool>("LorentzCorrection", true);
childAlg->setPropertyValue("OutputWorkspace", getPropertyValue("OutputWorkspace"));
childAlg->executeAsSubAlg();
// Workspace_sptr tempWS = childAlg->getProperty("OutputWorkspace");
// IMDEventWorkspace_sptr outWS = boost::dynamic_pointer_cast<IMDEventWorkspace>(tempWS);
IMDEventWorkspace_sptr outWS = boost::dynamic_pointer_cast<IMDEventWorkspace>(
AnalysisDataService::Instance().retrieve(getPropertyValue("OutputWorkspace")));
setProperty<Workspace_sptr>("OutputWorkspace", outWS);
}
示例2: sumSpectra
/** Sum all detector pixels except monitors and masked detectors
* @param WS :: The workspace containing the spectrum to sum
* @return A Workspace2D containing the sum
*/
API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::sumSpectra(API::MatrixWorkspace_sptr WS)
{
Algorithm_sptr childAlg = createSubAlgorithm("SumSpectra");
childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS);
childAlg->setProperty<bool>("IncludeMonitors", false);
childAlg->executeAsSubAlg();
return childAlg->getProperty("OutputWorkspace");
}
示例3: extractSpectrum
/** Extracts a single spectrum from a Workspace2D into a new workspaces. Uses CropWorkspace to do this.
* @param WS :: The workspace containing the spectrum to extract
* @param index :: The workspace index of the spectrum to extract
* @return A Workspace2D containing the extracted spectrum
*/
API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::extractSpectrum(API::MatrixWorkspace_sptr WS, const size_t index)
{
// Check that given spectra are monitors
if ( !WS->getDetector(index)->isMonitor() )
{
g_log.information("The Incident Beam Monitor UDET provided is not marked as a monitor");
}
Algorithm_sptr childAlg = createSubAlgorithm("ExtractSingleSpectrum",0.0,0.4);
childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS);
childAlg->setProperty<int>("WorkspaceIndex", static_cast<int>(index));
childAlg->executeAsSubAlg();
return childAlg->getProperty("OutputWorkspace");
}
示例4: fitToData
/** Uses 'Linear' as a subalgorithm to fit the log of the exponential curve expected for the transmission.
* @param WS :: The single-spectrum workspace to fit
* @return A workspace containing the fit
*/
API::MatrixWorkspace_sptr CalculateTransmissionBeamSpreader::fitToData(API::MatrixWorkspace_sptr WS)
{
g_log.information("Fitting the experimental transmission curve");
Algorithm_sptr childAlg = createSubAlgorithm("Linear",0.6,1.0);
childAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", WS);
const double lambdaMin = getProperty("MinWavelength");
const double lambdaMax = getProperty("MaxWavelength");
childAlg->setProperty<double>("StartX",lambdaMin);
childAlg->setProperty<double>("EndX",lambdaMax);
childAlg->executeAsSubAlg();
std::string fitStatus = childAlg->getProperty("FitStatus");
if ( fitStatus != "success" )
{
g_log.error("Unable to successfully fit the data: " + fitStatus);
throw std::runtime_error("Unable to successfully fit the data");
}
// Only get to here if successful
MatrixWorkspace_sptr result = childAlg->getProperty("OutputWorkspace");
if (logFit)
{
// Need to transform back to 'unlogged'
double b = childAlg->getProperty("FitIntercept");
double m = childAlg->getProperty("FitSlope");
b = std::pow(10,b);
m = std::pow(10,m);
const MantidVec & X = result->readX(0);
MantidVec & Y = result->dataY(0);
MantidVec & E = result->dataE(0);
for (size_t i = 0; i < Y.size(); ++i)
{
Y[i] = b*(std::pow(m,0.5*(X[i]+X[i+1])));
E[i] = std::abs(E[i]*Y[i]);
}
}
return result;
}