19using namespace Kernel;
20using namespace DataObjects;
22using DataObjects::EventList;
23using DataObjects::EventWorkspace;
27using Types::Core::DateAndTime;
34 "An input event workspace");
37 "The name to use for the output workspace");
40 "Name of the sample log to use to filter.\n"
41 "For example, the pulse charge is recorded in 'ProtonCharge'.");
47 auto min = std::make_shared<BoundedValidator<double>>();
50 "Tolerance, in seconds, for the event times to keep. How TimeTolerance is applied is highly "
51 "correlated to LogBoundary and PulseFilter. Check the help or algorithm documents for details.");
53 std::vector<std::string> types(2);
56 declareProperty(
"LogBoundary", types[0], std::make_shared<StringListValidator>(types),
57 "How to treat log values as being measured in the centre of "
58 "the time window for which log criteria are satisfied, or left (beginning) of time window boundary. "
59 "This value must be set to Left if the sample log is recorded upon changing,"
60 "which applies to most of the sample environment devices in SNS.");
63 "Optional. Filter out a notch of time for each entry in the "
65 "A notch of width 2*TimeTolerance is centered at each log "
66 "time. The value of the log is NOT used."
67 "This is used, for example, to filter out veto pulses.");
71 std::map<std::string, std::string> errors;
84 errors[
"LogName"] =
"'" + logname +
"' is not a time-series log.";
88 errors[
"LogName"] =
"The log '" + logname +
"' does not exist in the workspace '" + inputWS->getName() +
"'.";
95 errors[
"MinimumValue"] =
"MinimumValue must not be larger than MaximumValue";
96 errors[
"MaximumValue"] =
"MinimumValue must not be larger than MaximumValue";
114 const bool PulseFilter =
getProperty(
"PulseFilter");
118 DateAndTime run_start(0), run_stop(
"2100-01-01T00:00:00");
119 bool handle_edge_values =
false;
121 run_start = inputWS->getFirstPulseTime() -
tolerance;
122 run_stop = inputWS->getLastPulseTime() +
tolerance;
123 handle_edge_values =
true;
127 const auto &roiInputWS = inputWS->run().getTimeROI();
136 DateAndTime lastTime = run_start;
138 std::vector<DateAndTime>::iterator it;
139 for (it = times.begin(); it != times.end(); ++it) {
146 if (lastTime < run_stop)
147 roi->
addROI(lastTime, run_stop);
154 const TimeROI *tempTimeROI = &inputWS->run().getTimeROI();
156 if (log->realSize() > 0 && handle_edge_values) {
158 log->makeFilterByValue(min, max,
true,
TimeInterval(run_start, run_stop),
tolerance, centre, tempTimeROI);
166 size_t numberOfSpectra = inputWS->getNumberHistograms();
169 Progress prog(
this, 0.0, 1.0, numberOfSpectra);
171 if (inputWS == outputWS) {
175 for (int64_t i = 0; i < int64_t(numberOfSpectra); ++i) {
179 EventList &input_el = inputWS->getSpectrum(i);
189 auto newRun = Kernel::make_cow<Run>(inputWS->run());
190 newRun.access().setTimeROI(*roi);
192 inputWS->setSharedRun(newRun);
198 outputWS = create<EventWorkspace>(*inputWS);
202 for (int64_t i = 0; i < int64_t(numberOfSpectra); ++i) {
206 EventList *outputs{&outputWS->getSpectrum(i)};
209 const EventList &input_el = inputWS->getSpectrum(i);
220 if (!roiInputWS.useAll()) {
223 outputWS->mutableRun().setTimeROI(*roi);
224 outputWS->mutableRun().removeDataOutsideTimeROI();
#define DECLARE_ALGORITHM(classname)
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_FOR_NO_WSP_CHECK()
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
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.
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void exec() override
Executes the algorithm.
std::map< std::string, std::string > validateInputs() override
Method checking errors on ALL the inputs, before execution.
void init() override
Virtual method - must be overridden by concrete algorithm.
void filterInPlace(const Kernel::TimeROI *timeRoi)
Use a SplittingIntervalVec to filter the event list in place.
void filterByPulseTime(Types::Core::DateAndTime start, Types::Core::DateAndTime stop, EventList &output) const
Filter this EventList into an output EventList, using keeping only events within the >= start and < e...
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.
A non-templated interface to a TimeSeriesProperty.
virtual std::vector< Types::Core::DateAndTime > timesAsVector() const =0
Return the time series's times as a vector<DateAndTime>
void information(const std::string &msg)
Logs at information level.
Validator to check that a property is not left empty.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
Represents a time interval.
TimeROI : Object that holds information about when the time measurement was active.
std::size_t numBoundaries() const
void addROI(const std::string &startTime, const std::string &stopTime)
void update_intersection(const TimeROI &other)
Updates the TimeROI values with the intersection with another TimeROI.
std::string CENTRE("Centre")
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.