35 std::make_shared<WorkspaceUnitValidator>(
"TOF")),
36 "An input workspace.");
38 "An output workspace.");
40 auto validator = std::make_shared<BoundedValidator<double>>();
41 validator->setLower(0.0);
43 "The width of the time of flight (in microseconds) to remove "
46 "The frequency of the source (in Hz) used to calculate the "
47 "minimum time of flight to filter.");
67 if (eventWksp ==
nullptr) {
68 wksp->getXMinMax(tmin, tmax);
70 eventWksp->getEventXMinMax(tmin, tmax);
81 throw std::runtime_error(
"Failed to specify \'Width\' parameter");
93 throw std::runtime_error(
"Failed to determine the frequency");
97 double period = 1000000. / frequency;
102 getTofRange(inputWS, tmin, tmax);
103 g_log.
information() <<
"Data tmin=" << tmin <<
", tmax=" << tmax <<
", period=" << period <<
" microseconds\n";
107 if (pulseTimes.empty()) {
108 g_log.
notice() <<
"Not applying filter since prompt pulse is not in data "
111 setProperty(
"OutputWorkspace", std::const_pointer_cast<MatrixWorkspace>(inputWS));
115 for (
double pulseTime : pulseTimes)
120 for (
double &pulseTime : pulseTimes) {
121 double right = pulseTime + width;
123 g_log.
notice() <<
"Filtering tmin=" << pulseTime <<
", tmax=" <<
right <<
" microseconds\n";
128 algo->setProperty<
MatrixWorkspace_sptr>(
"InputWorkspace", std::const_pointer_cast<MatrixWorkspace>(outputWS));
130 algo->setProperty<
MatrixWorkspace_sptr>(
"InputWorkspace", std::const_pointer_cast<MatrixWorkspace>(inputWS));
135 algo->setProperty<
double>(
"XMin", pulseTime);
136 algo->setProperty<
double>(
"XMax",
right);
137 algo->executeAsChildAlg();
140 outputWS = algo->getProperty(
"OutputWorkspace");
150 if (!(this->
isEmpty(candidate)))
154 if (!(this->
isEmpty(candidate)))
158 if (!(this->
isEmpty(candidate)))
174 std::vector<double> times;
182 while (time < tmax) {
183 times.emplace_back(time);
#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.
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.
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
bool hasProperty(const std::string &name) const
Does the property exist on the object.
Kernel::Property * getLogData(const std::string &name) const
Access a single log entry.
This class stores information regarding an experimental run as a series of log entries.
A property class for workspaces.
const std::string name() const override
Algorithm's name for identification.
int version() const override
Algorithm's version for identification.
std::vector< double > calculatePulseTimes(const double tmin, const double tmax, const double period)
Calculate when all prompt pulses might be between the supplied times.
const std::string category() const override
Algorithm's category for identification.
double getFrequency(const API::Run &run)
Try to get the frequency from a given name.
void exec() override
Run the algorithm.
void init() override
Sets documentation strings for this algorithm.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void notice(const std::string &msg)
Logs at notice level.
void information(const std::string &msg)
Logs at information level.
A specialised Property class for holding a series of time-value pairs.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
double getMedian(const vector< TYPE > &data)
There are enough special cases in determining the median where it useful to put it in a single functi...
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.
Struct holding some useful statistics for a TimeSeriesProperty.
double median
Median value.