50 std::string sampleSetup =
"Sample Setup";
52 "File containing the sample data to reduce");
53 this->declareProperty(
55 "Workspace to be reduced");
58 "A monitor workspace associated with the input sample workspace.");
60 "A detector calibration file.");
61 this->declareProperty(
"RelocateDetectors",
false,
"Move detectors to position specified in cal file.");
62 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
63 mustBePositive->setLower(0.0);
64 auto mustBePosInt = std::make_shared<BoundedValidator<int>>();
65 mustBePosInt->setLower(0);
66 this->declareProperty(
"IncidentEnergyGuess",
EMPTY_DBL(), mustBePositive,
67 "Set the value of the incident energy guess in meV.");
68 this->declareProperty(
"UseIncidentEnergyGuess",
false,
69 "Use the incident energy guess as the actual value "
70 "(will not be calculated).");
71 this->declareProperty(
"TimeZeroGuess",
EMPTY_DBL(),
"Set the value of time zero offset in microseconds.");
72 this->setPropertySettings(
"TimeZeroGuess",
73 std::make_unique<VisibleWhenProperty>(
"UseIncidentEnergyGuess",
IS_EQUAL_TO,
"1"));
74 auto mustBePositiveInt = std::make_shared<BoundedValidator<int>>();
75 mustBePositiveInt->setLower(0);
76 this->declareProperty(
"Monitor1SpecId",
EMPTY_INT(), mustBePositiveInt,
77 "Spectrum No for the first monitor to use in Ei calculation.");
78 this->declareProperty(
"Monitor2SpecId",
EMPTY_INT(), mustBePositiveInt,
79 "Spectrum No for the second monitor to use in Ei calculation.");
80 this->declareProperty(
81 std::make_unique<
ArrayProperty<double>>(
"EnergyTransferRange", std::make_shared<RebinParamsValidator>(
true)),
82 "A comma separated list of first bin boundary, width, last bin "
84 "Negative width value indicates logarithmic binning.");
85 this->declareProperty(
"SofPhiEIsDistribution",
true,
"The final S(Phi, E) data is made to be a distribution.");
87 "A file or workspace containing a hard mask.");
89 "A file containing grouping (mapping) information.");
90 this->declareProperty(
"ShowIntermediateWorkspaces",
false,
91 "Flag to show the intermediate workspaces (diagnostic "
92 "mask, integrated detector vanadium, "
93 "integrated absolute units) from the reduction.");
95 this->setPropertyGroup(
"SampleInputFile", sampleSetup);
96 this->setPropertyGroup(
"SampleInputWorkspace", sampleSetup);
97 this->setPropertyGroup(
"SampleInputMonitorWorkspace", sampleSetup);
98 this->setPropertyGroup(
"DetCalFilename", sampleSetup);
99 this->setPropertyGroup(
"RelocateDetectors", sampleSetup);
100 this->setPropertyGroup(
"IncidentEnergyGuess", sampleSetup);
101 this->setPropertyGroup(
"UseIncidentEnergyGuess", sampleSetup);
102 this->setPropertyGroup(
"TimeZeroGuess", sampleSetup);
103 this->setPropertyGroup(
"Monitor1SpecId", sampleSetup);
104 this->setPropertyGroup(
"Monitor2SpecId", sampleSetup);
105 this->setPropertyGroup(
"EnergyTransferRange", sampleSetup);
106 this->setPropertyGroup(
"SofPhiEIsDistribution", sampleSetup);
107 this->setPropertyGroup(
"HardMaskFile", sampleSetup);
108 this->setPropertyGroup(
"GroupingFile", sampleSetup);
109 this->setPropertyGroup(
"ShowIntermediateWorkspaces", sampleSetup);
112 std::string dataCorr =
"Data Corrections";
115 std::vector<std::string> incidentBeamNormOptions;
116 incidentBeamNormOptions.emplace_back(
"None");
117 incidentBeamNormOptions.emplace_back(
"ByCurrent");
118 incidentBeamNormOptions.emplace_back(
"ToMonitor");
119 this->declareProperty(
"IncidentBeamNormalisation",
"None",
120 std::make_shared<StringListValidator>(incidentBeamNormOptions),
121 "Options for incident beam normalisation on data.");
122 this->declareProperty(
"MonitorIntRangeLow",
EMPTY_DBL(),
"Set the lower bound for monitor integration.");
123 this->setPropertySettings(
"MonitorIntRangeLow", std::make_unique<VisibleWhenProperty>(
"IncidentBeamNormalisation",
125 this->declareProperty(
"MonitorIntRangeHigh",
EMPTY_DBL(),
"Set the upper bound for monitor integration.");
126 this->setPropertySettings(
"MonitorIntRangeHigh", std::make_unique<VisibleWhenProperty>(
"IncidentBeamNormalisation",
128 this->declareProperty(
"TimeIndepBackgroundSub",
false,
129 "If true, time-independent background will be calculated and removed.");
130 this->declareProperty(
"TibTofRangeStart",
EMPTY_DBL(),
131 "Set the lower TOF bound for time-independent background subtraction.");
132 this->setPropertySettings(
"TibTofRangeStart",
133 std::make_unique<VisibleWhenProperty>(
"TimeIndepBackgroundSub",
IS_EQUAL_TO,
"1"));
134 this->declareProperty(
"TibTofRangeEnd",
EMPTY_DBL(),
135 "Set the upper TOF bound for time-independent background subtraction.");
136 this->setPropertySettings(
"TibTofRangeEnd",
137 std::make_unique<VisibleWhenProperty>(
"TimeIndepBackgroundSub",
IS_EQUAL_TO,
"1"));
138 this->declareProperty(
"CorrectKiKf",
true,
"Apply the ki/kf correction.");
139 this->declareProperty(
141 "File containing the sample detector vanadium data to reduce");
144 "Sample detector vanadium workspace to be reduced");
145 this->declareProperty(std::make_unique<
WorkspaceProperty<>>(
"DetectorVanadiumInputMonitorWorkspace",
"",
147 "A monitor workspace associated with the input sample detector vanadium "
149 this->declareProperty(
"SaveProcessedDetVan",
false,
"Save the processed detector vanadium workspace");
150 this->setPropertySettings(
"SaveProcessedDetVan",
151 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
152 this->declareProperty(
154 "Provide a filename for saving the processed detector vanadium.");
155 this->declareProperty(
"UseProcessedDetVan",
false,
156 "If true, treat the detector vanadium as processed.\n"
157 "This includes not running diagnostics on the processed data.");
158 this->declareProperty(
"UseBoundsForDetVan",
false,
"If true, integrate the detector vanadium over a given range.");
159 this->declareProperty(
"DetVanIntRangeLow",
EMPTY_DBL(),
"Set the lower bound for integrating the detector vanadium.");
160 this->setPropertySettings(
"DetVanIntRangeLow",
161 std::make_unique<VisibleWhenProperty>(
"UseBoundsForDetVan",
IS_EQUAL_TO,
"1"));
162 this->declareProperty(
"DetVanIntRangeHigh",
EMPTY_DBL(),
163 "Set the upper bound for integrating the detector vanadium.");
164 this->setPropertySettings(
"DetVanIntRangeHigh",
165 std::make_unique<VisibleWhenProperty>(
"UseBoundsForDetVan",
IS_EQUAL_TO,
"1"));
166 std::vector<std::string> detvanIntRangeUnits;
167 detvanIntRangeUnits.emplace_back(
"Energy");
168 detvanIntRangeUnits.emplace_back(
"Wavelength");
169 detvanIntRangeUnits.emplace_back(
"TOF");
170 this->declareProperty(
"DetVanIntRangeUnits",
"Energy", std::make_shared<StringListValidator>(detvanIntRangeUnits),
171 "Options for the units on the detector vanadium integration.");
172 this->setPropertySettings(
"DetVanIntRangeUnits",
173 std::make_unique<VisibleWhenProperty>(
"UseBoundsForDetVan",
IS_EQUAL_TO,
"1"));
176 this->setPropertyGroup(
"IncidentBeamNormalisation", dataCorr);
177 this->setPropertyGroup(
"MonitorIntRangeLow", dataCorr);
178 this->setPropertyGroup(
"MonitorIntRangeHigh", dataCorr);
179 this->setPropertyGroup(
"TimeIndepBackgroundSub", dataCorr);
180 this->setPropertyGroup(
"TibTofRangeStart", dataCorr);
181 this->setPropertyGroup(
"TibTofRangeEnd", dataCorr);
182 this->setPropertyGroup(
"CorrectKiKf", dataCorr);
183 this->setPropertyGroup(
"DetectorVanadiumInputFile", dataCorr);
184 this->setPropertyGroup(
"DetectorVanadiumInputWorkspace", dataCorr);
185 this->setPropertyGroup(
"DetectorVanadiumInputMonitorWorkspace", dataCorr);
186 this->setPropertyGroup(
"SaveProcessedDetVan", dataCorr);
187 this->setPropertyGroup(
"SaveProcDetVanFilename", dataCorr);
188 this->setPropertyGroup(
"UseProcessedDetVan", dataCorr);
189 this->setPropertyGroup(
"UseBoundsForDetVan", dataCorr);
190 this->setPropertyGroup(
"DetVanIntRangeLow", dataCorr);
191 this->setPropertyGroup(
"DetVanIntRangeHigh", dataCorr);
192 this->setPropertyGroup(
"DetVanIntRangeUnits", dataCorr);
195 std::string findBadDets =
"Finding Bad Detectors";
196 this->declareProperty(
"HighCounts",
EMPTY_DBL(), mustBePositive,
"Mask detectors above this threshold.");
197 this->setPropertySettings(
"HighCounts",
198 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
199 this->declareProperty(
"LowCounts",
EMPTY_DBL(), mustBePositive,
"Mask detectors below this threshold.");
200 this->setPropertySettings(
"LowCounts",
201 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
202 this->declareProperty(
"LowOutlier",
EMPTY_DBL(),
"Lower bound defining outliers as fraction of median value");
203 this->setPropertySettings(
"LowOutlier",
204 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
205 this->declareProperty(
"HighOutlier",
EMPTY_DBL(),
"Upper bound defining outliers as fraction of median value");
206 this->setPropertySettings(
"HighOutlier",
207 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
208 this->declareProperty(
"MedianTestHigh",
EMPTY_DBL(), mustBePositive,
"Mask detectors above this threshold.");
209 this->setPropertySettings(
"MedianTestHigh",
210 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
211 this->declareProperty(
"MedianTestLow",
EMPTY_DBL(), mustBePositive,
"Mask detectors below this threshold.");
212 this->setPropertySettings(
"MedianTestLow",
213 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
214 this->declareProperty(
"MedianTestLevelsUp", 0., mustBePositive,
"Mask detectors below this threshold.");
215 this->setPropertySettings(
"MedianTestLevelsUp",
216 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
217 this->declareProperty(
"MedianTestCorrectForSolidAngle",
false,
"Flag to correct for solid angle efficiency.");
218 this->setPropertySettings(
"MedianTestCorrectForSolidAngle",
219 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
220 this->declareProperty(
"ErrorBarCriterion",
EMPTY_DBL(), mustBePositive,
221 "Some selection criteria for the detector tests.");
222 this->setPropertySettings(
"ErrorBarCriterion",
223 std::make_unique<VisibleWhenProperty>(
"DetectorVanadiumInputFile",
IS_NOT_EQUAL_TO,
""));
224 this->declareProperty(
226 "File containing detector vanadium data to compare against");
229 "Detector vanadium workspace to compare against");
230 this->declareProperty(std::make_unique<
WorkspaceProperty<>>(
"DetectorVanadium2InputMonitorWorkspace",
"",
232 "A monitor workspace associated with the input comparison detector "
233 "vanadium workspace.");
235 this->declareProperty(
"DetVanRatioVariation",
EMPTY_DBL(), mustBePositive,
236 "Mask detectors if the time variation is above this threshold.");
237 this->setPropertySettings(
"DetVanRatioVariation",
238 std::make_unique<VisibleWhenProperty>(
"DetectorVanadium2InputFile",
IS_NOT_EQUAL_TO,
""));
240 this->declareProperty(
"BackgroundCheck",
false,
"If true, run a background check on detector vanadium.");
241 this->declareProperty(
"SamBkgMedianTestHigh",
EMPTY_DBL(), mustBePositive,
"Mask detectors above this threshold.");
242 this->setPropertySettings(
"SamBkgMedianTestHigh",
243 std::make_unique<VisibleWhenProperty>(
"BackgroundCheck",
IS_EQUAL_TO,
"1"));
244 this->declareProperty(
"SamBkgMedianTestLow",
EMPTY_DBL(), mustBePositive,
"Mask detectors below this threshold.");
245 this->setPropertySettings(
"SamBkgMedianTestLow",
246 std::make_unique<VisibleWhenProperty>(
"BackgroundCheck",
IS_EQUAL_TO,
"1"));
247 this->declareProperty(
"SamBkgErrorBarCriterion",
EMPTY_DBL(), mustBePositive,
248 "Some selection criteria for the detector tests.");
249 this->setPropertySettings(
"SamBkgErrorBarCriterion",
250 std::make_unique<VisibleWhenProperty>(
"BackgroundCheck",
IS_EQUAL_TO,
"1"));
251 this->declareProperty(
"BackgroundTofStart",
EMPTY_DBL(), mustBePositive,
"Start TOF for the background check.");
252 this->setPropertySettings(
"BackgroundTofStart",
253 std::make_unique<VisibleWhenProperty>(
"BackgroundCheck",
IS_EQUAL_TO,
"1"));
254 this->declareProperty(
"BackgroundTofEnd",
EMPTY_DBL(), mustBePositive,
"End TOF for the background check.");
255 this->setPropertySettings(
"BackgroundTofEnd",
256 std::make_unique<VisibleWhenProperty>(
"BackgroundCheck",
IS_EQUAL_TO,
"1"));
257 this->declareProperty(
"RejectZeroBackground",
false,
"If true, check the background region for anomolies.");
258 this->declareProperty(
"PsdBleed",
false,
"If true, perform a PSD bleed test.");
259 this->declareProperty(
"MaxFramerate",
EMPTY_DBL(),
"The maximum framerate to check.");
260 this->setPropertySettings(
"MaxFramerate", std::make_unique<VisibleWhenProperty>(
"PsdBleed",
IS_EQUAL_TO,
"1"));
261 this->declareProperty(
"IgnoredPixels",
EMPTY_DBL(),
"A list of pixels to ignore in the calculations.");
262 this->setPropertySettings(
"IgnoredPixels", std::make_unique<VisibleWhenProperty>(
"PsdBleed",
IS_EQUAL_TO,
"1"));
264 this->setPropertyGroup(
"HighCounts", findBadDets);
265 this->setPropertyGroup(
"LowCounts", findBadDets);
266 this->setPropertyGroup(
"LowOutlier", findBadDets);
267 this->setPropertyGroup(
"HighOutlier", findBadDets);
268 this->setPropertyGroup(
"MedianTestHigh", findBadDets);
269 this->setPropertyGroup(
"MedianTestLow", findBadDets);
270 this->setPropertyGroup(
"MedianTestLevelsUp", findBadDets);
271 this->setPropertyGroup(
"MedianTestCorrectForSolidAngle", findBadDets);
272 this->setPropertyGroup(
"ErrorBarCriterion", findBadDets);
273 this->setPropertyGroup(
"DetectorVanadium2InputFile", findBadDets);
274 this->setPropertyGroup(
"DetectorVanadium2InputWorkspace", findBadDets);
275 this->setPropertyGroup(
"DetectorVanadium2InputMonitorWorkspace", findBadDets);
276 this->setPropertyGroup(
"DetVanRatioVariation", findBadDets);
277 this->setPropertyGroup(
"BackgroundCheck", findBadDets);
278 this->setPropertyGroup(
"SamBkgMedianTestHigh", findBadDets);
279 this->setPropertyGroup(
"SamBkgMedianTestLow", findBadDets);
280 this->setPropertyGroup(
"SamBkgErrorBarCriterion", findBadDets);
281 this->setPropertyGroup(
"BackgroundTofStart", findBadDets);
282 this->setPropertyGroup(
"BackgroundTofEnd", findBadDets);
283 this->setPropertyGroup(
"RejectZeroBackground", findBadDets);
284 this->setPropertyGroup(
"PsdBleed", findBadDets);
285 this->setPropertyGroup(
"MaxFramerate", findBadDets);
286 this->setPropertyGroup(
"IgnoredPixels", findBadDets);
289 std::string absUnitsCorr =
"Absolute Units Correction";
290 this->declareProperty(
"DoAbsoluteUnits",
false,
"If true, perform an absolute units normalisation.");
292 "The sample (vanadium) file used in the absolute units normalisation.");
293 this->setPropertySettings(
"AbsUnitsSampleInputFile",
294 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
297 "The sample (vanadium) workspace for absolute units normalisation.");
298 this->setPropertySettings(
"AbsUnitsSampleInputWorkspace",
299 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
300 this->declareProperty(std::make_unique<
WorkspaceProperty<>>(
"AbsUnitsSampleInputMonitorWorkspace",
"",
302 "A monitor workspace associated with the input absolute units sample "
304 this->setPropertySettings(
"AbsUnitsSampleInputMonitorWorkspace",
305 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
306 this->declareProperty(
"AbsUnitsGroupingFile",
"",
"Grouping file for absolute units normalisation.");
307 this->setPropertySettings(
"AbsUnitsGroupingFile",
308 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
309 this->declareProperty(
311 "The detector vanadium file used in the absolute units normalisation.");
312 this->setPropertySettings(
"AbsUnitsDetectorVanadiumInputFile",
313 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
314 this->declareProperty(std::make_unique<
WorkspaceProperty<>>(
"AbsUnitsDetectorVanadiumInputWorkspace",
"",
316 "The detector vanadium workspace for absolute units normalisation.");
317 this->setPropertySettings(
"AbsUnitsDetectorVanadiumInputWorkspace",
318 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
319 this->declareProperty(std::make_unique<
WorkspaceProperty<>>(
"AbsUnitsDetectorVanadiumInputMonitorWorkspace",
"",
321 "A monitor workspace associated with the input absolute units sample "
322 "detector vanadium workspace.");
323 this->setPropertySettings(
"AbsUnitsDetectorVanadiumInputMonitorWorkspace",
324 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
325 this->declareProperty(
"AbsUnitsIncidentEnergy",
EMPTY_DBL(), mustBePositive,
326 "The incident energy for the vanadium sample.");
327 this->setPropertySettings(
"AbsUnitsIncidentEnergy",
328 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
329 this->declareProperty(
"AbsUnitsMinimumEnergy",
EMPTY_DBL(),
"The minimum energy for the integration range.");
330 this->setPropertySettings(
"AbsUnitsMinimumEnergy",
331 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
332 this->declareProperty(
"AbsUnitsMaximumEnergy",
EMPTY_DBL(),
"The maximum energy for the integration range.");
333 this->setPropertySettings(
"AbsUnitsMaximumEnergy",
334 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
335 this->declareProperty(
"VanadiumMass",
EMPTY_DBL(),
"The mass of vanadium.");
336 this->setPropertySettings(
"VanadiumMass", std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
337 this->declareProperty(
"SampleMass", 1.0,
"The mass of sample.");
338 this->setPropertySettings(
"SampleMass", std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
339 this->declareProperty(
"SampleRmm", 1.0,
"The rmm of sample.");
340 this->setPropertySettings(
"SampleRmm", std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
341 this->declareProperty(
"AbsUnitsLowOutlier",
EMPTY_DBL(),
"Lower bound defining outliers as fraction of median value");
342 this->setPropertySettings(
"AbsUnitsLowOutlier",
343 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
344 this->declareProperty(
"AbsUnitsHighOutlier",
EMPTY_DBL(),
345 "Upper bound defining outliers as fraction of median value");
346 this->setPropertySettings(
"AbsUnitsHighOutlier",
347 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
348 this->declareProperty(
"AbsUnitsMedianTestHigh",
EMPTY_DBL(), mustBePositive,
"Mask detectors above this threshold.");
349 this->setPropertySettings(
"AbsUnitsMedianTestHigh",
350 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
351 this->declareProperty(
"AbsUnitsMedianTestLow",
EMPTY_DBL(), mustBePositive,
"Mask detectors below this threshold.");
352 this->setPropertySettings(
"AbsUnitsMedianTestLow",
353 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
354 this->declareProperty(
"AbsUnitsErrorBarCriterion",
EMPTY_DBL(), mustBePositive,
355 "Some selection criteria for the detector tests.");
356 this->setPropertySettings(
"AbsUnitsErrorBarCriterion",
357 std::make_unique<VisibleWhenProperty>(
"DoAbsoluteUnits",
IS_EQUAL_TO,
"1"));
359 this->setPropertyGroup(
"DoAbsoluteUnits", absUnitsCorr);
360 this->setPropertyGroup(
"AbsUnitsSampleInputFile", absUnitsCorr);
361 this->setPropertyGroup(
"AbsUnitsSampleInputWorkspace", absUnitsCorr);
362 this->setPropertyGroup(
"AbsUnitsSampleInputMonitorWorkspace", absUnitsCorr);
363 this->setPropertyGroup(
"AbsUnitsGroupingFile", absUnitsCorr);
364 this->setPropertyGroup(
"AbsUnitsDetectorVanadiumInputFile", absUnitsCorr);
365 this->setPropertyGroup(
"AbsUnitsDetectorVanadiumInputWorkspace", absUnitsCorr);
366 this->setPropertyGroup(
"AbsUnitsDetectorVanadiumInputMonitorWorkspace", absUnitsCorr);
367 this->setPropertyGroup(
"AbsUnitsIncidentEnergy", absUnitsCorr);
368 this->setPropertyGroup(
"AbsUnitsMinimumEnergy", absUnitsCorr);
369 this->setPropertyGroup(
"AbsUnitsMaximumEnergy", absUnitsCorr);
370 this->setPropertyGroup(
"VanadiumMass", absUnitsCorr);
371 this->setPropertyGroup(
"SampleMass", absUnitsCorr);
372 this->setPropertyGroup(
"SampleRmm", absUnitsCorr);
373 this->setPropertyGroup(
"AbsUnitsLowOutlier", absUnitsCorr);
374 this->setPropertyGroup(
"AbsUnitsHighOutlier", absUnitsCorr);
375 this->setPropertyGroup(
"AbsUnitsMedianTestHigh", absUnitsCorr);
376 this->setPropertyGroup(
"AbsUnitsMedianTestLow", absUnitsCorr);
377 this->setPropertyGroup(
"AbsUnitsErrorBarCriterion", absUnitsCorr);
380 std::string powder =
"Powder Data Conversion";
381 this->declareProperty(
"DoPowderDataConversion",
false,
"Flag to switch on converting DeltaE to SQW.");
382 this->declareProperty(
383 std::make_unique<
ArrayProperty<double>>(
"PowderMomTransferRange", std::make_shared<RebinParamsValidator>(
true)),
384 "A comma separated list of first bin boundary, width, last bin "
386 "Negative width value indicates logarithmic binning.");
387 this->setPropertySettings(
"PowderMomTransferRange",
388 std::make_unique<VisibleWhenProperty>(
"DoPowderDataConversion",
IS_EQUAL_TO,
"1"));
389 this->declareProperty(
"SavePowderNexusFile",
true,
"Flag to use to save a processed NeXus file for powder data.");
390 this->setPropertySettings(
"SavePowderNexusFile",
391 std::make_unique<VisibleWhenProperty>(
"DoPowderDataConversion",
IS_EQUAL_TO,
"1"));
392 this->declareProperty(
394 "Provide a filename for saving the processed powder data.");
395 this->setPropertySettings(
"SavePowderNexusFilename",
396 std::make_unique<VisibleWhenProperty>(
"DoPowderDataConversion",
IS_EQUAL_TO,
"1"));
398 this->setPropertyGroup(
"DoPowderDataConversion", powder);
399 this->setPropertyGroup(
"PowderMomTransferRange", powder);
400 this->setPropertyGroup(
"SavePowderNexusFile", powder);
401 this->setPropertyGroup(
"SavePowderNexusFilename", powder);
406 "Provide a name for the output workspace.");
407 this->declareProperty(
"ReductionProperties",
"__dgs_reduction_properties",
Direction::Output);
530 const std::string reductionManagerName = this->
getProperty(
"ReductionProperties");
531 if (reductionManagerName.empty()) {
532 g_log.
error() <<
"ERROR: Reduction Property Manager name is empty\n";
536 PropertyManagerDataService::Instance().addOrReplace(reductionManagerName, this->
reductionManager);
539 const std::vector<Property *> props = this->getProperties();
540 for (
auto prop : props) {
541 if (!boost::contains(prop->name(),
"Input")) {
542 this->
reductionManager->declareProperty(std::unique_ptr<Property>(prop->clone()));
546 Progress progress(
this, 0.0, 1.0, 7);
551 const FacilityInfo defaultFacility = ConfigService::Instance().getFacility();
561 const InstrumentInfo info = ConfigService::Instance().getInstrument(WS->getInstrument()->getName());
563 std::ostringstream mess;
564 mess <<
"Default facility must be set to " << info.
facility().
name();
565 mess <<
" in order for reduction to work!";
566 throw std::runtime_error(mess.str());
571 const bool showIntermedWS = this->
getProperty(
"ShowIntermediateWorkspaces");
574 if (outputWsName.ends_with(
"_spe")) {
575 boost::erase_all(outputWsName,
"_spe");
578 progress.
report(
"Loading hard mask...");
582 if (hardMaskWS && showIntermedWS) {
583 std::string hardMaskName = outputWsName +
"_hardmask";
585 this->setProperty(
"ReductionHardMask", hardMaskWS);
588 progress.
report(
"Loading grouping file...");
591 if (groupingWS && showIntermedWS) {
592 std::string groupName = outputWsName +
"_grouping";
594 this->setProperty(
"ReductionGrouping", groupingWS);
603 bool isProcessedDetVan = this->
getProperty(
"UseProcessedDetVan");
609 if (detVanWS && !isProcessedDetVan) {
611 diag->setProperty(
"DetVanWorkspace", detVanWS);
612 diag->setProperty(
"DetVanMonitorWorkspace", detVanMonWS);
613 diag->setProperty(
"DetVanCompWorkspace", detVan2WS);
614 diag->setProperty(
"DetVanCompMonitorWorkspace", detVan2MonWS);
615 diag->setProperty(
"SampleWorkspace", sampleWS);
616 diag->setProperty(
"SampleMonitorWorkspace", sampleMonWS);
617 diag->setProperty(
"HardMaskWorkspace", hardMaskWS);
618 diag->setProperty(
"ReductionProperties",
getPropertyValue(
"ReductionProperties"));
619 diag->executeAsChildAlg();
620 maskWS = diag->getProperty(
"OutputWorkspace");
622 if (showIntermedWS) {
623 const std::string detVanMaskName = outputWsName +
"_diagmask";
624 this->declareProperty(
626 this->setProperty(
"SampleDetVanDiagMask", maskWS);
630 detVan->setProperty(
"InputWorkspace", detVanWS);
631 detVan->setProperty(
"InputMonitorWorkspace", detVanMonWS);
632 detVan->setProperty(
"MaskWorkspace", maskWS);
633 detVan->setProperty(
"ReductionProperties",
getPropertyValue(
"ReductionProperties"));
634 detVan->executeAsChildAlg();
636 idetVanWS = std::dynamic_pointer_cast<Workspace>(oWS);
638 if (showIntermedWS) {
639 const std::string idetVanName = outputWsName +
"_idetvan";
640 this->declareProperty(
642 this->setProperty(
"IntegratedNormWorkspace", idetVanWS);
645 idetVanWS = detVanWS;
646 maskWS = std::dynamic_pointer_cast<MatrixWorkspace>(idetVanWS);
650 progress.
report(
"Converting to energy transfer...");
652 etConv->setProperty(
"InputWorkspace", sampleWS);
653 etConv->setProperty(
"InputMonitorWorkspace", sampleMonWS);
654 etConv->setProperty(
"IntegratedDetectorVanadium", idetVanWS);
655 const double ei = this->
getProperty(
"IncidentEnergyGuess");
656 etConv->setProperty(
"IncidentEnergyGuess", ei);
657 if (!maskWS && hardMaskWS) {
660 etConv->setProperty(
"MaskWorkspace", maskWS);
662 etConv->setProperty(
"GroupingWorkspace", groupingWS);
664 etConv->setProperty(
"ReductionProperties",
getPropertyValue(
"ReductionProperties"));
666 etConv->executeAsChildAlg();
670 if (tibWS && showIntermedWS) {
672 this->setProperty(
"SampleTibWorkspace", tibWS);
677 progress.
report(
"Absolute units reduction...");
689 absUnitsRed->setProperty(
"InputWorkspace", absSampleWS);
690 absUnitsRed->setProperty(
"InputMonitorWorkspace", absSampleMonWS);
691 absUnitsRed->setProperty(
"DetectorVanadiumWorkspace", absDetVanWS);
692 absUnitsRed->setProperty(
"DetectorVanadiumMonitorWorkspace", absDetVanMonWS);
693 absUnitsRed->setProperty(
"GroupingWorkspace", absGroupingWS);
694 absUnitsRed->setProperty(
"MaskWorkspace", maskWS);
695 absUnitsRed->setProperty(
"ReductionProperties",
getPropertyValue(
"ReductionProperties"));
696 absUnitsRed->executeAsChildAlg();
703 mask->setProperty(
"Workspace", outputWS);
704 mask->setProperty(
"MaskedWorkspace", absMaskWS);
705 mask->executeAsChildAlg();
706 outputWS = mask->getProperty(
"Workspace");
709 outputWS =
divide(outputWS, absUnitsWS);
711 if (showIntermedWS) {
712 const std::string absWsName = outputWsName +
"_absunits";
714 this->setProperty(
"AbsUnitsWorkspace", absUnitsWS);
717 this->setProperty(
"AbsUnitsDiagMask", absMaskWS);
724 if (
auto eventWS = std::dynamic_pointer_cast<EventWorkspace>(outputWS)) {
725 const auto timerStart = std::chrono::high_resolution_clock::now();
728 addTimer(
"sortByTOF", timerStart, std::chrono::high_resolution_clock::now());
732 const bool doPowderConvert = this->
getProperty(
"DoPowderDataConversion");
733 if (doPowderConvert) {
736 std::string sqwWsName = outputWsName +
"_pd_sqw";
737 std::vector<double> qBinning = this->
getProperty(
"PowderMomTransferRange");
738 const auto initialEnergy = outputWS->run().getPropertyValueAsType<
double>(
"Ei");
741 sofqw->setProperty(
"InputWorkspace", outputWS);
742 sofqw->setProperty(
"QAxisBinning", qBinning);
743 sofqw->setProperty(
"EMode",
"Direct");
744 sofqw->setProperty(
"EFixed", initialEnergy);
745 sofqw->executeAsChildAlg();
748 this->setProperty(
"PowderSqwWorkspace", sqwWS);
750 const bool saveProcNexus = this->
getProperty(
"SavePowderNexusFile");
752 std::string saveProcNexusFilename = this->
getProperty(
"SavePowderNexusFilename");
753 if (saveProcNexusFilename.empty()) {
754 saveProcNexusFilename = sqwWsName +
".nxs";
757 saveNxs->setProperty(
"InputWorkspace", sqwWS);
758 saveNxs->setProperty(
"Filename", saveProcNexusFilename);
759 saveNxs->executeAsChildAlg();
765 this->setProperty(
"OutputWorkspace", outputWS);