36using namespace Kernel;
44const std::string INPUT_WKSP(
"InputWorkspace");
45const std::string OUTPUT_WKSP(
"OutputWorkspace");
46const std::string UNFOCUS_WKSP(
"UnfocussedWorkspace");
47const std::string CAL_FILE(
"CalFileName");
48const std::string GROUP_FILE(
"GroupFilename");
49const std::string GROUP_WKSP(
"GroupingWorkspace");
50const std::string CAL_WKSP(
"CalibrationWorkspace");
51const std::string OFFSET_WKSP(
"OffsetsWorkspace");
52const std::string MASK_WKSP(
"MaskWorkspace");
53const std::string MASK_TABLE(
"MaskBinTable");
54const std::string BINNING(
"Params");
55const std::string RESAMPLEX(
"ResampleX");
56const std::string BIN_IN_D(
"Dspacing");
57const std::string D_MINS(
"DMin");
58const std::string D_MAXS(
"DMax");
59const std::string RAGGED_DELTA(
"DeltaRagged");
60const std::string TOF_MIN(
"TMin");
61const std::string TOF_MAX(
"TMax");
62const std::string WL_MIN(
"CropWavelengthMin");
63const std::string WL_MAX(
"CropWavelengthMax");
64const std::string PRESERVE_EVENTS(
"PreserveEvents");
65const std::string REMOVE_PROMPT_PULSE(
"RemovePromptPulseWidth");
66const std::string RESONANCE_UNITS(
"ResonanceFilterUnits");
67const std::string RESONANCE_LOWER_LIMITS(
"ResonanceFilterLowerLimits");
68const std::string RESONANCE_UPPER_LIMITS(
"ResonanceFilterUpperLimits");
69const std::string COMPRESS_TOF_TOL(
"CompressTolerance");
70const std::string COMPRESS_WALL_TOL(
"CompressWallClockTolerance");
71const std::string COMPRESS_WALL_START(
"CompressStartTime");
72const std::string COMPRESS_MODE(
"CompressBinningMode");
73const std::string L1(
"PrimaryFlightPath");
74const std::string SPEC_IDS(
"SpectrumIDs");
75const std::string L2(
"L2");
76const std::string POLAR(
"Polar");
77const std::string AZIMUTHAL(
"Azimuthal");
78const std::string PM_NAME(
"ReductionProperties");
79const std::string LORENTZ(
"LorentzCorrection");
83 if (
const auto eventWksp = std::dynamic_pointer_cast<const EventWorkspace>(wksp)) {
84 eventWksp->getEventXMinMax(tmin, tmax);
86 wksp->getXMinMax(tmin, tmax);
90const std::vector<std::string> binningModeNames{
"Default",
"Linear",
"Logarithmic"};
104 "The input workspace");
107 "The result of diffraction focussing of InputWorkspace");
110 "Treated data in d-spacing before focussing (optional). This will likely "
118 std::vector<std::string>{
".h5",
".hd5",
".hdf",
".cal"}),
119 "The name of the calibration file with offset, masking, and "
122 std::vector<std::string>{
".xml",
".cal"}),
123 "Overrides grouping from CalFileName");
126 "Optional: A GroupingWorkspace giving the grouping info.");
130 "Optional: A Workspace containing the calibration information. Either "
131 "this or CalibrationFile needs to be specified.");
134 "Optional: An OffsetsWorkspace giving the detector calibration values.");
137 "Optional: A workspace giving which detectors are masked.");
140 "Optional: A workspace giving pixels and bins to mask.");
143 "A comma separated list of first bin boundary, width, last bin boundary. "
145 "this can be followed by a comma and more widths and last boundary "
147 "Negative width values indicate logarithmic binning.");
148 declareProperty(PropertyNames::RESAMPLEX, 0,
149 "Number of bins in x-axis. Non-zero value "
150 "overrides \"Params\" property. Negative "
151 "value means logarithmic binning.");
152 setPropertySettings(PropertyNames::BINNING,
153 std::make_unique<EnabledWhenProperty>(PropertyNames::RESAMPLEX,
IS_DEFAULT));
154 declareProperty(PropertyNames::BIN_IN_D,
true,
"Bin in Dspace. (True is Dspace; False is TOF)");
156 "Minimum for Dspace axis. (Default 0.) ");
157 mapPropertyName(PropertyNames::D_MINS,
"d_min");
159 "Maximum for Dspace axis. (Default 0.) ");
160 mapPropertyName(PropertyNames::D_MAXS,
"d_max");
161 declareProperty(std::make_unique<
ArrayProperty<double>>(PropertyNames::RAGGED_DELTA),
"Step parameter for rebin");
162 mapPropertyName(PropertyNames::RAGGED_DELTA,
"delta");
163 declareProperty(PropertyNames::TOF_MIN,
EMPTY_DBL(),
"Minimum for TOF axis. Defaults to 0. ");
164 mapPropertyName(PropertyNames::TOF_MIN,
"tof_min");
165 declareProperty(PropertyNames::TOF_MAX,
EMPTY_DBL(),
"Maximum for TOF or dspace axis. Defaults to 0. ");
166 mapPropertyName(PropertyNames::TOF_MAX,
"tof_max");
167 declareProperty(PropertyNames::PRESERVE_EVENTS,
true,
168 "If the InputWorkspace is an "
169 "EventWorkspace, this will preserve "
170 "the full event list (warning: this "
171 "will use much more memory!).");
172 declareProperty(PropertyNames::REMOVE_PROMPT_PULSE, 0.,
173 "Width of events (in "
174 "microseconds) near the prompt "
175 "pulse to remove. 0 disables");
176 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
177 mustBePositive->setLower(0.0);
179 std::vector<std::string> allowedResonanceUnits({
"Energy",
"Wavelength"});
180 declareProperty(PropertyNames::RESONANCE_UNITS, allowedResonanceUnits.back(),
181 std::make_shared<StringListValidator>(allowedResonanceUnits),
182 "Units for resonances to be filtered in. "
183 "The data will be converted to these units temporarily to filter.");
185 "Minimum values to filter absorption resonance. This must have same number of values as "
186 "ResonanceFilterUpperLimits. Default behavior is to not filter.");
188 "Maximum values to filter absorption resonance. This must have same number of values as "
189 "ResonanceFilterLowerLimits. Default behavior is to not filter.");
192 "Compress events (in microseconds) within this tolerance. (Default 1e-5). If negative then do "
193 "logorithmic compression.");
196 "The tolerance (in seconds) on the wall-clock time for comparison. Unset "
197 "means compressing all wall-clock times together disabling pulsetime "
199 auto dateValidator = std::make_shared<DateTimeValidator>();
200 dateValidator->allowEmpty(
true);
201 declareProperty(PropertyNames::COMPRESS_WALL_START,
"", dateValidator,
202 "An ISO formatted date/time string specifying the timestamp for "
203 "starting filtering. Ignored if WallClockTolerance is not specified. "
204 "Default is start of run",
206 declareProperty(PropertyNames::COMPRESS_MODE, binningModeNames[
size_t(BinningMode::DEFAULT)],
207 std::make_shared<Mantid::Kernel::StringListValidator>(binningModeNames),
208 "Optional. Binning behavior can be specified in the usual way through sign of tolerance "
209 "('Default'); or can be set to one of the allowed binning modes. ");
210 declareProperty(PropertyNames::LORENTZ,
false,
211 "Multiply each spectrum by "
212 "sin(theta) where theta is "
213 "half of the Bragg angle");
214 declareProperty(
"CropWavelengthMin", 0.,
"Crop the data at this minimum wavelength.");
215 mapPropertyName(PropertyNames::WL_MIN,
"wavelength_min");
216 declareProperty(
"CropWavelengthMax",
EMPTY_DBL(),
217 "Crop the data at this maximum wavelength. Forces use of "
218 "CropWavelengthMin.");
219 mapPropertyName(PropertyNames::WL_MAX,
"wavelength_max");
220 declareProperty(PropertyNames::L1, -1.0,
"If positive, focus positions are changed. (Default -1) ");
222 "Optional: Spectrum Nos (note that it is not detector ID or "
223 "workspace indices).");
225 "Optional: Secondary flight (L2) paths for each detector");
227 "Optional: Polar angles (two thetas) for detectors");
229 "Azimuthal angles (out-of-plain) for detectors");
231 declareProperty(PropertyNames::PM_NAME,
"__powdereduction",
Direction::Input);
235 std::map<std::string, std::string> result;
237 if (!isDefault(PropertyNames::UNFOCUS_WKSP)) {
240 result[PropertyNames::UNFOCUS_WKSP] =
"Cannot be the same as OutputWorkspace";
244 if ((!isDefault(PropertyNames::RAGGED_DELTA)) && (!isDefault(PropertyNames::RESAMPLEX))) {
245 result[PropertyNames::RAGGED_DELTA] =
"Cannot specify with " + PropertyNames::RESAMPLEX;
246 result[PropertyNames::RESAMPLEX] =
"Cannot specify with " + PropertyNames::RAGGED_DELTA;
250 auto inputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_inputW);
251 if (inputEW && inputEW->getNumberEvents() <= 0)
253 "Please plot the pCharge-time to identify suitable range for "
263 for (
size_t i = 0; i < NUM_WINDOWS; ++i) {
268 const std::string msg =
"Lower limits must be less than upper limits";
269 result[PropertyNames::RESONANCE_LOWER_LIMITS] = msg;
270 result[PropertyNames::RESONANCE_UPPER_LIMITS] = msg;
273 result[PropertyNames::RESONANCE_LOWER_LIMITS] =
274 "Must have same number of values as " + PropertyNames::RESONANCE_UPPER_LIMITS;
275 result[PropertyNames::RESONANCE_UPPER_LIMITS] =
276 "Must have same number of values as " + PropertyNames::RESONANCE_LOWER_LIMITS;
334 const bool applyLorentz =
getProperty(PropertyNames::LORENTZ);
343 double compressEventsTolerance =
getProperty(PropertyNames::COMPRESS_TOF_TOL);
344 const double wallClockTolerance =
getProperty(PropertyNames::COMPRESS_WALL_TOL);
346 if (mode == BinningMode::LINEAR)
347 compressEventsTolerance = std::fabs(compressEventsTolerance);
348 else if (mode == BinningMode::LOGARITHMIC)
349 compressEventsTolerance = -1. * std::fabs(compressEventsTolerance);
361 if (
m_params.size() == 1 && (!isEmpty(dmin)) && (!isEmpty(dmax))) {
362 if (dmin > 0. && dmax > dmin) {
371 g_log.
warning() <<
"something is wrong with dmin (" << dmin <<
") and dmax (" << dmax
372 <<
"). They are being ignored.\n";
386 <<
"). They are being ignored.\n";
407 if (
auto inputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_inputW)) {
412 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputEW);
422 m_progress = std::make_unique<Progress>(
this, 0., 1., 21);
425 g_log.
information() <<
"running MaskDetectors started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
430 maskDetAlg->setProperty(
"Workspace", outputw);
432 maskDetAlg->setProperty(
"MaskedWorkspace", mksws);
433 maskDetAlg->executeAsChildAlg();
434 outputw = maskDetAlg->getProperty(
"Workspace");
436 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
445 if (((!isEmpty(
xmin)) && (
xmin >= 0.)) || ((!isEmpty(
xmax)) && (
xmax > 0.))) {
449 cropAlg->setProperty(
"InputWorkspace",
m_outputW);
450 cropAlg->setProperty(
"OutputWorkspace",
m_outputW);
451 bool setxmin =
false;
452 if ((
xmin >= 0.) && (
xmin > tofmin)) {
453 cropAlg->setProperty(
"Xmin",
xmin);
457 bool setxmax =
false;
458 if ((
xmax > 0.) && (
xmax < tofmax)) {
459 cropAlg->setProperty(
"Xmax",
xmax);
464 if (setxmin || setxmax) {
466 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
467 cropAlg->executeAsChildAlg();
468 m_outputW = cropAlg->getProperty(
"OutputWorkspace");
474 const double removePromptPulseWidth =
getProperty(PropertyNames::REMOVE_PROMPT_PULSE);
475 if (removePromptPulseWidth > 0.) {
476 bool removePromptPulse(
false);
477 if (
auto outputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW)) {
478 removePromptPulse = (outputEW->getNumberEvents() > 0);
480 if (removePromptPulse) {
481 g_log.
information() <<
"running RemovePromptPulse(Width=" << removePromptPulseWidth <<
") started at "
482 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
484 filterPAlg->setProperty(
"InputWorkspace",
m_outputW);
485 filterPAlg->setProperty(
"OutputWorkspace",
m_outputW);
486 filterPAlg->setProperty(
"Width", removePromptPulseWidth);
490 filterPAlg->setProperty(
"TMin", tofmin);
491 filterPAlg->setProperty(
"TMax", tofmax);
493 filterPAlg->executeAsChildAlg();
494 m_outputW = filterPAlg->getProperty(
"OutputWorkspace");
501 if (maskBinTableWS) {
502 g_log.
information() <<
"running MaskBinsFromTable started at " << Types::Core::DateAndTime::getCurrentTime()
505 alg->setProperty(
"InputWorkspace",
m_outputW);
506 alg->setProperty(
"OutputWorkspace",
m_outputW);
507 alg->setProperty(
"MaskingInformation", maskBinTableWS);
508 alg->executeAsChildAlg();
509 m_outputW = alg->getProperty(
"OutputWorkspace");
525 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
528 applyDiffCalAlg->setProperty(
"InstrumentWorkspace", outputw);
530 applyDiffCalAlg->executeAsChildAlg();
532 outputw = applyDiffCalAlg->getProperty(
"InstrumentWorkspace");
533 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
551 applyDiffCalAlg->setProperty(
"InstrumentWorkspace", outputw);
552 applyDiffCalAlg->setProperty(
"ClearCalibration",
true);
553 applyDiffCalAlg->executeAsChildAlg();
555 outputw = applyDiffCalAlg->getProperty(
"InstrumentWorkspace");
556 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
568 g_log.
information() <<
"Applying Lorentz correction started at " << Types::Core::DateAndTime::getCurrentTime()
572 alg->setProperty(
"InputWorkspace",
m_outputW);
573 alg->setProperty(
"OutputWorkspace",
m_outputW);
574 alg->setPropertyValue(
"Type",
"PowderTOF");
575 alg->executeAsChildAlg();
576 m_outputW = alg->getProperty(
"OutputWorkspace");
583 if (
const auto ews = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW))
584 g_log.
information() <<
"Number of events = " << ews->getNumberEvents() <<
".\n";
591 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
594 removeAlg->setProperty(
"InputWorkspace",
m_outputW);
595 removeAlg->setProperty(
"OutputWorkspace",
m_outputW);
596 removeAlg->setProperty(
"XMin",
minwl);
597 removeAlg->setProperty(
"XMax",
maxwl);
598 removeAlg->executeAsChildAlg();
599 m_outputW = removeAlg->getProperty(
"OutputWorkspace");
600 if (
const auto ews = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW))
601 g_log.
information() <<
"Number of events = " << ews->getNumberEvents() <<
".\n";
618 if (!isDefault(
"UnfocussedWorkspace")) {
620 setProperty(
"UnfocussedWorkspace", std::move(wkspCopy));
648 }
catch (std::runtime_error &e) {
668 setProperty(
"OutputWorkspace",
m_outputW);
675 const std::vector<double> &polars,
676 const std::vector<specnum_t> &specids,
677 const std::vector<double> &l2s,
678 const std::vector<double> &phis) {
679 g_log.
information() <<
"running EditInstrumentGeometry started at " << Types::Core::DateAndTime::getCurrentTime()
683 editAlg->setProperty(
"Workspace", ws);
685 editAlg->setProperty(
"PrimaryFlightPath",
m_l1);
687 editAlg->setProperty(
"Polar", polars);
689 editAlg->setProperty(
"SpectrumIDs",
specids);
691 editAlg->setProperty(
"L2",
l2s);
693 editAlg->setProperty(
"Azimuthal",
phis);
694 editAlg->executeAsChildAlg();
696 ws = editAlg->getProperty(
"Workspace");
714 g_log.
information() <<
"running DiffractionFocussing(PreserveEvents=" << preserveEvents <<
") started at "
715 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
718 focusAlg->setProperty(
"InputWorkspace", ws);
719 focusAlg->setProperty(
"OutputWorkspace", ws);
720 focusAlg->setProperty(
"GroupingWorkspace",
m_groupWS);
721 focusAlg->setProperty(
"PreserveEvents", preserveEvents);
722 focusAlg->executeAsChildAlg();
723 ws = focusAlg->getProperty(
"OutputWorkspace");
738 focusAlg->setProperty(
"InputWorkspace", ws);
739 focusAlg->setProperty(
"OutputWorkspace", ws);
740 focusAlg->setProperty(
"GroupingWorkspace",
m_groupWS);
742 focusAlg->setProperty(
"DMin",
m_dmins);
743 focusAlg->setProperty(
"DMax",
m_dmaxs);
750 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
752 focusAlg->executeAsChildAlg();
753 ws = focusAlg->getProperty(
"OutputWorkspace");
761 const std::string &target) {
762 g_log.
information() <<
"running ConvertUnits(Target=" << target <<
") started at "
763 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
766 convert2Alg->setProperty(
"InputWorkspace", matrixws);
767 convert2Alg->setProperty(
"OutputWorkspace", matrixws);
768 convert2Alg->setProperty(
"Target", target);
769 convert2Alg->executeAsChildAlg();
771 matrixws = convert2Alg->getProperty(
"OutputWorkspace");
778 const std::string PREVIOUS_UNITS(matrixws->getAxis(0)->unit()->unitID());
787 for (
size_t i = 0; i < NUM_WINDOWS; ++i) {
789 <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
790 maskBinsAlg->setProperty(
"InputWorkspace", matrixws);
791 maskBinsAlg->setProperty(
"OutputWorkspace", matrixws);
794 maskBinsAlg->executeAsChildAlg();
796 matrixws = maskBinsAlg->getProperty(
"OutputWorkspace");
814 <<
", dMin(" <<
m_dmins.size() <<
"), dmax(" <<
m_dmaxs.size() <<
")) started at "
815 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
817 alg->setProperty(
"InputWorkspace", matrixws);
818 alg->setProperty(
"OutputWorkspace", matrixws);
820 size_t numHist =
m_outputW->getNumberHistograms();
822 alg->setProperty(
"XMin",
m_dmins);
823 alg->setProperty(
"XMax",
m_dmaxs);
826 <<
"number of workspace indices. Ignoring the parameters.\n";
831 alg->executeAsChildAlg();
832 matrixws = alg->getProperty(
"OutputWorkspace");
838 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
844 rebin3Alg->setProperty(
"InputWorkspace", matrixws);
845 rebin3Alg->setProperty(
"OutputWorkspace", matrixws);
846 rebin3Alg->setProperty(
"Params",
m_params);
847 rebin3Alg->executeAsChildAlg();
848 matrixws = rebin3Alg->getProperty(
"OutputWorkspace");
858 bool print_xmin =
false;
859 bool print_xmax =
false;
866 alg->setProperty(
"XMin",
m_dmins);
870 alg->setProperty(
"XMax",
m_dmaxs);
876 alg->setProperty(
"XMin", std::vector<double>(1,
tmin));
881 alg->setProperty(
"XMax", std::vector<double>(1,
tmax));
885 alg->setProperty(
"InputWorkspace", matrixws);
886 alg->setProperty(
"OutputWorkspace", matrixws);
896 g_log.
information() <<
" ) started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
899 alg->executeAsChildAlg();
900 matrixws = alg->getProperty(
"OutputWorkspace");
909 alg->setProperty(
"OffsetsWorkspace", offsetsWS);
910 alg->setPropertyValue(
"OutputWorkspace",
m_instName +
"_cal");
911 alg->executeAsChildAlg();
925 if ((!
m_groupWS) && (!calFilename.empty()) && (!groupFilename.empty())) {
926 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_group"))
934 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_cal"))
937 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_offsets")) {
944 if ((!
m_maskWS) && (!calFilename.empty())) {
945 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_mask"))
954 if (calFilename.empty() && groupFilename.empty())
962 if (calFilename.empty()) {
963 g_log.
information() <<
"Loading Grouping file \"" << groupFilename <<
"\"\n";
966 alg->setProperty(
"InputFile", groupFilename);
967 alg->setProperty(
"InputWorkspace",
m_inputW);
968 alg->executeAsChildAlg();
970 m_groupWS = alg->getProperty(
"OutputWorkspace");
971 const std::string groupname =
m_instName +
"_group";
972 AnalysisDataService::Instance().addOrReplace(groupname,
m_groupWS);
973 this->setPropertyValue(PropertyNames::GROUP_WKSP, groupname);
975 g_log.
information() <<
"Loading Calibration file \"" << calFilename <<
"\"";
976 if (!groupFilename.empty())
981 alg->setProperty(
"InputWorkspace",
m_inputW);
982 alg->setPropertyValue(
"Filename", calFilename);
983 alg->setPropertyValue(
"GroupFilename", groupFilename);
984 alg->setProperty<
bool>(
"MakeCalWorkspace", loadCalibration);
985 alg->setProperty<
bool>(
"MakeGroupingWorkspace", loadGrouping);
986 alg->setProperty<
bool>(
"MakeMaskWorkspace", loadMask);
987 alg->setProperty<
double>(
"TofMin",
getProperty(
"TMin"));
988 alg->setProperty<
double>(
"TofMax",
getProperty(
"TMax"));
989 alg->setPropertyValue(
"WorkspaceName",
m_instName);
990 alg->executeAsChildAlg();
994 m_groupWS = alg->getProperty(
"OutputGroupingWorkspace");
996 const std::string groupname =
m_instName +
"_group";
997 AnalysisDataService::Instance().addOrReplace(groupname,
m_groupWS);
998 this->setPropertyValue(PropertyNames::GROUP_WKSP, groupname);
1000 if (loadCalibration) {
1003 const std::string calname =
m_instName +
"_cal";
1004 AnalysisDataService::Instance().addOrReplace(calname,
m_calibrationWS);
1005 this->setPropertyValue(PropertyNames::CAL_WKSP, calname);
1008 m_maskWS = alg->getProperty(
"OutputMaskWorkspace");
1010 const std::string maskname =
m_instName +
"_mask";
1011 AnalysisDataService::Instance().addOrReplace(maskname,
m_maskWS);
1012 this->setPropertyValue(PropertyNames::MASK_WKSP, maskname);
1018 const double wallClockTolerance) {
1019 if (compressEventsTolerance == 0.)
1022 if (
auto outputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW)) {
1023 g_log.
information() <<
"running CompressEvents(Tolerance=" << compressEventsTolerance;
1024 if (!isEmpty(wallClockTolerance))
1026 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
1028 compressAlg->setProperty(
"InputWorkspace", outputEW);
1029 compressAlg->setProperty(
"OutputWorkspace", outputEW);
1030 compressAlg->setProperty(
"Tolerance", compressEventsTolerance);
1031 if (!isEmpty(wallClockTolerance)) {
1032 compressAlg->setProperty(
"WallClockTolerance", wallClockTolerance);
1033 compressAlg->setPropertyValue(
"StartTime",
getPropertyValue(PropertyNames::COMPRESS_WALL_START));
1035 compressAlg->executeAsChildAlg();
1036 outputEW = compressAlg->getProperty(
"OutputWorkspace");
1037 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputEW);
1047 const double tofmax,
const bool hasWallClockTolerance) {
1049 if (hasWallClockTolerance)
1052 if (compressTolerance == 0.)
1055 if (
const auto eventWS = std::dynamic_pointer_cast<const EventWorkspace>(
m_outputW)) {
1058 double tofmin_wksp = tofmin;
1059 double tofmax_wksp = tofmax;
1060 if (isEmpty(tofmin) || isEmpty(tofmax))
1061 getTofRange(
m_outputW, tofmin_wksp, tofmax_wksp);
1062 const double tofRange = std::fabs(tofmax_wksp - tofmin_wksp);
1065 constexpr double TOF_EVENT_BYTE_SIZE{
static_cast<double>(
sizeof(Types::Event::TofEvent))};
1066 constexpr double WEIGHTED_EVENT_BYTE_SIZE{
static_cast<double>(
sizeof(
WeightedEvent))};
1067 constexpr double WEIGHTED_NOTIME_EVENT_BYTE_SIZE{
static_cast<double>(
sizeof(
WeightedEventNoTime))};
1071 double sizeWeightedEventsEstimate;
1072 if (compressTolerance > 0)
1073 sizeWeightedEventsEstimate = WEIGHTED_NOTIME_EVENT_BYTE_SIZE * tofRange / compressTolerance;
1075 if (tofmin_wksp < 0)
1078 if (tofmin_wksp == 0)
1079 tofmin_wksp = compressTolerance;
1081 sizeWeightedEventsEstimate =
1082 WEIGHTED_NOTIME_EVENT_BYTE_SIZE * log(tofmax_wksp / tofmin_wksp) / log1p(abs(compressTolerance));
1085 double numEvents =
static_cast<double>(eventWS->getNumberEvents());
1086 const auto eventType = eventWS->getEventType();
1103 <<
" and comparing to " << sizeWeightedEventsEstimate <<
"\n";
1104 return sizeWeightedEventsEstimate <
numEvents;
#define DECLARE_ALGORITHM(classname)
A specialized class for dealing with file properties.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
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) override
Create a Child Algorithm.
Kernel::IPropertyManager::TypedValue getProperty(const std::string &name) const override
Get the property held by this object.
std::string getPropertyValue(const std::string &name) const override
Get the property held by this object.
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
Base MatrixWorkspace Abstract Class.
A property class for workspaces.
A GroupingWorkspace is a subclass of Workspace2D where each spectrum has a single number entry,...
An OffsetsWorkspace is a specialized Workspace2D where the Y value at each pixel is the offset to be ...
Info about a single neutron detection event, including a weight and error value, but excluding the pu...
Info about a single neutron detection event, including a weight and error value:
Support for a property that holds an array of values.
Exception for when an item is not found in a collection.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
The concrete, templated class for properties.
This is a parent algorithm that uses several different child algorithms to perform it's task.
void exec() override
Executes the algorithm.
void loadCalFile(const std::string &calFilename, const std::string &groupFilename)
Loads the .cal file if necessary.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
API::MatrixWorkspace_sptr m_inputW
API::MatrixWorkspace_sptr diffractionFocusRaggedRebinInDspace(API::MatrixWorkspace_sptr ws)
Call diffraction focus to a matrix workspace with ragged rebin parameters.
DataObjects::GroupingWorkspace_sptr m_groupWS
std::vector< double > m_dmins
bool shouldCompressUnfocused(const double compressTolerance, const double tofmin, const double tofmax, const bool hasWallClockTolerance)
Return true if a rough estimate suggests that the size of the events will be smaller after compressin...
void convertOffsetsToCal(DataObjects::OffsetsWorkspace_sptr &offsetsWS)
API::ITableWorkspace_sptr m_calibrationWS
API::MatrixWorkspace_sptr editInstrument(API::MatrixWorkspace_sptr ws, const std::vector< double > &polars, const std::vector< specnum_t > &specids, const std::vector< double > &l2s, const std::vector< double > &phis)
Call edit instrument geometry.
std::vector< double > l2s
API::MatrixWorkspace_sptr diffractionFocus(API::MatrixWorkspace_sptr ws)
Call diffraction focus to a matrix workspace.
std::unique_ptr< API::Progress > m_progress
Progress reporting.
std::vector< int32_t > specids
DataObjects::MaskWorkspace_sptr m_maskWS
API::MatrixWorkspace_sptr filterResonances(API::MatrixWorkspace_sptr matrixws)
Filter out absorption resonances.
std::vector< double > m_params
std::vector< double > tths
std::vector< double > m_resonanceLower
std::vector< double > m_resonanceUpper
std::vector< double > m_delta_ragged
API::MatrixWorkspace_sptr rebinRagged(API::MatrixWorkspace_sptr matrixws, const bool inDspace)
RebinRagged this should only be done on the final focussed workspace.
API::MatrixWorkspace_sptr m_outputW
double getVecPropertyFromPmOrSelf(const std::string &name, std::vector< double > &avec)
Function to get a vector property either from a PropertyManager or the algorithm properties.
API::MatrixWorkspace_sptr convertUnits(API::MatrixWorkspace_sptr matrixws, const std::string &target)
Convert units.
API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr matrixws)
Rebin.
std::vector< double > phis
void compressEventsOutputWS(const double compressEventsTolerance, const double wallClockTolerance)
std::vector< double > m_dmaxs
std::map< std::string, std::string > validateInputs() override
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::size_t numEvents(Nexus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix)
Get the number of events in the currently opened group.
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< OffsetsWorkspace > OffsetsWorkspace_sptr
shared pointer to the OffsetsWorkspace class
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
const std::string BINMODE("BinningMode")
const std::string OUTPUT_WKSP("OutputWorkspace")
const std::string INPUT_WKSP("InputWorkspace")
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ InOut
Both an input & output workspace.
@ Input
An input workspace.
@ Output
An output workspace.