38using namespace Kernel;
46const std::string INPUT_WKSP(
"InputWorkspace");
47const std::string OUTPUT_WKSP(
"OutputWorkspace");
48const std::string UNFOCUS_WKSP(
"UnfocussedWorkspace");
49const std::string CAL_FILE(
"CalFileName");
50const std::string GROUP_FILE(
"GroupFilename");
51const std::string GROUP_WKSP(
"GroupingWorkspace");
52const std::string CAL_WKSP(
"CalibrationWorkspace");
53const std::string OFFSET_WKSP(
"OffsetsWorkspace");
54const std::string MASK_WKSP(
"MaskWorkspace");
55const std::string MASK_TABLE(
"MaskBinTable");
56const std::string BINNING(
"Params");
57const std::string RESAMPLEX(
"ResampleX");
58const std::string BIN_IN_D(
"Dspacing");
59const std::string D_MINS(
"DMin");
60const std::string D_MAXS(
"DMax");
61const std::string RAGGED_DELTA(
"DeltaRagged");
62const std::string TOF_MIN(
"TMin");
63const std::string TOF_MAX(
"TMax");
64const std::string WL_MIN(
"CropWavelengthMin");
65const std::string WL_MAX(
"CropWavelengthMax");
66const std::string PRESERVE_EVENTS(
"PreserveEvents");
67const std::string REMOVE_PROMPT_PULSE(
"RemovePromptPulseWidth");
68const std::string RESONANCE_UNITS(
"ResonanceFilterUnits");
69const std::string RESONANCE_LOWER_LIMITS(
"ResonanceFilterLowerLimits");
70const std::string RESONANCE_UPPER_LIMITS(
"ResonanceFilterUpperLimits");
71const std::string COMPRESS_TOF_TOL(
"CompressTolerance");
72const std::string COMPRESS_WALL_TOL(
"CompressWallClockTolerance");
73const std::string COMPRESS_WALL_START(
"CompressStartTime");
74const std::string COMPRESS_MODE(
"CompressBinningMode");
75const std::string L1(
"PrimaryFlightPath");
76const std::string SPEC_IDS(
"SpectrumIDs");
77const std::string L2(
"L2");
78const std::string POLAR(
"Polar");
79const std::string AZIMUTHAL(
"Azimuthal");
80const std::string PM_NAME(
"ReductionProperties");
81const std::string LORENTZ(
"LorentzCorrection");
85 if (
const auto eventWksp = std::dynamic_pointer_cast<const EventWorkspace>(wksp)) {
86 eventWksp->getEventXMinMax(tmin, tmax);
88 std::tie(tmin, tmax) = wksp->getXMinMax();
92const std::vector<std::string> binningModeNames{
"Default",
"Linear",
"Logarithmic"};
106 "The input workspace");
109 "The result of diffraction focussing of InputWorkspace");
112 "Treated data in d-spacing before focussing (optional). This will likely "
120 std::vector<std::string>{
".h5",
".hd5",
".hdf",
".cal"}),
121 "The name of the calibration file with offset, masking, and "
124 std::vector<std::string>{
".xml",
".cal"}),
125 "Overrides grouping from CalFileName");
128 "Optional: A GroupingWorkspace giving the grouping info.");
132 "Optional: A Workspace containing the calibration information. Either "
133 "this or CalibrationFile needs to be specified.");
136 "Optional: An OffsetsWorkspace giving the detector calibration values.");
139 "Optional: A workspace giving which detectors are masked.");
142 "Optional: A workspace giving pixels and bins to mask.");
145 "A comma separated list of first bin boundary, width, last bin boundary. "
147 "this can be followed by a comma and more widths and last boundary "
149 "Negative width values indicate logarithmic binning.");
150 declareProperty(PropertyNames::RESAMPLEX, 0,
151 "Number of bins in x-axis. Non-zero value "
152 "overrides \"Params\" property. Negative "
153 "value means logarithmic binning.");
154 setPropertySettings(PropertyNames::BINNING,
155 std::make_unique<EnabledWhenProperty>(PropertyNames::RESAMPLEX,
IS_DEFAULT));
156 declareProperty(PropertyNames::BIN_IN_D,
true,
"Bin in Dspace. (True is Dspace; False is TOF)");
158 "Minimum for Dspace axis. (Default 0.) ");
159 mapPropertyName(PropertyNames::D_MINS,
"d_min");
161 "Maximum for Dspace axis. (Default 0.) ");
162 mapPropertyName(PropertyNames::D_MAXS,
"d_max");
163 declareProperty(std::make_unique<
ArrayProperty<double>>(PropertyNames::RAGGED_DELTA),
"Step parameter for rebin");
164 mapPropertyName(PropertyNames::RAGGED_DELTA,
"delta");
165 declareProperty(PropertyNames::TOF_MIN,
EMPTY_DBL(),
"Minimum for TOF axis. Defaults to 0. ");
166 mapPropertyName(PropertyNames::TOF_MIN,
"tof_min");
167 declareProperty(PropertyNames::TOF_MAX,
EMPTY_DBL(),
"Maximum for TOF or dspace axis. Defaults to 0. ");
168 mapPropertyName(PropertyNames::TOF_MAX,
"tof_max");
169 declareProperty(PropertyNames::PRESERVE_EVENTS,
true,
170 "If the InputWorkspace is an "
171 "EventWorkspace, this will preserve "
172 "the full event list (warning: this "
173 "will use much more memory!).");
174 declareProperty(PropertyNames::REMOVE_PROMPT_PULSE, 0.,
175 "Width of events (in "
176 "microseconds) near the prompt "
177 "pulse to remove. 0 disables");
178 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
179 mustBePositive->setLower(0.0);
181 std::vector<std::string> allowedResonanceUnits({
"Energy",
"Wavelength"});
182 declareProperty(PropertyNames::RESONANCE_UNITS, allowedResonanceUnits.back(),
183 std::make_shared<StringListValidator>(allowedResonanceUnits),
184 "Units for resonances to be filtered in. "
185 "The data will be converted to these units temporarily to filter.");
187 "Minimum values to filter absorption resonance. This must have same number of values as "
188 "ResonanceFilterUpperLimits. Default behavior is to not filter.");
190 "Maximum values to filter absorption resonance. This must have same number of values as "
191 "ResonanceFilterLowerLimits. Default behavior is to not filter.");
194 "Compress events (in microseconds) within this tolerance. (Default 1e-5). If negative then do "
195 "logorithmic compression.");
198 "The tolerance (in seconds) on the wall-clock time for comparison. Unset "
199 "means compressing all wall-clock times together disabling pulsetime "
201 auto dateValidator = std::make_shared<DateTimeValidator>();
202 dateValidator->allowEmpty(
true);
203 declareProperty(PropertyNames::COMPRESS_WALL_START,
"", dateValidator,
204 "An ISO formatted date/time string specifying the timestamp for "
205 "starting filtering. Ignored if WallClockTolerance is not specified. "
206 "Default is start of run",
208 declareProperty(PropertyNames::COMPRESS_MODE, binningModeNames[
size_t(BinningMode::DEFAULT)],
209 std::make_shared<Mantid::Kernel::StringListValidator>(binningModeNames),
210 "Optional. Binning behavior can be specified in the usual way through sign of tolerance "
211 "('Default'); or can be set to one of the allowed binning modes. ");
212 declareProperty(PropertyNames::LORENTZ,
false,
213 "Multiply each spectrum by "
214 "sin(theta) where theta is "
215 "half of the Bragg angle");
216 declareProperty(
"CropWavelengthMin", 0.,
"Crop the data at this minimum wavelength.");
217 mapPropertyName(PropertyNames::WL_MIN,
"wavelength_min");
218 declareProperty(
"CropWavelengthMax",
EMPTY_DBL(),
219 "Crop the data at this maximum wavelength. Forces use of "
220 "CropWavelengthMin.");
221 mapPropertyName(PropertyNames::WL_MAX,
"wavelength_max");
222 declareProperty(PropertyNames::L1, -1.0,
"If positive, focus positions are changed. (Default -1) ");
224 "Optional: Spectrum Nos (note that it is not detector ID or "
225 "workspace indices).");
227 "Optional: Secondary flight (L2) paths for each detector");
229 "Optional: Polar angles (two thetas) for detectors");
231 "Azimuthal angles (out-of-plain) for detectors");
233 declareProperty(PropertyNames::PM_NAME,
"__powdereduction",
Direction::Input);
237 std::map<std::string, std::string> result;
239 if (!isDefault(PropertyNames::UNFOCUS_WKSP)) {
242 result[PropertyNames::UNFOCUS_WKSP] =
"Cannot be the same as OutputWorkspace";
246 if ((!isDefault(PropertyNames::RAGGED_DELTA)) && (!isDefault(PropertyNames::RESAMPLEX))) {
247 result[PropertyNames::RAGGED_DELTA] =
"Cannot specify with " + PropertyNames::RESAMPLEX;
248 result[PropertyNames::RESAMPLEX] =
"Cannot specify with " + PropertyNames::RAGGED_DELTA;
252 auto inputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_inputW);
253 if (inputEW && inputEW->getNumberEvents() <= 0)
255 "Please plot the pCharge-time to identify suitable range for "
265 for (
size_t i = 0; i < NUM_WINDOWS; ++i) {
270 const std::string msg =
"Lower limits must be less than upper limits";
271 result[PropertyNames::RESONANCE_LOWER_LIMITS] = msg;
272 result[PropertyNames::RESONANCE_UPPER_LIMITS] = msg;
275 result[PropertyNames::RESONANCE_LOWER_LIMITS] =
276 "Must have same number of values as " + PropertyNames::RESONANCE_UPPER_LIMITS;
277 result[PropertyNames::RESONANCE_UPPER_LIMITS] =
278 "Must have same number of values as " + PropertyNames::RESONANCE_LOWER_LIMITS;
336 const bool applyLorentz =
getProperty(PropertyNames::LORENTZ);
345 double compressEventsTolerance =
getProperty(PropertyNames::COMPRESS_TOF_TOL);
346 const double wallClockTolerance =
getProperty(PropertyNames::COMPRESS_WALL_TOL);
348 if (mode == BinningMode::LINEAR)
349 compressEventsTolerance = std::fabs(compressEventsTolerance);
350 else if (mode == BinningMode::LOGARITHMIC)
351 compressEventsTolerance = -1. * std::fabs(compressEventsTolerance);
363 if (
m_params.size() == 1 && (!isEmpty(dmin)) && (!isEmpty(dmax))) {
364 if (dmin > 0. && dmax > dmin) {
373 g_log.
warning() <<
"something is wrong with dmin (" << dmin <<
") and dmax (" << dmax
374 <<
"). They are being ignored.\n";
388 <<
"). They are being ignored.\n";
409 if (
auto inputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_inputW)) {
414 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputEW);
424 m_progress = std::make_unique<Progress>(
this, 0., 1., 21);
427 g_log.
information() <<
"running MaskDetectors started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
432 maskDetAlg->setProperty(
"Workspace", outputw);
434 maskDetAlg->setProperty(
"MaskedWorkspace", mksws);
435 maskDetAlg->executeAsChildAlg();
436 outputw = maskDetAlg->getProperty(
"Workspace");
438 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
447 if (((!isEmpty(
xmin)) && (
xmin >= 0.)) || ((!isEmpty(
xmax)) && (
xmax > 0.))) {
451 cropAlg->setProperty(
"InputWorkspace",
m_outputW);
452 cropAlg->setProperty(
"OutputWorkspace",
m_outputW);
453 bool setxmin =
false;
454 if ((
xmin >= 0.) && (
xmin > tofmin)) {
455 cropAlg->setProperty(
"Xmin",
xmin);
459 bool setxmax =
false;
460 if ((
xmax > 0.) && (
xmax < tofmax)) {
461 cropAlg->setProperty(
"Xmax",
xmax);
466 if (setxmin || setxmax) {
468 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
469 cropAlg->executeAsChildAlg();
470 m_outputW = cropAlg->getProperty(
"OutputWorkspace");
476 const double removePromptPulseWidth =
getProperty(PropertyNames::REMOVE_PROMPT_PULSE);
477 if (removePromptPulseWidth > 0.) {
478 bool removePromptPulse(
false);
479 if (
auto outputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW)) {
480 removePromptPulse = (outputEW->getNumberEvents() > 0);
482 if (removePromptPulse) {
483 g_log.
information() <<
"running RemovePromptPulse(Width=" << removePromptPulseWidth <<
") started at "
484 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
486 filterPAlg->setProperty(
"InputWorkspace",
m_outputW);
487 filterPAlg->setProperty(
"OutputWorkspace",
m_outputW);
488 filterPAlg->setProperty(
"Width", removePromptPulseWidth);
492 filterPAlg->setProperty(
"TMin", tofmin);
493 filterPAlg->setProperty(
"TMax", tofmax);
495 filterPAlg->executeAsChildAlg();
496 m_outputW = filterPAlg->getProperty(
"OutputWorkspace");
503 if (maskBinTableWS) {
504 g_log.
information() <<
"running MaskBinsFromTable started at " << Types::Core::DateAndTime::getCurrentTime()
507 alg->setProperty(
"InputWorkspace",
m_outputW);
508 alg->setProperty(
"OutputWorkspace",
m_outputW);
509 alg->setProperty(
"MaskingInformation", maskBinTableWS);
510 alg->executeAsChildAlg();
511 m_outputW = alg->getProperty(
"OutputWorkspace");
527 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
530 applyDiffCalAlg->setProperty(
"InstrumentWorkspace", outputw);
532 applyDiffCalAlg->executeAsChildAlg();
534 outputw = applyDiffCalAlg->getProperty(
"InstrumentWorkspace");
535 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
553 applyDiffCalAlg->setProperty(
"InstrumentWorkspace", outputw);
554 applyDiffCalAlg->setProperty(
"ClearCalibration",
true);
555 applyDiffCalAlg->executeAsChildAlg();
557 outputw = applyDiffCalAlg->getProperty(
"InstrumentWorkspace");
558 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
570 g_log.
information() <<
"Applying Lorentz correction started at " << Types::Core::DateAndTime::getCurrentTime()
574 alg->setProperty(
"InputWorkspace",
m_outputW);
575 alg->setProperty(
"OutputWorkspace",
m_outputW);
576 alg->setPropertyValue(
"Type",
"PowderTOF");
577 alg->executeAsChildAlg();
578 m_outputW = alg->getProperty(
"OutputWorkspace");
585 if (
const auto ews = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW))
586 g_log.
information() <<
"Number of events = " << ews->getNumberEvents() <<
".\n";
593 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
596 removeAlg->setProperty(
"InputWorkspace",
m_outputW);
597 removeAlg->setProperty(
"OutputWorkspace",
m_outputW);
598 removeAlg->setProperty(
"XMin",
minwl);
599 removeAlg->setProperty(
"XMax",
maxwl);
600 removeAlg->executeAsChildAlg();
601 m_outputW = removeAlg->getProperty(
"OutputWorkspace");
602 if (
const auto ews = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW))
603 g_log.
information() <<
"Number of events = " << ews->getNumberEvents() <<
".\n";
620 if (!isDefault(
"UnfocussedWorkspace")) {
622 setProperty(
"UnfocussedWorkspace", std::move(wkspCopy));
650 }
catch (std::runtime_error &e) {
670 setProperty(
"OutputWorkspace",
m_outputW);
677 const std::vector<double> &polars,
678 const std::vector<specnum_t> &specids,
679 const std::vector<double> &l2s,
680 const std::vector<double> &phis) {
681 g_log.
information() <<
"running EditInstrumentGeometry started at " << Types::Core::DateAndTime::getCurrentTime()
685 editAlg->setProperty(
"Workspace", ws);
687 editAlg->setProperty(
"PrimaryFlightPath",
m_l1);
689 editAlg->setProperty(
"Polar", polars);
691 editAlg->setProperty(
"SpectrumIDs",
specids);
693 editAlg->setProperty(
"L2",
l2s);
695 editAlg->setProperty(
"Azimuthal",
phis);
696 editAlg->executeAsChildAlg();
698 ws = editAlg->getProperty(
"Workspace");
716 g_log.
information() <<
"running DiffractionFocussing(PreserveEvents=" << preserveEvents <<
") started at "
717 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
720 focusAlg->setProperty(
"InputWorkspace", ws);
721 focusAlg->setProperty(
"OutputWorkspace", ws);
722 focusAlg->setProperty(
"GroupingWorkspace",
m_groupWS);
723 focusAlg->setProperty(
"PreserveEvents", preserveEvents);
724 focusAlg->executeAsChildAlg();
725 ws = focusAlg->getProperty(
"OutputWorkspace");
740 focusAlg->setProperty(
"InputWorkspace", ws);
741 focusAlg->setProperty(
"OutputWorkspace", ws);
742 focusAlg->setProperty(
"GroupingWorkspace",
m_groupWS);
744 focusAlg->setProperty(
"DMin",
m_dmins);
745 focusAlg->setProperty(
"DMax",
m_dmaxs);
752 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
754 focusAlg->executeAsChildAlg();
755 ws = focusAlg->getProperty(
"OutputWorkspace");
763 const std::string &target) {
764 g_log.
information() <<
"running ConvertUnits(Target=" << target <<
") started at "
765 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
768 convert2Alg->setProperty(
"InputWorkspace", matrixws);
769 convert2Alg->setProperty(
"OutputWorkspace", matrixws);
770 convert2Alg->setProperty(
"Target", target);
771 convert2Alg->executeAsChildAlg();
773 matrixws = convert2Alg->getProperty(
"OutputWorkspace");
780 const std::string PREVIOUS_UNITS(matrixws->getAxis(0)->unit()->unitID());
789 for (
size_t i = 0; i < NUM_WINDOWS; ++i) {
791 <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
792 maskBinsAlg->setProperty(
"InputWorkspace", matrixws);
793 maskBinsAlg->setProperty(
"OutputWorkspace", matrixws);
796 maskBinsAlg->executeAsChildAlg();
798 matrixws = maskBinsAlg->getProperty(
"OutputWorkspace");
816 <<
", dMin(" <<
m_dmins.size() <<
"), dmax(" <<
m_dmaxs.size() <<
")) started at "
817 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
819 alg->setProperty(
"InputWorkspace", matrixws);
820 alg->setProperty(
"OutputWorkspace", matrixws);
822 size_t numHist =
m_outputW->getNumberHistograms();
824 alg->setProperty(
"XMin",
m_dmins);
825 alg->setProperty(
"XMax",
m_dmaxs);
828 <<
"number of workspace indices. Ignoring the parameters.\n";
833 alg->executeAsChildAlg();
834 matrixws = alg->getProperty(
"OutputWorkspace");
840 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
846 rebin3Alg->setProperty(
"InputWorkspace", matrixws);
847 rebin3Alg->setProperty(
"OutputWorkspace", matrixws);
848 rebin3Alg->setProperty(
"Params",
m_params);
849 rebin3Alg->executeAsChildAlg();
850 matrixws = rebin3Alg->getProperty(
"OutputWorkspace");
860 bool print_xmin =
false;
861 bool print_xmax =
false;
868 alg->setProperty(
"XMin",
m_dmins);
872 alg->setProperty(
"XMax",
m_dmaxs);
878 alg->setProperty(
"XMin", std::vector<double>(1,
tmin));
883 alg->setProperty(
"XMax", std::vector<double>(1,
tmax));
887 alg->setProperty(
"InputWorkspace", matrixws);
888 alg->setProperty(
"OutputWorkspace", matrixws);
898 g_log.
information() <<
" ) started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
901 alg->executeAsChildAlg();
902 matrixws = alg->getProperty(
"OutputWorkspace");
911 alg->setProperty(
"OffsetsWorkspace", offsetsWS);
912 alg->setPropertyValue(
"OutputWorkspace",
m_instName +
"_cal");
913 alg->executeAsChildAlg();
927 if ((!
m_groupWS) && (!calFilename.empty()) && (!groupFilename.empty())) {
928 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_group"))
936 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_cal"))
939 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_offsets")) {
946 if ((!
m_maskWS) && (!calFilename.empty())) {
947 if (AnalysisDataService::Instance().doesExist(
m_instName +
"_mask"))
956 if (calFilename.empty() && groupFilename.empty())
964 if (calFilename.empty()) {
965 g_log.
information() <<
"Loading Grouping file \"" << groupFilename <<
"\"\n";
968 alg->setProperty(
"InputFile", groupFilename);
969 alg->setProperty(
"InputWorkspace",
m_inputW);
970 alg->executeAsChildAlg();
972 m_groupWS = alg->getProperty(
"OutputWorkspace");
973 const std::string groupname =
m_instName +
"_group";
974 AnalysisDataService::Instance().addOrReplace(groupname,
m_groupWS);
975 this->setPropertyValue(PropertyNames::GROUP_WKSP, groupname);
977 g_log.
information() <<
"Loading Calibration file \"" << calFilename <<
"\"";
978 if (!groupFilename.empty())
983 alg->setProperty(
"InputWorkspace",
m_inputW);
984 alg->setPropertyValue(
"Filename", calFilename);
985 alg->setPropertyValue(
"GroupFilename", groupFilename);
986 alg->setProperty<
bool>(
"MakeCalWorkspace", loadCalibration);
987 alg->setProperty<
bool>(
"MakeGroupingWorkspace", loadGrouping);
988 alg->setProperty<
bool>(
"MakeMaskWorkspace", loadMask);
989 alg->setProperty<
double>(
"TofMin",
getProperty(
"TMin"));
990 alg->setProperty<
double>(
"TofMax",
getProperty(
"TMax"));
991 alg->setPropertyValue(
"WorkspaceName",
m_instName);
992 alg->executeAsChildAlg();
996 m_groupWS = alg->getProperty(
"OutputGroupingWorkspace");
998 const std::string groupname =
m_instName +
"_group";
999 AnalysisDataService::Instance().addOrReplace(groupname,
m_groupWS);
1000 this->setPropertyValue(PropertyNames::GROUP_WKSP, groupname);
1002 if (loadCalibration) {
1005 const std::string calname =
m_instName +
"_cal";
1006 AnalysisDataService::Instance().addOrReplace(calname,
m_calibrationWS);
1007 this->setPropertyValue(PropertyNames::CAL_WKSP, calname);
1010 m_maskWS = alg->getProperty(
"OutputMaskWorkspace");
1012 const std::string maskname =
m_instName +
"_mask";
1013 AnalysisDataService::Instance().addOrReplace(maskname,
m_maskWS);
1014 this->setPropertyValue(PropertyNames::MASK_WKSP, maskname);
1020 const double wallClockTolerance) {
1021 if (compressEventsTolerance == 0.)
1024 if (
auto outputEW = std::dynamic_pointer_cast<EventWorkspace>(
m_outputW)) {
1025 g_log.
information() <<
"running CompressEvents(Tolerance=" << compressEventsTolerance;
1026 if (!isEmpty(wallClockTolerance))
1028 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
1030 compressAlg->setProperty(
"InputWorkspace", outputEW);
1031 compressAlg->setProperty(
"OutputWorkspace", outputEW);
1032 compressAlg->setProperty(
"Tolerance", compressEventsTolerance);
1033 if (!isEmpty(wallClockTolerance)) {
1034 compressAlg->setProperty(
"WallClockTolerance", wallClockTolerance);
1035 compressAlg->setPropertyValue(
"StartTime",
getPropertyValue(PropertyNames::COMPRESS_WALL_START));
1037 compressAlg->executeAsChildAlg();
1038 outputEW = compressAlg->getProperty(
"OutputWorkspace");
1039 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputEW);
1049 const double tofmax,
const bool hasWallClockTolerance) {
1051 if (hasWallClockTolerance)
1054 if (compressTolerance == 0.)
1057 if (
const auto eventWS = std::dynamic_pointer_cast<const EventWorkspace>(
m_outputW)) {
1060 double tofmin_wksp = tofmin;
1061 double tofmax_wksp = tofmax;
1062 if (isEmpty(tofmin) || isEmpty(tofmax))
1063 getTofRange(
m_outputW, tofmin_wksp, tofmax_wksp);
1064 const double tofRange = std::fabs(tofmax_wksp - tofmin_wksp);
1067 constexpr double TOF_EVENT_BYTE_SIZE{
static_cast<double>(
sizeof(Types::Event::TofEvent))};
1068 constexpr double WEIGHTED_EVENT_BYTE_SIZE{
static_cast<double>(
sizeof(
WeightedEvent))};
1069 constexpr double WEIGHTED_NOTIME_EVENT_BYTE_SIZE{
static_cast<double>(
sizeof(
WeightedEventNoTime))};
1073 double sizeWeightedEventsEstimate;
1074 if (compressTolerance > 0)
1075 sizeWeightedEventsEstimate = WEIGHTED_NOTIME_EVENT_BYTE_SIZE * tofRange / compressTolerance;
1077 if (tofmin_wksp < 0)
1080 if (tofmin_wksp == 0)
1081 tofmin_wksp = compressTolerance;
1083 sizeWeightedEventsEstimate =
1084 WEIGHTED_NOTIME_EVENT_BYTE_SIZE * log(tofmax_wksp / tofmin_wksp) / log1p(abs(compressTolerance));
1087 double numEvents =
static_cast<double>(eventWS->getNumberEvents());
1088 const auto eventType = eventWS->getEventType();
1105 <<
" and comparing to " << sizeWeightedEventsEstimate <<
"\n";
1106 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.