22#include <boost/algorithm/string.hpp>
23#include <boost/algorithm/string/predicate.hpp>
24#include <boost/algorithm/string/split.hpp>
37using namespace HistogramData;
43using namespace CurveFitting;
51 : m_dataWS(), m_outputWS(), m_wsIndex(-1), m_lowerBound(DBL_MAX), m_upperBound(DBL_MIN), m_bkgdType(),
60 "Name of the output workspace containing the processed background.");
63 declareProperty(
"WorkspaceIndex", 0,
"Workspace index for the input workspaces.");
67 "Output workspace containing processed background");
70 std::vector<std::string> options{
"SelectBackgroundPoints",
"RemovePeaks",
"DeleteRegion",
"AddRegion"};
72 auto validator = std::make_shared<Kernel::StringListValidator>(options);
73 declareProperty(
"Options",
"RemovePeaks", validator,
"Name of the functionality realized by this algorithm.");
79 auto refwsprop = std::make_unique<WorkspaceProperty<Workspace2D>>(
"ReferenceWorkspace",
"",
Direction::Input,
81 declareProperty(std::move(refwsprop),
"Name of the workspace containing the data "
82 "required by function AddRegion.");
86 std::vector<std::string> bkgdtype{
"Polynomial",
"Chebyshev"};
87 auto bkgdvalidator = std::make_shared<Kernel::StringListValidator>(bkgdtype);
89 "Type of the background. Options include Polynomial and Chebyshev.");
91 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
93 vector<string> funcoptions{
"N/A",
"FitGivenDataPoints",
"UserFunction"};
94 auto fovalidator = std::make_shared<StringListValidator>(funcoptions);
96 "If choise is UserFunction, background will be selected by "
97 "an input background "
98 "function. Otherwise, background function will be fitted "
99 "from user's input data points.");
101 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
103 declareProperty(
"BackgroundOrder", 0,
"Order of polynomial or chebyshev background. ");
105 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
107 std::make_unique<VisibleWhenProperty>(
"SelectionMode",
IS_EQUAL_TO,
"FitGivenDataPoints"));
110 auto arrayproperty = std::make_unique<Kernel::ArrayProperty<double>>(
"BackgroundPoints");
111 declareProperty(std::move(arrayproperty),
"Vector of doubles, each of which is the "
112 "X-axis value of the background point "
113 "selected by user.");
115 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
117 std::make_unique<VisibleWhenProperty>(
"SelectionMode",
IS_EQUAL_TO,
"FitGivenDataPoints"));
121 "Name of the table workspace containing background "
122 "parameters for mode SelectBackgroundPoints.");
124 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
126 std::make_unique<VisibleWhenProperty>(
"SelectionMode",
IS_EQUAL_TO,
"UserFunction"));
129 vector<string> pointsselectmode{
"All Background Points",
"Input Background Points Only"};
130 auto modevalidator = std::make_shared<StringListValidator>(pointsselectmode);
131 declareProperty(
"BackgroundPointSelectMode",
"All Background Points", modevalidator,
132 "Mode to select background points. ");
134 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
136 std::make_unique<VisibleWhenProperty>(
"SelectionMode",
IS_EQUAL_TO,
"FitGivenDataPoints"));
141 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
146 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
151 "Output workspace containing fitted background from points "
152 "specified by users.");
154 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
159 "Output parameter table workspace containing the background fitting "
162 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
165 std::vector<std::string> outbkgdtype{
"Polynomial",
"Chebyshev"};
166 auto outbkgdvalidator = std::make_shared<Kernel::StringListValidator>(outbkgdtype);
167 declareProperty(
"OutputBackgroundType",
"Polynomial", outbkgdvalidator,
168 "Type of background to fit with selected background points.");
170 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
173 declareProperty(
"OutputBackgroundOrder", 6,
"Order of background to fit with selected background points.");
175 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"SelectBackgroundPoints"));
180 "Name of table workspace containing peaks' parameters. ");
182 std::make_unique<VisibleWhenProperty>(
"Options",
IS_EQUAL_TO,
"RemovePeaks"));
185 declareProperty(
"NumberOfFWHM", 1.0,
"Number of FWHM to as the peak region to have peak removed. ");
196 g_log.
error() <<
"Input Workspace cannot be obtained.\n";
197 throw std::invalid_argument(
"Input Workspace cannot be obtained.");
204 throw std::invalid_argument(
"WorkspaceIndex is not allowed to be less than 0. ");
207 throw runtime_error(
"Workspace index is out of boundary.");
218 if (option ==
"RemovePeaks") {
220 }
else if (option ==
"DeleteRegion") {
222 }
else if (option ==
"AddRegion") {
224 }
else if (option ==
"SelectBackgroundPoints") {
228 g_log.
error() <<
"Option " << option <<
" is not supported. \n";
229 throw std::invalid_argument(
"Unsupported option. ");
248 setProperty(
"OutputBackgroundParameterWorkspace", dummytbws);
257 throw std::invalid_argument(
"Using DeleteRegion. Both LowerBound and "
258 "UpperBound must be specified.");
261 throw std::invalid_argument(
"Lower boundary cannot be equal or larger than upper boundary.");
269 std::vector<size_t> incIndexes;
270 for (
size_t i = 0; i < dataY.size(); i++) {
272 incIndexes.emplace_back(i);
275 size_t sizex = incIndexes.size();
276 size_t sizey = sizex;
277 if (dataX.size() > dataY.size()) {
284 m_outputWS = std::dynamic_pointer_cast<DataObjects::Workspace2D>(mws);
287 for (
size_t i = 0; i < sizey; i++) {
288 size_t index = incIndexes[i];
294 m_outputWS->mutableX(0)[sizex - 1] = dataX.back();
307 throw std::invalid_argument(
"Using AddRegion. Both LowerBound and UpperBound must be specified.");
310 throw std::invalid_argument(
"Lower boundary cannot be equal or larger than upper boundary.");
318 std::vector<double> vx, vy, ve;
319 for (
size_t i = 0; i < vecY.size(); ++i) {
320 double xtmp = vecX[i];
322 vx.emplace_back(vecX[i]);
323 vy.emplace_back(vecY[i]);
324 ve.emplace_back(vecE[i]);
329 if (vecX.size() > vecY.size())
330 vx.emplace_back(vecX.back());
335 throw std::invalid_argument(
"ReferenceWorkspace is not given. ");
337 const auto &refX = refWS->x(0);
338 const auto &refY = refWS->y(0);
339 const auto &refE = refWS->e(0);
343 std::vector<double>::const_iterator refiter;
344 refiter = std::lower_bound(refX.begin(), refX.end(),
m_lowerBound);
345 size_t sindex = size_t(refiter - refX.begin());
346 refiter = std::lower_bound(refX.begin(), refX.end(),
m_upperBound);
347 size_t eindex = size_t(refiter - refX.begin());
349 for (
size_t i = sindex; i < eindex; ++i) {
350 const double tmpx = refX[i];
351 const double tmpy = refY[i];
352 const double tmpe = refE[i];
355 auto newit = std::lower_bound(vx.begin(), vx.end(), tmpx);
356 size_t newindex = size_t(newit - vx.begin());
359 vx.insert(newit, tmpx);
361 newit = vy.begin() + newindex;
362 vy.insert(newit, tmpy);
364 newit = ve.begin() + newindex;
365 ve.insert(newit, tmpe);
369 for (
auto it = vx.begin() + 1; it != vx.end(); ++it) {
370 if (*it <= *it - 1) {
371 g_log.
error() <<
"The vector X with value inserted is not ordered incrementally\n";
372 throw std::runtime_error(
"Build new vector error!");
377 m_outputWS = std::dynamic_pointer_cast<DataObjects::Workspace2D>(
380 m_outputWS->setHistogram(0, Histogram(Points(vx), Counts(vy), CountStandardDeviations(ve)));
396 if (smode ==
"FitGivenDataPoints") {
398 }
else if (smode ==
"UserFunction") {
401 throw runtime_error(
"N/A is not supported.");
406 string outbkgdparwsname =
getPropertyValue(
"OutputBackgroundParameterWorkspace");
407 if (!outbkgdparwsname.empty() && outbkgdparwsname !=
"_dummy02") {
423 std::vector<double> bkgdpoints =
getProperty(
"BackgroundPoints");
424 string mode =
getProperty(
"BackgroundPointSelectMode");
427 std::vector<size_t> realIndexes;
431 for (
size_t i = 0; i < bkgdpoints.size(); ++i) {
433 double bkgdpoint = bkgdpoints[i];
434 if (bkgdpoint < vecX.front()) {
435 g_log.
warning() <<
"Input background point " << bkgdpoint <<
" is out of lower boundary. "
436 <<
"Use X[0] = " << vecX.front() <<
" instead."
438 bkgdpoint = vecX.front();
439 }
else if (bkgdpoint > vecX.back()) {
440 g_log.
warning() <<
"Input background point " << bkgdpoint
441 <<
" is out of upper boundary. Use X[-1] = " << vecX.back() <<
" instead."
443 bkgdpoint = vecX.back();
447 std::vector<double>::const_iterator it;
448 it = std::lower_bound(vecX.begin(), vecX.end(), bkgdpoint);
449 size_t index = size_t(it - vecX.begin());
451 g_log.
debug() <<
"DBx502 Background Points " << i <<
" Index = " <<
index <<
" For TOF = " << bkgdpoints[i]
452 <<
" in [" << vecX[0] <<
", " << vecX.back() <<
"] "
456 realIndexes.emplace_back(
index);
460 size_t wsSize = realIndexes.size();
463 for (
size_t i = 0; i < wsSize; ++i) {
464 size_t index = realIndexes[i];
465 bkgdWS->mutableX(0)[i] = vecX[
index];
466 bkgdWS->mutableY(0)[i] = vecY[
index];
467 bkgdWS->mutableE(0)[i] = vecE[
index];
471 if (mode ==
"All Background Points") {
474 }
else if (mode ==
"Input Background Points Only") {
479 errss <<
"Background select mode " << mode <<
" is not supported by ProcessBackground.";
481 throw runtime_error(errss.str());
494 size_t numrows = bkgdtablews->rowCount();
495 map<string, double> parmap;
496 for (
size_t i = 0; i < numrows; ++i) {
497 TableRow row = bkgdtablews->getRow(i);
500 row >> parname >> parvalue;
501 if (parname[0] ==
'A')
502 parmap.emplace(parname, parvalue);
505 auto bkgdorder =
static_cast<int>(parmap.size() - 1);
506 bkgdfunc->setAttributeValue(
"n", bkgdorder);
507 for (
auto &mit : parmap) {
508 string parname = mit.first;
509 double parvalue = mit.second;
510 bkgdfunc->setParameter(parname, parvalue);
526 g_log.
warning(
"(Input) background function order is 0. It might not be "
527 "able to give a good estimation.");
529 bkgdfunction->setAttributeValue(
"n", bkgdorder);
530 bkgdfunction->initialize();
532 g_log.
information() <<
"Input background points has " << bkgdWS->x(0).size() <<
" data points for fit " << bkgdorder
533 <<
"-th order " << bkgdfunction->name() <<
" (background) function" << bkgdfunction->asString()
541 g_log.
error() <<
"Requires CurveFitting library.\n";
547 fit->setProperty(
"Function", std::dynamic_pointer_cast<API::IFunction>(bkgdfunction));
548 fit->setProperty(
"InputWorkspace", bkgdWS);
549 fit->setProperty(
"WorkspaceIndex", 0);
550 fit->setProperty(
"MaxIterations", 500);
551 fit->setProperty(
"StartX", startx);
552 fit->setProperty(
"EndX", endx);
553 fit->setProperty(
"Minimizer",
"Levenberg-Marquardt");
554 fit->setProperty(
"CostFunction",
"Least squares");
556 fit->executeAsChildAlg();
560 std::string fitStatus = fit->getProperty(
"OutputStatus");
561 bool allowedfailure = (fitStatus.find(
"Changes") < fitStatus.size()) && (fitStatus.find(
"small") < fitStatus.size());
562 if (fitStatus !=
"success" && !allowedfailure) {
563 g_log.
error() <<
"ProcessBackground: Fit Status = " << fitStatus <<
". Not to update fit result\n";
564 throw std::runtime_error(
"Bad Fit " + fitStatus);
568 const double chi2 = fit->getProperty(
"OutputChi2overDoF");
569 g_log.
information() <<
"Fit background: Fit Status = " << fitStatus <<
", chi2 = " << chi2 <<
"\n";
583 if (backgroundtype ==
"Polynomial") {
584 bkgdfunction = std::dynamic_pointer_cast<Functions::BackgroundFunction>(std::make_shared<Functions::Polynomial>());
585 bkgdfunction->initialize();
586 }
else if (backgroundtype ==
"Chebyshev") {
588 bkgdfunction = std::dynamic_pointer_cast<Functions::BackgroundFunction>(cheby);
589 bkgdfunction->initialize();
592 bkgdfunction->setAttributeValue(
"StartX",
m_lowerBound);
596 errss <<
"Background of type " << backgroundtype <<
" is not supported. ";
598 throw std::invalid_argument(errss.str());
608 double posnoisetolerance =
getProperty(
"NoiseTolerance");
609 double negnoisetolerance =
getProperty(
"NegativeNoiseTolerance");
610 if (
isEmpty(negnoisetolerance))
611 negnoisetolerance = posnoisetolerance;
617 bkgdfunction->function(domain, values);
619 g_log.
information() <<
"Function used to select background points : " << bkgdfunction->asString() <<
"\n";
623 if (userbkgdwsname.empty())
624 throw runtime_error(
"In mode SelectBackgroundPoints, "
625 "UserBackgroundWorkspace must be given!");
627 size_t sizex = domain.
size();
628 size_t sizey = values.
size();
631 for (
size_t i = 0; i < sizex; ++i) {
632 for (
size_t j = 0; j < 4; ++j) {
633 visualws->mutableX(j)[i] = domain[i];
636 for (
size_t i = 0; i < sizey; ++i) {
637 visualws->mutableY(0)[i] = values[i];
639 visualws->mutableY(2)[i] = posnoisetolerance;
640 visualws->mutableY(3)[i] = -negnoisetolerance;
645 std::vector<size_t> selectedIndexes;
646 for (
size_t i = 0; i < domain.
size(); ++i) {
647 double purey = visualws->y(1)[i];
648 if (purey < posnoisetolerance && purey > -negnoisetolerance) {
649 selectedIndexes.emplace_back(i);
652 size_t wsSize = selectedIndexes.size();
654 <<
" total data points. "
659 Workspace2D_sptr outws = std::dynamic_pointer_cast<DataObjects::Workspace2D>(
661 for (
size_t i = 0; i < wsSize; ++i) {
662 size_t index = selectedIndexes[i];
663 for (
size_t j = 0; j < nspec; ++j)
664 outws->mutableX(j)[i] = domain[
index];
679 int bkgdorder =
getProperty(
"OutputBackgroundOrder");
680 bkgdfunction->setAttributeValue(
"n", bkgdorder);
682 if (bkgdfunctiontype ==
"Chebyshev") {
685 g_log.
information() <<
"Chebyshev Fit range: " << xmin <<
", " << xmax <<
"\n";
686 bkgdfunction->setAttributeValue(
"StartX", xmin);
687 bkgdfunction->setAttributeValue(
"EndX", xmax);
690 g_log.
information() <<
"Fit selected background " << bkgdfunctiontype <<
" to data workspace with "
691 <<
m_outputWS->getNumberHistograms() <<
" spectra."
699 g_log.
error() <<
"Requires CurveFitting library.\n";
703 g_log.
information() <<
"Fitting background function: " << bkgdfunction->asString() <<
"\n";
707 fit->setProperty(
"Function", std::dynamic_pointer_cast<API::IFunction>(bkgdfunction));
708 fit->setProperty(
"InputWorkspace",
m_outputWS);
709 fit->setProperty(
"WorkspaceIndex", 0);
710 fit->setProperty(
"MaxIterations", 500);
711 fit->setProperty(
"StartX", startx);
712 fit->setProperty(
"EndX", endx);
713 fit->setProperty(
"Minimizer",
"Levenberg-MarquardtMD");
714 fit->setProperty(
"CostFunction",
"Least squares");
716 fit->executeAsChildAlg();
719 std::string fitStatus = fit->getProperty(
"OutputStatus");
720 bool allowedfailure = (fitStatus.find(
"Changes") < fitStatus.size()) && (fitStatus.find(
"small") < fitStatus.size());
721 if (fitStatus !=
"success" && !allowedfailure) {
722 g_log.
error() <<
"ProcessBackground: Fit Status = " << fitStatus <<
". Not to update fit result\n";
723 throw std::runtime_error(
"Bad Fit " + fitStatus);
726 const double chi2 = fit->getProperty(
"OutputChi2overDoF");
727 g_log.
information() <<
"Fit background: Fit Status = " << fitStatus <<
", chi2 = " << chi2 <<
"\n";
732 outbkgdparws->addColumn(
"str",
"Name");
733 outbkgdparws->addColumn(
"double",
"Value");
735 TableRow typerow = outbkgdparws->appendRow();
736 typerow << bkgdfunctiontype << 0.;
738 vector<string> parnames = funcout->getParameterNames();
739 size_t nparam = funcout->nParams();
740 for (
size_t i = 0; i < nparam; ++i) {
741 TableRow newrow = outbkgdparws->appendRow();
742 newrow << parnames[i] << funcout->getParameter(i);
745 TableRow chi2row = outbkgdparws->appendRow();
746 chi2row <<
"Chi-square" << chi2;
748 g_log.
information() <<
"Set table workspace (#row = " << outbkgdparws->rowCount()
749 <<
") to OutputBackgroundParameterTable. "
751 setProperty(
"OutputBackgroundParameterWorkspace", outbkgdparws);
759 funcout->function(domain, values);
763 for (
size_t i = 0; i < dataModel.size(); ++i) {
764 dataModel[i] = values[i];
765 dataDiff[i] = vecY[i] - dataModel[i];
780 throw runtime_error(
"Option RemovePeaks requires input to BgraggPeaTablekWorkspace.");
784 throw runtime_error(
"NumberOfFWHM must be larger than 0. ");
788 remove.
setup(peaktablews);
804 throw runtime_error(
"Number of peak centres and FWHMs are different!");
806 throw runtime_error(
"There is not any peak entry in input table workspace.");
815 throw runtime_error(
"RemovePeaks has not been setup yet. ");
818 const auto &vecX = dataws->x(wsindex);
819 const auto &vecY = dataws->y(wsindex);
820 const auto &vecE = dataws->e(wsindex);
822 size_t sizex = vecX.size();
823 vector<bool> vec_useX(sizex,
true);
827 size_t numbkgdpointsy = numbkgdpoints;
828 size_t sizey = vecY.size();
835 outws->getAxis(0)->setUnit(dataws->getAxis(0)->unit()->unitID());
836 auto &outX = outws->mutableX(0);
837 auto &outY = outws->mutableY(0);
838 auto &outE = outws->mutableE(0);
840 for (
size_t i = 0; i < sizex; ++i) {
842 if (
index >= numbkgdpoints)
843 throw runtime_error(
"Programming logic error (1)");
844 outX[
index] = vecX[i];
849 for (
size_t i = 0; i < sizey; ++i) {
851 if (
index >= numbkgdpointsy)
852 throw runtime_error(
"Programming logic error (2)");
853 outY[
index] = vecY[i];
854 outE[
index] = vecE[i];
866 vector<double> &vec_peakfwhm) {
868 vector<string> colnames = peaktablews->getColumnNames();
869 int index_centre = -1;
871 for (
int i = 0; i < static_cast<int>(colnames.size()); ++i) {
872 string colname = colnames[i];
873 if (colname ==
"TOF_h")
875 else if (colname ==
"FWHM")
879 if (index_centre < 0 || index_fwhm < 0) {
880 throw runtime_error(
"Input Bragg peak table workspace does not have TOF_h and/or FWHM");
884 size_t numrows = peaktablews->rowCount();
885 vec_peakcentre.resize(numrows, 0.);
886 vec_peakfwhm.resize(numrows, 0.);
888 for (
size_t i = 0; i < numrows; ++i) {
889 double centre = peaktablews->cell<
double>(i, index_centre);
890 double fwhm = peaktablews->cell<
double>(i, index_fwhm);
891 vec_peakcentre[i] = centre;
892 vec_peakfwhm[i] = fwhm;
900 vector<double> v_fwhm,
double num_fwhm) {
902 if (v_centre.size() != v_fwhm.size())
903 throw runtime_error(
"Input different number of peak centres and fwhm.");
904 if (v_inX.size() != v_useX.size())
905 throw runtime_error(
"Input differetn number of vec X and flag X.");
908 size_t numpeaks = v_centre.size();
909 for (
size_t i = 0; i < numpeaks; ++i) {
911 double centre = v_centre[i];
912 double fwhm = v_fwhm[i];
913 double xmin = centre - num_fwhm * fwhm;
914 double xmax = centre + num_fwhm * fwhm;
916 vector<double>::iterator viter;
920 if (xmin <= v_inX.front())
922 else if (xmin >= v_inX.back())
923 i_min =
static_cast<int>(v_inX.size()) - 1;
925 viter = lower_bound(v_inX.begin(), v_inX.end(), xmin);
926 i_min =
static_cast<int>(viter - v_inX.begin());
929 if (xmax <= v_inX.front())
931 else if (xmax >= v_inX.back())
932 i_max =
static_cast<int>(v_inX.size()) - 1;
934 viter = lower_bound(v_inX.begin(), v_inX.end(), xmax);
935 i_max =
static_cast<int>(viter - v_inX.begin());
939 for (
int excluded = i_min; excluded <= i_max; ++excluded)
940 v_useX[excluded] =
false;
943 return std::count(v_useX.cbegin(), v_useX.cend(),
true);
#define DECLARE_ALGORITHM(classname)
std::map< DeltaEMode::Type, std::string > index
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
void setPropertyValue(const std::string &name, const std::string &value) override
Set the value of a property by string N.B.
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
Implements FunctionDomain1D with its own storage in form of a std::vector.
size_t size() const override
Return the number of arguments in the domain.
A class to store values calculated by a function.
size_t size() const
Return the number of values.
TableRow represents a row in a TableWorkspace.
A property class for workspaces.
ProcessBackground : Process background obtained from LeBailFit.
DataObjects::Workspace2D_sptr autoBackgroundSelection(const DataObjects::Workspace2D_sptr &bkgdWS)
Select background points automatically.
void selectBkgdPoints()
Select b...
void fitBackgroundFunction(const std::string &bkgdfunctiontype)
Fit background function.
DataObjects::Workspace2D_const_sptr m_dataWS
void setupDummyOutputWSes()
Set up dummy output optional workspaces.
void removePeaks()
Remove peaks in a certain region.
void selectFromGivenFunction()
Select background points (main)
void init() override
Define properties.
BackgroundFunction_sptr createBackgroundFunction(const std::string &backgroundtype)
Create a background function from input properties.
DataObjects::Workspace2D_sptr m_outputWS
double m_numFWHM
Number of FWHM of range of peak to be removed.
DataObjects::Workspace2D_sptr filterForBackground(const BackgroundFunction_sptr &bkgdfunction)
Filter non-background data points out and create a background workspace.
void addRegion()
Add a certain region from a reference workspace.
void exec() override
Execution body.
void deleteRegion()
Remove a certain region from input workspace.
void selectFromGivenXValues()
Select background points (main)
void parsePeakTableWorkspace(const DataObjects::TableWorkspace_sptr &peaktablews, std::vector< double > &vec_peakcentre, std::vector< double > &vec_peakfwhm)
Parse peak centre and FWHM from a table workspace.
std::vector< double > m_vecPeakCentre
void setup(const DataObjects::TableWorkspace_sptr &peaktablews)
Set up: parse peak workspace to vectors.
size_t excludePeaks(std::vector< double > v_inX, std::vector< bool > &v_useX, std::vector< double > v_centre, std::vector< double > v_fwhm, double num_fwhm)
Exclude peak regions.
std::vector< double > m_vecPeakFWHM
DataObjects::Workspace2D_sptr removePeaks(const API::MatrixWorkspace_const_sptr &dataws, int wsindex, double numfwhm)
Remove peaks from a input workspace.
Exception for when an item is not found in a collection.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< Chebyshev > Chebyshev_sptr
std::shared_ptr< BackgroundFunction > BackgroundFunction_sptr
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< const Workspace2D > Workspace2D_const_sptr
shared pointer to Mantid::DataObjects::Workspace2D (const version)
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
Helper class which provides the Collimation Length for SANS instruments.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.