本文整理汇总了C++中api::IAlgorithm_sptr::execute方法的典型用法代码示例。如果您正苦于以下问题:C++ IAlgorithm_sptr::execute方法的具体用法?C++ IAlgorithm_sptr::execute怎么用?C++ IAlgorithm_sptr::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::IAlgorithm_sptr
的用法示例。
在下文中一共展示了IAlgorithm_sptr::execute方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createChildAlgorithm
/**
* Places the detector at the right sample_detector_distance
*/
void LoadSpice2D::moveDetector(double sample_detector_distance,
double translation_distance) {
// Some tests fail if the detector is moved here.
// TODO: Move the detector here and not the SANSLoad
UNUSED_ARG(translation_distance);
// Move the detector to the right position
API::IAlgorithm_sptr mover = createChildAlgorithm("MoveInstrumentComponent");
// Finding the name of the detector object.
std::string detID =
m_workspace->getInstrument()->getStringParameter("detector-name")[0];
g_log.information("Moving " + detID);
try {
mover->setProperty<API::MatrixWorkspace_sptr>("Workspace", m_workspace);
mover->setProperty("ComponentName", detID);
mover->setProperty("Z", sample_detector_distance / 1000.0);
// mover->setProperty("X", -translation_distance);
mover->execute();
} catch (std::invalid_argument &e) {
g_log.error("Invalid argument to MoveInstrumentComponent Child Algorithm");
g_log.error(e.what());
} catch (std::runtime_error &e) {
g_log.error(
"Unable to successfully run MoveInstrumentComponent Child Algorithm");
g_log.error(e.what());
}
}
示例2: exec
/**
* Execute the algorithm.
*/
void FitResolutionConvolvedModel::exec() {
API::IAlgorithm_sptr fit = createFittingAlgorithm();
fit->setPropertyValue("Function", createFunctionString());
fit->setProperty("InputWorkspace", getPropertyValue(INPUT_WS_NAME));
fit->setProperty("DomainType",
"Simple"); // Parallel not quite giving correct answers
fit->setProperty("Minimizer", "Levenberg-MarquardtMD");
const int maxIter = niterations();
fit->setProperty("MaxIterations", maxIter);
fit->setProperty("CreateOutput", true);
fit->setPropertyValue("Output", getPropertyValue(SIMULATED_NAME));
try {
fit->execute();
} catch (std::exception &exc) {
throw std::runtime_error(
std::string("FitResolutionConvolvedModel - Error running Fit: ") +
exc.what());
}
// Pass on the relevant properties
IMDEventWorkspace_sptr simulatedData = fit->getProperty("OutputWorkspace");
this->setProperty(SIMULATED_NAME, simulatedData);
if (this->existsProperty(OUTPUT_PARS)) {
ITableWorkspace_sptr outputPars = fit->getProperty("OutputParameters");
setProperty(OUTPUT_PARS, outputPars);
}
if (this->existsProperty(OUTPUTCOV_MATRIX)) {
ITableWorkspace_sptr covarianceMatrix =
fit->getProperty("OutputNormalisedCovarianceMatrix");
setProperty(OUTPUTCOV_MATRIX, covarianceMatrix);
}
}
示例3: doFitGaussianPeak
/**
* Fit peak without background i.e, with background removed
* inspired from FitPowderDiffPeaks.cpp
* copied from PoldiPeakDetection2.cpp
*
@param workspaceindex :: indice of the row to use
@param center :: gaussian parameter - center
@param sigma :: gaussian parameter - width
@param height :: gaussian parameter - height
@param startX :: fit range - start X value
@param endX :: fit range - end X value
@returns A boolean status flag, true for fit success, false else
*/
bool ConvertEmptyToTof::doFitGaussianPeak(int workspaceindex, double ¢er,
double &sigma, double &height,
double startX, double endX) {
g_log.debug("Calling doFitGaussianPeak...");
// 1. Estimate
sigma = sigma * 0.5;
// 2. Use factory to generate Gaussian
auto temppeak = API::FunctionFactory::Instance().createFunction("Gaussian");
auto gaussianpeak = boost::dynamic_pointer_cast<API::IPeakFunction>(temppeak);
gaussianpeak->setHeight(height);
gaussianpeak->setCentre(center);
gaussianpeak->setFwhm(sigma);
// 3. Constraint
double centerleftend = center - sigma * 0.5;
double centerrightend = center + sigma * 0.5;
std::ostringstream os;
os << centerleftend << " < PeakCentre < " << centerrightend;
auto *centerbound = API::ConstraintFactory::Instance().createInitialized(
gaussianpeak.get(), os.str(), false);
gaussianpeak->addConstraint(centerbound);
g_log.debug("Calling createChildAlgorithm : Fit...");
// 4. Fit
API::IAlgorithm_sptr fitalg = createChildAlgorithm("Fit", -1, -1, true);
fitalg->initialize();
fitalg->setProperty(
"Function", boost::dynamic_pointer_cast<API::IFunction>(gaussianpeak));
fitalg->setProperty("InputWorkspace", m_inputWS);
fitalg->setProperty("WorkspaceIndex", workspaceindex);
fitalg->setProperty("Minimizer", "Levenberg-MarquardtMD");
fitalg->setProperty("CostFunction", "Least squares");
fitalg->setProperty("MaxIterations", 1000);
fitalg->setProperty("Output", "FitGaussianPeak");
fitalg->setProperty("StartX", startX);
fitalg->setProperty("EndX", endX);
// 5. Result
bool successfulfit = fitalg->execute();
if (!fitalg->isExecuted() || !successfulfit) {
// Early return due to bad fit
g_log.warning() << "Fitting Gaussian peak for peak around "
<< gaussianpeak->centre() << '\n';
return false;
}
// 6. Get result
center = gaussianpeak->centre();
height = gaussianpeak->height();
double fwhm = gaussianpeak->fwhm();
return fwhm > 0.0;
}
示例4: groupDetectors
/** Group detectors in the workspace.
* @param ws :: A local workspace
* @param spectraList :: A list of spectra to group.
*/
void PlotAsymmetryByLogValue::groupDetectors(API::MatrixWorkspace_sptr& ws,const std::vector<int>& spectraList)
{
API::IAlgorithm_sptr group = createChildAlgorithm("GroupDetectors");
group->setProperty("InputWorkspace",ws);
group->setProperty("SpectraList",spectraList);
group->setProperty("KeepUngroupedSpectra",true);
group->execute();
ws = group->getProperty("OutputWorkspace");
}
示例5: createChildAlgorithm
/** Fit function
* Minimizer: "Levenberg-MarquardtMD"/"Simplex"
*/
bool RefinePowderInstrumentParameters2::doFitFunction(IFunction_sptr function, Workspace2D_sptr dataws, int wsindex,
string minimizer, int numiters, double& chi2, string& fitstatus)
{
// 0. Debug output
stringstream outss;
outss << "Fit function: " << m_positionFunc->asString() << endl << "Data To Fit: \n";
for (size_t i = 0; i < dataws->readX(0).size(); ++i)
outss << dataws->readX(wsindex)[i] << "\t\t" << dataws->readY(wsindex)[i] << "\t\t"
<< dataws->readE(wsindex)[i] << "\n";
g_log.information() << outss.str();
// 1. Create and setup fit algorithm
API::IAlgorithm_sptr fitalg = createChildAlgorithm("Fit", 0.0, 0.2, true);
fitalg->initialize();
fitalg->setProperty("Function", function);
fitalg->setProperty("InputWorkspace", dataws);
fitalg->setProperty("WorkspaceIndex", wsindex);
fitalg->setProperty("Minimizer", minimizer);
fitalg->setProperty("CostFunction", "Least squares");
fitalg->setProperty("MaxIterations", numiters);
fitalg->setProperty("CalcErrors", true);
// 2. Fit
bool successfulfit = fitalg->execute();
if (!fitalg->isExecuted() || ! successfulfit)
{
// Early return due to bad fit
g_log.warning("Fitting to instrument geometry function failed. ");
chi2 = DBL_MAX;
fitstatus = "Minimizer throws exception.";
return false;
}
// 3. Understand solution
chi2 = fitalg->getProperty("OutputChi2overDoF");
string tempfitstatus = fitalg->getProperty("OutputStatus");
fitstatus = tempfitstatus;
bool goodfit = fitstatus.compare("success") == 0;
stringstream dbss;
dbss << "Fit Result (GSL): Chi^2 = " << chi2
<< "; Fit Status = " << fitstatus << ", Return Bool = " << goodfit << std::endl;
vector<string> funcparnames = function->getParameterNames();
for (size_t i = 0; i < funcparnames.size(); ++i)
dbss << funcparnames[i] << " = " << setw(20) << function->getParameter(funcparnames[i])
<< " +/- " << function->getError(i) << "\n";
g_log.debug() << dbss.str();
return goodfit;
}
示例6: createChildAlgorithm
void LoadNexusMonitors2::runLoadLogs(const std::string filename,
API::MatrixWorkspace_sptr localWorkspace) {
// do the actual work
API::IAlgorithm_sptr loadLogs = createChildAlgorithm("LoadNexusLogs");
// Now execute the Child Algorithm. Catch and log any error, but don't stop.
try {
g_log.information() << "Loading logs from NeXus file..." << std::endl;
loadLogs->setPropertyValue("Filename", filename);
loadLogs->setProperty<API::MatrixWorkspace_sptr>("Workspace",
localWorkspace);
loadLogs->execute();
} catch (...) {
g_log.error() << "Error while loading Logs from Nexus. Some sample logs "
"may be missing." << std::endl;
}
}
示例7: reflectometryPeak
/**
* Gaussian fit to determine peak position if no user position given.
*
* @return :: detector position of the peak: Gaussian fit and position
* of the maximum (serves as start value for the optimization)
*/
double LoadILLReflectometry::reflectometryPeak() {
if (!isDefault("BeamCentre")) {
return getProperty("BeamCentre");
}
size_t startIndex;
size_t endIndex;
std::tie(startIndex, endIndex) =
fitIntegrationWSIndexRange(*m_localWorkspace);
IAlgorithm_sptr integration = createChildAlgorithm("Integration");
integration->initialize();
integration->setProperty("InputWorkspace", m_localWorkspace);
integration->setProperty("OutputWorkspace", "__unused_for_child");
integration->setProperty("StartWorkspaceIndex", static_cast<int>(startIndex));
integration->setProperty("EndWorkspaceIndex", static_cast<int>(endIndex));
integration->execute();
MatrixWorkspace_sptr integralWS = integration->getProperty("OutputWorkspace");
IAlgorithm_sptr transpose = createChildAlgorithm("Transpose");
transpose->initialize();
transpose->setProperty("InputWorkspace", integralWS);
transpose->setProperty("OutputWorkspace", "__unused_for_child");
transpose->execute();
integralWS = transpose->getProperty("OutputWorkspace");
rebinIntegralWorkspace(*integralWS);
// determine initial height: maximum value
const auto maxValueIt =
std::max_element(integralWS->y(0).cbegin(), integralWS->y(0).cend());
const double height = *maxValueIt;
// determine initial centre: index of the maximum value
const size_t maxIndex = std::distance(integralWS->y(0).cbegin(), maxValueIt);
const double centreByMax = static_cast<double>(maxIndex);
g_log.debug() << "Peak maximum position: " << centreByMax << '\n';
// determine sigma
const auto &ys = integralWS->y(0);
auto lessThanHalfMax = [height](const double x) { return x < 0.5 * height; };
using IterType = HistogramData::HistogramY::const_iterator;
std::reverse_iterator<IterType> revMaxValueIt{maxValueIt};
auto revMinFwhmIt = std::find_if(revMaxValueIt, ys.crend(), lessThanHalfMax);
auto maxFwhmIt = std::find_if(maxValueIt, ys.cend(), lessThanHalfMax);
std::reverse_iterator<IterType> revMaxFwhmIt{maxFwhmIt};
if (revMinFwhmIt == ys.crend() || maxFwhmIt == ys.cend()) {
g_log.warning() << "Couldn't determine fwhm of beam, using position of max "
"value as beam center.\n";
return centreByMax;
}
const double fwhm =
static_cast<double>(std::distance(revMaxFwhmIt, revMinFwhmIt) + 1);
g_log.debug() << "Initial fwhm (full width at half maximum): " << fwhm
<< '\n';
// generate Gaussian
auto func =
API::FunctionFactory::Instance().createFunction("CompositeFunction");
auto sum = boost::dynamic_pointer_cast<API::CompositeFunction>(func);
func = API::FunctionFactory::Instance().createFunction("Gaussian");
auto gaussian = boost::dynamic_pointer_cast<API::IPeakFunction>(func);
gaussian->setHeight(height);
gaussian->setCentre(centreByMax);
gaussian->setFwhm(fwhm);
sum->addFunction(gaussian);
func = API::FunctionFactory::Instance().createFunction("LinearBackground");
func->setParameter("A0", 0.);
func->setParameter("A1", 0.);
sum->addFunction(func);
// call Fit child algorithm
API::IAlgorithm_sptr fit = createChildAlgorithm("Fit");
fit->initialize();
fit->setProperty("Function",
boost::dynamic_pointer_cast<API::IFunction>(sum));
fit->setProperty("InputWorkspace", integralWS);
fit->setProperty("StartX", centreByMax - 3 * fwhm);
fit->setProperty("EndX", centreByMax + 3 * fwhm);
fit->execute();
const std::string fitStatus = fit->getProperty("OutputStatus");
if (fitStatus != "success") {
g_log.warning("Fit not successful, using position of max value.\n");
return centreByMax;
}
const auto centre = gaussian->centre();
g_log.debug() << "Sigma: " << gaussian->fwhm() << '\n';
g_log.debug() << "Estimated peak position: " << centre << '\n';
return centre;
}
示例8: exec
//.........这里部分代码省略.........
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;
try
{
// Fit the function
API::IAlgorithm_sptr fit = createSubAlgorithm("Fit");
fit->initialize();
fit->setProperty("InputWorkspace",data.ws);
//fit->setPropertyValue("InputWorkspace",data.ws->getName());
fit->setProperty("WorkspaceIndex",j);
fit->setPropertyValue("Function",fun);
fit->setPropertyValue("StartX",getPropertyValue("StartX"));
fit->setPropertyValue("EndX",getPropertyValue("EndX"));
fit->setPropertyValue("Minimizer",getPropertyValue("Minimizer"));
fit->setPropertyValue("CostFunction",getPropertyValue("CostFunction"));
fit->execute();
resFun = fit->getPropertyValue("Function");
errors = fit->getProperty("Errors");
chi2 = fit->getProperty("OutputChi2overDoF");
}
catch(...)
{
g_log.error("Error in Fit subalgorithm");
throw;
}
if (sequential)
{
fun = resFun;
}
// Extract the fitted parameters and put them into the result table
TableRow row = result->appendRow();
if (isDataName)
{
row << wsNames[i].name;
}
else
{
row << logValue;
}
ifun = FunctionFactory::Instance().createInitialized(resFun);
for(size_t iPar=0;iPar<ifun->nParams();++iPar)
{
row << ifun->getParameter(iPar) << errors[iPar];
}
row << chi2;
delete ifun;
Prog += dProg;
progress(Prog);
interruption_point();
} // for(;j < jend;++j)
}
}
示例9: getWorkspace
/** Get a workspace identified by an InputData structure.
* @param data :: InputData with name and either spec or i fields defined.
* @return InputData structure with the ws field set if everything was OK.
*/
PlotPeakByLogValue::InputData PlotPeakByLogValue::getWorkspace(const InputData& data)
{
InputData out(data);
if (API::AnalysisDataService::Instance().doesExist(data.name))
{
DataObjects::Workspace2D_sptr ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(
API::AnalysisDataService::Instance().retrieve(data.name));
if (ws)
{
out.ws = ws;
}
else
{
return data;
}
}
else
{
std::ifstream fil(data.name.c_str());
if (!fil)
{
g_log.warning() << "File "<<data.name<<" does not exist\n";
return data;
}
fil.close();
std::string::size_type i = data.name.find_last_of('.');
if (i == std::string::npos)
{
g_log.warning() << "Cannot open file "<<data.name<<"\n";
return data;
}
std::string ext = data.name.substr(i);
try
{
API::IAlgorithm_sptr load = createSubAlgorithm("Load");
load->initialize();
load->setPropertyValue("FileName",data.name);
load->execute();
if (load->isExecuted())
{
API::Workspace_sptr rws = load->getProperty("OutputWorkspace");
if (rws)
{
DataObjects::Workspace2D_sptr ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(rws);
if (ws)
{
out.ws = ws;
}
else
{
API::WorkspaceGroup_sptr gws = boost::dynamic_pointer_cast<API::WorkspaceGroup>(rws);
if (gws)
{
std::vector<std::string> wsNames = gws->getNames();
std::string propName = "OUTPUTWORKSPACE_" + boost::lexical_cast<std::string>(data.period);
if (load->existsProperty(propName))
{
Workspace_sptr rws1 = load->getProperty(propName);
out.ws = boost::dynamic_pointer_cast<DataObjects::Workspace2D>(rws1);
}
}
}
}
}
}
catch(std::exception& e)
{
g_log.error(e.what());
return data;
}
}
if (!out.ws) return data;
API::Axis* axis = out.ws->getAxis(1);
if (axis->isSpectra())
{// spectra axis
if (out.spec < 0)
{
if (out.i >= 0)
{
out.spec = axis->spectraNo(out.i);
}
else
{// i < 0 && spec < 0 => use start and end
for(size_t i=0;i<axis->length();++i)
{
double s = double(axis->spectraNo(i));
if (s >= out.start && s <= out.end)
{
out.indx.push_back(static_cast<int>(i));
}
}
}
}
else
//.........这里部分代码省略.........
示例10: b_re_sig
//.........这里部分代码省略.........
ws->getAxis(0)->unit() = Kernel::UnitFactory::Instance().create("Wavelength");
ws->setYUnit("");
API::Workspace_sptr workspace = boost::static_pointer_cast<API::Workspace>(ws);
setProperty("OutputWorkspace", workspace);
// Parse out each pixel. Pixels can be separated by white space, a tab, or an end-of-line character
Poco::StringTokenizer pixels(data_str, " \n\t", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
Poco::StringTokenizer::Iterator pixel = pixels.begin();
// Check that we don't keep within the size of the workspace
size_t pixelcount = pixels.count();
if( pixelcount != static_cast<size_t>(numberXPixels*numberYPixels) )
{
throw Kernel::Exception::FileError("Inconsistent data set: "
"There were more data pixels found than declared in the Spice XML meta-data.", fileName);
}
if( numSpectra == 0 )
{
throw Kernel::Exception::FileError("Empty data set: the data file has no pixel data.", fileName);
}
// Go through all detectors/channels
int ipixel = 0;
// Store monitor count
store_value(ws, ipixel++, monitorCounts, monitorCounts>0 ? sqrt(monitorCounts) : 0.0,
wavelength, dwavelength);
// Store counting time
store_value(ws, ipixel++, countingTime, 0.0, wavelength, dwavelength);
// Store detector pixels
while (pixel != pixels.end())
{
//int ix = ipixel%npixelsx;
//int iy = (int)ipixel/npixelsx;
// Get the count value and assign it to the right bin
double count = 0.0;
from_string<double>(count, *pixel, std::dec);
// Data uncertainties, computed according to the HFIR/IGOR reduction code
// The following is what I would suggest instead...
// error = count > 0 ? sqrt((double)count) : 0.0;
double error = sqrt( 0.5 + fabs( count - 0.5 ));
store_value(ws, ipixel, count, error, wavelength, dwavelength);
// Set the spectrum number
ws->getAxis(1)->setValue(ipixel, ipixel);
++pixel;
ipixel++;
}
// run load instrument
runLoadInstrument(instrument, ws);
runLoadMappingTable(ws, numberXPixels, numberYPixels);
// Set the run properties
ws->mutableRun().addProperty("sample-detector-distance", distance, "mm", true);
ws->mutableRun().addProperty("beam-trap-diameter", beam_trap_diam, "mm", true);
ws->mutableRun().addProperty("number-of-guides", nguides, true);
ws->mutableRun().addProperty("source-sample-distance", source_distance, "mm", true);
ws->mutableRun().addProperty("source-aperture-diameter", source_apert, "mm", true);
ws->mutableRun().addProperty("sample-aperture-diameter", sample_apert, "mm", true);
ws->mutableRun().addProperty("sample-thickness", sample_thickness, "cm", true);
ws->mutableRun().addProperty("wavelength", wavelength, "Angstrom", true);
ws->mutableRun().addProperty("wavelength-spread", dwavelength, "Angstrom", true);
ws->mutableRun().addProperty("timer", countingTime, "sec", true);
ws->mutableRun().addProperty("monitor", monitorCounts, "", true);
ws->mutableRun().addProperty("start_time", start_time, "", true);
ws->mutableRun().addProperty("run_start", start_time, "", true);
// Move the detector to the right position
API::IAlgorithm_sptr mover = createChildAlgorithm("MoveInstrumentComponent");
// Finding the name of the detector object.
std::string detID = ws->getInstrument()->getStringParameter("detector-name")[0];
g_log.information("Moving "+detID);
try
{
mover->setProperty<API::MatrixWorkspace_sptr> ("Workspace", ws);
mover->setProperty("ComponentName", detID);
mover->setProperty("Z", distance/1000.0);
mover->execute();
} catch (std::invalid_argument& e)
{
g_log.error("Invalid argument to MoveInstrumentComponent Child Algorithm");
g_log.error(e.what());
} catch (std::runtime_error& e)
{
g_log.error("Unable to successfully run MoveInstrumentComponent Child Algorithm");
g_log.error(e.what());
}
// Release the XML document memory
pDoc->release();
}
示例11: exec
void MaskBinsFromTable::exec()
{
MatrixWorkspace_sptr inputWS = getProperty("InputWorkspace");
DataObjects::TableWorkspace_sptr paramWS = getProperty("MaskingInformation");
// 1. Check input table workspace and column order
g_log.debug() << "Lines of parameters workspace = " << paramWS->rowCount() << std::endl;
bool colname_specx = false;
if (!paramWS)
{
throw std::invalid_argument("Input table workspace is not accepted.");
}
else
{
std::vector<std::string> colnames = paramWS->getColumnNames();
// check colum name order
if (colnames.size() < 3)
{
g_log.error() << "Input MaskingInformation table workspace has fewer than 3 columns. " << colnames.size()
<< " columns indeed" << std::endl;
throw std::invalid_argument("MaskingInformation (TableWorkspace) has too few columns.");
}
if (colnames[0].compare("XMin") == 0)
{
// 1. Style XMin, XMax, SpectraList. Check rest
if (colnames[1].compare("XMax") != 0 || colnames[2].compare("SpectraList") != 0)
{
g_log.error() << "INput MaskingInformation table workspace has wrong column order. " << std::endl;
throw std::invalid_argument("MaskingInformation (TableWorkspace) has too few columns.");
}
}
else if (colnames[0].compare("SpectraList") == 0)
{
// 2. Style SpectraList, XMin, XMax
colname_specx = true;
if (colnames[1].compare("XMin") != 0 || colnames[2].compare("XMax") != 0)
{
g_log.error() << "INput MaskingInformation table workspace has wrong column order. " << std::endl;
throw std::invalid_argument("MaskingInformation (TableWorkspace) has too few columns.");
}
}
else
{
g_log.error() << "INput MaskingInformation table workspace has wrong column order. " << std::endl;
throw std::invalid_argument("MaskingInformation (TableWorkspace) has too few columns.");
}
}
// 2. Loop over all rows
bool firstloop = true;
API::MatrixWorkspace_sptr outputws = this->getProperty("OutputWorkspace");
for (size_t ib = 0; ib < paramWS->rowCount(); ++ib)
{
API::TableRow therow = paramWS->getRow(ib);
double xmin, xmax;
std::string speclist;
if (colname_specx)
{
therow >> speclist >> xmin >> xmax;
}
else
{
therow >> xmin >> xmax >> speclist;
}
g_log.debug() << "Row " << ib << " XMin = " << xmin << " XMax = " << xmax << " SpectraList = " << speclist << std::endl;
API::IAlgorithm_sptr maskbins = this->createChildAlgorithm("MaskBins", 0, 0.3, true);
maskbins->initialize();
if (firstloop)
{
maskbins->setProperty("InputWorkspace", inputWS);
firstloop = false;
}
else
{
maskbins->setProperty("InputWorkspace", outputws);
}
maskbins->setProperty("OutputWorkspace", outputws);
maskbins->setPropertyValue("SpectraList", speclist);
maskbins->setProperty("XMin", xmin);
maskbins->setProperty("XMax", xmax);
bool isexec = maskbins->execute();
if (!isexec)
{
g_log.error() << "MaskBins() is not executed for row " << ib << std::endl;
throw std::runtime_error("MaskBins() is not executed");
}
outputws = maskbins->getProperty("OutputWorkspace");
if (!outputws)
{
g_log.error() << "OutputWorkspace is not retrieved for row " << ib << ". " << std::endl;
throw std::runtime_error("OutputWorkspace is not got from MaskBins");
}
}