19using namespace Kernel;
20using namespace DataObjects;
22using DataObjects::EventList;
23using DataObjects::EventWorkspace;
26using Types::Core::DateAndTime;
33 "An input event workspace");
36 "The name to use for the output workspace");
39 "Name of the sample log to use to filter.\n"
40 "For example, the pulse charge is recorded in 'ProtonCharge'.");
46 auto min = std::make_shared<BoundedValidator<double>>();
49 "Tolerance, in seconds, for the event times to keep. How TimeTolerance is applied is highly "
50 "correlated to LogBoundary and PulseFilter. Check the help or algorithm documents for details.");
52 std::vector<std::string> types(2);
55 declareProperty(
"LogBoundary", types[0], std::make_shared<StringListValidator>(types),
56 "How to treat log values as being measured in the centre of "
57 "the time window for which log criteria are satisfied, or left (beginning) of time window boundary. "
58 "This value must be set to Left if the sample log is recorded upon changing,"
59 "which applies to most of the sample environment devices in SNS.");
62 "Optional. Filter out a notch of time for each entry in the "
64 "A notch of width 2*TimeTolerance is centered at each log "
65 "time. The value of the log is NOT used."
66 "This is used, for example, to filter out veto pulses.");
70 std::map<std::string, std::string> errors;
83 errors[
"LogName"] =
"'" + logname +
"' is not a time-series log.";
87 errors[
"LogName"] =
"The log '" + logname +
"' does not exist in the workspace '" + inputWS->getName() +
"'.";
94 errors[
"MinimumValue"] =
"MinimumValue must not be larger than MaximumValue";
95 errors[
"MaximumValue"] =
"MinimumValue must not be larger than MaximumValue";
113 const bool PulseFilter =
getProperty(
"PulseFilter");
117 DateAndTime run_start(0), run_stop(
"2100-01-01T00:00:00");
118 bool handle_edge_values =
false;
120 run_start = inputWS->getFirstPulseTime() -
tolerance;
121 run_stop = inputWS->getLastPulseTime() +
tolerance;
122 handle_edge_values =
true;
133 DateAndTime lastTime = run_start;
135 std::vector<DateAndTime>::iterator it;
136 for (it = times.begin(); it != times.end(); ++it) {
140 splitter.emplace_back(interval);
143 splitter.emplace_back(lastTime, run_stop, 0);
151 log->makeFilterByValue(splitter, min, max,
tolerance, (logBoundary ==
CENTRE));
153 if (log->realSize() >= 1 && handle_edge_values) {
154 log->expandFilterToRange(splitter, min, max,
TimeInterval(run_start, run_stop));
160 size_t numberOfSpectra = inputWS->getNumberHistograms();
163 Progress prog(
this, 0.0, 1.0, numberOfSpectra);
166 if (inputWS == outputWS) {
170 for (int64_t i = 0; i < int64_t(numberOfSpectra); ++i) {
174 EventList &input_el = inputWS->getSpectrum(i);
186 auto newRun = Kernel::make_cow<Run>(inputWS->run());
187 std::vector<LogManager *> splitRuns = {&newRun.access()};
188 inputWS->run().splitByTime(splitter, splitRuns);
190 inputWS->setSharedRun(newRun);
191 inputWS->mutableRun().integrateProtonCharge();
197 outputWS = create<EventWorkspace>(*inputWS);
201 for (int64_t i = 0; i < int64_t(numberOfSpectra); ++i) {
205 std::vector<EventList *> outputs{&outputWS->getSpectrum(i)};
208 const EventList &input_el = inputWS->getSpectrum(i);
221 std::vector<LogManager *> output_runs;
222 output_runs.emplace_back(&outputWS->mutableRun());
223 inputWS->run().splitByTime(splitter, output_runs);
#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(Kernel::TimeSplitterType &splitter)
Use a TimeSplitterType to filter the event list in place.
void splitByTime(Kernel::TimeSplitterType &splitter, std::vector< EventList * > outputs) const
Split the event list into n outputs.
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.
Class holding a start/end time and a destination for splitting event lists and logs.
Represents a time interval.
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
std::vector< SplittingInterval > TimeSplitterType
A typedef for splitting events according their pulse time.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.