16#include "tbb/parallel_for.h"
25using namespace Kernel;
27using namespace DataObjects;
31 "The name of the EventWorkspace on which to perform the algorithm");
34 "The name of the output EventWorkspace.");
37 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
38 mustBePositive->setLower(0.0);
40 "The tolerance on each event's X value (normally TOF, but may be a "
41 "different unit if you have used ConvertUnits).\n"
42 "Any events within Tolerance will be summed into a single event.");
46 "The tolerance (in seconds) on the wall-clock time for comparison. Unset "
47 "means compressing all wall-clock times together disabling pulsetime "
50 auto dateValidator = std::make_shared<DateTimeValidator>();
51 dateValidator->allowEmpty(
true);
53 "An ISO formatted date/time string specifying the timestamp for "
54 "starting filtering. Ignored if WallClockTolerance is not specified. "
55 "Default is start of run",
63 const double toleranceTof =
getProperty(
"Tolerance");
64 const double toleranceWallClock =
getProperty(
"WallClockTolerance");
65 const bool compressFat = !
isEmpty(toleranceWallClock);
66 Types::Core::DateAndTime startTime;
69 std::string startTimeProp =
getProperty(
"StartTime");
70 if (startTimeProp.empty()) {
71 startTime = inputWS->run().startTime();
79 bool inplace = (inputWS == outputWS);
80 const size_t noSpectra = inputWS->getNumberHistograms();
81 Progress prog(
this, 0.0, 1.0, noSpectra * 2);
90 outputWS = create<EventWorkspace>(*inputWS, HistogramData::BinEdges(2));
93 tbb::parallel_for(tbb::blocked_range<size_t>(0, noSpectra),
94 [compressFat, toleranceTof, startTime, toleranceWallClock, &inputWS, &outputWS,
95 &prog](
const tbb::blocked_range<size_t> &range) {
98 EventList &input_el = inputWS->getSpectrum(index);
100 EventList &output_el = outputWS->getSpectrum(index);
102 output_el.setX(input_el.ptrX());
105 input_el.compressFatEvents(toleranceTof, startTime, toleranceWallClock, &output_el);
107 input_el.compressEvents(toleranceTof, &output_el);
108 prog.report(
"Compressing");
112 tbb::parallel_for(tbb::blocked_range<size_t>(0, noSpectra),
113 [compressFat, toleranceTof, startTime, toleranceWallClock, &outputWS,
114 &prog](
const tbb::blocked_range<size_t> &range) {
117 auto &output_el = outputWS->getSpectrum(index);
120 output_el.compressFatEvents(toleranceTof, startTime, toleranceWallClock, &output_el);
122 output_el.compressEvents(toleranceTof, &output_el);
123 prog.report(
"Compressing");
#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.
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 init() override
Virtual method - must be overridden by concrete algorithm.
void exec() override
Virtual method - must be overridden by concrete algorithm.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
The concrete, templated class for properties.
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
MANTID_KERNEL_DLL Types::Core::DateAndTime createFromSanitizedISO8601(const std::string &date)
Creates a DateAndTime object from a date string even if the string does not exactly conform to ISO860...
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.