37using namespace Kernel;
45const std::string INPUT_WKSP(
"InputWorkspace");
46const std::string OUTPUT_WKSP(
"OutputWorkspace");
47const std::string UNFOCUS_WKSP(
"UnfocussedWorkspace");
48const std::string CAL_FILE(
"CalFileName");
49const std::string GROUP_FILE(
"GroupFilename");
50const std::string GROUP_WKSP(
"GroupingWorkspace");
51const std::string CAL_WKSP(
"CalibrationWorkspace");
52const std::string OFFSET_WKSP(
"OffsetsWorkspace");
53const std::string MASK_WKSP(
"MaskWorkspace");
54const std::string MASK_TABLE(
"MaskBinTable");
55const std::string BINNING(
"Params");
56const std::string RESAMPLEX(
"ResampleX");
57const std::string BIN_IN_D(
"Dspacing");
58const std::string D_MINS(
"DMin");
59const std::string D_MAXS(
"DMax");
60const std::string RAGGED_DELTA(
"DeltaRagged");
61const std::string TOF_MIN(
"TMin");
62const std::string TOF_MAX(
"TMax");
63const std::string WL_MIN(
"CropWavelengthMin");
64const std::string WL_MAX(
"CropWavelengthMax");
65const std::string PRESERVE_EVENTS(
"PreserveEvents");
66const std::string REMOVE_PROMPT_PULSE(
"RemovePromptPulseWidth");
67const std::string RESONANCE_UNITS(
"ResonanceFilterUnits");
68const std::string RESONANCE_LOWER_LIMITS(
"ResonanceFilterLowerLimits");
69const std::string RESONANCE_UPPER_LIMITS(
"ResonanceFilterUpperLimits");
70const std::string COMPRESS_TOF_TOL(
"CompressTolerance");
71const std::string COMPRESS_WALL_TOL(
"CompressWallClockTolerance");
72const std::string COMPRESS_WALL_START(
"CompressStartTime");
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");
80const std::string UNWRAP_REF(
"UnwrapRef");
81const std::string LOWRES_REF(
"LowResRef");
82const std::string LOWRES_SPEC_OFF(
"LowResSpectrumOffset");
94 "The input workspace");
97 "The result of diffraction focussing of InputWorkspace");
100 "Treated data in d-spacing before focussing (optional). This will likely "
108 std::vector<std::string>{
".h5",
".hd5",
".hdf",
".cal"}),
109 "The name of the calibration file with offset, masking, and "
112 std::vector<std::string>{
".xml",
".cal"}),
113 "Overrides grouping from CalFileName");
116 "Optional: A GroupingWorkspace giving the grouping info.");
120 "Optional: A Workspace containing the calibration information. Either "
121 "this or CalibrationFile needs to be specified.");
124 "Optional: An OffsetsWorkspace giving the detector calibration values.");
127 "Optional: A workspace giving which detectors are masked.");
130 "Optional: A workspace giving pixels and bins to mask.");
133 "A comma separated list of first bin boundary, width, last bin boundary. "
135 "this can be followed by a comma and more widths and last boundary "
137 "Negative width values indicate logarithmic binning.");
138 declareProperty(PropertyNames::RESAMPLEX, 0,
139 "Number of bins in x-axis. Non-zero value "
140 "overrides \"Params\" property. Negative "
141 "value means logarithmic binning.");
142 setPropertySettings(PropertyNames::BINNING,
143 std::make_unique<EnabledWhenProperty>(PropertyNames::RESAMPLEX,
IS_DEFAULT));
144 declareProperty(PropertyNames::BIN_IN_D,
true,
"Bin in Dspace. (True is Dspace; False is TOF)");
146 "Minimum for Dspace axis. (Default 0.) ");
147 mapPropertyName(PropertyNames::D_MINS,
"d_min");
149 "Maximum for Dspace axis. (Default 0.) ");
150 mapPropertyName(PropertyNames::D_MAXS,
"d_max");
151 declareProperty(std::make_unique<
ArrayProperty<double>>(PropertyNames::RAGGED_DELTA),
"Step parameter for rebin");
152 mapPropertyName(PropertyNames::RAGGED_DELTA,
"delta");
153 declareProperty(PropertyNames::TOF_MIN,
EMPTY_DBL(),
"Minimum for TOF axis. Defaults to 0. ");
154 mapPropertyName(PropertyNames::TOF_MIN,
"tof_min");
155 declareProperty(PropertyNames::TOF_MAX,
EMPTY_DBL(),
"Maximum for TOF or dspace axis. Defaults to 0. ");
156 mapPropertyName(PropertyNames::TOF_MAX,
"tof_max");
157 declareProperty(PropertyNames::PRESERVE_EVENTS,
true,
158 "If the InputWorkspace is an "
159 "EventWorkspace, this will preserve "
160 "the full event list (warning: this "
161 "will use much more memory!).");
162 declareProperty(PropertyNames::REMOVE_PROMPT_PULSE, 0.,
163 "Width of events (in "
164 "microseconds) near the prompt "
165 "pulse to remove. 0 disables");
166 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
167 mustBePositive->setLower(0.0);
169 std::vector<std::string> allowedResonanceUnits({
"Energy",
"Wavelength"});
170 declareProperty(PropertyNames::RESONANCE_UNITS, allowedResonanceUnits.back(),
171 std::make_shared<StringListValidator>(allowedResonanceUnits),
172 "Units for resonances to be filtered in. "
173 "The data will be converted to these units temporarily to filter.");
175 "Minimum values to filter absorption resonance. This must have same number of values as "
176 "ResonanceFilterUpperLimits. Default behavior is to not filter.");
178 "Maximum values to filter absorption resonance. This must have same number of values as "
179 "ResonanceFilterLowerLimits. Default behavior is to not filter.");
183 "Compress events (in "
184 "microseconds) within this "
185 "tolerance. (Default 1e-5)");
188 "The tolerance (in seconds) on the wall-clock time for comparison. Unset "
189 "means compressing all wall-clock times together disabling pulsetime "
192 auto dateValidator = std::make_shared<DateTimeValidator>();
193 dateValidator->allowEmpty(
true);
194 declareProperty(PropertyNames::COMPRESS_WALL_START,
"", dateValidator,
195 "An ISO formatted date/time string specifying the timestamp for "
196 "starting filtering. Ignored if WallClockTolerance is not specified. "
197 "Default is start of run",
199 declareProperty(PropertyNames::LORENTZ,
false,
200 "Multiply each spectrum by "
201 "sin(theta) where theta is "
202 "half of the Bragg angle");
203 declareProperty(PropertyNames::UNWRAP_REF, 0.,
204 "Reference total flight path for frame "
205 "unwrapping. Zero skips the correction");
206 declareProperty(PropertyNames::LOWRES_REF, 0.,
"Reference DIFC for resolution removal. Zero skips the correction");
207 declareProperty(
"CropWavelengthMin", 0.,
"Crop the data at this minimum wavelength. Overrides LowResRef.");
208 mapPropertyName(PropertyNames::WL_MIN,
"wavelength_min");
209 declareProperty(
"CropWavelengthMax",
EMPTY_DBL(),
210 "Crop the data at this maximum wavelength. Forces use of "
211 "CropWavelengthMin.");
212 mapPropertyName(PropertyNames::WL_MAX,
"wavelength_max");
213 declareProperty(PropertyNames::L1, -1.0,
"If positive, focus positions are changed. (Default -1) ");
215 "Optional: Spectrum Nos (note that it is not detector ID or "
216 "workspace indices).");
218 "Optional: Secondary flight (L2) paths for each detector");
220 "Optional: Polar angles (two thetas) for detectors");
222 "Azimuthal angles (out-of-plain) for detectors");
224 declareProperty(PropertyNames::LOWRES_SPEC_OFF, -1,
225 "Offset on spectrum No of low resolution spectra from high "
227 "If negative, then all the low resolution TOF will not be "
228 "processed. Otherwise, low resolution TOF "
229 "will be stored in an additional set of spectra. "
230 "If offset is equal to 0, then the low resolution will have "
231 "same spectrum Nos as the normal ones. "
232 "Otherwise, the low resolution spectra will have spectrum "
233 "IDs offset from normal ones. ");
234 declareProperty(PropertyNames::PM_NAME,
"__powdereduction",
Direction::Input);
238 std::map<std::string, std::string> result;
240 if (!isDefault(PropertyNames::UNFOCUS_WKSP)) {
242 result[PropertyNames::OUTPUT_WKSP] =
"Cannot be the same as UnfocussedWorkspace";
243 result[PropertyNames::UNFOCUS_WKSP] =
"Cannot be the same as OutputWorkspace";
247 if ((!isDefault(PropertyNames::RAGGED_DELTA)) && (!isDefault(PropertyNames::RESAMPLEX))) {
248 result[PropertyNames::RAGGED_DELTA] =
"Cannot specify with " + PropertyNames::RESAMPLEX;
249 result[PropertyNames::RESAMPLEX] =
"Cannot specify with " + PropertyNames::RAGGED_DELTA;
255 result[PropertyNames::INPUT_WKSP] =
"Empty workspace encounter, possibly due to beam down."
256 "Please plot the pCharge-time to identify suitable range for "
266 for (
size_t i = 0; i < NUM_WINDOWS; ++i) {
271 const std::string msg =
"Lower limits must be less than upper limits";
272 result[PropertyNames::RESONANCE_LOWER_LIMITS] = msg;
273 result[PropertyNames::RESONANCE_UPPER_LIMITS] = msg;
276 result[PropertyNames::RESONANCE_LOWER_LIMITS] =
277 "Must have same number of values as " + PropertyNames::RESONANCE_UPPER_LIMITS;
278 result[PropertyNames::RESONANCE_UPPER_LIMITS] =
279 "Must have same number of values as " + PropertyNames::RESONANCE_LOWER_LIMITS;
290template <
typename NumT>
297 if (orig.size() == numVal) {
298 out.
reg.assign(orig.begin(), orig.end());
299 out.
low.assign(orig.begin(), orig.end());
300 }
else if (orig.size() == 2 * numVal) {
301 out.
reg.assign(orig.begin(), orig.begin() + numVal);
302 out.
low.assign(orig.begin() + numVal, orig.begin());
304 std::stringstream msg;
305 msg <<
"Input number of " << label <<
" ids is not equal to "
306 <<
"the number of histograms or empty (" << orig.size() <<
" != 0 or " << numVal <<
" or " << (2 * numVal)
308 throw std::runtime_error(msg.str());
369 const bool applyLorentz =
getProperty(PropertyNames::LORENTZ);
378 const double compressEventsTolerance =
getProperty(PropertyNames::COMPRESS_TOF_TOL);
379 const double wallClockTolerance =
getProperty(PropertyNames::COMPRESS_WALL_TOL);
390 if (
m_params.size() == 1 && (!isEmpty(dmin)) && (!isEmpty(dmax))) {
391 if (dmin > 0. && dmax > dmin) {
400 g_log.
warning() <<
"something is wrong with dmin (" << dmin <<
") and dmax (" << dmax
401 <<
"). They are being ignored.\n";
415 <<
"). They are being ignored.\n";
433 int lowresoffset =
getProperty(PropertyNames::LOWRES_SPEC_OFF);
434 if (lowresoffset < 0) {
464 throw std::runtime_error(
"Input workspace is not EventWorkspace. It is not supported now.");
467 m_lowResEW = std::dynamic_pointer_cast<EventWorkspace>(
477 m_progress = std::make_unique<Progress>(
this, 0., 1., 22);
480 if (compressEventsTolerance > 0.) {
481 g_log.
information() <<
"running CompressEvents(Tolerance=" << compressEventsTolerance;
482 if (!isEmpty(wallClockTolerance))
484 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
486 compressAlg->setProperty(
"InputWorkspace",
m_outputEW);
487 compressAlg->setProperty(
"OutputWorkspace",
m_outputEW);
488 compressAlg->setProperty(
"OutputWorkspace",
m_outputEW);
489 compressAlg->setProperty(
"Tolerance", compressEventsTolerance);
490 if (!isEmpty(wallClockTolerance)) {
491 compressAlg->setProperty(
"WallClockTolerance", wallClockTolerance);
492 compressAlg->setPropertyValue(
"StartTime",
getPropertyValue(PropertyNames::COMPRESS_WALL_START));
494 compressAlg->executeAsChildAlg();
495 m_outputEW = compressAlg->getProperty(
"OutputWorkspace");
511 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
513 cropAlg->setProperty(
"InputWorkspace",
m_outputW);
514 cropAlg->setProperty(
"OutputWorkspace",
m_outputW);
515 if ((
xmin >= 0.) && (
xmin > tempmin))
516 cropAlg->setProperty(
"Xmin",
xmin);
517 if ((
xmax > 0.) && (
xmax < tempmax))
518 cropAlg->setProperty(
"Xmax",
xmax);
519 cropAlg->executeAsChildAlg();
520 m_outputW = cropAlg->getProperty(
"OutputWorkspace");
526 double removePromptPulseWidth =
getProperty(PropertyNames::REMOVE_PROMPT_PULSE);
527 if (removePromptPulseWidth > 0.) {
530 g_log.
information() <<
"running RemovePromptPulse(Width=" << removePromptPulseWidth <<
") started at "
531 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
533 filterPAlg->setProperty(
"InputWorkspace",
m_outputW);
534 filterPAlg->setProperty(
"OutputWorkspace",
m_outputW);
535 filterPAlg->setProperty(
"Width", removePromptPulseWidth);
536 filterPAlg->executeAsChildAlg();
537 m_outputW = filterPAlg->getProperty(
"OutputWorkspace");
545 if (maskBinTableWS) {
546 g_log.
information() <<
"running MaskBinsFromTable started at " << Types::Core::DateAndTime::getCurrentTime()
549 alg->setProperty(
"InputWorkspace",
m_outputW);
550 alg->setProperty(
"OutputWorkspace",
m_outputW);
551 alg->setProperty(
"MaskingInformation", maskBinTableWS);
552 alg->executeAsChildAlg();
553 m_outputW = alg->getProperty(
"OutputWorkspace");
559 g_log.
information() <<
"running MaskDetectors started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
564 maskDetAlg->setProperty(
"Workspace", outputw);
566 maskDetAlg->setProperty(
"MaskedWorkspace", mksws);
567 maskDetAlg->executeAsChildAlg();
568 outputw = maskDetAlg->getProperty(
"Workspace");
570 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
582 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
585 applyDiffCalAlg->setProperty(
"InstrumentWorkspace", outputw);
587 applyDiffCalAlg->executeAsChildAlg();
589 outputw = applyDiffCalAlg->getProperty(
"InstrumentWorkspace");
590 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
608 applyDiffCalAlg->setProperty(
"InstrumentWorkspace", outputw);
609 applyDiffCalAlg->setProperty(
"ClearCalibration",
true);
610 applyDiffCalAlg->executeAsChildAlg();
612 outputw = applyDiffCalAlg->getProperty(
"InstrumentWorkspace");
613 m_outputW = std::dynamic_pointer_cast<MatrixWorkspace>(outputw);
625 g_log.
information() <<
"Applying Lorentz correction started at " << Types::Core::DateAndTime::getCurrentTime()
629 alg->setProperty(
"InputWorkspace",
m_outputW);
630 alg->setProperty(
"OutputWorkspace",
m_outputW);
631 alg->setPropertyValue(
"Type",
"PowderTOF");
632 alg->executeAsChildAlg();
633 m_outputW = alg->getProperty(
"OutputWorkspace");
645 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
647 removeAlg->setProperty(
"InputWorkspace",
m_outputW);
648 removeAlg->setProperty(
"OutputWorkspace",
m_outputW);
649 removeAlg->setProperty(
"LRef",
LRef);
651 removeAlg->setProperty(
"Tmin",
tmin);
653 removeAlg->setProperty(
"Tmax",
tmax);
654 removeAlg->executeAsChildAlg();
655 m_outputW = removeAlg->getProperty(
"OutputWorkspace");
665 g_log.
information() <<
"Number of events = " << ews->getNumberEvents() <<
". ";
673 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
676 removeAlg->setProperty(
"InputWorkspace",
m_outputW);
677 removeAlg->setProperty(
"OutputWorkspace",
m_outputW);
678 removeAlg->setProperty(
"XMin",
minwl);
679 removeAlg->setProperty(
"XMax",
maxwl);
680 removeAlg->executeAsChildAlg();
681 m_outputW = removeAlg->getProperty(
"OutputWorkspace");
683 g_log.
information() <<
"Number of events = " << ews->getNumberEvents() <<
".\n";
686 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
689 g_log.
information() <<
"Number of events = " << ews->getNumberEvents() <<
". ";
693 removeAlg->setProperty(
"InputWorkspace",
m_outputW);
694 removeAlg->setProperty(
"OutputWorkspace",
m_outputW);
695 removeAlg->setProperty(
"ReferenceDIFC",
DIFCref);
696 removeAlg->setProperty(
"K", 3.22);
698 removeAlg->setProperty(
"Tmin",
tmin);
700 removeAlg->setProperty(
"LowResTOFWorkspace",
m_lowResW);
702 removeAlg->executeAsChildAlg();
703 m_outputW = removeAlg->getProperty(
"OutputWorkspace");
705 m_lowResW = removeAlg->getProperty(
"LowResTOFWorkspace");
711 size_t numhighevents = ews->getNumberEvents();
714 size_t numlowevents = lowes->getNumberEvents();
715 g_log.
information() <<
"Number of high TOF events = " << numhighevents <<
"; "
716 <<
"Number of low TOF events = " << numlowevents <<
".\n";
743 if (!isDefault(
"UnfocussedWorkspace")) {
745 setProperty(
"UnfocussedWorkspace", std::move(wkspCopy));
776 size_t numreg =
m_outputW->getNumberHistograms();
791 }
catch (std::runtime_error &e) {
810 if ((
m_outputEW) && (compressEventsTolerance > 0.)) {
811 g_log.
information() <<
"running CompressEvents(Tolerance=" << compressEventsTolerance;
812 if (!isEmpty(wallClockTolerance))
814 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
816 compressAlg->setProperty(
"InputWorkspace",
m_outputEW);
817 compressAlg->setProperty(
"OutputWorkspace",
m_outputEW);
818 compressAlg->setProperty(
"Tolerance", compressEventsTolerance);
819 if (!isEmpty(wallClockTolerance)) {
820 compressAlg->setProperty(
"WallClockTolerance", wallClockTolerance);
821 compressAlg->setPropertyValue(
"StartTime",
getPropertyValue(
"CompressStartTime"));
823 compressAlg->executeAsChildAlg();
824 m_outputEW = compressAlg->getProperty(
"OutputWorkspace");
834 setProperty(
"OutputWorkspace",
m_outputW);
841 const std::vector<double> &polars,
842 const std::vector<specnum_t> &specids,
843 const std::vector<double> &l2s,
844 const std::vector<double> &phis) {
845 g_log.
information() <<
"running EditInstrumentGeometry started at " << Types::Core::DateAndTime::getCurrentTime()
849 editAlg->setProperty(
"Workspace", ws);
851 editAlg->setProperty(
"PrimaryFlightPath",
m_l1);
853 editAlg->setProperty(
"Polar", polars);
855 editAlg->setProperty(
"SpectrumIDs",
specids);
857 editAlg->setProperty(
"L2",
l2s);
859 editAlg->setProperty(
"Azimuthal",
phis);
860 editAlg->executeAsChildAlg();
862 ws = editAlg->getProperty(
"Workspace");
878 maskAlg->setProperty(
"Workspace",
m_groupWS);
879 maskAlg->setProperty(
"MaskedWorkspace",
m_maskWS);
880 maskAlg->executeAsChildAlg();
883 g_log.
information() <<
"running DiffractionFocussing started at " << Types::Core::DateAndTime::getCurrentTime()
887 focusAlg->setProperty(
"InputWorkspace", ws);
888 focusAlg->setProperty(
"OutputWorkspace", ws);
889 focusAlg->setProperty(
"GroupingWorkspace",
m_groupWS);
891 focusAlg->executeAsChildAlg();
892 ws = focusAlg->getProperty(
"OutputWorkspace");
901 const std::string &target) {
902 g_log.
information() <<
"running ConvertUnits(Target=" << target <<
") started at "
903 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
906 convert2Alg->setProperty(
"InputWorkspace", matrixws);
907 convert2Alg->setProperty(
"OutputWorkspace", matrixws);
908 convert2Alg->setProperty(
"Target", target);
909 convert2Alg->executeAsChildAlg();
911 matrixws = convert2Alg->getProperty(
"OutputWorkspace");
918 const std::string PREVIOUS_UNITS(matrixws->getAxis(0)->unit()->unitID());
927 for (
size_t i = 0; i < NUM_WINDOWS; ++i) {
929 <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
930 maskBinsAlg->setProperty(
"InputWorkspace", matrixws);
931 maskBinsAlg->setProperty(
"OutputWorkspace", matrixws);
934 maskBinsAlg->executeAsChildAlg();
936 matrixws = maskBinsAlg->getProperty(
"OutputWorkspace");
954 <<
", dMin(" <<
m_dmins.size() <<
"), dmax(" <<
m_dmaxs.size() <<
")) started at "
955 << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
957 alg->setProperty(
"InputWorkspace", matrixws);
958 alg->setProperty(
"OutputWorkspace", matrixws);
960 size_t numHist =
m_outputW->getNumberHistograms();
962 alg->setProperty(
"XMin",
m_dmins);
963 alg->setProperty(
"XMax",
m_dmaxs);
966 <<
"number of workspace indices. Ignoring the parameters.\n";
971 alg->executeAsChildAlg();
972 matrixws = alg->getProperty(
"OutputWorkspace");
978 g_log.
information() <<
") started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
984 rebin3Alg->setProperty(
"InputWorkspace", matrixws);
985 rebin3Alg->setProperty(
"OutputWorkspace", matrixws);
986 rebin3Alg->setProperty(
"Params",
m_params);
987 rebin3Alg->executeAsChildAlg();
988 matrixws = rebin3Alg->getProperty(
"OutputWorkspace");
998 bool print_xmin =
false;
999 bool print_xmax =
false;
1006 alg->setProperty(
"XMin",
m_dmins);
1010 alg->setProperty(
"XMax",
m_dmaxs);
1016 alg->setProperty(
"XMin", std::vector<double>(1,
tmin));
1021 alg->setProperty(
"XMax", std::vector<double>(1,
tmax));
1025 alg->setProperty(
"InputWorkspace", matrixws);
1026 alg->setProperty(
"OutputWorkspace", matrixws);
1035 g_log.
information() <<
" ) started at " << Types::Core::DateAndTime::getCurrentTime() <<
"\n";
1038 alg->executeAsChildAlg();
1039 matrixws = alg->getProperty(
"OutputWorkspace");
1050 size_t nspec1 = ws1->getNumberHistograms();
1052 std::vector<specnum_t> origspecNos;
1053 for (
size_t i = 0; i < nspec1; ++i) {
1054 specnum_t tmpspecNo = ws1->getSpectrum(i).getSpectrumNo();
1055 origspecNos.emplace_back(tmpspecNo);
1056 if (tmpspecNo > maxspecNo1)
1057 maxspecNo1 = tmpspecNo;
1060 g_log.
information() <<
"[DBx536] Max spectrum number of ws1 = " << maxspecNo1 <<
", Offset = " << offset <<
".\n";
1062 size_t nspec2 = ws2->getNumberHistograms();
1069 alg->setProperty(
"InputWorkspace1", ws1);
1070 alg->setProperty(
"InputWorkspace2", ws2);
1071 alg->setProperty(
"OutputWorkspace", ws1);
1072 alg->setProperty(
"ValidateInputs",
false);
1074 alg->executeAsChildAlg();
1079 for (
size_t i = 0; i < nspec1; ++i) {
1080 specnum_t tmpspecNo = outws->getSpectrum(i).getSpectrumNo();
1081 outws->getSpectrum(i).setSpectrumNo(origspecNos[i]);
1083 g_log.
information() <<
"[DBx540] Conjoined spectrum " << i <<
": restore spectrum number to "
1084 << outws->getSpectrum(i).getSpectrumNo() <<
" from spectrum number = " << tmpspecNo <<
".\n";
1089 for (
size_t i = 0; i < nspec2; ++i) {
1091 outws->getSpectrum(nspec1 + i).setSpectrumNo(newspecid);
1106 alg->setProperty(
"OffsetsWorkspace", offsetsWS);
1107 alg->setPropertyValue(
"OutputWorkspace",
m_instName +
"_cal");
1108 alg->executeAsChildAlg();
1122 if ((!
m_groupWS) && (!calFilename.empty()) && (!groupFilename.empty())) {
1141 if ((!
m_maskWS) && (!calFilename.empty())) {
1151 if (calFilename.empty() && groupFilename.empty())
1159 if (calFilename.empty()) {
1160 g_log.
information() <<
"Loading Grouping file \"" << groupFilename <<
"\"\n";
1163 alg->setProperty(
"InputFile", groupFilename);
1164 alg->setProperty(
"InputWorkspace",
m_inputW);
1165 alg->executeAsChildAlg();
1167 m_groupWS = alg->getProperty(
"OutputWorkspace");
1170 this->setPropertyValue(PropertyNames::GROUP_WKSP,
name);
1172 g_log.
information() <<
"Loading Calibration file \"" << calFilename <<
"\"";
1173 if (!groupFilename.empty())
1178 alg->setProperty(
"InputWorkspace",
m_inputW);
1179 alg->setPropertyValue(
"Filename", calFilename);
1180 alg->setPropertyValue(
"GroupFilename", groupFilename);
1181 alg->setProperty<
bool>(
"MakeCalWorkspace", loadCalibration);
1182 alg->setProperty<
bool>(
"MakeGroupingWorkspace", loadGrouping);
1183 alg->setProperty<
bool>(
"MakeMaskWorkspace", loadMask);
1184 alg->setProperty<
double>(
"TofMin",
getProperty(
"TMin"));
1185 alg->setProperty<
double>(
"TofMax",
getProperty(
"TMax"));
1186 alg->setPropertyValue(
"WorkspaceName",
m_instName);
1187 alg->executeAsChildAlg();
1191 m_groupWS = alg->getProperty(
"OutputGroupingWorkspace");
1195 this->setPropertyValue(PropertyNames::GROUP_WKSP,
name);
1197 if (loadCalibration) {
1202 this->setPropertyValue(PropertyNames::CAL_WKSP,
name);
1205 m_maskWS = alg->getProperty(
"OutputMaskWorkspace");
1209 this->setPropertyValue(PropertyNames::MASK_WKSP,
name);
1225 alg->setProperty(
"InputWorkspace", eventWS);
1226 alg->setPropertyValue(
"SortBy",
"X Value");
1227 alg->executeAsChildAlg();
#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 ...
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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
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.
void doSortEvents(const Mantid::API::Workspace_sptr &ws)
Perform SortEvents on the output workspaces but only if they are EventWorkspaces.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
API::MatrixWorkspace_sptr m_inputW
DataObjects::GroupingWorkspace_sptr m_groupWS
std::vector< double > m_dmins
API::MatrixWorkspace_sptr m_lowResW
Low resolution TOF matrix workspace.
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
DataObjects::EventWorkspace_sptr m_outputEW
size_t m_lowResSpecOffset
Offset to low resolution TOF spectra.
API::MatrixWorkspace_sptr diffractionFocus(API::MatrixWorkspace_sptr ws)
Call diffraction focus to a matrix workspace.
std::unique_ptr< API::Progress > m_progress
Progress reporting.
DataObjects::EventWorkspace_sptr m_lowResEW
Low resolution TOF event workspace.
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.
bool m_processLowResTOF
Flag to process low resolution workspace.
API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr matrixws)
Rebin.
std::vector< double > phis
std::vector< double > m_dmaxs
DataObjects::EventWorkspace_sptr m_inputEW
API::MatrixWorkspace_sptr conjoinWorkspaces(const API::MatrixWorkspace_sptr &ws1, const API::MatrixWorkspace_sptr &ws2, size_t offset)
Add workspace2 to workspace1 by adding spectrum.
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< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
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::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
RegLowVectorPair< NumT > splitVectors(const std::vector< NumT > &orig, const size_t numVal, const std::string &label)
int32_t specnum_t
Typedef for a spectrum Number.
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.