Mantid
Loading...
Searching...
No Matches
GetAllEi.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include "MantidAPI/Axis.h"
10#include "MantidAPI/Run.h"
17#include "MantidIndexing/Extract.h"
18#include "MantidIndexing/IndexInfo.h"
22#include "MantidKernel/Unit.h"
25
26#include <boost/algorithm/string.hpp>
27#include <boost/format.hpp>
28
29#include <string>
30
31namespace Mantid::Algorithms {
32
33using namespace Mantid::DataObjects;
34using namespace Mantid::HistogramData;
35DECLARE_ALGORITHM(GetAllEi)
36
37
39 : Algorithm(), m_FilterWithDerivative(true),
40 // minimal resolution for all instruments
41 m_min_Eresolution(0.08),
42 // half maximal resolution for LET
43 m_max_Eresolution(0.5e-3), m_peakEnergyRatio2reject(0.1), m_phase(0), m_chopper(), m_pFilterLog(nullptr) {}
44
47
50 "The input workspace containing the monitor's spectra "
51 "measured after the last chopper");
52 auto nonNegative = std::make_shared<Kernel::BoundedValidator<int>>();
53 nonNegative->setLower(0);
54
55 declareProperty("Monitor1SpecID", EMPTY_INT(), nonNegative,
56 "The workspace index (ID) of the spectra, containing first monitor's"
57 " signal to analyze.");
58 declareProperty("Monitor2SpecID", EMPTY_INT(), nonNegative,
59 "The workspace index (ID) of the spectra, containing second monitor's"
60 " signal to analyze.");
61
62 declareProperty("ChopperSpeedLog", "Defined in IDF",
63 "Name of the instrument log, "
64 "containing chopper angular velocity. If 'Defined in IDF' "
65 "option is specified, "
66 "the log name is obtained from the IDF");
67 declareProperty("ChopperDelayLog", "Defined in IDF",
68 "Name of the instrument log, "
69 "containing chopper delay time or chopper phase v.r.t. the pulse time. "
70 "If 'Defined in IDF' option is specified, "
71 "the log name is obtained from IDF");
72 declareProperty("FilterBaseLog", "Defined in IDF",
73 "Name of the instrument log, "
74 "with positive values indicating that instrument is running\n "
75 "and 0 or negative that it is not.\n"
76 "The log is used to identify time interval to evaluate"
77 " chopper speed and chopper delay which matter.\n"
78 "If such log is not present, average log values are calculated "
79 "within experiment start&end time range.");
80 declareProperty("FilterWithDerivative", true,
81 "Use derivative of 'FilterBaseLog' "
82 "rather then log values itself to filter invalid time intervals.\n"
83 "Invalid values are then the "
84 "values where the derivative of the log turns zero.\n"
85 "E.g. the 'proton_chage' log grows for each frame "
86 "when instrument is counting and is constant otherwise.");
87 setPropertySettings("FilterWithDerivative",
88 std::make_unique<Kernel::EnabledWhenProperty>(
89 "FilterBaseLog", Kernel::ePropertyCriterion::IS_EQUAL_TO, "Defined in IDF"));
90
91 auto maxInRange = std::make_shared<Kernel::BoundedValidator<double>>();
92 maxInRange->setLower(1.e-6);
93 maxInRange->setUpper(0.1);
94
95 declareProperty("MaxInstrResolution", 0.0005, maxInRange,
96 "The maximal energy resolution possible for an "
97 "instrument at working energies (full width at half "
98 "maximum). \nPeaks, sharper then "
99 "this width are rejected. Accepted limits are: 1e^(-6)-0.1");
100
101 auto minInRange = std::make_shared<Kernel::BoundedValidator<double>>();
102 minInRange->setLower(0.001);
103 minInRange->setUpper(0.5);
104 declareProperty("MinInstrResolution", 0.08, minInRange,
105 "The minimal energy resolution possible for an "
106 "instrument at working energies (full width at half maximum).\n"
107 "Peaks broader then this width are rejected. Accepted limits are: "
108 "0.001-0.5");
109
110 auto peakInRange = std::make_shared<Kernel::BoundedValidator<double>>();
111 peakInRange->setLower(0.0);
112 minInRange->setUpper(1.);
113 declareProperty("PeaksRatioToReject", 0.1, peakInRange,
114 "Ratio of a peak energy to the maximal energy among all peaks. "
115 "If the ratio is lower then the value specified here, "
116 "peak is treated as insignificant and rejected.\n"
117 "Accepted limits are:0.0 (All accepted) to 1 -- only one peak \n"
118 "(or peaks with max and equal intensity) are accepted.");
119 declareProperty("IgnoreSecondMonitor", false,
120 "Usually peaks are analyzed and accepted "
121 "only if identified on both monitors. If this property is set to true, "
122 "only first monitor peaks are analyzed.\n"
123 "This is debugging option as getEi has to use both monitors.");
124
126 std::make_unique<API::WorkspaceProperty<API::Workspace>>("OutputWorkspace", "", Kernel::Direction::Output),
127 "Name of the output matrix workspace, containing single spectra with"
128 " monitor peaks energies\n"
129 "together with total intensity within each peak.");
130}
131
132// unnamed namespace for auxiliary file-based compilation units
133namespace {
134
141template <class T> void removeInvalidValues(const std::vector<bool> &guessValid, std::vector<T> &guess) {
142 std::vector<T> new_guess;
143 new_guess.reserve(guess.size());
144
145 for (size_t i = 0; i < guessValid.size(); i++) {
146 if (guessValid[i]) {
147 new_guess.emplace_back(guess[i]);
148 }
149 }
150 new_guess.swap(guess);
151}
153struct peakKeeper {
154 double position;
155 double height;
156 double sigma;
157 double energy;
158
159 peakKeeper(double pos, double heigh, double sig) : position(pos), height(heigh), sigma(sig) {
160 this->energy = std::sqrt(2 * M_PI) * height * sigma;
161 }
162 // to sort peaks
163 bool operator<(const peakKeeper &str) const { return (energy > str.energy); }
164};
165
166} // namespace
167
170 // Get pointers to the workspace, parameter map and table
171 API::MatrixWorkspace_sptr inputWS = getProperty("Workspace");
172 m_min_Eresolution = getProperty("MinInstrResolution");
173 m_max_Eresolution = getProperty("MaxInstrResolution");
174 m_peakEnergyRatio2reject = getProperty("PeaksRatioToReject");
175
177 auto pInstrument = inputWS->getInstrument();
178 // auto lastChopPositionComponent =
179 // pInstrument->getComponentByName("chopper-position");
180 // auto chopPoint1 = pInstrument->getChopperPoint(0); ->TODO: BUG! this
181 // operation loses parameters map.
182 m_chopper = pInstrument->getComponentByName("chopper-position");
183 if (!m_chopper)
184 throw std::runtime_error("Instrument " + pInstrument->getName() + " does not have 'chopper-position' component");
185
186 auto phase = m_chopper->getNumberParameter("initial_phase");
187
188 if (phase.empty()) {
189 throw std::runtime_error("Can not find initial_phase parameter"
190 " attached to the chopper-position component");
191 }
192 if (phase.size() > 1) {
193 throw std::runtime_error("Can not deal with multiple phases for initial_phase"
194 " parameter attached to the chopper-position component");
195 }
196 m_phase = phase[0];
197
198 this->setFilterLog(inputWS);
199
200 // auto chopPoint1 = pInstrument->getComponentByName("fermi-chopper");
201 // auto par = chopPoint1->getDoubleParameter("Delay (us)");
202 double chopSpeed, chopDelay;
203 findChopSpeedAndDelay(inputWS, chopSpeed, chopDelay);
204 g_log.debug() << boost::str(boost::format("*Identified avrg ChopSpeed: %8.2f and Delay: %8.2f\n") % chopSpeed %
205 chopDelay);
206
207 auto moderator = pInstrument->getSource();
208 double chopDistance = m_chopper->getDistance(*moderator); // location[0].distance(moderator->getPos());
209 double velocity = chopDistance / chopDelay;
210
211 // build workspace to find monitor's peaks
212 size_t det1WSIndex;
213 auto monitorWS = buildWorkspaceToFit(inputWS, det1WSIndex);
214
215 // recalculate delay time from chopper position to monitor position
216 const auto &detector1 = inputWS->spectrumInfo().detector(det1WSIndex);
217 double mon1Distance = detector1.getDistance(*moderator);
218 double TOF0 = mon1Distance / velocity;
219
220 //--->> below is reserved until full chopper's implementation is available;
221 // auto nChoppers = pInstrument->getNumberOfChopperPoints();
222 // get last chopper.
223 /*
224 if( nChoppers==0)throw std::runtime_error("Instrument does not have any
225 choppers defined");
226
227 auto lastChopper = pInstrument->getChopperPoint(nChoppers-1);
229 */
230 auto &baseSpectrum = inputWS->getSpectrum(det1WSIndex);
231 std::pair<double, double> TOF_range = baseSpectrum.getXDataRange();
232
233 double Period = (0.5 * 1.e+6) / chopSpeed; // 0.5 because some choppers open twice.
234 // Would be nice to have it 1 or 0.5 depending on chopper type, but
235 // it looks like not enough information on what chopper is available on ws;
236 auto destUnit = Kernel::UnitFactory::Instance().create("Energy");
237
238 std::vector<double> guess_opening;
239
240 this->findGuessOpeningTimes(TOF_range, TOF0, Period, guess_opening);
241 if (guess_opening.empty()) {
242 throw std::runtime_error(
243 "Can not find any chopper opening time within TOF range: " + boost::lexical_cast<std::string>(TOF_range.first) +
244 ':' + boost::lexical_cast<std::string>(TOF_range.second));
245 } else {
246 destUnit->initialize(mon1Distance, static_cast<int>(Kernel::DeltaEMode::Elastic), {{Kernel::UnitParams::l2, 0.}});
247 printDebugModeInfo(guess_opening, TOF_range, destUnit);
248 }
249 std::pair<double, double> Mon1_Erange = monitorWS->getSpectrum(0).getXDataRange();
250 std::pair<double, double> Mon2_Erange = monitorWS->getSpectrum(1).getXDataRange();
251 double eMin = std::max(Mon1_Erange.first, Mon2_Erange.first);
252 double eMax = std::min(Mon1_Erange.second, Mon2_Erange.second);
253 g_log.debug() << boost::str(boost::format("Monitors record data in energy range Emin=%8.2f; Emax=%8.2f\n") % eMin %
254 eMax);
255
256 // convert to energy
257 std::vector<double> guess_ei;
258 guess_ei.reserve(guess_opening.size());
259 destUnit->initialize(mon1Distance, static_cast<int>(Kernel::DeltaEMode::Elastic), {{Kernel::UnitParams::l2, 0.}});
260 for (double time : guess_opening) {
261 double eGuess = destUnit->singleFromTOF(time);
262 if (eGuess > eMin && eGuess < eMax) {
263 guess_ei.emplace_back(eGuess);
264 }
265 }
266 g_log.debug() << "*From all chopper opening only: " + std::to_string(guess_ei.size()) +
267 " fell within both monitor's recording energy range\n";
268 g_log.debug() << " Guess Energies are:\n";
269 for (double ei : guess_ei) {
270 g_log.debug() << boost::str(boost::format(" %8.2f; ") % ei);
271 }
272 g_log.debug() << '\n';
273
274 std::sort(guess_ei.begin(), guess_ei.end());
275
276 std::vector<size_t> irange_min, irange_max;
277 std::vector<bool> guessValid;
278 // preprocess first monitors peaks;
279 g_log.debug() << "*Looking for real energy peaks on first monitor\n";
280 findBinRanges(monitorWS->x(0), monitorWS->y(0), guess_ei, this->m_min_Eresolution / (2. * std::sqrt(2. * M_LN2)),
281 irange_min, irange_max, guessValid);
282
283 // remove invalid guess values
284 removeInvalidValues<double>(guessValid, guess_ei);
285
286 // preprocess second monitors peaks
287 std::vector<size_t> irange1_min, irange1_max;
288 if (!this->getProperty("IgnoreSecondMonitor")) {
289 g_log.debug() << "*Looking for real energy peaks on second monitor\n";
290 findBinRanges(monitorWS->x(1), monitorWS->y(1), guess_ei, this->m_min_Eresolution / (2. * std::sqrt(2. * M_LN2)),
291 irange1_min, irange1_max, guessValid);
292 removeInvalidValues<double>(guessValid, guess_ei);
293 removeInvalidValues<size_t>(guessValid, irange_min);
294 removeInvalidValues<size_t>(guessValid, irange_max);
295 } else {
296 // this is wrong but will not be used anyway
297 // (except formally looping through vector)
298 irange1_min.assign(irange_min.begin(), irange_min.end());
299 irange1_max.assign(irange_max.begin(), irange_max.end());
300 }
301 g_log.debug() << "*Identified: " + std::to_string(guess_ei.size()) +
302 " peaks with sufficient signal around guess chopper opening\n";
303
304 std::vector<peakKeeper> peaks;
305
306 double maxPeakEnergy(0);
307 std::vector<size_t> monsRangeMin(2), monsRangeMax(2);
308 for (size_t i = 0; i < guess_ei.size(); i++) {
309 monsRangeMin[0] = irange_min[i];
310 monsRangeMax[0] = irange_max[i];
311 monsRangeMin[1] = irange1_min[i];
312 monsRangeMax[1] = irange1_max[i];
313
314 double energy, height, twoSigma;
315 bool found = findMonitorPeak(monitorWS, guess_ei[i], monsRangeMin, monsRangeMax, energy, height, twoSigma);
316 if (found) {
317 peaks.emplace_back(energy, height, 0.5 * twoSigma);
318 if (peaks.back().energy > maxPeakEnergy)
319 maxPeakEnergy = peaks.back().energy;
320 }
321 }
322 monitorWS.reset();
323
324 size_t nPeaks = peaks.size();
325 if (nPeaks == 0) {
326 throw std::runtime_error("Can not identify any energy peaks");
327 }
328 // sort peaks and remove invalid one
329 guessValid.resize(nPeaks);
330 bool needsRemoval(false);
331 for (size_t i = 0; i < nPeaks; i++) {
332 peaks[i].energy /= maxPeakEnergy;
333 if (peaks[i].energy < m_peakEnergyRatio2reject) {
334 guessValid[i] = false;
335 g_log.debug() << "*Rejecting peak at Ei=" + boost::lexical_cast<std::string>(peaks[i].position) +
336 " as its total energy lower then the threshold\n";
337 needsRemoval = true;
338 } else {
339 guessValid[i] = true;
340 }
341 }
342 if (needsRemoval)
343 removeInvalidValues<peakKeeper>(guessValid, peaks);
344 nPeaks = peaks.size();
345 // sort by energy decreasing -- see class definition
346 std::sort(peaks.begin(), peaks.end());
347
348 // finalize output
349 auto result_ws = create<Workspace2D>(1, Points(nPeaks));
350
351 HistogramX peaks_positions(peaks.size());
352 std::transform(peaks.cbegin(), peaks.cend(), peaks_positions.begin(), [](peakKeeper peak) { return peak.position; });
353 auto &Signal = result_ws->mutableY(0);
354 std::transform(peaks.cbegin(), peaks.cend(), Signal.begin(), [](peakKeeper peak) { return peak.height; });
355
356 auto &Error = result_ws->mutableE(0);
357 std::transform(peaks.cbegin(), peaks.cend(), Error.begin(), [](peakKeeper peak) { return peak.sigma; });
358
359 result_ws->setPoints(0, peaks_positions);
360
361 setProperty("OutputWorkspace", std::move(result_ws));
362}
372void GetAllEi::printDebugModeInfo(const std::vector<double> &guess_opening, const std::pair<double, double> &TOF_range,
373 std::shared_ptr<Kernel::Unit> &destUnit) {
374
375 g_log.debug() << "*Found : " << guess_opening.size()
376 << " chopper prospective opening within time frame: " << TOF_range.first << " to: " << TOF_range.second
377 << '\n';
378 g_log.debug() << " Timings are:\n";
379 for (double time : guess_opening) {
380 g_log.debug() << boost::str(boost::format(" %8.2f; ") % time);
381 }
382 g_log.debug() << '\n';
383 g_log.debug() << " Corresponding to energies:\n";
384 for (double time : guess_opening) {
385 double ei = destUnit->singleFromTOF(time);
386 g_log.debug() << boost::str(boost::format(" %8.2f; ") % ei);
387 }
388 g_log.debug() << '\n';
389}
390
391// unnamed namespace for auxiliary file-based functions, converted from lambda
392// as not all Mantid compilers support lambda yet.
393
400
401 std::string filerLogName;
402 std::string filterBase = getProperty("FilterBaseLog");
403 if (boost::iequals(filterBase, "Defined in IDF")) {
404 filerLogName = m_chopper->getStringParameter("FilterBaseLog")[0];
405 m_FilterWithDerivative = m_chopper->getBoolParameter("filter_with_derivative")[0];
406 } else {
407 filerLogName = filterBase;
408 m_FilterWithDerivative = getProperty("FilterWithDerivative");
409 }
410 try {
411 m_pFilterLog = dynamic_cast<Kernel::TimeSeriesProperty<double> *>(inputWS->run().getProperty(filerLogName));
412 } catch (std::runtime_error &) {
413 g_log.warning() << " Can not retrieve (double) filtering log: " + filerLogName +
414 " from current workspace\n"
415 " Using total experiment range to "
416 "find logs averages for chopper parameters\n";
418 }
419}
435bool GetAllEi::peakGuess(const API::MatrixWorkspace_sptr &inputWS, size_t index, double Ei,
436 const std::vector<size_t> &monsRangeMin, const std::vector<size_t> &monsRangeMax,
437 double &peakPos, double &peakHeight, double &peakTwoSigma) {
438
439 // calculate sigma from half-width parameters
440 double maxSigma = Ei * m_min_Eresolution / (2. * std::sqrt(2. * M_LN2));
441
442 double sMin(std::numeric_limits<double>::max());
443 double sMax(-sMin);
444 double xOfMax(0), dXmax(0);
445 double Intensity(0);
446
447 const auto &X = inputWS->x(index);
448 const auto &S = inputWS->y(index);
449 size_t ind_min = monsRangeMin[index];
450 size_t ind_max = monsRangeMax[index];
451 // interval too small -- not interested in a peak there
452 if (std::fabs(double(ind_max - ind_min)) < 5)
453 return false;
454
455 // double xMin = X[ind_min];
456 // double xMax = X[ind_max];
457 // size_t ind_Ofmax(ind_min);
458
459 for (size_t i = ind_min; i < ind_max; i++) {
460 double dX = X[i + 1] - X[i];
461 double signal = S[i] / dX;
462 if (signal < sMin)
463 sMin = signal;
464 if (signal > sMax) {
465 sMax = signal;
466 dXmax = dX;
467 xOfMax = X[i];
468 // ind_Ofmax=i;
469 }
470 Intensity += S[i];
471 }
472 // monitor peak should not have just two counts in it.
473 if (sMax * dXmax <= 2)
474 return false;
475 //
476 // size_t SearchAreaSize = ind_max - ind_min;
477
478 double SmoothRange = 2 * maxSigma;
479
480 std::vector<double> SAvrg, binsAvrg;
481 Kernel::VectorHelper::smoothInRange(S.rawData(), SAvrg, SmoothRange, &X.rawData(), ind_min, ind_max, &binsAvrg);
482
483 double realPeakPos(xOfMax); // this position is less shifted
484 // due to the skew in averaging formula
485 bool foundRealPeakPos(false);
486 std::vector<double> der1Avrg, der2Avrg, peaks, hillsPos, SAvrg1, binsAvrg1;
487 size_t nPeaks = this->calcDerivativeAndCountZeros(binsAvrg, SAvrg, der1Avrg, peaks);
488 size_t nHills = this->calcDerivativeAndCountZeros(binsAvrg, der1Avrg, der2Avrg, hillsPos);
489 if (nPeaks == 1) {
490 foundRealPeakPos = true;
491 realPeakPos = peaks[0];
492 }
493
494 size_t ic(0), stay_still_count(0);
495 bool iterations_fail(false);
496 while ((nPeaks > 1 || nHills > 2) && (!iterations_fail)) {
497 Kernel::VectorHelper::smoothInRange(SAvrg, SAvrg1, SmoothRange, &binsAvrg, 0, ind_max - ind_min, &binsAvrg1);
498 const auto nPrevHills = nHills;
499
500 nPeaks = this->calcDerivativeAndCountZeros(binsAvrg1, SAvrg1, der1Avrg, peaks);
501 nHills = this->calcDerivativeAndCountZeros(binsAvrg1, der1Avrg, der2Avrg, hillsPos);
502 SAvrg.swap(SAvrg1);
503 binsAvrg.swap(binsAvrg1);
504 if (nPeaks == 1 && !foundRealPeakPos) { // fix first peak position found
505 foundRealPeakPos = true; // as averaging shift peaks on
506 realPeakPos = peaks[0]; // irregular grid.
507 }
508 ic++;
509 if (nPrevHills <= nHills) {
510 stay_still_count++;
511 } else {
512 stay_still_count = 0;
513 }
514 if (ic > 50 || stay_still_count > 3)
515 iterations_fail = true;
516 }
517 if (iterations_fail) {
518 g_log.information() << "*No peak search convergence after " + std::to_string(ic) +
519 " smoothing iterations at still_count: " + std::to_string(stay_still_count) +
520 " Wrong energy or noisy peak at Ei=" + boost::lexical_cast<std::string>(Ei)
521 << '\n';
522 }
523 g_log.debug() << "*Performed: " + std::to_string(ic) + " averages for spectra " + std::to_string(index) +
524 " at energy: " + boost::lexical_cast<std::string>(Ei) +
525 "\n and found: " + std::to_string(nPeaks) + "peaks and " + std::to_string(nHills) + " hills\n";
526 if (nPeaks != 1) {
527 g_log.debug() << "*Peak rejected as n-peaks !=1 after averaging\n";
528 return false;
529 }
530
531 peakPos = peaks[0];
532 if (nHills > 2) {
533 size_t peakIndex = Kernel::VectorHelper::getBinIndex(hillsPos, peaks[0]);
534 peakTwoSigma = hillsPos[peakIndex + 1] - hillsPos[peakIndex];
535 } else {
536 if (hillsPos.size() == 2) {
537 peakTwoSigma = hillsPos[1] - hillsPos[0];
538 } else {
539 g_log.debug() << "*Peak rejected as averaging gives: " + std::to_string(nPeaks) + " peaks and " +
540 std::to_string(nHills) + " heals\n";
541
542 return false;
543 }
544 }
545 // assuming that averaging conserves intensity and removing linear
546 // background:
547 peakHeight = Intensity / (0.5 * std::sqrt(2. * M_PI) * peakTwoSigma) - sMin;
548 peakPos = realPeakPos;
549
550 return true;
551}
552
566 const std::vector<size_t> &monsRangeMin, const std::vector<size_t> &monsRangeMax,
567 double &position, double &height, double &twoSigma) {
568 // calculate sigma from half-width parameters
569 double maxSigma = Ei * m_min_Eresolution / (2. * std::sqrt(2. * M_LN2));
570 double minSigma = Ei * m_max_Eresolution / (2. * std::sqrt(2. * M_LN2));
571 //--------------------------------------------------------------------
572 double peak1Pos, peak1TwoSigma, peak1Height;
573 if (!peakGuess(inputWS, 0, Ei, monsRangeMin, monsRangeMax, peak1Pos, peak1Height, peak1TwoSigma))
574 return false;
575 if (0.25 * peak1TwoSigma > maxSigma || peak1TwoSigma < minSigma) {
576 g_log.debug() << "*Rejecting due to width: Peak at mon1 Ei=" + boost::lexical_cast<std::string>(peak1Pos) +
577 " with Height:" + boost::lexical_cast<std::string>(peak1Height) +
578 " and 2*Sigma: " + boost::lexical_cast<std::string>(peak1TwoSigma)
579 << '\n';
580 return false;
581 }
582
583 if (!this->getProperty("IgnoreSecondMonitor")) {
584 double peak2Pos, peak2TwoSigma, peak2Height;
585 if (!peakGuess(inputWS, 1, Ei, monsRangeMin, monsRangeMax, peak2Pos, peak2Height, peak2TwoSigma))
586 return false;
587 // Let's not check anything except peak position for monitor2, as
588 // its intensity may be very low for some instruments.
589 // if(0.25*peak2TwoSigma>maxSigma||peak2TwoSigma<minSigma)return false;
590
591 // peak in first and second monitors are too far from each other. May be the
592 // instrument
593 // is ill-calibrated but GetEi will probably not find this peak anyway.
594 if (std::fabs(peak1Pos - peak2Pos) > 0.25 * (peak1TwoSigma + peak2TwoSigma)) {
595 g_log.debug() << "*Rejecting due to displacement between Peak at mon1: Ei=" +
596 boost::lexical_cast<std::string>(peak1Pos) +
597 " with Height:" + boost::lexical_cast<std::string>(peak1Height) +
598 " and 2*Sigma: " + boost::lexical_cast<std::string>(peak1TwoSigma) +
599 "\n and Peak at mon2: Ei= " + boost::lexical_cast<std::string>(peak2Pos) +
600 "and height: " + boost::lexical_cast<std::string>(peak1Height)
601 << '\n';
602
603 return false;
604 }
605 }
606
607 position = peak1Pos;
608 twoSigma = peak1TwoSigma;
609 height = peak1Height;
610
611 return true;
612}
613namespace { // for lambda extracted from calcDerivativeAndCountZeros
619bool signChanged(double val, int &prevSign) {
620 int curSign = (val >= 0 ? 1 : -1);
621 bool changed = curSign != prevSign;
622 prevSign = curSign;
623 return changed;
624}
625} // namespace
626
639size_t GetAllEi::calcDerivativeAndCountZeros(const std::vector<double> &bins, const std::vector<double> &signal,
640 std::vector<double> &deriv, std::vector<double> &zeros) {
641 size_t nPoints = signal.size();
642 deriv.resize(nPoints);
643 zeros.resize(0);
644
645 std::list<double> funVal;
646 double bin0 = bins[1] - bins[0];
647 double f0 = signal[0] / bin0;
648 double bin1 = bins[2] - bins[1];
649 double f1 = signal[1] / bin1;
650
651 size_t nZeros(0);
652
653 funVal.push_front(f1);
654 deriv[0] = 2 * (f1 - f0) / (bin0 + bin1);
655 int prevSign = (deriv[0] >= 0 ? 1 : -1);
656
657 for (size_t i = 1; i < nPoints - 1; i++) {
658 bin1 = (bins[i + 2] - bins[i + 1]);
659 f1 = signal[i + 1] / bin1;
660 deriv[i] = (f1 - f0) / (bins[i + 2] - bins[i]);
661 f0 = funVal.back();
662 funVal.pop_back();
663 funVal.push_front(f1);
664
665 if (signChanged(deriv[i], prevSign)) {
666 nZeros++;
667 zeros.emplace_back(0.5 * (bins[i - 1] + bins[i]));
668 }
669 }
670 deriv[nPoints - 1] = 2 * (f1 - f0) / (bin1 + bin0);
671 if (signChanged(deriv[nPoints - 1], prevSign)) {
672 zeros.emplace_back(bins[nPoints - 1]);
673 nZeros++;
674 }
675
676 return nZeros;
677}
678namespace { // for lambda extracted from findBinRanges
679// get bin range corresponding to the energy range
680void getBinRange(const HistogramData::HistogramX &eBins, double eMin, double eMax, size_t &index_min,
681 size_t &index_max) {
682
683 const auto &bins = eBins.rawData();
684 const size_t nBins = bins.size();
685 if (eMin <= bins[0]) {
686 index_min = 0;
687 } else {
688 index_min = Kernel::VectorHelper::getBinIndex(bins, eMin);
689 }
690
691 if (eMax >= eBins[nBins - 1]) {
692 index_max = nBins - 1;
693 } else {
694 index_max = Kernel::VectorHelper::getBinIndex(bins, eMax) + 1;
695 if (index_max >= nBins)
696 index_max = nBins - 1; // last bin range anyway. Should not happen
697 }
698}
699
700// refine bin range. May need better procedure for this.
701bool refineEGuess(const HistogramX &eBins, const HistogramY &signal, double &eGuess, size_t index_min,
702 size_t index_max) {
703
704 size_t ind_Emax = index_min;
705 double SMax(0);
706 for (size_t i = index_min; i < index_max; i++) {
707 double dX = eBins[i + 1] - eBins[i];
708 double sig = signal[i] / dX;
709 if (sig > SMax) {
710 SMax = sig;
711 ind_Emax = i;
712 }
713 }
714 if (ind_Emax == index_min || ind_Emax == index_max) {
715 return false;
716 }
717 eGuess = 0.5 * (eBins[ind_Emax] + eBins[ind_Emax + 1]);
718 return true;
719}
720
721struct peakKeeper2 {
722 double left_rng;
723 double right_rng;
724 peakKeeper2() : left_rng(.0), right_rng(.0){};
725 peakKeeper2(double left, double right) : left_rng(left), right_rng(right) {}
726};
727} // namespace
728
741void GetAllEi::findBinRanges(const HistogramX &eBins, const HistogramY &signal, const std::vector<double> &guess_energy,
742 double eResolution, std::vector<size_t> &irangeMin, std::vector<size_t> &irangeMax,
743 std::vector<bool> &guessValid) {
744
745 // size_t nBins = eBins.size();
746 guessValid.resize(guess_energy.size());
747
748 // Do the job
749 size_t ind_min, ind_max;
750 irangeMin.resize(0);
751 irangeMax.resize(0);
752
753 // identify guess bin ranges
754 std::vector<peakKeeper2> guess_peak(guess_energy.size());
755 for (size_t nGuess = 0; nGuess < guess_energy.size(); nGuess++) {
756 double eGuess = guess_energy[nGuess];
757 getBinRange(eBins, eGuess * (1 - 4 * eResolution), eGuess * (1 + 4 * eResolution), ind_min, ind_max);
758 guess_peak[nGuess] = peakKeeper2(eBins[ind_min], eBins[ind_max]);
759 }
760 // verify that the ranges not intercept and refine interceptions
761 for (size_t i = 1; i < guess_energy.size(); i++) {
762 if (guess_peak[i - 1].right_rng > guess_peak[i].left_rng) {
763 double mid_pnt = 0.5 * (guess_peak[i - 1].right_rng + guess_peak[i].left_rng);
764 guess_peak[i - 1].right_rng = mid_pnt;
765 guess_peak[i].left_rng = mid_pnt;
766 }
767 }
768 // identify final bin ranges
769 for (size_t nGuess = 0; nGuess < guess_energy.size(); nGuess++) {
770
771 double eGuess = guess_energy[nGuess];
772 getBinRange(eBins, guess_peak[nGuess].left_rng, guess_peak[nGuess].right_rng, ind_min, ind_max);
773
774 if (refineEGuess(eBins, signal, eGuess, ind_min, ind_max)) {
775 getBinRange(eBins, std::max(guess_peak[nGuess].left_rng, eGuess * (1 - 3 * eResolution)),
776 std::max(guess_peak[nGuess].right_rng, eGuess * (1 + 3 * eResolution)), ind_min, ind_max);
777 irangeMin.emplace_back(ind_min);
778 irangeMax.emplace_back(ind_max);
779 guessValid[nGuess] = true;
780 } else {
781 guessValid[nGuess] = false;
782 g_log.debug() << "*Incorrect guess energy: " << boost::lexical_cast<std::string>(eGuess)
783 << " no energy peak found in 4*Sigma range\n";
784 }
785 }
786 // if array decreasing rather then increasing, indexes behave differently.
787 // Will it still work?
788 if (!irangeMax.empty()) {
789 if (irangeMax[0] < irangeMin[0]) {
790 irangeMax.swap(irangeMin);
791 }
792 }
793}
794
803
804 // at this stage all properties are validated so its safe to access them
805 // without
806 // additional checks.
807 specnum_t specNum1 = getProperty("Monitor1SpecID");
808 wsIndex0 = inputWS->getIndexFromSpectrumNumber(specNum1);
809 specnum_t specNum2 = getProperty("Monitor2SpecID");
810 size_t wsIndex1 = inputWS->getIndexFromSpectrumNumber(specNum2);
811
812 // assuming equally binned ws.
813 std::shared_ptr<API::HistoWorkspace> working_ws = DataObjects::create<API::HistoWorkspace>(
814 *inputWS, Indexing::extract(inputWS->indexInfo(), std::vector<size_t>{wsIndex0, wsIndex1}),
815 inputWS->histogram(wsIndex0));
816
817 // signal 1
818 working_ws->setSharedY(0, inputWS->sharedY(wsIndex0));
819 // signal 2
820 working_ws->setSharedY(1, inputWS->sharedY(wsIndex1));
821 // error 1
822 working_ws->setSharedE(0, inputWS->sharedE(wsIndex0));
823 // error 2
824 working_ws->setSharedE(1, inputWS->sharedE(wsIndex1));
825
826 if (inputWS->getAxis(0)->unit()->caption() != "Energy") {
827 auto conv = createChildAlgorithm("ConvertUnits");
828 conv->initialize();
829 conv->setProperty("InputWorkspace", working_ws);
830 conv->setProperty("OutputWorkspace", working_ws);
831 conv->setPropertyValue("Target", "Energy");
832 conv->setPropertyValue("EMode", "Elastic");
833 // conv->setProperty("AlignBins",true); --> throws due to bug in
834 // ConvertUnits
835 conv->execute();
836 }
837
838 return working_ws;
839}
850void GetAllEi::findGuessOpeningTimes(const std::pair<double, double> &TOF_range, double ChopDelay, double Period,
851 std::vector<double> &guess_opening_times) {
852
853 if (ChopDelay >= TOF_range.second) {
854 std::string chop = boost::str(boost::format("%.2g") % ChopDelay);
855 std::string t_min = boost::str(boost::format("%.2g") % TOF_range.first);
856 std::string t_max = boost::str(boost::format("%.2g") % TOF_range.second);
857 throw std::runtime_error("Logical error: Chopper opening time: " + chop + " is outside of time interval: " + t_min +
858 ":" + t_max + " of the signal, measured on monitors.");
859 }
860
861 // number of times chopper with specified rotation period opens.
862 size_t n_openings = static_cast<size_t>((TOF_range.second - ChopDelay) / Period) + 1;
863 // number of periods falling outside of the time period, measuring on monitor.
864 size_t n_start(0);
865 if (ChopDelay < TOF_range.first) {
866 n_start = static_cast<size_t>((TOF_range.first - ChopDelay) / Period) + 1;
867 n_openings -= n_start;
868 }
869
870 guess_opening_times.resize(n_openings);
871 for (size_t i = n_start; i < n_openings + n_start; i++) {
872 guess_opening_times[i - n_start] = ChopDelay + static_cast<double>(i) * Period;
873 }
874}
883 const std::string &propertyName) {
884
885 std::string LogName = this->getProperty(propertyName);
886 if (boost::iequals(LogName, "Defined in IDF")) {
887 auto AllNames = m_chopper->getStringParameter(propertyName);
888 if (AllNames.size() != 1)
889 return nullptr;
890 LogName = AllNames[0];
891 }
892 auto pIProperty = (inputWS->run().getProperty(LogName));
893
894 return pIProperty;
895}
896
905double GetAllEi::getAvrgLogValue(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName,
906 std::vector<Kernel::SplittingInterval> &splitter) {
907
908 auto pIProperty = getPLogForProperty(inputWS, propertyName);
909
910 // this will always provide a defined pointer as this has been verified in
911 // validator.
912 auto pTimeSeries = dynamic_cast<Kernel::TimeSeriesProperty<double> *>(pIProperty);
913
914 if (!pTimeSeries) {
915 throw std::runtime_error("Could not retrieve a time series property for the property name " + propertyName);
916 }
917
918 if (splitter.empty()) {
919 auto TimeStart = inputWS->run().startTime();
920 auto TimeEnd = inputWS->run().endTime();
921 pTimeSeries->filterByTime(TimeStart, TimeEnd);
922 } else {
923 pTimeSeries->filterByTimes(splitter);
924 }
925 if (pTimeSeries->size() == 0) {
926 throw std::runtime_error("Can not find average value for log defined by property" + propertyName +
927 " As no valid log values are found.");
928 }
929
930 return pTimeSeries->getStatistics().mean;
931}
932namespace { // former lambda function for findChopSpeedAndDelay
933
948bool SelectInterval(const Types::Core::DateAndTime &t_beg, const Types::Core::DateAndTime &t_end, double value,
949 bool &inSelection, Types::Core::DateAndTime &startTime, Types::Core::DateAndTime &endTime) {
950
951 if (value > 0) {
952 if (!inSelection) {
953 startTime = t_beg;
954 }
955 inSelection = true;
956 } else {
957 if (inSelection) {
958 inSelection = false;
959 if (endTime > startTime)
960 return true;
961 }
962 }
963 endTime = t_end;
964 return false;
965}
966} // namespace
972void GetAllEi::findChopSpeedAndDelay(const API::MatrixWorkspace_sptr &inputWS, double &chop_speed, double &chop_delay) {
973
974 // TODO: Make it dependent on inputWS time range
975
976 std::vector<Kernel::SplittingInterval> splitter;
977 if (m_pFilterLog) {
978 std::unique_ptr<Kernel::TimeSeriesProperty<double>> pDerivative;
979
980 // Define selecting function
981 bool inSelection(false);
982 // time interval to select (start-end)
983 Types::Core::DateAndTime startTime, endTime;
984 //
985 // Analyze filtering log
986 auto dateAndTimes = m_pFilterLog->valueAsCorrectMap();
987 auto it = dateAndTimes.begin();
988 auto next = it;
989 next++;
990 std::map<Types::Core::DateAndTime, double> derivMap;
991 auto itder = it;
993 pDerivative = m_pFilterLog->getDerivative();
994 derivMap = pDerivative->valueAsCorrectMap();
995 itder = derivMap.begin();
996 }
997
998 // initialize selection log
999 if (dateAndTimes.size() <= 1) {
1000 SelectInterval(it->first, it->first, itder->second, inSelection, startTime, endTime);
1001 if (inSelection) {
1002 startTime = inputWS->run().startTime();
1003 endTime = inputWS->run().endTime();
1004 Kernel::SplittingInterval interval(startTime, endTime, 0);
1005 splitter.emplace_back(interval);
1006 } else {
1007 throw std::runtime_error("filtered all data points. Nothing to do");
1008 }
1009 } else {
1010 SelectInterval(it->first, next->first, itder->second, inSelection, startTime, endTime);
1011 }
1012
1013 // if its filtered using log, both iterator walk through the same values
1014 // if use derivative, derivative's values are used for filtering
1015 // and derivative assumed in a center of an interval
1016 for (; next != dateAndTimes.end(); ++next, ++itder) {
1017 if (SelectInterval(it->first, next->first, itder->second, inSelection, startTime, endTime)) {
1018 Kernel::SplittingInterval interval(startTime, endTime, 0);
1019 splitter.emplace_back(interval);
1020 }
1021 it = next;
1022 }
1023 // final interval
1024 if (inSelection && (endTime > startTime)) {
1025 Kernel::SplittingInterval interval(startTime, endTime, 0);
1026 splitter.emplace_back(interval);
1027 }
1028 } // End of USE filter log.
1029
1030 chop_speed = this->getAvrgLogValue(inputWS, "ChopperSpeedLog", splitter);
1031 chop_speed = std::fabs(chop_speed);
1032 if (chop_speed < 1.e-7) {
1033 throw std::runtime_error("Chopper speed can not be zero ");
1034 }
1035 chop_delay = std::fabs(this->getAvrgLogValue(inputWS, "ChopperDelayLog", splitter));
1036
1037 // process chopper delay in the units of degree (phase)
1038 auto pProperty = getPLogForProperty(inputWS, "ChopperDelayLog");
1039 if (!pProperty)
1040 throw std::runtime_error("ChopperDelayLog has been removed from workspace "
1041 "during the algorithm execution");
1042 std::string units = pProperty->units();
1043 // its chopper phase provided
1044 if (units == "deg" || units.c_str()[0] == -80) { //<- userd in ISIS ASCII representation of o(deg)
1045 chop_delay *= 1.e+6 / (360. * chop_speed); // convert in uSec
1046 }
1047 chop_delay += m_phase / chop_speed;
1048}
1049
1050namespace { // namespace for lambda functions, used in validators
1051
1052/* former Lambda to validate if appropriate log is present in workspace
1053and if it's present, it is a time-series property
1054* @param prop_name -- the name of the log to check
1055* @param err_presence -- core error message to return if no log found
1056* @param err_type -- core error message to return if
1057* log is of incorrect type
1058* @param fail -- fail or warn if appropriate log is not available.
1059*
1060* @param result -- map to add the result of check for errors
1061* if no error found the map is not modified and remains
1062* empty.
1063
1064
1065* @return -- false if all checks are fine, or true if check is
1066* failed
1067*/
1068bool check_time_series_property(const GetAllEi *algo, const API::MatrixWorkspace_sptr &inputWS,
1069 const std::shared_ptr<const Geometry::IComponent> &chopper,
1070 const std::string &prop_name, const std::string &err_presence,
1071 const std::string &err_type, bool fail, std::map<std::string, std::string> &result) {
1072
1073 std::string LogName = algo->getProperty(prop_name);
1074 if (boost::iequals(LogName, "Defined in IDF")) {
1075 try {
1076 auto theLogs = chopper->getStringParameter(prop_name);
1077 if (theLogs.empty()) {
1078 if (fail)
1079 result[prop_name] = "Can not retrieve parameter " + prop_name + " from the instrument definition file.";
1080 return true;
1081 }
1082 LogName = theLogs[0];
1083 } catch (...) {
1084 result[prop_name] = "Can not retrieve parameter " + prop_name + " from the instrument definition file.";
1085 return true;
1086 }
1087 }
1088 try {
1089 Kernel::Property *pProp = inputWS->run().getProperty(LogName);
1090 auto pTSProp = dynamic_cast<Kernel::TimeSeriesProperty<double> *>(pProp);
1091 if (!pTSProp) {
1092 if (fail)
1093 result[prop_name] = "Workspace contains " + err_type + LogName + " But its type is not a timeSeries property";
1094 return true;
1095 }
1096 } catch (std::runtime_error &) {
1097 if (fail)
1098 result[prop_name] = "Workspace has to contain " + err_presence + LogName;
1099 return true;
1100 }
1101 return false;
1102}
1103} // namespace
1104
1109std::map<std::string, std::string> GetAllEi::validateInputs() {
1110
1111 // Do Validation
1112 std::map<std::string, std::string> result;
1113
1114 API::MatrixWorkspace_sptr inputWS = getProperty("Workspace");
1115 if (!inputWS) {
1116 result["Workspace"] = "Input workspace can not be identified";
1117 return result;
1118 }
1119 if (!inputWS->isHistogramData()) {
1120 result["Workspace"] = "Only histogram workspaces are currently supported. "
1121 "Rebin input workspace first.";
1122 }
1123
1124 specnum_t specNum1 = getProperty("Monitor1SpecID");
1125 try {
1126 inputWS->getIndexFromSpectrumNumber(specNum1);
1127 } catch (std::runtime_error &) {
1128 result["Monitor1SpecID"] = "Input workspace does not contain spectra with ID: " + std::to_string(specNum1);
1129 }
1130 specnum_t specNum2 = getProperty("Monitor2SpecID");
1131 try {
1132 inputWS->getIndexFromSpectrumNumber(specNum2);
1133 } catch (std::runtime_error &) {
1134 result["Monitor2SpecID"] = "Input workspace does not contain spectra with ID: " + std::to_string(specNum2);
1135 }
1136 // check chopper and initiate it if present (for debugging)
1137 m_chopper = inputWS->getInstrument()->getComponentByName("chopper-position");
1138 if (!m_chopper) {
1139 result["Workspace_chopper"] = " For this algorithm to work workspace has"
1140 " to contain well defined 'chopper-position' component";
1141 return result;
1142 }
1143
1144 check_time_series_property(this, inputWS, m_chopper, "ChopperSpeedLog",
1145 "chopper speed log with name: ", "chopper speed log ", true, result);
1146 check_time_series_property(this, inputWS, m_chopper, "ChopperDelayLog",
1147 "property related to chopper delay log with name: ", "chopper delay log ", true, result);
1148 bool failed = check_time_series_property(this, inputWS, m_chopper, "FilterBaseLog",
1149 "filter base log named: ", "filter base log: ", false, result);
1150 if (failed) {
1151 g_log.warning() << " Can not find a log to identify good DAE operations.\n"
1152 " Assuming that good operations start from experiment time=0";
1153 } else {
1154 this->setFilterLog(inputWS);
1155 }
1156 return result;
1157}
1158
1159} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
double value
The value of the point.
Definition: FitMW.cpp:51
double energy
Definition: GetAllEi.cpp:157
double sigma
Definition: GetAllEi.cpp:156
double height
Definition: GetAllEi.cpp:155
double left_rng
Definition: GetAllEi.cpp:722
double position
Definition: GetAllEi.cpp:154
double right_rng
Definition: GetAllEi.cpp:723
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
double left
Definition: LineProfile.cpp:80
double right
Definition: LineProfile.cpp:81
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Definition: Algorithm.cpp:1913
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
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.
Definition: Algorithm.cpp:842
Kernel::Logger & g_log
Definition: Algorithm.h:451
A property class for workspaces.
Estimate all incident energies, used by chopper instrument.
Definition: GetAllEi.h:29
double getAvrgLogValue(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName, std::vector< Kernel::SplittingInterval > &splitter)
Return average time series log value for the appropriately filtered log.
Definition: GetAllEi.cpp:905
Kernel::TimeSeriesProperty< double > * m_pFilterLog
Definition: GetAllEi.h:103
void findGuessOpeningTimes(const std::pair< double, double > &TOF_range, double ChopDelay, double Period, std::vector< double > &guess_opening_times)
function calculates list of provisional chopper opening times.
Definition: GetAllEi.cpp:850
bool findMonitorPeak(const API::MatrixWorkspace_sptr &inputWS, double Ei, const std::vector< size_t > &monsRangeMin, const std::vector< size_t > &monsRangeMax, double &position, double &height, double &twoSigma)
Get energy of monitor peak if one is present.
Definition: GetAllEi.cpp:565
Kernel::Property * getPLogForProperty(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName)
Finds pointer to log value for the property with the name provided.
Definition: GetAllEi.cpp:882
std::shared_ptr< const Geometry::IComponent > m_chopper
Definition: GetAllEi.h:101
API::MatrixWorkspace_sptr buildWorkspaceToFit(const API::MatrixWorkspace_sptr &inputWS, size_t &wsIndex0)
Build 2-spectra workspace in units of energy, used as source to identify actual monitors spectra.
Definition: GetAllEi.cpp:802
void exec() override
Executes the algorithm – found all existing monitor peaks.
Definition: GetAllEi.cpp:169
void findChopSpeedAndDelay(const API::MatrixWorkspace_sptr &inputWS, double &chop_speed, double &chop_delay)
process logs and retrieve chopper speed and chopper delay
Definition: GetAllEi.cpp:972
std::map< std::string, std::string > validateInputs() override
Cross-check properties with each other.
Definition: GetAllEi.cpp:1109
bool peakGuess(const API::MatrixWorkspace_sptr &inputWS, size_t index, double Ei, const std::vector< size_t > &monsRangeMin, const std::vector< size_t > &monsRangeMax, double &peakPos, double &peakHeight, double &peakTwoSigma)
Former lambda to identify guess values for a peak at given index and set up these parameters as input...
Definition: GetAllEi.cpp:435
void findBinRanges(const HistogramData::HistogramX &eBins, const HistogramData::HistogramY &signal, const std::vector< double > &guess_energy, double eResolution, std::vector< size_t > &irangeMin, std::vector< size_t > &irangeMax, std::vector< bool > &guessValid)
Find indexes of each expected peak intervals.
Definition: GetAllEi.cpp:741
size_t calcDerivativeAndCountZeros(const std::vector< double > &bins, const std::vector< double > &signal, std::vector< double > &deriv, std::vector< double > &zeros)
Bare-bone function to calculate numerical derivative, and estimate number of zeros this derivative ha...
Definition: GetAllEi.cpp:639
bool m_FilterWithDerivative
if true, take derivate of the filter log to identify interval when instrument is running.
Definition: GetAllEi.h:89
void printDebugModeInfo(const std::vector< double > &guess_opening, const std::pair< double, double > &TOF_range, std::shared_ptr< Kernel::Unit > &destUnit)
Auxiliary method to print guess chopper energies in debug mode.
Definition: GetAllEi.cpp:372
void init() override
Initialization method.
Definition: GetAllEi.cpp:46
void setFilterLog(const API::MatrixWorkspace_sptr &inputWS)
The internal procedure to set filter log from properties, defining it.
Definition: GetAllEi.cpp:399
double m_min_Eresolution
maximal relative peak width to consider acceptable.
Definition: GetAllEi.h:93
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void debug(const std::string &msg)
Logs at debug level.
Definition: Logger.cpp:114
void warning(const std::string &msg)
Logs at warning level.
Definition: Logger.cpp:86
void information(const std::string &msg)
Logs at information level.
Definition: Logger.cpp:105
Base class for properties.
Definition: Property.h:94
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Class holding a start/end time and a destination for splitting event lists and logs.
Definition: TimeSplitter.h:23
A specialised Property class for holding a series of time-value pairs.
std::map< Types::Core::DateAndTime, TYPE > valueAsCorrectMap() const
Return the time series as a correct C++ map<DateAndTime, TYPE>.
std::unique_ptr< TimeSeriesProperty< double > > getDerivative() const
Return time series property, containing time derivative of current property.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
MANTID_KERNEL_DLL void smoothInRange(const std::vector< double > &input, std::vector< double > &output, double avrgInterval, std::vector< double > const *const binBndrs=nullptr, size_t startIndex=0, size_t endIndex=0, std::vector< double > *const outBins=nullptr)
Basic running average of input vector within specified range, considering variable bin-boundaries if ...
MANTID_KERNEL_DLL int getBinIndex(const std::vector< double > &bins, const double value)
Return the index into a vector of bin boundaries for a particular X value.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
Definition: EmptyValues.h:25
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16
std::string to_string(const wide_integer< Bits, Signed > &n)
constexpr bool operator<(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)
@ Input
An input workspace.
Definition: Property.h:53
@ Output
An output workspace.
Definition: Property.h:54