21#include "Poco/NumberFormatter.h"
28using namespace Kernel;
30using namespace Geometry;
34 std::string load_grp =
"Load Options";
36 "If true, the edges of the TOF distribution will be cut "
37 "according to the configuration file");
39 "TOF value below which events will not be "
40 "loaded into the workspace at load-time");
42 "TOF value above which events will not be "
43 "loaded into the workspace at load-time");
45 "Wavelength steps to be used when "
46 "rebinning the data before performing "
49 "If true, the masking information "
50 "found in the configuration file "
52 declareProperty(
"UseConfig",
true,
"If true, the best configuration file found will be used");
54 "If true, the TOF will be modified for the true flight path "
55 "from the sample to the detector pixel");
57 declareProperty(
"SkipTOFCorrection",
false,
"If true, the EQSANS TOF correction will be skipped");
58 declareProperty(
"PreserveEvents",
false,
"If true, the output workspace will be an event workspace");
61 "Sample to detector distance to use (overrides meta data), in mm");
64 "Offset to the sample to detector distance (use only when "
65 "using the detector distance found in the meta data), in mm");
67 "Offset applies to the sample position (use only when "
68 "using the detector distance found in the meta data), in mm");
70 "Offset applies to the detector position (use only when "
71 "using the distance found in the meta data), in mm");
73 declareProperty(
"SolidAngleCorrection",
true,
"If true, the solid angle correction will be applied to the data");
74 declareProperty(
"DetectorTubes",
false,
"If true, the solid angle correction for tube detectors will be applied");
77 "Reads the embedded Instrument XML from the NeXus file "
78 "(optional, default True). ");
103 std::string center_grp =
"Beam Center";
104 std::vector<std::string> centerOptions{
"None",
"Value",
"DirectBeam",
"Scattering"};
106 declareProperty(
"BeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
107 "Method for determining the data beam center");
111 declareProperty(
"UseConfigBeam",
false,
"If True, the beam center will be taken from the config file");
122 "The name of the input event Nexus file to load");
124 std::make_unique<VisibleWhenProperty>(
"BeamCenterMethod",
IS_NOT_EQUAL_TO,
"None"));
128 auto positiveDouble = std::make_shared<BoundedValidator<double>>();
129 positiveDouble->setLower(0);
133 "Radius of the beam area used the exclude the beam when calculating "
134 "the center of mass of the scattering pattern [pixels]. Default=3.0");
136 std::make_unique<VisibleWhenProperty>(
"BeamCenterMethod",
IS_EQUAL_TO,
"Scattering"));
149 std::string norm_grp =
"Normalisation";
150 std::vector<std::string> incidentBeamNormOptions;
151 incidentBeamNormOptions.emplace_back(
"None");
153 incidentBeamNormOptions.emplace_back(
"Monitor");
156 incidentBeamNormOptions.emplace_back(
"BeamProfileAndCharge");
158 incidentBeamNormOptions.emplace_back(
"Charge");
160 std::make_shared<StringListValidator>(incidentBeamNormOptions),
161 "Options for data normalisation");
163 declareProperty(
"LoadMonitors",
false,
"If true, the monitor workspace will be loaded");
170 "The name of the beam monitor reference file used for normalisation");
179 "The name of the input event Nexus file to load as dark current.");
182 std::string eff_grp =
"Sensitivity";
185 "Flood field or sensitivity file.");
187 "Minimum efficiency for a pixel to be considered (default: no minimum).");
189 "Maximum efficiency for a pixel to be considered (default: no maximum).");
191 "If true, the dark current subtracted "
192 "from the sample data will also be "
193 "subtracted from the flood field.");
196 "The name of the input file to load as dark current.");
198 declareProperty(
"SensitivityBeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
199 "Method for determining the sensitivity data beam center");
204 std::make_unique<VisibleWhenProperty>(
"SensitivityBeamCenterMethod",
IS_EQUAL_TO,
"Value"));
208 std::make_unique<VisibleWhenProperty>(
"SensitivityBeamCenterMethod",
IS_EQUAL_TO,
"Value"));
213 "The name of the input data file to load");
215 std::make_unique<VisibleWhenProperty>(
"SensitivityBeamCenterMethod",
IS_NOT_EQUAL_TO,
"None"));
218 "Radius of the beam area used the exclude the beam when calculating "
219 "the center of mass of the scattering pattern [pixels]. Default=3.0");
221 std::make_unique<VisibleWhenProperty>(
"BeamCenterMethod",
IS_EQUAL_TO,
"Scattering"));
223 declareProperty(
"OutputSensitivityWorkspace",
"",
"Name to give the sensitivity workspace");
239 std::string trans_grp =
"Transmission";
240 std::vector<std::string> transOptions{
"Value",
"DirectBeam"};
241 declareProperty(
"TransmissionMethod",
"Value", std::make_shared<StringListValidator>(transOptions),
242 "Transmission determination method");
247 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"Value"));
250 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"Value"));
253 declareProperty(
"TransmissionBeamRadius", 3.0,
"Radius of the beam area used to compute the transmission [pixels]");
255 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
258 "Sample data file for transmission calculation");
260 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
263 "Empty data file for transmission calculation");
265 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
266 declareProperty(
"FitFramesTogether",
false,
"If true, the two frames will be fit together");
268 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
271 declareProperty(
"TransmissionBeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
272 "Method for determining the transmission data beam center");
274 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
279 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
282 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
287 "The name of the input data file to load");
289 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
293 "The name of the input data file to load as transmission dark current.");
295 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_NOT_EQUAL_TO,
"Value"));
298 "If true, the sample dark current will be used IF a dark current file is"
301 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_NOT_EQUAL_TO,
"Value"));
304 "If true, a theta-dependent transmission correction will be applied.");
324 std::string bck_grp =
"Background";
326 declareProperty(
"BckTransmissionMethod",
"Value", std::make_shared<StringListValidator>(transOptions),
327 "Transmission determination method");
332 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"Value"));
336 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"Value"));
340 "Radius of the beam area used to compute the transmission [pixels]");
342 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
345 "Sample data file for transmission calculation");
347 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
350 "Empty data file for transmission calculation");
352 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
353 declareProperty(
"BckFitFramesTogether",
false,
"If true, the two frames will be fit together");
355 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
358 declareProperty(
"BckTransmissionBeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
359 "Method for determining the transmission data beam center");
361 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
365 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
369 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
372 "The name of the input data file to load");
374 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
376 declareProperty(std::make_unique<API::FileProperty>(
"BckTransmissionDarkCurrentFile",
"",
378 "The name of the input data file to load as background "
379 "transmission dark current.");
381 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
384 "If true, a theta-dependent transmission correction will be applied.");
404 std::string mask_grp =
"Mask";
407 "Number of pixels to mask on the edges: X-low, X-high, Y-low, Y-high");
408 std::vector<std::string> maskOptions{
"None",
"Front",
"Back"};
409 declareProperty(
"MaskedSide",
"None", std::make_shared<StringListValidator>(maskOptions),
410 "Mask one side of the detector");
417 std::string abs_scale_grp =
"Absolute Scale";
418 std::vector<std::string> scaleOptions;
419 scaleOptions.emplace_back(
"None");
420 scaleOptions.emplace_back(
"Value");
421 scaleOptions.emplace_back(
"ReferenceData");
422 declareProperty(
"AbsoluteScaleMethod",
"None", std::make_shared<StringListValidator>(scaleOptions),
423 "Absolute scale correction method");
424 declareProperty(
"AbsoluteScalingFactor", 1.0,
"Absolute scaling factor");
426 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"Value"));
428 declareProperty(std::make_unique<API::FileProperty>(
"AbsoluteScalingReferenceFilename",
"",
431 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
433 "Beamstop diameter for computing the absolute scale factor [mm]. "
434 "Read from file if not supplied.");
436 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
438 "Attenuator transmission value for computing the absolute scale factor");
440 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
442 "Apply sensitivity correction to the reference data "
443 "when computing the absolute scale factor");
445 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
455 std::string iq1d_grp =
"I(q) Calculation";
457 auto positiveInt = std::make_shared<BoundedValidator<int>>();
458 positiveInt->setLower(0);
459 declareProperty(
"IQNumberOfBins", 100, positiveInt,
"Number of I(q) bins when binning is not specified");
460 declareProperty(
"IQLogBinning",
false,
"I(q) log binning when binning is not specified");
462 "If true and frame skipping is "
463 "used, each frame will have "
465 declareProperty(
"IQScaleResults",
true,
"If true and frame skipping is used, frame 1 will be scaled to frame 2");
466 declareProperty(
"ComputeResolution",
false,
"If true the Q resolution will be computed");
467 declareProperty(
"SampleApertureDiameter", 10.0,
"Sample aperture diameter [mm]");
470 declareProperty(
"IQ2DNumberOfBins", 100, positiveInt,
"Number of I(qx,qy) bins.");
485 declareProperty(
"OutputDirectory",
"",
"Directory to put the output files in");
492 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
493 if (reductionManagerName.empty()) {
494 g_log.
error() <<
"ERROR: Reduction Property Manager name is empty\n";
497 std::shared_ptr<PropertyManager> reductionManager = std::make_shared<PropertyManager>();
504 const std::string processInfo =
getProperty(
"ProcessInfo");
508 const std::string outputDirectory =
getProperty(
"OutputDirectory");
509 reductionManager->declareProperty(
513 const std::string normalization =
getProperty(
"Normalisation");
515 const std::string monitorRefFile =
getPropertyValue(
"MonitorReferenceFile");
519 if (boost::contains(normalization,
"BeamProfileAndCharge")) {
520 normAlg->setProperty(
"NormaliseToBeam",
true);
521 normAlg->setProperty(
"BeamSpectrumFile", monitorRefFile);
522 }
else if (boost::contains(normalization,
"Charge")) {
523 normAlg->setProperty(
"NormaliseToBeam",
false);
524 }
else if (boost::contains(normalization,
"Monitor")) {
525 if (monitorRefFile.empty()) {
526 g_log.
error() <<
"ERROR: normalize-to-monitor was turned ON but no "
527 "reference data was selected\n";
531 normAlg->setProperty(
"NormaliseToMonitor",
true);
532 normAlg->setProperty(
"BeamSpectrumFile", monitorRefFile);
534 normAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
535 auto normAlgProp = std::make_unique<AlgorithmProperty>(
"NormaliseAlgorithm");
536 normAlgProp->setValue(normAlg->toString());
537 reductionManager->declareProperty(std::move(normAlgProp));
541 const bool useConfigBeam =
getProperty(
"UseConfigBeam");
542 loadAlg->setProperty(
"UseConfigBeam", useConfigBeam);
543 const bool useConfigTOFCuts =
getProperty(
"UseConfigTOFCuts");
544 loadAlg->setProperty(
"UseConfigTOFCuts", useConfigTOFCuts);
545 if (!useConfigTOFCuts) {
547 const double highTOFCut =
getProperty(
"HighTOFCut");
548 loadAlg->setProperty(
"LowTOFCut", lowTOFCut);
549 loadAlg->setProperty(
"HighTOFCut", highTOFCut);
552 const bool skipTOFCorrection =
getProperty(
"SkipTOFCorrection");
553 loadAlg->setProperty(
"SkipTOFCorrection", skipTOFCorrection);
555 const bool correctForFlightPath =
getProperty(
"CorrectForFlightPath");
556 loadAlg->setProperty(
"CorrectForFlightPath", correctForFlightPath);
558 const bool preserveEvents =
getProperty(
"PreserveEvents");
559 loadAlg->setProperty(
"PreserveEvents", preserveEvents);
561 loadAlg->setProperty(
"LoadMonitors", (loadMonitors && monitorRefFile.empty()));
563 const double sdd =
getProperty(
"SampleDetectorDistance");
564 loadAlg->setProperty(
"SampleDetectorDistance", sdd);
565 const double sddOffset =
getProperty(
"SampleDetectorDistanceOffset");
566 loadAlg->setProperty(
"SampleDetectorDistanceOffset", sddOffset);
567 const double dOffset =
getProperty(
"DetectorOffset");
568 loadAlg->setProperty(
"DetectorOffset", dOffset);
569 const double sOffset =
getProperty(
"SampleOffset");
570 loadAlg->setProperty(
"SampleOffset", sOffset);
571 const double wlStep =
getProperty(
"WavelengthStep");
572 loadAlg->setProperty(
"WavelengthStep", wlStep);
575 loadAlg->setProperty(
"UseConfig", useConfig);
576 const bool useConfigMask =
getProperty(
"UseConfigMask");
577 loadAlg->setProperty(
"UseConfigMask", useConfigMask);
578 const bool loadNexusInstrumentXML =
getProperty(
"LoadNexusInstrumentXML");
579 loadAlg->setProperty(
"LoadNexusInstrumentXML", loadNexusInstrumentXML);
580 auto loadAlgProp = std::make_unique<AlgorithmProperty>(
"LoadAlgorithm");
581 loadAlgProp->setValue(loadAlg->toString());
582 reductionManager->declareProperty(std::move(loadAlgProp));
586 if (!darkCurrentFile.empty()) {
588 darkAlg->setProperty(
"Filename", darkCurrentFile);
589 darkAlg->setProperty(
"OutputDarkCurrentWorkspace",
"");
590 darkAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
591 auto dcAlgProp = std::make_unique<AlgorithmProperty>(
"DarkCurrentAlgorithm");
592 dcAlgProp->setValue(darkAlg->toString());
593 reductionManager->declareProperty(std::move(dcAlgProp));
598 darkDefaultAlg->setProperty(
"OutputDarkCurrentWorkspace",
"");
599 darkDefaultAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
600 auto ddcAlgProp = std::make_unique<AlgorithmProperty>(
"DefaultDarkCurrentAlgorithm");
601 ddcAlgProp->setValue(darkDefaultAlg->toString());
602 reductionManager->declareProperty(std::move(ddcAlgProp));
605 const bool solidAngleCorrection =
getProperty(
"SolidAngleCorrection");
606 if (solidAngleCorrection) {
607 const bool detectorTubes =
getProperty(
"DetectorTubes");
609 solidAlg->setProperty(
"DetectorTubes", detectorTubes);
610 auto ssaAlgProp = std::make_unique<AlgorithmProperty>(
"SANSSolidAngleCorrection");
611 ssaAlgProp->setValue(solidAlg->toString());
612 reductionManager->declareProperty(std::move(ssaAlgProp));
616 const double beamCenterX =
getProperty(
"BeamCenterX");
617 const double beamCenterY =
getProperty(
"BeamCenterY");
621 if (boost::iequals(centerMethod,
"Value")) {
626 }
else if (!boost::iequals(centerMethod,
"None")) {
627 bool useDirectBeamMethod =
true;
628 if (!boost::iequals(centerMethod,
"DirectBeam"))
629 useDirectBeamMethod =
false;
630 const std::string beamCenterFile =
getProperty(
"BeamCenterFile");
631 if (!beamCenterFile.empty()) {
632 const double beamRadius =
getProperty(
"BeamRadius");
635 ctrAlg->setProperty(
"Filename", beamCenterFile);
636 ctrAlg->setProperty(
"UseDirectBeamMethod", useDirectBeamMethod);
638 ctrAlg->setProperty(
"BeamRadius", beamRadius);
639 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
641 auto ctrAlgProp = std::make_unique<AlgorithmProperty>(
"SANSBeamFinderAlgorithm");
642 ctrAlgProp->setValue(ctrAlg->toString());
643 reductionManager->declareProperty(std::move(ctrAlgProp));
645 g_log.
error() <<
"ERROR: Beam center determination was required"
646 " but no file was provided\n";
656 const double thickness =
getProperty(
"SampleThickness");
659 thickAlg->setProperty(
"SampleThickness", thickness);
661 auto geomAlgProp = std::make_unique<AlgorithmProperty>(
"GeometryAlgorithm");
662 geomAlgProp->setValue(thickAlg->toString());
663 reductionManager->declareProperty(std::move(geomAlgProp));
669 const std::string maskSide =
getProperty(
"MaskedSide");
673 maskAlg->setPropertyValue(
"Facility",
"SNS");
674 maskAlg->setPropertyValue(
"MaskedDetectorList", maskDetList);
675 maskAlg->setPropertyValue(
"MaskedEdges", maskEdges);
676 maskAlg->setProperty(
"MaskedSide", maskSide);
677 auto maskAlgProp = std::make_unique<AlgorithmProperty>(
"MaskAlgorithm");
678 maskAlgProp->setValue(maskAlg->toString());
679 reductionManager->declareProperty(std::move(maskAlgProp));
682 const std::string absScaleMethod =
getProperty(
"AbsoluteScaleMethod");
683 if (boost::iequals(absScaleMethod,
"Value")) {
684 const double absScaleFactor =
getProperty(
"AbsoluteScalingFactor");
687 absAlg->setProperty(
"Method", absScaleMethod);
688 absAlg->setProperty(
"ScalingFactor", absScaleFactor);
689 absAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
690 auto absAlgProp = std::make_unique<AlgorithmProperty>(
"AbsoluteScaleAlgorithm");
691 absAlgProp->setValue(absAlg->toString());
692 reductionManager->declareProperty(std::move(absAlgProp));
693 }
else if (boost::iequals(absScaleMethod,
"ReferenceData")) {
694 const std::string absRefFile =
getPropertyValue(
"AbsoluteScalingReferenceFilename");
695 const double beamDiam =
getProperty(
"AbsoluteScalingBeamDiameter");
696 const double attTrans =
getProperty(
"AbsoluteScalingAttenuatorTrans");
697 const bool applySensitivity =
getProperty(
"AbsoluteScalingApplySensitivity");
700 absAlg->setProperty(
"Method", absScaleMethod);
701 absAlg->setProperty(
"ReferenceDataFilename", absRefFile);
702 absAlg->setProperty(
"BeamstopDiameter", beamDiam);
703 absAlg->setProperty(
"AttenuatorTransmission", attTrans);
704 absAlg->setProperty(
"ApplySensitivity", applySensitivity);
705 absAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
706 auto scaleAlgProp = std::make_unique<AlgorithmProperty>(
"AbsoluteScaleAlgorithm");
707 scaleAlgProp->setValue(absAlg->toString());
708 reductionManager->declareProperty(std::move(scaleAlgProp));
712 const bool doAveraging =
getProperty(
"DoAzimuthalAverage");
715 const bool logBinning =
getProperty(
"IQLogBinning");
716 const double sampleApert =
getProperty(
"SampleApertureDiameter");
717 const bool computeResolution =
getProperty(
"ComputeResolution");
718 const bool indepBinning =
getProperty(
"IQIndependentBinning");
719 const bool scaleResults =
getProperty(
"IQScaleResults");
722 iqAlg->setPropertyValue(
"NumberOfBins", nBins);
723 iqAlg->setProperty(
"LogBinning", logBinning);
724 iqAlg->setProperty(
"ScaleResults", scaleResults);
725 iqAlg->setProperty(
"ComputeResolution", computeResolution);
726 iqAlg->setProperty(
"IndependentBinning", indepBinning);
727 iqAlg->setProperty(
"SampleApertureDiameter", sampleApert);
728 iqAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
730 auto iqalgProp = std::make_unique<AlgorithmProperty>(
"IQAlgorithm");
731 iqalgProp->setValue(iqAlg->toString());
732 reductionManager->declareProperty(std::move(iqalgProp));
736 const bool do2DReduction =
getProperty(
"Do2DReduction");
740 iqAlg->setPropertyValue(
"NumberOfBins", n_bins);
741 auto xyalgProp = std::make_unique<AlgorithmProperty>(
"IQXYAlgorithm");
742 xyalgProp->setValue(iqAlg->toString());
743 reductionManager->declareProperty(std::move(xyalgProp));
748 auto setupAlgProp = std::make_unique<AlgorithmProperty>(
"SetupAlgorithm");
750 reductionManager->declareProperty(std::move(setupAlgProp));
754 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
757 if (!sensitivityFile.empty()) {
758 const bool useSampleDC =
getProperty(
"UseDefaultDC");
759 const std::string sensitivityDarkCurrentFile =
getPropertyValue(
"SensitivityDarkCurrentFile");
760 const std::string outputSensitivityWS =
getPropertyValue(
"OutputSensitivityWorkspace");
761 const double minEff =
getProperty(
"MinEfficiency");
762 const double maxEff =
getProperty(
"MaxEfficiency");
763 const double sensitivityBeamCenterX =
getProperty(
"SensitivityBeamCenterX");
764 const double sensitivityBeamCenterY =
getProperty(
"SensitivityBeamCenterY");
767 effAlg->setProperty(
"Filename", sensitivityFile);
768 effAlg->setProperty(
"UseSampleDC", useSampleDC);
769 effAlg->setProperty(
"DarkCurrentFile", sensitivityDarkCurrentFile);
770 effAlg->setProperty(
"MinEfficiency", minEff);
771 effAlg->setProperty(
"MaxEfficiency", maxEff);
774 const std::string centerMethod =
getPropertyValue(
"SensitivityBeamCenterMethod");
775 if (boost::iequals(centerMethod,
"Value")) {
776 if (!
isEmpty(sensitivityBeamCenterX) && !
isEmpty(sensitivityBeamCenterY)) {
777 effAlg->setProperty(
"BeamCenterX", sensitivityBeamCenterX);
778 effAlg->setProperty(
"BeamCenterY", sensitivityBeamCenterY);
780 }
else if (boost::iequals(centerMethod,
"DirectBeam") || boost::iequals(centerMethod,
"Scattering")) {
781 const std::string beamCenterFile =
getProperty(
"SensitivityBeamCenterFile");
782 const double sensitivityBeamRadius =
getProperty(
"SensitivityBeamCenterRadius");
783 bool useDirectBeam = boost::iequals(centerMethod,
"DirectBeam");
784 if (!beamCenterFile.empty()) {
786 ctrAlg->setProperty(
"Filename", beamCenterFile);
787 ctrAlg->setProperty(
"UseDirectBeamMethod", useDirectBeam);
788 ctrAlg->setProperty(
"PersistentCorrection",
false);
789 if (!
isEmpty(sensitivityBeamRadius))
790 ctrAlg->setProperty(
"BeamRadius", sensitivityBeamRadius);
791 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
793 auto sensAlgProp = std::make_unique<AlgorithmProperty>(
"SensitivityBeamCenterAlgorithm");
794 sensAlgProp->setValue(ctrAlg->toString());
795 reductionManager->declareProperty(std::move(sensAlgProp));
797 g_log.
error() <<
"ERROR: Sensitivity beam center determination was required"
798 " but no file was provided\n";
802 effAlg->setPropertyValue(
"OutputSensitivityWorkspace", outputSensitivityWS);
803 effAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
805 auto algProp = std::make_unique<AlgorithmProperty>(
"SensitivityAlgorithm");
806 algProp->setValue(effAlg->toString());
807 reductionManager->declareProperty(std::move(algProp));
811 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
813 const bool thetaDependentTrans =
getProperty(
"ThetaDependentTransmission");
814 const std::string transMethod =
getProperty(
"TransmissionMethod");
815 const std::string darkCurrent =
getPropertyValue(
"TransmissionDarkCurrentFile");
816 const bool useSampleDC =
getProperty(
"TransmissionUseSampleDC");
819 if (boost::iequals(transMethod,
"Value")) {
820 const double transValue =
getProperty(
"TransmissionValue");
821 const double transError =
getProperty(
"TransmissionError");
824 transAlg->setProperty(
"TransmissionValue", transValue);
825 transAlg->setProperty(
"TransmissionError", transError);
826 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
828 auto algProp = std::make_unique<AlgorithmProperty>(
"TransmissionAlgorithm");
829 algProp->setValue(transAlg->toString());
830 reductionManager->declareProperty(std::move(algProp));
833 "expected transmission/error values and got empty values");
837 else if (boost::iequals(transMethod,
"DirectBeam")) {
838 const std::string sampleFilename =
getPropertyValue(
"TransmissionSampleDataFile");
839 const std::string emptyFilename =
getPropertyValue(
"TransmissionEmptyDataFile");
840 const double beamRadius =
getProperty(
"TransmissionBeamRadius");
841 const bool fitFramesTogether =
getProperty(
"FitFramesTogether");
842 const double beamX =
getProperty(
"TransmissionBeamCenterX");
843 const double beamY =
getProperty(
"TransmissionBeamCenterY");
844 const std::string centerMethod =
getPropertyValue(
"TransmissionBeamCenterMethod");
847 transAlg->setProperty(
"FitFramesTogether", fitFramesTogether);
848 transAlg->setProperty(
"SampleDataFilename", sampleFilename);
849 transAlg->setProperty(
"EmptyDataFilename", emptyFilename);
850 transAlg->setProperty(
"BeamRadius", beamRadius);
851 transAlg->setProperty(
"DarkCurrentFilename", darkCurrent);
852 transAlg->setProperty(
"UseSampleDarkCurrent", useSampleDC);
855 if (boost::iequals(centerMethod,
"Value") && !
isEmpty(beamX) && !
isEmpty(beamY)) {
856 transAlg->setProperty(
"BeamCenterX", beamX);
857 transAlg->setProperty(
"BeamCenterY", beamY);
858 }
else if (boost::iequals(centerMethod,
"DirectBeam")) {
859 const std::string beamCenterFile =
getProperty(
"TransmissionBeamCenterFile");
860 if (!beamCenterFile.empty()) {
862 ctrAlg->setProperty(
"Filename", beamCenterFile);
863 ctrAlg->setProperty(
"UseDirectBeamMethod",
true);
864 ctrAlg->setProperty(
"PersistentCorrection",
false);
865 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
867 auto algProp = std::make_unique<AlgorithmProperty>(
"TransmissionBeamCenterAlgorithm");
868 algProp->setValue(ctrAlg->toString());
869 reductionManager->declareProperty(std::move(algProp));
871 g_log.
error() <<
"ERROR: Transmission beam center determination was required"
872 " but no file was provided\n";
875 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
876 auto algProp = std::make_unique<AlgorithmProperty>(
"TransmissionAlgorithm");
877 algProp->setValue(transAlg->toString());
878 reductionManager->declareProperty(std::move(algProp));
883 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
886 if (!backgroundFile.empty())
887 reductionManager->declareProperty(
892 const std::string darkCurrent =
getPropertyValue(
"BckTransmissionDarkCurrentFile");
893 const bool bckThetaDependentTrans =
getProperty(
"BckThetaDependentTransmission");
894 const std::string bckTransMethod =
getProperty(
"BckTransmissionMethod");
895 if (boost::iequals(bckTransMethod,
"Value")) {
896 const double transValue =
getProperty(
"BckTransmissionValue");
897 const double transError =
getProperty(
"BckTransmissionError");
900 transAlg->setProperty(
"TransmissionValue", transValue);
901 transAlg->setProperty(
"TransmissionError", transError);
902 transAlg->setProperty(
"ThetaDependent", bckThetaDependentTrans);
904 auto algProp = std::make_unique<AlgorithmProperty>(
"BckTransmissionAlgorithm");
905 algProp->setValue(transAlg->toString());
906 reductionManager->declareProperty(std::move(algProp));
909 "expected transmission/error values and got empty values");
911 }
else if (boost::iequals(bckTransMethod,
"DirectBeam")) {
912 const std::string sampleFilename =
getPropertyValue(
"BckTransmissionSampleDataFile");
913 const std::string emptyFilename =
getPropertyValue(
"BckTransmissionEmptyDataFile");
914 const double beamRadius =
getProperty(
"BckTransmissionBeamRadius");
915 const double beamX =
getProperty(
"BckTransmissionBeamCenterX");
916 const double beamY =
getProperty(
"BckTransmissionBeamCenterY");
917 const bool thetaDependentTrans =
getProperty(
"BckThetaDependentTransmission");
918 const bool useSampleDC =
getProperty(
"TransmissionUseSampleDC");
919 const bool fitFramesTogether =
getProperty(
"BckFitFramesTogether");
922 transAlg->setProperty(
"FitFramesTogether", fitFramesTogether);
923 transAlg->setProperty(
"SampleDataFilename", sampleFilename);
924 transAlg->setProperty(
"EmptyDataFilename", emptyFilename);
925 transAlg->setProperty(
"BeamRadius", beamRadius);
926 transAlg->setProperty(
"DarkCurrentFilename", darkCurrent);
927 transAlg->setProperty(
"UseSampleDarkCurrent", useSampleDC);
930 const std::string centerMethod =
getPropertyValue(
"BckTransmissionBeamCenterMethod");
931 if (boost::iequals(centerMethod,
"Value") && !
isEmpty(beamX) && !
isEmpty(beamY)) {
932 transAlg->setProperty(
"BeamCenterX", beamX);
933 transAlg->setProperty(
"BeamCenterY", beamY);
934 }
else if (boost::iequals(centerMethod,
"DirectBeam")) {
935 const std::string beamCenterFile =
getProperty(
"BckTransmissionBeamCenterFile");
936 if (!beamCenterFile.empty()) {
938 ctrAlg->setProperty(
"Filename", beamCenterFile);
939 ctrAlg->setProperty(
"UseDirectBeamMethod",
true);
940 ctrAlg->setProperty(
"PersistentCorrection",
false);
941 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
943 auto algProp = std::make_unique<AlgorithmProperty>(
"BckTransmissionBeamCenterAlgorithm");
944 algProp->setValue(ctrAlg->toString());
945 reductionManager->declareProperty(std::move(algProp));
947 g_log.
error() <<
"ERROR: Beam center determination was required"
948 " but no file was provided\n";
951 transAlg->setProperty(
"DarkCurrentFilename", darkCurrent);
952 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
953 auto algProp = std::make_unique<AlgorithmProperty>(
"BckTransmissionAlgorithm");
954 algProp->setValue(transAlg->toString());
955 reductionManager->declareProperty(std::move(algProp));
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
std::string toString() const override
Serialize an object to a string.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
void setPropertyValue(const std::string &name, const std::string &value) override
Set the value of a property by string N.B.
static bool isEmpty(const NumT toCheck)
checks that the value was not set by users, uses the value in empty double/int.
@ OptionalLoad
to specify a file to read but the file doesn't have to exist
Support for a property that holds an array of values.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
void error(const std::string &msg)
Logs at error 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...
void setupSensitivity(const std::shared_ptr< Kernel::PropertyManager > &reductionManager)
void setupBackground(const std::shared_ptr< Kernel::PropertyManager > &reductionManager)
void init() override
Initialisation code.
void setupTransmission(const std::shared_ptr< Kernel::PropertyManager > &reductionManager)
void exec() override
Execution code.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.