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(),
353 [](const peakKeeper &peak) { return peak.position; });
354 auto &Signal = result_ws->mutableY(0);
355 std::transform(peaks.cbegin(), peaks.cend(), Signal.begin(), [](const peakKeeper &peak) { return peak.height; });
356
357 auto &Error = result_ws->mutableE(0);
358 std::transform(peaks.cbegin(), peaks.cend(), Error.begin(), [](const peakKeeper &peak) { return peak.sigma; });
359
360 result_ws->setPoints(0, peaks_positions);
361
362 setProperty("OutputWorkspace", std::move(result_ws));
363}
373void GetAllEi::printDebugModeInfo(const std::vector<double> &guess_opening, const std::pair<double, double> &TOF_range,
374 std::shared_ptr<Kernel::Unit> &destUnit) {
375
376 g_log.debug() << "*Found : " << guess_opening.size()
377 << " chopper prospective opening within time frame: " << TOF_range.first << " to: " << TOF_range.second
378 << '\n';
379 g_log.debug() << " Timings are:\n";
380 for (double time : guess_opening) {
381 g_log.debug() << boost::str(boost::format(" %8.2f; ") % time);
382 }
383 g_log.debug() << '\n';
384 g_log.debug() << " Corresponding to energies:\n";
385 for (double time : guess_opening) {
386 double ei = destUnit->singleFromTOF(time);
387 g_log.debug() << boost::str(boost::format(" %8.2f; ") % ei);
388 }
389 g_log.debug() << '\n';
390}
391
392// unnamed namespace for auxiliary file-based functions, converted from lambda
393// as not all Mantid compilers support lambda yet.
394
401
402 std::string filerLogName;
403 std::string filterBase = getProperty("FilterBaseLog");
404 if (boost::iequals(filterBase, "Defined in IDF")) {
405 filerLogName = m_chopper->getStringParameter("FilterBaseLog")[0];
406 m_FilterWithDerivative = m_chopper->getBoolParameter("filter_with_derivative")[0];
407 } else {
408 filerLogName = filterBase;
409 m_FilterWithDerivative = getProperty("FilterWithDerivative");
410 }
411 try {
412 m_pFilterLog = dynamic_cast<Kernel::TimeSeriesProperty<double> *>(inputWS->run().getProperty(filerLogName));
413 } catch (std::runtime_error &) {
414 g_log.warning() << " Can not retrieve (double) filtering log: " + filerLogName +
415 " from current workspace\n"
416 " Using total experiment range to "
417 "find logs averages for chopper parameters\n";
419 }
420}
436bool GetAllEi::peakGuess(const API::MatrixWorkspace_sptr &inputWS, size_t index, double Ei,
437 const std::vector<size_t> &monsRangeMin, const std::vector<size_t> &monsRangeMax,
438 double &peakPos, double &peakHeight, double &peakTwoSigma) {
439
440 // calculate sigma from half-width parameters
441 double maxSigma = Ei * m_min_Eresolution / (2. * std::sqrt(2. * M_LN2));
442
443 double sMin(std::numeric_limits<double>::max());
444 double sMax(-sMin);
445 double xOfMax(0), dXmax(0);
446 double Intensity(0);
447
448 const auto &X = inputWS->x(index);
449 const auto &S = inputWS->y(index);
450 size_t ind_min = monsRangeMin[index];
451 size_t ind_max = monsRangeMax[index];
452 // interval too small -- not interested in a peak there
453 if (std::fabs(double(ind_max - ind_min)) < 5)
454 return false;
455
456 // double xMin = X[ind_min];
457 // double xMax = X[ind_max];
458 // size_t ind_Ofmax(ind_min);
459
460 for (size_t i = ind_min; i < ind_max; i++) {
461 double dX = X[i + 1] - X[i];
462 double signal = S[i] / dX;
463 if (signal < sMin)
464 sMin = signal;
465 if (signal > sMax) {
466 sMax = signal;
467 dXmax = dX;
468 xOfMax = X[i];
469 // ind_Ofmax=i;
470 }
471 Intensity += S[i];
472 }
473 // monitor peak should not have just two counts in it.
474 if (sMax * dXmax <= 2)
475 return false;
476 //
477 // size_t SearchAreaSize = ind_max - ind_min;
478
479 double SmoothRange = 2 * maxSigma;
480
481 std::vector<double> SAvrg, binsAvrg;
482 Kernel::VectorHelper::smoothInRange(S.rawData(), SAvrg, SmoothRange, &X.rawData(), ind_min, ind_max, &binsAvrg);
483
484 double realPeakPos(xOfMax); // this position is less shifted
485 // due to the skew in averaging formula
486 bool foundRealPeakPos(false);
487 std::vector<double> der1Avrg, der2Avrg, peaks, hillsPos, SAvrg1, binsAvrg1;
488 size_t nPeaks = this->calcDerivativeAndCountZeros(binsAvrg, SAvrg, der1Avrg, peaks);
489 size_t nHills = this->calcDerivativeAndCountZeros(binsAvrg, der1Avrg, der2Avrg, hillsPos);
490 if (nPeaks == 1) {
491 foundRealPeakPos = true;
492 realPeakPos = peaks[0];
493 }
494
495 size_t ic(0), stay_still_count(0);
496 bool iterations_fail(false);
497 while ((nPeaks > 1 || nHills > 2) && (!iterations_fail)) {
498 Kernel::VectorHelper::smoothInRange(SAvrg, SAvrg1, SmoothRange, &binsAvrg, 0, ind_max - ind_min, &binsAvrg1);
499 const auto nPrevHills = nHills;
500
501 nPeaks = this->calcDerivativeAndCountZeros(binsAvrg1, SAvrg1, der1Avrg, peaks);
502 nHills = this->calcDerivativeAndCountZeros(binsAvrg1, der1Avrg, der2Avrg, hillsPos);
503 SAvrg.swap(SAvrg1);
504 binsAvrg.swap(binsAvrg1);
505 if (nPeaks == 1 && !foundRealPeakPos) { // fix first peak position found
506 foundRealPeakPos = true; // as averaging shift peaks on
507 realPeakPos = peaks[0]; // irregular grid.
508 }
509 ic++;
510 if (nPrevHills <= nHills) {
511 stay_still_count++;
512 } else {
513 stay_still_count = 0;
514 }
515 if (ic > 50 || stay_still_count > 3)
516 iterations_fail = true;
517 }
518 if (iterations_fail) {
519 g_log.information() << "*No peak search convergence after " + std::to_string(ic) +
520 " smoothing iterations at still_count: " + std::to_string(stay_still_count) +
521 " Wrong energy or noisy peak at Ei=" + boost::lexical_cast<std::string>(Ei)
522 << '\n';
523 }
524 g_log.debug() << "*Performed: " + std::to_string(ic) + " averages for spectra " + std::to_string(index) +
525 " at energy: " + boost::lexical_cast<std::string>(Ei) +
526 "\n and found: " + std::to_string(nPeaks) + "peaks and " + std::to_string(nHills) + " hills\n";
527 if (nPeaks != 1) {
528 g_log.debug() << "*Peak rejected as n-peaks !=1 after averaging\n";
529 return false;
530 }
531
532 peakPos = peaks[0];
533 if (nHills > 2) {
534 auto peakIndex = std::size_t(Kernel::VectorHelper::getBinIndex(hillsPos, peaks[0]));
535 peakTwoSigma = hillsPos[peakIndex + 1] - hillsPos[peakIndex];
536 } else {
537 if (hillsPos.size() == 2) {
538 peakTwoSigma = hillsPos[1] - hillsPos[0];
539 } else {
540 g_log.debug() << "*Peak rejected as averaging gives: " + std::to_string(nPeaks) + " peaks and " +
541 std::to_string(nHills) + " heals\n";
542
543 return false;
544 }
545 }
546 // assuming that averaging conserves intensity and removing linear
547 // background:
548 peakHeight = Intensity / (0.5 * std::sqrt(2. * M_PI) * peakTwoSigma) - sMin;
549 peakPos = realPeakPos;
550
551 return true;
552}
553
567 const std::vector<size_t> &monsRangeMin, const std::vector<size_t> &monsRangeMax,
568 double &position, double &height, double &twoSigma) {
569 // calculate sigma from half-width parameters
570 double maxSigma = Ei * m_min_Eresolution / (2. * std::sqrt(2. * M_LN2));
571 double minSigma = Ei * m_max_Eresolution / (2. * std::sqrt(2. * M_LN2));
572 //--------------------------------------------------------------------
573 double peak1Pos, peak1TwoSigma, peak1Height;
574 if (!peakGuess(inputWS, 0, Ei, monsRangeMin, monsRangeMax, peak1Pos, peak1Height, peak1TwoSigma))
575 return false;
576 if (0.25 * peak1TwoSigma > maxSigma || peak1TwoSigma < minSigma) {
577 g_log.debug() << "*Rejecting due to width: Peak at mon1 Ei=" + boost::lexical_cast<std::string>(peak1Pos) +
578 " with Height:" + boost::lexical_cast<std::string>(peak1Height) +
579 " and 2*Sigma: " + boost::lexical_cast<std::string>(peak1TwoSigma)
580 << '\n';
581 return false;
582 }
583
584 if (!this->getProperty("IgnoreSecondMonitor")) {
585 double peak2Pos, peak2TwoSigma, peak2Height;
586 if (!peakGuess(inputWS, 1, Ei, monsRangeMin, monsRangeMax, peak2Pos, peak2Height, peak2TwoSigma))
587 return false;
588 // Let's not check anything except peak position for monitor2, as
589 // its intensity may be very low for some instruments.
590 // if(0.25*peak2TwoSigma>maxSigma||peak2TwoSigma<minSigma)return false;
591
592 // peak in first and second monitors are too far from each other. May be the
593 // instrument
594 // is ill-calibrated but GetEi will probably not find this peak anyway.
595 if (std::fabs(peak1Pos - peak2Pos) > 0.25 * (peak1TwoSigma + peak2TwoSigma)) {
596 g_log.debug() << "*Rejecting due to displacement between Peak at mon1: Ei=" +
597 boost::lexical_cast<std::string>(peak1Pos) +
598 " with Height:" + boost::lexical_cast<std::string>(peak1Height) +
599 " and 2*Sigma: " + boost::lexical_cast<std::string>(peak1TwoSigma) +
600 "\n and Peak at mon2: Ei= " + boost::lexical_cast<std::string>(peak2Pos) +
601 "and height: " + boost::lexical_cast<std::string>(peak1Height)
602 << '\n';
603
604 return false;
605 }
606 }
607
608 position = peak1Pos;
609 twoSigma = peak1TwoSigma;
610 height = peak1Height;
611
612 return true;
613}
614namespace { // for lambda extracted from calcDerivativeAndCountZeros
620bool signChanged(double val, int &prevSign) {
621 int curSign = (val >= 0 ? 1 : -1);
622 bool changed = curSign != prevSign;
623 prevSign = curSign;
624 return changed;
625}
626} // namespace
627
640size_t GetAllEi::calcDerivativeAndCountZeros(const std::vector<double> &bins, const std::vector<double> &signal,
641 std::vector<double> &deriv, std::vector<double> &zeros) {
642 size_t nPoints = signal.size();
643 deriv.resize(nPoints);
644 zeros.resize(0);
645
646 std::list<double> funVal;
647 double bin0 = bins[1] - bins[0];
648 double f0 = signal[0] / bin0;
649 double bin1 = bins[2] - bins[1];
650 double f1 = signal[1] / bin1;
651
652 size_t nZeros(0);
653
654 funVal.push_front(f1);
655 deriv[0] = 2 * (f1 - f0) / (bin0 + bin1);
656 int prevSign = (deriv[0] >= 0 ? 1 : -1);
657
658 for (size_t i = 1; i < nPoints - 1; i++) {
659 bin1 = (bins[i + 2] - bins[i + 1]);
660 f1 = signal[i + 1] / bin1;
661 deriv[i] = (f1 - f0) / (bins[i + 2] - bins[i]);
662 f0 = funVal.back();
663 funVal.pop_back();
664 funVal.push_front(f1);
665
666 if (signChanged(deriv[i], prevSign)) {
667 nZeros++;
668 zeros.emplace_back(0.5 * (bins[i - 1] + bins[i]));
669 }
670 }
671 deriv[nPoints - 1] = 2 * (f1 - f0) / (bin1 + bin0);
672 if (signChanged(deriv[nPoints - 1], prevSign)) {
673 zeros.emplace_back(bins[nPoints - 1]);
674 nZeros++;
675 }
676
677 return nZeros;
678}
679namespace { // for lambda extracted from findBinRanges
680// get bin range corresponding to the energy range
681void getBinRange(const HistogramData::HistogramX &eBins, double eMin, double eMax, size_t &index_min,
682 size_t &index_max) {
683
684 const auto &bins = eBins.rawData();
685 const size_t nBins = bins.size();
686 if (eMin <= bins[0]) {
687 index_min = 0;
688 } else {
689 index_min = std::size_t(Kernel::VectorHelper::getBinIndex(bins, eMin));
690 }
691
692 if (eMax >= eBins[nBins - 1]) {
693 index_max = nBins - 1;
694 } else {
695 index_max = std::size_t(Kernel::VectorHelper::getBinIndex(bins, eMax)) + 1;
696 if (index_max >= nBins)
697 index_max = nBins - 1; // last bin range anyway. Should not happen
698 }
699}
700
701// refine bin range. May need better procedure for this.
702bool refineEGuess(const HistogramX &eBins, const HistogramY &signal, double &eGuess, size_t index_min,
703 size_t index_max) {
704
705 size_t ind_Emax = index_min;
706 double SMax(0);
707 for (size_t i = index_min; i < index_max; i++) {
708 double dX = eBins[i + 1] - eBins[i];
709 double sig = signal[i] / dX;
710 if (sig > SMax) {
711 SMax = sig;
712 ind_Emax = i;
713 }
714 }
715 if (ind_Emax == index_min || ind_Emax == index_max) {
716 return false;
717 }
718 eGuess = 0.5 * (eBins[ind_Emax] + eBins[ind_Emax + 1]);
719 return true;
720}
721
722struct peakKeeper2 {
723 double left_rng;
724 double right_rng;
725 peakKeeper2() : left_rng(.0), right_rng(.0) {};
726 peakKeeper2(double left, double right) : left_rng(left), right_rng(right) {}
727};
728} // namespace
729
742void GetAllEi::findBinRanges(const HistogramX &eBins, const HistogramY &signal, const std::vector<double> &guess_energy,
743 double eResolution, std::vector<size_t> &irangeMin, std::vector<size_t> &irangeMax,
744 std::vector<bool> &guessValid) {
745
746 // size_t nBins = eBins.size();
747 guessValid.resize(guess_energy.size());
748
749 // Do the job
750 size_t ind_min, ind_max;
751 irangeMin.resize(0);
752 irangeMax.resize(0);
753
754 // identify guess bin ranges
755 std::vector<peakKeeper2> guess_peak(guess_energy.size());
756 for (size_t nGuess = 0; nGuess < guess_energy.size(); nGuess++) {
757 double eGuess = guess_energy[nGuess];
758 getBinRange(eBins, eGuess * (1 - 4 * eResolution), eGuess * (1 + 4 * eResolution), ind_min, ind_max);
759 guess_peak[nGuess] = peakKeeper2(eBins[ind_min], eBins[ind_max]);
760 }
761 // verify that the ranges not intercept and refine interceptions
762 for (size_t i = 1; i < guess_energy.size(); i++) {
763 if (guess_peak[i - 1].right_rng > guess_peak[i].left_rng) {
764 double mid_pnt = 0.5 * (guess_peak[i - 1].right_rng + guess_peak[i].left_rng);
765 guess_peak[i - 1].right_rng = mid_pnt;
766 guess_peak[i].left_rng = mid_pnt;
767 }
768 }
769 // identify final bin ranges
770 for (size_t nGuess = 0; nGuess < guess_energy.size(); nGuess++) {
771
772 double eGuess = guess_energy[nGuess];
773 getBinRange(eBins, guess_peak[nGuess].left_rng, guess_peak[nGuess].right_rng, ind_min, ind_max);
774
775 if (refineEGuess(eBins, signal, eGuess, ind_min, ind_max)) {
776 getBinRange(eBins, std::max(guess_peak[nGuess].left_rng, eGuess * (1 - 3 * eResolution)),
777 std::max(guess_peak[nGuess].right_rng, eGuess * (1 + 3 * eResolution)), ind_min, ind_max);
778 irangeMin.emplace_back(ind_min);
779 irangeMax.emplace_back(ind_max);
780 guessValid[nGuess] = true;
781 } else {
782 guessValid[nGuess] = false;
783 g_log.debug() << "*Incorrect guess energy: " << boost::lexical_cast<std::string>(eGuess)
784 << " no energy peak found in 4*Sigma range\n";
785 }
786 }
787 // if array decreasing rather then increasing, indexes behave differently.
788 // Will it still work?
789 if (!irangeMax.empty()) {
790 if (irangeMax[0] < irangeMin[0]) {
791 irangeMax.swap(irangeMin);
792 }
793 }
794}
795
804
805 // at this stage all properties are validated so its safe to access them
806 // without
807 // additional checks.
808 specnum_t specNum1 = getProperty("Monitor1SpecID");
809 wsIndex0 = inputWS->getIndexFromSpectrumNumber(specNum1);
810 specnum_t specNum2 = getProperty("Monitor2SpecID");
811 size_t wsIndex1 = inputWS->getIndexFromSpectrumNumber(specNum2);
812
813 // assuming equally binned ws.
814 std::shared_ptr<API::HistoWorkspace> working_ws = DataObjects::create<API::HistoWorkspace>(
815 *inputWS, Indexing::extract(inputWS->indexInfo(), std::vector<size_t>{wsIndex0, wsIndex1}),
816 inputWS->histogram(wsIndex0));
817
818 // signal 1
819 working_ws->setSharedY(0, inputWS->sharedY(wsIndex0));
820 // signal 2
821 working_ws->setSharedY(1, inputWS->sharedY(wsIndex1));
822 // error 1
823 working_ws->setSharedE(0, inputWS->sharedE(wsIndex0));
824 // error 2
825 working_ws->setSharedE(1, inputWS->sharedE(wsIndex1));
826
827 if (inputWS->getAxis(0)->unit()->caption() != "Energy") {
828 auto conv = createChildAlgorithm("ConvertUnits");
829 conv->initialize();
830 conv->setProperty("InputWorkspace", working_ws);
831 conv->setProperty("OutputWorkspace", working_ws);
832 conv->setPropertyValue("Target", "Energy");
833 conv->setPropertyValue("EMode", "Elastic");
834 // conv->setProperty("AlignBins",true); --> throws due to bug in
835 // ConvertUnits
836 conv->execute();
837 }
838
839 return working_ws;
840}
851void GetAllEi::findGuessOpeningTimes(const std::pair<double, double> &TOF_range, double ChopDelay, double Period,
852 std::vector<double> &guess_opening_times) {
853
854 if (ChopDelay >= TOF_range.second) {
855 std::string chop = boost::str(boost::format("%.2g") % ChopDelay);
856 std::string t_min = boost::str(boost::format("%.2g") % TOF_range.first);
857 std::string t_max = boost::str(boost::format("%.2g") % TOF_range.second);
858 throw std::runtime_error("Logical error: Chopper opening time: " + chop + " is outside of time interval: " + t_min +
859 ":" + t_max + " of the signal, measured on monitors.");
860 }
861
862 // number of times chopper with specified rotation period opens.
863 size_t n_openings = static_cast<size_t>((TOF_range.second - ChopDelay) / Period) + 1;
864 // number of periods falling outside of the time period, measuring on monitor.
865 size_t n_start(0);
866 if (ChopDelay < TOF_range.first) {
867 n_start = static_cast<size_t>((TOF_range.first - ChopDelay) / Period) + 1;
868 n_openings -= n_start;
869 }
870
871 guess_opening_times.resize(n_openings);
872 for (size_t i = n_start; i < n_openings + n_start; i++) {
873 guess_opening_times[i - n_start] = ChopDelay + static_cast<double>(i) * Period;
874 }
875}
884 const std::string &propertyName) {
885
886 std::string LogName = this->getProperty(propertyName);
887 if (boost::iequals(LogName, "Defined in IDF")) {
888 auto AllNames = m_chopper->getStringParameter(propertyName);
889 if (AllNames.size() != 1)
890 return nullptr;
891 LogName = AllNames[0];
892 }
893 auto pIProperty = (inputWS->run().getProperty(LogName));
894
895 return pIProperty;
896}
897
905double GetAllEi::getAvrgLogValue(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName,
906 const Kernel::TimeROI &timeroi) {
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 const 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 double value;
919 if (timeroi.useAll()) {
920 const auto timeStart = inputWS->run().startTime();
921 const auto timeStop = inputWS->run().endTime();
922 if (timeStart < timeStop) {
923 Kernel::TimeROI localROI(timeStart, timeStop);
924 value = pTimeSeries->getStatistics(&localROI).mean;
925 } else {
926 // all values in pTimeSeries will be used
927 value = pTimeSeries->getStatistics().mean;
928 }
929 } else {
930 value = pTimeSeries->getStatistics(&timeroi).mean;
931 }
932 // statistics returns nan as mean of empty vector
933 if (std::isnan(value)) {
934 throw std::runtime_error("Can not find average value for log defined by property" + propertyName +
935 " As no valid log values are found.");
936 }
937
938 return value;
939}
940namespace { // former lambda function for findChopSpeedAndDelay
941
956bool SelectInterval(const Types::Core::DateAndTime &t_beg, const Types::Core::DateAndTime &t_end, double value,
957 bool &inSelection, Types::Core::DateAndTime &startTime, Types::Core::DateAndTime &endTime) {
958
959 if (value > 0) {
960 if (!inSelection) {
961 startTime = t_beg;
962 }
963 inSelection = true;
964 } else {
965 if (inSelection) {
966 inSelection = false;
967 if (endTime > startTime)
968 return true;
969 }
970 }
971 endTime = t_end;
972 return false;
973}
974} // namespace
980void GetAllEi::findChopSpeedAndDelay(const API::MatrixWorkspace_sptr &inputWS, double &chop_speed, double &chop_delay) {
981
982 // TODO: Make it dependent on inputWS time range
983
984 Kernel::TimeROI timeroi;
985 if (m_pFilterLog) {
986 std::unique_ptr<Kernel::TimeSeriesProperty<double>> pDerivative;
987
988 // Define selecting function
989 bool inSelection(false);
990 // time interval to select (start-end)
991 Types::Core::DateAndTime startTime, endTime;
992 //
993 // Analyze filtering log
994 auto dateAndTimes = m_pFilterLog->valueAsCorrectMap();
995 auto it = dateAndTimes.begin();
996 auto next = it;
997 next++;
998 std::map<Types::Core::DateAndTime, double> derivMap;
999 auto itder = it;
1001 pDerivative = m_pFilterLog->getDerivative();
1002 derivMap = pDerivative->valueAsCorrectMap();
1003 itder = derivMap.begin();
1004 }
1005
1006 // initialize selection log
1007 if (dateAndTimes.size() <= 1) {
1008 SelectInterval(it->first, it->first, itder->second, inSelection, startTime, endTime);
1009 if (inSelection) {
1010 startTime = inputWS->run().startTime();
1011 endTime = inputWS->run().endTime();
1012 timeroi.addROI(startTime, endTime);
1013 } else {
1014 throw std::runtime_error("filtered all data points. Nothing to do");
1015 }
1016 } else {
1017 SelectInterval(it->first, next->first, itder->second, inSelection, startTime, endTime);
1018 }
1019
1020 // if its filtered using log, both iterator walk through the same values
1021 // if use derivative, derivative's values are used for filtering
1022 // and derivative assumed in a center of an interval
1023 for (; next != dateAndTimes.end(); ++next, ++itder) {
1024 if (SelectInterval(it->first, next->first, itder->second, inSelection, startTime, endTime)) {
1025 timeroi.addROI(startTime, endTime);
1026 }
1027 it = next;
1028 }
1029 // final interval
1030 if (inSelection && (endTime > startTime)) {
1031 timeroi.addROI(startTime, endTime);
1032 }
1033 } // End of USE filter log.
1034
1035 chop_speed = this->getAvrgLogValue(inputWS, "ChopperSpeedLog", timeroi);
1036 chop_speed = std::fabs(chop_speed);
1037 if (chop_speed < 1.e-7) {
1038 throw std::runtime_error("Chopper speed can not be zero ");
1039 }
1040 chop_delay = std::fabs(this->getAvrgLogValue(inputWS, "ChopperDelayLog", timeroi));
1041
1042 // process chopper delay in the units of degree (phase)
1043 const auto *pProperty = getPLogForProperty(inputWS, "ChopperDelayLog");
1044 if (!pProperty)
1045 throw std::runtime_error("ChopperDelayLog has been removed from workspace "
1046 "during the algorithm execution");
1047 std::string units = pProperty->units();
1048 // its chopper phase provided
1049 if (units == "deg" || units.c_str()[0] == -80) { //<- userd in ISIS ASCII representation of o(deg)
1050 chop_delay *= 1.e+6 / (360. * chop_speed); // convert in uSec
1051 }
1052 chop_delay += m_phase / chop_speed;
1053}
1054
1055namespace { // namespace for lambda functions, used in validators
1056
1057/* former Lambda to validate if appropriate log is present in workspace
1058and if it's present, it is a time-series property
1059* @param prop_name -- the name of the log to check
1060* @param err_presence -- core error message to return if no log found
1061* @param err_type -- core error message to return if
1062* log is of incorrect type
1063* @param fail -- fail or warn if appropriate log is not available.
1064*
1065* @param result -- map to add the result of check for errors
1066* if no error found the map is not modified and remains
1067* empty.
1068
1069
1070* @return -- false if all checks are fine, or true if check is
1071* failed
1072*/
1073bool check_time_series_property(const GetAllEi *algo, const API::MatrixWorkspace_sptr &inputWS,
1074 const std::shared_ptr<const Geometry::IComponent> &chopper,
1075 const std::string &prop_name, const std::string &err_presence,
1076 const std::string &err_type, bool fail, std::map<std::string, std::string> &result) {
1077
1078 std::string LogName = algo->getProperty(prop_name);
1079 if (boost::iequals(LogName, "Defined in IDF")) {
1080 try {
1081 auto theLogs = chopper->getStringParameter(prop_name);
1082 if (theLogs.empty()) {
1083 if (fail)
1084 result[prop_name] = "Can not retrieve parameter " + prop_name + " from the instrument definition file.";
1085 return true;
1086 }
1087 LogName = theLogs[0];
1088 } catch (...) {
1089 result[prop_name] = "Can not retrieve parameter " + prop_name + " from the instrument definition file.";
1090 return true;
1091 }
1092 }
1093 try {
1094 Kernel::Property *pProp = inputWS->run().getProperty(LogName);
1095 const auto *pTSProp = dynamic_cast<Kernel::TimeSeriesProperty<double> *>(pProp);
1096 if (!pTSProp) {
1097 if (fail)
1098 result[prop_name] = "Workspace contains " + err_type + LogName + " But its type is not a timeSeries property";
1099 return true;
1100 }
1101 } catch (std::runtime_error &) {
1102 if (fail)
1103 result[prop_name] = "Workspace has to contain " + err_presence + LogName;
1104 return true;
1105 }
1106 return false;
1107}
1108} // namespace
1109
1114std::map<std::string, std::string> GetAllEi::validateInputs() {
1115
1116 // Do Validation
1117 std::map<std::string, std::string> result;
1118
1119 API::MatrixWorkspace_sptr inputWS = getProperty("Workspace");
1120 if (!inputWS) {
1121 result["Workspace"] = "Input workspace can not be identified";
1122 return result;
1123 }
1124 if (!inputWS->isHistogramData()) {
1125 result["Workspace"] = "Only histogram workspaces are currently supported. "
1126 "Rebin input workspace first.";
1127 }
1128
1129 specnum_t specNum1 = getProperty("Monitor1SpecID");
1130 try {
1131 inputWS->getIndexFromSpectrumNumber(specNum1);
1132 } catch (std::runtime_error &) {
1133 result["Monitor1SpecID"] = "Input workspace does not contain spectra with ID: " + std::to_string(specNum1);
1134 }
1135 specnum_t specNum2 = getProperty("Monitor2SpecID");
1136 try {
1137 inputWS->getIndexFromSpectrumNumber(specNum2);
1138 } catch (std::runtime_error &) {
1139 result["Monitor2SpecID"] = "Input workspace does not contain spectra with ID: " + std::to_string(specNum2);
1140 }
1141 // check chopper and initiate it if present (for debugging)
1142 m_chopper = inputWS->getInstrument()->getComponentByName("chopper-position");
1143 if (!m_chopper) {
1144 result["Workspace_chopper"] = " For this algorithm to work workspace has"
1145 " to contain well defined 'chopper-position' component";
1146 return result;
1147 }
1148
1149 check_time_series_property(this, inputWS, m_chopper, "ChopperSpeedLog",
1150 "chopper speed log with name: ", "chopper speed log ", true, result);
1151 check_time_series_property(this, inputWS, m_chopper, "ChopperDelayLog",
1152 "property related to chopper delay log with name: ", "chopper delay log ", true, result);
1153 bool failed = check_time_series_property(this, inputWS, m_chopper, "FilterBaseLog",
1154 "filter base log named: ", "filter base log: ", false, result);
1155 if (failed) {
1156 g_log.warning() << " Can not find a log to identify good DAE operations.\n"
1157 " Assuming that good operations start from experiment time=0";
1158 } else {
1159 this->setFilterLog(inputWS);
1160 }
1161 return result;
1162}
1163
1164} // namespace Mantid::Algorithms
#define DECLARE_ALGORITHM(classname)
Definition Algorithm.h:538
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:723
double position
Definition GetAllEi.cpp:154
double right_rng
Definition GetAllEi.cpp:724
std::map< DeltaEMode::Type, std::string > index
double left
double right
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
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.
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.
Kernel::Logger & g_log
Definition Algorithm.h:422
A property class for workspaces.
Estimate all incident energies, used by chopper instrument.
Definition GetAllEi.h:29
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:851
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:566
double getAvrgLogValue(const API::MatrixWorkspace_sptr &inputWS, const std::string &propertyName, const Kernel::TimeROI &timeroi)
Return average time series log value for the appropriately filtered log.
Definition GetAllEi.cpp:905
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:883
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:803
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:980
std::map< std::string, std::string > validateInputs() override
Cross-check properties with each other.
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:436
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:742
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:640
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:373
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:400
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:145
void warning(const std::string &msg)
Logs at warning level.
Definition Logger.cpp:117
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
Base class for properties.
Definition Property.h:94
TimeROI : Object that holds information about when the time measurement was active.
Definition TimeROI.h:18
void addROI(const std::string &startTime, const std::string &stopTime)
Definition TimeROI.cpp:76
bool useAll() const
TimeROI selects all time to be used.
Definition TimeROI.cpp:693
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:24
int32_t specnum_t
Typedef for a spectrum Number.
Definition IDTypes.h:14
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