40 const Peak &fullPeak =
dynamic_cast<const Peak &
>(p);
51using namespace Kernel;
53using API::IPeaksWorkspace;
68 "The input workspace");
70 "The filtered workspace");
73 const std::string FILTER(
"Filter Options");
74 std::vector<std::string> filters{
"h+k+l",
"h^2+k^2+l^2",
"Intensity",
"Signal/Noise",
"QMod",
75 "Wavelength",
"DSpacing",
"TOF",
"RunNumber"};
76 declareProperty(
"FilterVariable",
"h+k+l", std::make_shared<StringListValidator>(filters),
77 "The variable on which to filter the peaks");
81 std::vector<std::string> operation{
"<",
">",
"=",
"!=",
"<=",
">="};
82 declareProperty(
"Operator",
"<", std::make_shared<StringListValidator>(operation),
"");
88 const std::string SELECT(
"Select Bank by Name");
89 std::vector<std::string> action{
"=",
"!="};
90 declareProperty(
"Criterion",
"=", std::make_shared<StringListValidator>(action),
"");
91 declareProperty(
"BankName",
"",
"Selected bank name, empty means skip selection. Applicable only to PeaksWorkspace");
104 filteredWS->copyExperimentInfoFrom(inputWS.get());
106 const double filterValue =
getProperty(
"FilterValue");
107 const std::string Operator =
getProperty(
"Operator");
108 const std::string filterVariable =
getProperty(
"FilterVariable");
110 const std::string bankname =
getProperty(
"BankName");
111 const std::string criterion =
getProperty(
"Criterion");
113 if (!bankname.empty() && (inputWS->id() ==
"PeaksWorkspace")) {
117 if (criterion ==
"=")
118 filterPeaksStr<std::equal_to<std::string>>(*inputWS, *selectedWS, filterFunction, bankname);
119 else if (criterion ==
"!=")
120 filterPeaksStr<std::not_equal_to<std::string>>(*inputWS, *selectedWS, filterFunction, bankname);
122 throw std::invalid_argument(
"Unsupported operator " + criterion +
" for BankName filter");
124 inputWS = selectedWS;
132 filterPeaks<std::less<double>>(*inputWS, *filteredWS, filterFunction, filterValue);
133 else if (Operator ==
">")
134 filterPeaks<std::greater<double>>(*inputWS, *filteredWS, filterFunction, filterValue);
135 else if (Operator ==
"=")
136 filterPeaks<std::equal_to<double>>(*inputWS, *filteredWS, filterFunction, filterValue);
137 else if (Operator ==
"!=")
138 filterPeaks<std::not_equal_to<double>>(*inputWS, *filteredWS, filterFunction, filterValue);
139 else if (Operator ==
"<=")
140 filterPeaks<std::less_equal<double>>(*inputWS, *filteredWS, filterFunction, filterValue);
141 else if (Operator ==
">=")
142 filterPeaks<std::greater_equal<double>>(*inputWS, *filteredWS, filterFunction, filterValue);
144 throw std::invalid_argument(
"Unknown Operator " + Operator);
162 if (filterVariable ==
"h+k+l")
163 filterFunction = &HKLSum;
164 else if (filterVariable ==
"h^2+k^2+l^2")
165 filterFunction = &HKL2;
166 else if (filterVariable ==
"Intensity")
167 filterFunction = &intensity;
168 else if (filterVariable ==
"Wavelength")
169 filterFunction = &wavelength;
170 else if (filterVariable ==
"DSpacing")
171 filterFunction = &dspacing;
172 else if (filterVariable ==
"TOF")
173 filterFunction = &tof;
174 else if (filterVariable ==
"Signal/Noise")
175 filterFunction = &SN;
176 else if (filterVariable ==
"QMod")
177 filterFunction = &QMOD;
178 else if (filterVariable ==
"RunNumber")
179 filterFunction = &RUN;
181 throw std::invalid_argument(
"Unknown FilterVariable: " + filterVariable);
182 return filterFunction;
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
bool isDefault(const std::string &name) const
A property class for workspaces.
void init() override
Override for algorithm init.
const std::string name() const override
Algorithm's name for identification.
FilterFunction getFilterVariableFunction(const std::string &filterVariable) const
Get a function to filter peaks by.
void exec() override
Override for algorithm exec.
const std::string category() const override
Algorithm's category for identification.
std::function< double(const Geometry::IPeak &)> FilterFunction
Typedef for the function to get the variable we're filtering against.
std::function< std::string(const Geometry::IPeak &)> FilterFunctionStr
int version() const override
Algorithm's version for identification.
Structure describing a single-crystal peak.
std::string getBankName() const
Find the name of the bank that is the parent of the detector.
Structure describing a single-crystal peak.
virtual double getH() const =0
virtual double getTOF() const =0
virtual double getSigmaIntensity() const =0
virtual double getWavelength() const =0
virtual double getDSpacing() const =0
virtual double getK() const =0
virtual int getRunNumber() const =0
virtual Mantid::Kernel::V3D getQSampleFrame() const =0
virtual double getIntensity() const =0
virtual double getL() const =0
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
double norm() const noexcept
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
std::shared_ptr< const IPeaksWorkspace > IPeaksWorkspace_const_sptr
shared pointer to Mantid::API::IPeaksWorkspace (const version)
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.