20#include <boost/algorithm/string/predicate.hpp>
26using namespace Kernel;
28using namespace Geometry;
29using namespace DataObjects;
33 std::string load_grp =
"Load Options";
36 "Sample to detector distance to use (overrides meta data), in mm");
38 "Offset to the sample to detector distance (use only when "
39 "using the distance found in the meta data), in mm");
40 declareProperty(
"SolidAngleCorrection",
true,
"If true, the solid angle correction will be applied to the data");
41 declareProperty(
"DetectorTubes",
false,
"If true, the solid angle correction for tube detectors will be applied");
43 "If true, the solid angle "
44 "correction for the Wing Detector (curved detector) "
50 auto mustBePositive = std::make_shared<Kernel::BoundedValidator<double>>();
51 mustBePositive->setLower(0.0);
53 "Wavelength value to use when loading the data file (Angstrom).");
55 "Wavelength spread to use when loading the data file (default 0.0)");
66 std::string center_grp =
"Beam Center";
67 std::vector<std::string> centerOptions{
"None",
"Value",
"DirectBeam",
"Scattering"};
69 declareProperty(
"BeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
70 "Method for determining the data beam center");
80 "The name of the input data file to load");
82 std::make_unique<VisibleWhenProperty>(
"BeamCenterMethod",
IS_NOT_EQUAL_TO,
"None"));
86 auto positiveDouble = std::make_shared<BoundedValidator<double>>();
87 positiveDouble->setLower(0);
89 "Radius of the beam area used the exclude the beam when calculating "
90 "the center of mass of the scattering pattern [pixels]. Default=3.0");
92 std::make_unique<VisibleWhenProperty>(
"BeamCenterMethod",
IS_EQUAL_TO,
"Scattering"));
102 std::vector<std::string> incidentBeamNormOptions;
103 incidentBeamNormOptions.emplace_back(
"None");
104 incidentBeamNormOptions.emplace_back(
"Monitor");
105 incidentBeamNormOptions.emplace_back(
"Timer");
106 this->
declareProperty(
"Normalisation",
"Monitor", std::make_shared<StringListValidator>(incidentBeamNormOptions),
107 "Options for data normalisation");
111 "The name of the input data file to load as dark current.");
114 std::string eff_grp =
"Sensitivity";
116 "Flood field or sensitivity file.");
118 "Minimum efficiency for a pixel to be considered (default: no minimum).");
120 "Maximum efficiency for a pixel to be considered (default: no maximum).");
122 "If true, the dark current subtracted "
123 "from the sample data will also be "
124 "subtracted from the flood field.");
127 "The name of the input file to load as dark current.");
129 std::make_unique<VisibleWhenProperty>(
"UseDefaultDC",
IS_EQUAL_TO,
"0"));
132 declareProperty(
"SensitivityBeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
133 "Method for determining the sensitivity data beam center");
138 std::make_unique<VisibleWhenProperty>(
"SensitivityBeamCenterMethod",
IS_EQUAL_TO,
"Value"));
142 std::make_unique<VisibleWhenProperty>(
"SensitivityBeamCenterMethod",
IS_EQUAL_TO,
"Value"));
147 "The name of the input data file to load");
149 std::make_unique<VisibleWhenProperty>(
"SensitivityBeamCenterMethod",
IS_NOT_EQUAL_TO,
"None"));
152 "Radius of the beam area used the exclude the beam when calculating "
153 "the center of mass of the scattering pattern [pixels]. Default=3.0");
155 std::make_unique<VisibleWhenProperty>(
"BeamCenterMethod",
IS_EQUAL_TO,
"Scattering"));
173 std::string trans_grp =
"Transmission";
174 std::vector<std::string> transOptions{
"Value",
"DirectBeam",
"BeamSpreader"};
175 declareProperty(
"TransmissionMethod",
"Value", std::make_shared<StringListValidator>(transOptions),
176 "Transmission determination method");
181 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"Value"));
184 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"Value"));
187 declareProperty(
"TransmissionBeamRadius", 3.0,
"Radius of the beam area used to compute the transmission [pixels]");
189 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
192 "Sample data file for transmission calculation");
194 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
197 "Empty data file for transmission calculation");
199 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
202 declareProperty(
"TransmissionBeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
203 "Method for determining the transmission data beam center");
205 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
210 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
213 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
218 "The name of the input data file to load");
220 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
226 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
230 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
231 declareProperty(std::make_unique<API::FileProperty>(
"TransSampleScatteringFilename",
"",
234 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
235 declareProperty(std::make_unique<API::FileProperty>(
"TransDirectScatteringFilename",
"",
238 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
239 declareProperty(
"SpreaderTransmissionValue", 1.0,
"Beam spreader transmission value");
241 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
242 declareProperty(
"SpreaderTransmissionError", 0.0,
"Beam spreader transmission error");
244 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
248 "The name of the input data file to load as transmission dark current.");
250 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_NOT_EQUAL_TO,
"Value"));
253 "If true, the sample dark current will be used IF a dark current file is"
256 std::make_unique<VisibleWhenProperty>(
"TransmissionMethod",
IS_NOT_EQUAL_TO,
"Value"));
259 "If true, a theta-dependent transmission correction will be applied.");
283 std::string bck_grp =
"Background";
285 declareProperty(
"BckTransmissionMethod",
"Value", std::make_shared<StringListValidator>(transOptions),
286 "Transmission determination method");
291 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"Value"));
295 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"Value"));
299 "Radius of the beam area used to compute the transmission [pixels]");
301 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
304 "Sample data file for transmission calculation");
306 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
309 "Empty data file for transmission calculation");
311 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
314 declareProperty(
"BckTransmissionBeamCenterMethod",
"None", std::make_shared<StringListValidator>(centerOptions),
315 "Method for determining the transmission data beam center");
317 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
321 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
325 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
328 "The name of the input data file to load");
330 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"DirectBeam"));
333 declareProperty(std::make_unique<API::FileProperty>(
"BckTransSampleSpreaderFilename",
"",
336 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
337 declareProperty(std::make_unique<API::FileProperty>(
"BckTransDirectSpreaderFilename",
"",
340 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
341 declareProperty(std::make_unique<API::FileProperty>(
"BckTransSampleScatteringFilename",
"",
344 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
345 declareProperty(std::make_unique<API::FileProperty>(
"BckTransDirectScatteringFilename",
"",
348 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
349 declareProperty(
"BckSpreaderTransmissionValue", 1.0,
"Beam spreader transmission value");
351 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
352 declareProperty(
"BckSpreaderTransmissionError", 0.0,
"Beam spreader transmission error");
354 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
356 declareProperty(std::make_unique<API::FileProperty>(
"BckTransmissionDarkCurrentFile",
"",
358 "The name of the input data file to load as background "
359 "transmission dark current.");
361 std::make_unique<VisibleWhenProperty>(
"BckTransmissionMethod",
IS_EQUAL_TO,
"BeamSpreader"));
364 "If true, a theta-dependent transmission correction will be applied.");
390 std::string mask_grp =
"Mask";
393 "Number of pixels to mask on the edges: X-low, X-high, Y-low, Y-high");
394 declareProperty(
"MaskedComponent",
"",
"Component Name to mask the edges according to the IDF file.");
395 std::vector<std::string> maskOptions;
396 maskOptions.emplace_back(
"None");
397 maskOptions.emplace_back(
"Front");
398 maskOptions.emplace_back(
"Back");
399 declareProperty(
"MaskedSide",
"None", std::make_shared<StringListValidator>(maskOptions),
400 "Mask one side of the detector");
401 declareProperty(
"MaskedFullComponent",
"",
"Component Name to mask the edges according to the IDF file.");
410 std::string abs_scale_grp =
"Absolute Scale";
411 std::vector<std::string> scaleOptions;
412 scaleOptions.emplace_back(
"None");
413 scaleOptions.emplace_back(
"Value");
414 scaleOptions.emplace_back(
"ReferenceData");
415 declareProperty(
"AbsoluteScaleMethod",
"None", std::make_shared<StringListValidator>(scaleOptions),
416 "Absolute scale correction method");
417 declareProperty(
"AbsoluteScalingFactor", 1.0,
"Absolute scaling factor");
419 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"Value"));
421 declareProperty(std::make_unique<API::FileProperty>(
"AbsoluteScalingReferenceFilename",
"",
424 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
426 "Beamstop diameter for computing the absolute scale factor [mm]. "
427 "Read from file if not supplied.");
429 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
431 "Attenuator transmission value for computing the absolute scale factor");
433 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
435 "Apply sensitivity correction to the reference data "
436 "when computing the absolute scale factor");
438 std::make_unique<VisibleWhenProperty>(
"AbsoluteScaleMethod",
IS_EQUAL_TO,
"ReferenceData"));
448 std::string iq1d_grp =
"I(q) Calculation";
452 auto positiveInt = std::make_shared<BoundedValidator<int>>();
453 positiveInt->setLower(0);
454 declareProperty(
"IQNumberOfBins", 100, positiveInt,
"Number of I(q) bins when binning is not specified.");
455 declareProperty(
"IQLogBinning",
false,
"I(q) log binning when binning is not specified.");
457 "If true and log binning was selected, the bins will be aligned to log "
459 "and the number of bins will be used as the number of bins per decade.");
462 "Number of sub-pixels used for each detector pixel in each direction."
463 "The total number of sub-pixels will be NPixelDivision*NPixelDivision.");
464 declareProperty(
"ErrorWeighting",
false,
"Choose whether each pixel contribution will be weighted by 1/error^2.");
467 declareProperty(
"NumberOfWedges", 2, positiveInt,
"Number of wedges to calculate.");
468 declareProperty(
"WedgeAngle", 30.0,
"Opening angle of each wedge, in degrees.");
469 declareProperty(
"WedgeOffset", 0.0,
"Angular offset for the wedges, in degrees.");
472 declareProperty(
"IQ2DNumberOfBins", 100, positiveInt,
"Number of I(qx,qy) bins.");
473 declareProperty(
"IQxQyLogBinning",
false,
"I(qx,qy) log binning when binning is not specified.");
483 declareProperty(
"OutputDirectory",
"",
"Directory to put the output files in");
490 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
491 if (reductionManagerName.empty()) {
492 g_log.
error() <<
"ERROR: Reduction Property Manager name is empty\n";
495 std::shared_ptr<PropertyManager> reductionManager = std::make_shared<PropertyManager>();
502 const std::string processInfo =
getProperty(
"ProcessInfo");
506 const std::string outputDirectory =
getProperty(
"OutputDirectory");
507 reductionManager->declareProperty(
511 const double sdd =
getProperty(
"SampleDetectorDistance");
512 const double sddOffset =
getProperty(
"SampleDetectorDistanceOffset");
513 const double wavelength =
getProperty(
"Wavelength");
514 const double wavelengthSpread =
getProperty(
"WavelengthSpread");
518 loadAlg->setProperty(
"SampleDetectorDistance", sdd);
520 loadAlg->setProperty(
"SampleDetectorDistanceOffset", sddOffset);
522 loadAlg->setProperty(
"Wavelength", wavelength);
523 loadAlg->setProperty(
"WavelengthSpread", wavelengthSpread);
525 auto loadAlgProp = std::make_unique<AlgorithmProperty>(
"LoadAlgorithm");
526 loadAlgProp->setValue(loadAlg->toString());
527 reductionManager->declareProperty(std::move(loadAlgProp));
530 const double beamCenterX =
getProperty(
"BeamCenterX");
531 const double beamCenterY =
getProperty(
"BeamCenterY");
535 if (boost::iequals(centerMethod,
"Value")) {
540 }
else if (!boost::iequals(centerMethod,
"None")) {
541 bool useDirectBeamMethod =
true;
542 if (!boost::iequals(centerMethod,
"DirectBeam"))
543 useDirectBeamMethod =
false;
544 const std::string beamCenterFile =
getProperty(
"BeamCenterFile");
545 if (!beamCenterFile.empty()) {
546 const double beamRadius =
getProperty(
"BeamRadius");
549 ctrAlg->setProperty(
"Filename", beamCenterFile);
550 ctrAlg->setProperty(
"UseDirectBeamMethod", useDirectBeamMethod);
552 ctrAlg->setProperty(
"BeamRadius", beamRadius);
553 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
555 auto beamFinderAlgProp = std::make_unique<AlgorithmProperty>(
"SANSBeamFinderAlgorithm");
556 beamFinderAlgProp->setValue(ctrAlg->toString());
557 reductionManager->declareProperty(std::move(beamFinderAlgProp));
559 g_log.
error() <<
"ERROR: Beam center determination was required"
560 " but no file was provided\n";
566 if (!darkCurrentFile.empty()) {
568 darkAlg->setProperty(
"Filename", darkCurrentFile);
569 darkAlg->setProperty(
"OutputDarkCurrentWorkspace",
"");
570 darkAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
571 auto dcAlgProp = std::make_unique<AlgorithmProperty>(
"DarkCurrentAlgorithm");
572 dcAlgProp->setValue(darkAlg->toString());
573 reductionManager->declareProperty(std::move(dcAlgProp));
578 darkDefaultAlg->setProperty(
"OutputDarkCurrentWorkspace",
"");
579 darkDefaultAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
580 auto ddcAlgProp = std::make_unique<AlgorithmProperty>(
"DefaultDarkCurrentAlgorithm");
581 ddcAlgProp->setValue(darkDefaultAlg->toString());
582 reductionManager->declareProperty(std::move(ddcAlgProp));
585 const bool solidAngleCorrection =
getProperty(
"SolidAngleCorrection");
586 const bool isTubeDetector =
getProperty(
"DetectorTubes");
587 const bool isCurvedDetector =
getProperty(
"DetectorWing");
588 if (solidAngleCorrection) {
590 solidAlg->setProperty(
"DetectorTubes", isTubeDetector);
591 solidAlg->setProperty(
"DetectorWing", isCurvedDetector);
592 auto ssaAlgProp = std::make_unique<AlgorithmProperty>(
"SANSSolidAngleCorrection");
593 ssaAlgProp->setValue(solidAlg->toString());
594 reductionManager->declareProperty(std::move(ssaAlgProp));
598 const std::string normalization =
getProperty(
"Normalisation");
599 if (!boost::contains(normalization,
"None")) {
601 normAlg->setProperty(
"NormalisationType", normalization);
602 auto normAlgProp = std::make_unique<AlgorithmProperty>(
"NormaliseAlgorithm");
603 normAlgProp->setValue(normAlg->toString());
604 reductionManager->declareProperty(std::move(normAlgProp));
605 reductionManager->declareProperty(
608 reductionManager->declareProperty(
617 const double thickness =
getProperty(
"SampleThickness");
620 thickAlg->setProperty(
"SampleThickness", thickness);
622 auto thickAlgProp = std::make_unique<AlgorithmProperty>(
"GeometryAlgorithm");
623 thickAlgProp->setValue(thickAlg->toString());
624 reductionManager->declareProperty(std::move(thickAlgProp));
630 const std::string maskSide =
getProperty(
"MaskedSide");
632 const std::string maskFullComponent =
getPropertyValue(
"MaskedFullComponent");
636 maskAlg->setPropertyValue(
"Facility",
"HFIR");
637 maskAlg->setPropertyValue(
"MaskedDetectorList", maskDetList);
638 maskAlg->setPropertyValue(
"MaskedEdges", maskEdges);
639 maskAlg->setProperty(
"MaskedSide", maskSide);
640 maskAlg->setProperty(
"MaskedComponent", maskComponent);
641 maskAlg->setProperty(
"MaskedFullComponent", maskFullComponent);
643 auto maskAlgProp = std::make_unique<AlgorithmProperty>(
"MaskAlgorithm");
644 maskAlgProp->setValue(maskAlg->toString());
645 reductionManager->declareProperty(std::move(maskAlgProp));
648 const std::string absScaleMethod =
getProperty(
"AbsoluteScaleMethod");
649 if (boost::iequals(absScaleMethod,
"Value")) {
650 const double absScaleFactor =
getProperty(
"AbsoluteScalingFactor");
653 absAlg->setProperty(
"Method", absScaleMethod);
654 absAlg->setProperty(
"ScalingFactor", absScaleFactor);
655 absAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
656 auto absScaleAlgProp = std::make_unique<AlgorithmProperty>(
"AbsoluteScaleAlgorithm");
657 absScaleAlgProp->setValue(absAlg->toString());
658 reductionManager->declareProperty(std::move(absScaleAlgProp));
659 }
else if (boost::iequals(absScaleMethod,
"ReferenceData")) {
660 const std::string absRefFile =
getPropertyValue(
"AbsoluteScalingReferenceFilename");
661 const double beamDiam =
getProperty(
"AbsoluteScalingBeamDiameter");
662 const double attTrans =
getProperty(
"AbsoluteScalingAttenuatorTrans");
663 const bool applySensitivity =
getProperty(
"AbsoluteScalingApplySensitivity");
666 absAlg->setProperty(
"Method", absScaleMethod);
667 absAlg->setProperty(
"ReferenceDataFilename", absRefFile);
668 absAlg->setProperty(
"BeamstopDiameter", beamDiam);
669 absAlg->setProperty(
"AttenuatorTransmission", attTrans);
670 absAlg->setProperty(
"ApplySensitivity", applySensitivity);
671 absAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
672 auto refScaleAlgProp = std::make_unique<AlgorithmProperty>(
"AbsoluteScaleAlgorithm");
673 refScaleAlgProp->setValue(absAlg->toString());
674 reductionManager->declareProperty(std::move(refScaleAlgProp));
678 const bool doAveraging =
getProperty(
"DoAzimuthalAverage");
682 const bool log_binning =
getProperty(
"IQLogBinning");
684 const bool err_weighting =
getProperty(
"ErrorWeighting");
687 const double wedge_angle =
getProperty(
"WedgeAngle");
688 const double wedge_offset =
getProperty(
"WedgeOffset");
689 const bool align =
getProperty(
"IQAlignLogWithDecades");
692 iqAlg->setPropertyValue(
"Binning", binning);
693 iqAlg->setPropertyValue(
"NumberOfBins", n_bins);
694 iqAlg->setProperty(
"LogBinning", log_binning);
695 iqAlg->setPropertyValue(
"NumberOfSubpixels", n_subpix);
696 iqAlg->setProperty(
"ErrorWeighting", err_weighting);
697 iqAlg->setProperty(
"ComputeResolution",
true);
698 iqAlg->setProperty(
"NumberOfWedges", n_wedges);
699 iqAlg->setProperty(
"WedgeAngle", wedge_angle);
700 iqAlg->setProperty(
"WedgeOffset", wedge_offset);
701 iqAlg->setProperty(
"AlignWithDecades", align);
702 iqAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
704 auto iqAlgProp = std::make_unique<AlgorithmProperty>(
"IQAlgorithm");
705 iqAlgProp->setValue(iqAlg->toString());
706 reductionManager->declareProperty(std::move(iqAlgProp));
710 const bool do2DReduction =
getProperty(
"Do2DReduction");
713 const bool log_binning =
getProperty(
"IQxQyLogBinning");
715 iqAlg->setPropertyValue(
"NumberOfBins", n_bins);
716 iqAlg->setProperty(
"IQxQyLogBinning", log_binning);
717 auto xyAlgProp = std::make_unique<AlgorithmProperty>(
"IQXYAlgorithm");
718 xyAlgProp->setValue(iqAlg->toString());
719 reductionManager->declareProperty(std::move(xyAlgProp));
725 auto setupAlgProp = std::make_unique<AlgorithmProperty>(
"SetupAlgorithm");
727 reductionManager->declareProperty(std::move(setupAlgProp));
731 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
734 if (!sensitivityFile.empty()) {
735 const bool useSampleDC =
getProperty(
"UseDefaultDC");
736 const std::string sensitivityDarkCurrentFile =
getPropertyValue(
"SensitivityDarkCurrentFile");
737 const std::string outputSensitivityWS =
getPropertyValue(
"OutputSensitivityWorkspace");
738 const double minEff =
getProperty(
"MinEfficiency");
739 const double maxEff =
getProperty(
"MaxEfficiency");
740 const double sensitivityBeamCenterX =
getProperty(
"SensitivityBeamCenterX");
741 const double sensitivityBeamCenterY =
getProperty(
"SensitivityBeamCenterY");
742 const std::string maskFullComponent =
getPropertyValue(
"MaskedFullComponent");
746 std::vector<int> maskEdges =
getProperty(
"MaskedEdges");
750 std::stringstream maskEdgesStringStream;
751 for (
size_t i = 0; i < maskEdges.size(); i++) {
753 maskEdgesStringStream <<
",";
754 if (maskEdges[i] <= 10)
755 maskEdgesStringStream << 0;
757 maskEdgesStringStream << maskEdges[i];
761 effAlg->setProperty(
"Filename", sensitivityFile);
762 effAlg->setProperty(
"UseSampleDC", useSampleDC);
763 effAlg->setProperty(
"DarkCurrentFile", sensitivityDarkCurrentFile);
764 effAlg->setProperty(
"MinEfficiency", minEff);
765 effAlg->setProperty(
"MaxEfficiency", maxEff);
766 effAlg->setProperty(
"MaskedFullComponent", maskFullComponent);
767 effAlg->setProperty(
"MaskedComponent", maskComponent);
768 effAlg->setPropertyValue(
"MaskedEdges", maskEdgesStringStream.str());
771 const std::string centerMethod =
getPropertyValue(
"SensitivityBeamCenterMethod");
772 if (boost::iequals(centerMethod,
"Value")) {
773 if (!
isEmpty(sensitivityBeamCenterX) && !
isEmpty(sensitivityBeamCenterY)) {
774 effAlg->setProperty(
"BeamCenterX", sensitivityBeamCenterX);
775 effAlg->setProperty(
"BeamCenterY", sensitivityBeamCenterY);
777 }
else if (boost::iequals(centerMethod,
"DirectBeam") || boost::iequals(centerMethod,
"Scattering")) {
778 const std::string beamCenterFile =
getProperty(
"SensitivityBeamCenterFile");
779 const double sensitivityBeamRadius =
getProperty(
"SensitivityBeamCenterRadius");
780 bool useDirectBeam = boost::iequals(centerMethod,
"DirectBeam");
781 if (!beamCenterFile.empty()) {
783 ctrAlg->setProperty(
"Filename", beamCenterFile);
784 ctrAlg->setProperty(
"UseDirectBeamMethod", useDirectBeam);
785 ctrAlg->setProperty(
"PersistentCorrection",
false);
786 if (useDirectBeam && !
isEmpty(sensitivityBeamRadius))
787 ctrAlg->setProperty(
"BeamRadius", sensitivityBeamRadius);
788 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
790 auto beamCentreAlgProp = std::make_unique<AlgorithmProperty>(
"SensitivityBeamCenterAlgorithm");
791 beamCentreAlgProp->setValue(ctrAlg->toString());
792 reductionManager->declareProperty(std::move(beamCentreAlgProp));
794 g_log.
error() <<
"ERROR: Sensitivity beam center determination was required"
795 " but no file was provided\n";
799 effAlg->setProperty(
"OutputSensitivityWorkspace", outputSensitivityWS);
800 effAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
802 auto effAlgProp = std::make_unique<AlgorithmProperty>(
"SensitivityAlgorithm");
803 effAlgProp->setValue(effAlg->toString());
804 reductionManager->declareProperty(std::move(effAlgProp));
809 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
812 if (!backgroundFile.empty())
813 reductionManager->declareProperty(
818 const std::string darkCurrent =
getPropertyValue(
"BckTransmissionDarkCurrentFile");
819 const bool bckThetaDependentTrans =
getProperty(
"BckThetaDependentTransmission");
820 const std::string bckTransMethod =
getProperty(
"BckTransmissionMethod");
821 if (boost::iequals(bckTransMethod,
"Value")) {
822 const double transValue =
getProperty(
"BckTransmissionValue");
823 const double transError =
getProperty(
"BckTransmissionError");
826 transAlg->setProperty(
"TransmissionValue", transValue);
827 transAlg->setProperty(
"TransmissionError", transError);
828 transAlg->setProperty(
"ThetaDependent", bckThetaDependentTrans);
830 auto backTransAlgProp = std::make_unique<AlgorithmProperty>(
"BckTransmissionAlgorithm");
831 backTransAlgProp->setValue(transAlg->toString());
832 reductionManager->declareProperty(std::move(backTransAlgProp));
835 "expected transmission/error values and got empty values");
837 }
else if (boost::iequals(bckTransMethod,
"DirectBeam")) {
838 const std::string sampleFilename =
getPropertyValue(
"BckTransmissionSampleDataFile");
839 const std::string emptyFilename =
getPropertyValue(
"BckTransmissionEmptyDataFile");
840 const double beamRadius =
getProperty(
"BckTransmissionBeamRadius");
841 const double beamX =
getProperty(
"BckTransmissionBeamCenterX");
842 const double beamY =
getProperty(
"BckTransmissionBeamCenterY");
843 const bool thetaDependentTrans =
getProperty(
"BckThetaDependentTransmission");
846 transAlg->setProperty(
"SampleDataFilename", sampleFilename);
847 transAlg->setProperty(
"EmptyDataFilename", emptyFilename);
848 transAlg->setProperty(
"BeamRadius", beamRadius);
851 const std::string centerMethod =
getPropertyValue(
"BckTransmissionBeamCenterMethod");
852 if (boost::iequals(centerMethod,
"Value") && !
isEmpty(beamX) && !
isEmpty(beamY)) {
853 transAlg->setProperty(
"BeamCenterX", beamX);
854 transAlg->setProperty(
"BeamCenterY", beamY);
855 }
else if (boost::iequals(centerMethod,
"DirectBeam")) {
856 const std::string beamCenterFile =
getProperty(
"BckTransmissionBeamCenterFile");
857 if (!beamCenterFile.empty()) {
859 ctrAlg->setProperty(
"Filename", beamCenterFile);
860 ctrAlg->setProperty(
"UseDirectBeamMethod",
true);
861 ctrAlg->setProperty(
"PersistentCorrection",
false);
862 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
864 auto backBeamCentreAlgProp = std::make_unique<AlgorithmProperty>(
"BckTransmissionBeamCenterAlgorithm");
865 backBeamCentreAlgProp->setValue(ctrAlg->toString());
866 reductionManager->declareProperty(std::move(backBeamCentreAlgProp));
868 g_log.
error() <<
"ERROR: Beam center determination was required"
869 " but no file was provided\n";
872 transAlg->setProperty(
"DarkCurrentFilename", darkCurrent);
873 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
874 auto btAlgProp = std::make_unique<AlgorithmProperty>(
"BckTransmissionAlgorithm");
875 btAlgProp->setValue(transAlg->toString());
876 reductionManager->declareProperty(std::move(btAlgProp));
879 else if (boost::iequals(bckTransMethod,
"BeamSpreader")) {
880 const std::string sampleSpread =
getPropertyValue(
"BckTransSampleSpreaderFilename");
881 const std::string directSpread =
getPropertyValue(
"BckTransDirectSpreaderFilename");
882 const std::string sampleScatt =
getPropertyValue(
"BckTransSampleScatteringFilename");
883 const std::string directScatt =
getPropertyValue(
"BckTransDirectScatteringFilename");
884 const double spreaderTrValue =
getProperty(
"BckSpreaderTransmissionValue");
885 const double spreaderTrError =
getProperty(
"BckSpreaderTransmissionError");
886 const bool thetaDependentTrans =
getProperty(
"BckThetaDependentTransmission");
889 transAlg->setProperty(
"SampleSpreaderFilename", sampleSpread);
890 transAlg->setProperty(
"DirectSpreaderFilename", directSpread);
891 transAlg->setProperty(
"SampleScatteringFilename", sampleScatt);
892 transAlg->setProperty(
"DirectScatteringFilename", directScatt);
893 transAlg->setProperty(
"SpreaderTransmissionValue", spreaderTrValue);
894 transAlg->setProperty(
"SpreaderTransmissionError", spreaderTrError);
895 transAlg->setProperty(
"DarkCurrentFilename", darkCurrent);
896 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
897 auto btSpreaderAlgProp = std::make_unique<AlgorithmProperty>(
"BckTransmissionAlgorithm");
898 btSpreaderAlgProp->setValue(transAlg->toString());
899 reductionManager->declareProperty(std::move(btSpreaderAlgProp));
904 const std::string reductionManagerName =
getProperty(
"ReductionProperties");
906 const bool thetaDependentTrans =
getProperty(
"ThetaDependentTransmission");
907 const std::string transMethod =
getProperty(
"TransmissionMethod");
908 const std::string darkCurrent =
getPropertyValue(
"TransmissionDarkCurrentFile");
909 const bool useSampleDC =
getProperty(
"TransmissionUseSampleDC");
912 if (boost::iequals(transMethod,
"Value")) {
913 const double transValue =
getProperty(
"TransmissionValue");
914 const double transError =
getProperty(
"TransmissionError");
917 transAlg->setProperty(
"TransmissionValue", transValue);
918 transAlg->setProperty(
"TransmissionError", transError);
919 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
921 auto transAlgProp = std::make_unique<AlgorithmProperty>(
"TransmissionAlgorithm");
922 transAlgProp->setValue(transAlg->toString());
923 reductionManager->declareProperty(std::move(transAlgProp));
926 "expected transmission/error values and got empty values");
930 else if (boost::iequals(transMethod,
"DirectBeam")) {
931 const std::string sampleFilename =
getPropertyValue(
"TransmissionSampleDataFile");
932 const std::string emptyFilename =
getPropertyValue(
"TransmissionEmptyDataFile");
933 const double beamRadius =
getProperty(
"TransmissionBeamRadius");
934 const double beamX =
getProperty(
"TransmissionBeamCenterX");
935 const double beamY =
getProperty(
"TransmissionBeamCenterY");
936 const std::string centerMethod =
getPropertyValue(
"TransmissionBeamCenterMethod");
939 transAlg->setProperty(
"SampleDataFilename", sampleFilename);
940 transAlg->setProperty(
"EmptyDataFilename", emptyFilename);
941 transAlg->setProperty(
"BeamRadius", beamRadius);
942 transAlg->setProperty(
"DarkCurrentFilename", darkCurrent);
943 transAlg->setProperty(
"UseSampleDarkCurrent", useSampleDC);
946 if (boost::iequals(centerMethod,
"Value") && !
isEmpty(beamX) && !
isEmpty(beamY)) {
947 transAlg->setProperty(
"BeamCenterX", beamX);
948 transAlg->setProperty(
"BeamCenterY", beamY);
949 }
else if (boost::iequals(centerMethod,
"DirectBeam")) {
950 const std::string beamCenterFile =
getProperty(
"TransmissionBeamCenterFile");
951 if (!beamCenterFile.empty()) {
953 ctrAlg->setProperty(
"Filename", beamCenterFile);
954 ctrAlg->setProperty(
"UseDirectBeamMethod",
true);
955 ctrAlg->setProperty(
"PersistentCorrection",
false);
956 ctrAlg->setPropertyValue(
"ReductionProperties", reductionManagerName);
958 auto tbcAlgProp = std::make_unique<AlgorithmProperty>(
"TransmissionBeamCenterAlgorithm");
959 tbcAlgProp->setValue(ctrAlg->toString());
960 reductionManager->declareProperty(std::move(tbcAlgProp));
962 g_log.
error() <<
"ERROR: Transmission beam center determination was required"
963 " but no file was provided\n";
966 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
967 auto thetaTransAlgProp = std::make_unique<AlgorithmProperty>(
"TransmissionAlgorithm");
968 thetaTransAlgProp->setValue(transAlg->toString());
969 reductionManager->declareProperty(std::move(thetaTransAlgProp));
972 else if (boost::iequals(transMethod,
"BeamSpreader")) {
973 const std::string sampleSpread =
getPropertyValue(
"TransSampleSpreaderFilename");
974 const std::string directSpread =
getPropertyValue(
"TransDirectSpreaderFilename");
975 const std::string sampleScatt =
getPropertyValue(
"TransSampleScatteringFilename");
976 const std::string directScatt =
getPropertyValue(
"TransDirectScatteringFilename");
977 const double spreaderTrValue =
getProperty(
"SpreaderTransmissionValue");
978 const double spreaderTrError =
getProperty(
"SpreaderTransmissionError");
981 transAlg->setProperty(
"SampleSpreaderFilename", sampleSpread);
982 transAlg->setProperty(
"DirectSpreaderFilename", directSpread);
983 transAlg->setProperty(
"SampleScatteringFilename", sampleScatt);
984 transAlg->setProperty(
"DirectScatteringFilename", directScatt);
985 transAlg->setProperty(
"SpreaderTransmissionValue", spreaderTrValue);
986 transAlg->setProperty(
"SpreaderTransmissionError", spreaderTrError);
987 transAlg->setProperty(
"DarkCurrentFilename", darkCurrent);
988 transAlg->setProperty(
"ThetaDependent", thetaDependentTrans);
989 auto directTransAlgProp = std::make_unique<AlgorithmProperty>(
"TransmissionAlgorithm");
990 directTransAlgProp->setValue(transAlg->toString());
991 reductionManager->declareProperty(std::move(directTransAlgProp));
#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
A property class for workspaces.
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 setupBackground(const std::shared_ptr< Kernel::PropertyManager > &reductionManager)
void exec() override
Execution code.
void setupSensitivity(const std::shared_ptr< Kernel::PropertyManager > &reductionManager)
void setupTransmission(const std::shared_ptr< Kernel::PropertyManager > &reductionManager)
void init() override
Initialisation code.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.