84 const double toleranceWallClock =
getProperty(
"WallClockTolerance");
85 const bool compressFat = !
isEmpty(toleranceWallClock);
89 if (mode == BinningMode::LINEAR)
90 toleranceTof = std::fabs(toleranceTof);
91 else if (mode == BinningMode::LOGARITHMIC)
92 toleranceTof = -1. * std::fabs(toleranceTof);
94 Types::Core::DateAndTime startTime;
97 std::string startTimeProp =
getProperty(
"StartTime");
98 if (startTimeProp.empty()) {
99 startTime = inputWS->run().startTime();
107 bool inplace = (inputWS == outputWS);
108 const size_t noSpectra = inputWS->getNumberHistograms();
109 Progress prog(
this, 0.0, 1.0, noSpectra * 2);
113 if (!compressFat && sortFirst) {
114 const auto timerStart = std::chrono::high_resolution_clock::now();
116 addTimer(
"sortByTOF", timerStart, std::chrono::high_resolution_clock::now());
120 auto histogram_bin_edges = std::make_shared<std::vector<double>>();
122 if (!compressFat && !sortFirst && !(inputWS->getSortType() ==
TOF_SORT)) {
124 double tof_min_fixed;
125 double tof_max_fixed;
126 inputWS->getEventXMinMax(tof_min_fixed, tof_max_fixed);
128 {tof_min_fixed, toleranceTof, (tof_max_fixed + std::abs(toleranceTof))}, *histogram_bin_edges,
true,
true);
129 num_edges = histogram_bin_edges->size();
134 outputWS = create<EventWorkspace>(*inputWS, HistogramData::BinEdges(2));
137 tbb::parallel_for(tbb::blocked_range<size_t>(0, noSpectra),
138 [compressFat, sortFirst, toleranceTof, startTime, toleranceWallClock, num_edges,
139 &histogram_bin_edges, &inputWS, &outputWS, &prog](
const tbb::blocked_range<size_t> &range) {
149 input_el.
compressFatEvents(toleranceTof, startTime, toleranceWallClock, &output_el);
153 input_el.
compressEvents(toleranceTof, &output_el, histogram_bin_edges);
154 prog.
report(
"Compressing");
158 tbb::parallel_for(tbb::blocked_range<size_t>(0, noSpectra),
159 [compressFat, sortFirst, toleranceTof, startTime, toleranceWallClock, num_edges,
160 &histogram_bin_edges, &outputWS, &prog](
const tbb::blocked_range<size_t> &range) {
163 auto &output_el = outputWS->getSpectrum(
index);
166 output_el.compressFatEvents(toleranceTof, startTime, toleranceWallClock, &output_el);
167 else if (sortFirst || output_el.isSortedByTof() || output_el.getNumberEvents() <= num_edges)
168 output_el.compressEvents(toleranceTof, &output_el);
170 output_el.compressEvents(toleranceTof, &output_el, histogram_bin_edges);
171 prog.
report(
"Compressing");
int MANTID_KERNEL_DLL createAxisFromRebinParams(const std::vector< double > ¶ms, std::vector< double > &xnew, const bool resize_xnew=true, const bool full_bins_only=false, const double xMinHint=std::nan(""), const double xMaxHint=std::nan(""), const bool useReverseLogarithmic=false, const double power=-1)
Creates a new output X array given a 'standard' set of rebinning parameters.