diff --git a/Framework/MDAlgorithms/CMakeLists.txt b/Framework/MDAlgorithms/CMakeLists.txt index eaabe33c98e4c9bf03d755364a3cf19cc57a982f..74165e18ae2e40222e6ffa37acb04ec485bf97e4 100644 --- a/Framework/MDAlgorithms/CMakeLists.txt +++ b/Framework/MDAlgorithms/CMakeLists.txt @@ -1,383 +1,386 @@ # GLOBs should be replaced with explicit listings set ( SRC_FILES - # Old TMP convertToMD code prepared for deprecation: - # src/CreateMDFitWorkspace.cpp - #end TMP - src/AccumulateMD.cpp - src/AndMD.cpp - src/BaseConvertToDiffractionMDWorkspace.cpp - src/BinMD.cpp - src/BinaryOperationMD.cpp - src/BooleanBinaryOperationMD.cpp - src/BoxControllerSettingsAlgorithm.cpp - src/CalculateCoverageDGS.cpp - src/CentroidPeaksMD.cpp - src/CentroidPeaksMD2.cpp - src/ChangeQConvention.cpp - src/CloneMDWorkspace.cpp - src/CompactMD.cpp - src/CompareMDWorkspaces.cpp - src/ConvToMDBase.cpp - src/ConvToMDEventsWS.cpp - src/ConvToMDHistoWS.cpp - src/ConvToMDSelector.cpp - src/ConvertCWPDMDToSpectra.cpp - src/ConvertCWSDExpToMomentum.cpp - src/ConvertCWSDMDtoHKL.cpp - src/ConvertMDHistoToMatrixWorkspace.cpp - src/ConvertSpiceDataToRealSpace.cpp - src/ConvertToDetectorFaceMD.cpp - src/ConvertToDiffractionMDWorkspace.cpp - src/ConvertToDiffractionMDWorkspace2.cpp - src/ConvertToDiffractionMDWorkspace3.cpp - src/ConvertToMD.cpp - src/ConvertToMDMinMaxGlobal.cpp - src/ConvertToMDMinMaxLocal.cpp - src/ConvertToMDParent.cpp - src/ConvertToReflectometryQ.cpp - src/CreateMD.cpp - src/CreateMDHistoWorkspace.cpp - src/CreateMDWorkspace.cpp - src/CutMD.cpp - src/DisplayNormalizationSetter.cpp - src/DivideMD.cpp - src/EqualToMD.cpp - src/EvaluateMDFunction.cpp - src/ExponentialMD.cpp - src/FakeMDEventData.cpp - src/FindPeaksMD.cpp - src/FitMD.cpp - src/GetSpiceDataRawCountsFromMD.cpp - src/GreaterThanMD.cpp - src/IDynamicRebinning.cpp - src/ImportMDEventWorkspace.cpp - src/ImportMDHistoWorkspace.cpp - src/ImportMDHistoWorkspaceBase.cpp - src/Integrate3DEvents.cpp - src/IntegrateEllipsoids.cpp - src/IntegrateEllipsoidsTwoStep.cpp - src/IntegrateFlux.cpp - src/IntegrateMDHistoWorkspace.cpp - src/IntegratePeaksMD.cpp - src/IntegratePeaksMD2.cpp - src/IntegratePeaksMDHKL.cpp - src/IntegratePeaksCWSD.cpp - src/InvalidParameter.cpp - src/InvalidParameterParser.cpp - src/LessThanMD.cpp - src/LoadMD.cpp - src/LoadSQW.cpp - src/LoadSQW2.cpp - src/LogarithmMD.cpp - src/MDEventWSWrapper.cpp - src/MDNormDirectSC.cpp - src/MDNormSCD.cpp - src/MDTransfAxisNames.cpp - src/MDTransfFactory.cpp - src/MDTransfModQ.cpp - src/MDTransfNoQ.cpp - src/MDTransfQ3D.cpp - src/MDWSDescription.cpp - src/MDWSTransform.cpp - src/MaskMD.cpp - src/MergeMD.cpp - src/MergeMDFiles.cpp - src/MinusMD.cpp - src/MultiplyMD.cpp - src/NotMD.cpp - src/OneStepMDEW.cpp - src/OrMD.cpp - src/PlusMD.cpp - src/PowerMD.cpp - src/PreprocessDetectorsToMD.cpp - src/Quantification/CachedExperimentInfo.cpp - src/Quantification/FitResolutionConvolvedModel.cpp - src/Quantification/ForegroundModel.cpp - src/Quantification/ForegroundModelFactory.cpp - src/Quantification/MDResolutionConvolution.cpp - src/Quantification/MDResolutionConvolutionFactory.cpp - src/Quantification/Models/MullerAnsatz.cpp - src/Quantification/Models/QCoordinate.cpp - src/Quantification/Models/Strontium122.cpp - src/Quantification/Resolution/ModeratorChopperResolution.cpp - src/Quantification/Resolution/TobyFitBMatrix.cpp - src/Quantification/Resolution/TobyFitResolutionModel.cpp - src/Quantification/Resolution/TobyFitYVector.cpp - src/Quantification/ResolutionConvolvedCrossSection.cpp - src/Quantification/SimulateResolutionConvolvedModel.cpp - src/QueryMDWorkspace.cpp - src/ReflectometryTransformKiKf.cpp - src/ReflectometryTransformP.cpp - src/ReflectometryTransformQxQz.cpp - src/ReplicateMD.cpp - src/SaveIsawQvector.cpp - src/SaveMD.cpp - src/SaveMD2.cpp - src/SaveZODS.cpp - src/SetMDFrame.cpp - src/SetMDUsingMask.cpp - src/SliceMD.cpp - src/SlicingAlgorithm.cpp - src/SmoothMD.cpp - src/ThresholdMD.cpp - src/TransformMD.cpp - src/TransposeMD.cpp - src/UnaryOperationMD.cpp - src/UnitsConversionHelper.cpp - src/UserFunctionMD.cpp - src/WeightedMeanMD.cpp - src/XorMD.cpp - ) + # Old TMP convertToMD code prepared for deprecation: + # src/CreateMDFitWorkspace.cpp + #end TMP + src/AccumulateMD.cpp + src/AndMD.cpp + src/BaseConvertToDiffractionMDWorkspace.cpp + src/BinMD.cpp + src/BinaryOperationMD.cpp + src/BooleanBinaryOperationMD.cpp + src/BoxControllerSettingsAlgorithm.cpp + src/CalculateCoverageDGS.cpp + src/CentroidPeaksMD.cpp + src/CentroidPeaksMD2.cpp + src/ChangeQConvention.cpp + src/CloneMDWorkspace.cpp + src/CompactMD.cpp + src/CompareMDWorkspaces.cpp + src/ConvToMDBase.cpp + src/ConvToMDEventsWS.cpp + src/ConvToMDHistoWS.cpp + src/ConvToMDSelector.cpp + src/ConvertCWPDMDToSpectra.cpp + src/ConvertCWSDExpToMomentum.cpp + src/ConvertCWSDMDtoHKL.cpp + src/ConvertMDHistoToMatrixWorkspace.cpp + src/ConvertSpiceDataToRealSpace.cpp + src/ConvertToDetectorFaceMD.cpp + src/ConvertToDiffractionMDWorkspace.cpp + src/ConvertToDiffractionMDWorkspace2.cpp + src/ConvertToDiffractionMDWorkspace3.cpp + src/ConvertToMD.cpp + src/ConvertToMDMinMaxGlobal.cpp + src/ConvertToMDMinMaxLocal.cpp + src/ConvertToMDParent.cpp + src/ConvertToReflectometryQ.cpp + src/CreateMD.cpp + src/CreateMDHistoWorkspace.cpp + src/CreateMDWorkspace.cpp + src/CutMD.cpp + src/DisplayNormalizationSetter.cpp + src/DivideMD.cpp + src/EqualToMD.cpp + src/EvaluateMDFunction.cpp + src/ExponentialMD.cpp + src/FakeMDEventData.cpp + src/FindPeaksMD.cpp + src/FitMD.cpp + src/GetSpiceDataRawCountsFromMD.cpp + src/GreaterThanMD.cpp + src/IDynamicRebinning.cpp + src/ImportMDEventWorkspace.cpp + src/ImportMDHistoWorkspace.cpp + src/ImportMDHistoWorkspaceBase.cpp + src/Integrate3DEvents.cpp + src/IntegrateEllipsoids.cpp + src/IntegrateEllipsoidsTwoStep.cpp + src/IntegrateFlux.cpp + src/IntegrateMDHistoWorkspace.cpp + src/IntegratePeaksCWSD.cpp + src/IntegratePeaksMD.cpp + src/IntegratePeaksMD2.cpp + src/IntegratePeaksMDHKL.cpp + src/InvalidParameter.cpp + src/InvalidParameterParser.cpp + src/LessThanMD.cpp + src/LoadDNSSCD.cpp + src/LoadMD.cpp + src/LoadSQW.cpp + src/LoadSQW2.cpp + src/LogarithmMD.cpp + src/MDEventWSWrapper.cpp + src/MDNormDirectSC.cpp + src/MDNormSCD.cpp + src/MDTransfAxisNames.cpp + src/MDTransfFactory.cpp + src/MDTransfModQ.cpp + src/MDTransfNoQ.cpp + src/MDTransfQ3D.cpp + src/MDWSDescription.cpp + src/MDWSTransform.cpp + src/MaskMD.cpp + src/MergeMD.cpp + src/MergeMDFiles.cpp + src/MinusMD.cpp + src/MultiplyMD.cpp + src/NotMD.cpp + src/OneStepMDEW.cpp + src/OrMD.cpp + src/PlusMD.cpp + src/PowerMD.cpp + src/PreprocessDetectorsToMD.cpp + src/Quantification/CachedExperimentInfo.cpp + src/Quantification/FitResolutionConvolvedModel.cpp + src/Quantification/ForegroundModel.cpp + src/Quantification/ForegroundModelFactory.cpp + src/Quantification/MDResolutionConvolution.cpp + src/Quantification/MDResolutionConvolutionFactory.cpp + src/Quantification/Models/MullerAnsatz.cpp + src/Quantification/Models/QCoordinate.cpp + src/Quantification/Models/Strontium122.cpp + src/Quantification/Resolution/ModeratorChopperResolution.cpp + src/Quantification/Resolution/TobyFitBMatrix.cpp + src/Quantification/Resolution/TobyFitResolutionModel.cpp + src/Quantification/Resolution/TobyFitYVector.cpp + src/Quantification/ResolutionConvolvedCrossSection.cpp + src/Quantification/SimulateResolutionConvolvedModel.cpp + src/QueryMDWorkspace.cpp + src/ReflectometryTransformKiKf.cpp + src/ReflectometryTransformP.cpp + src/ReflectometryTransformQxQz.cpp + src/ReplicateMD.cpp + src/SaveIsawQvector.cpp + src/SaveMD.cpp + src/SaveMD2.cpp + src/SaveZODS.cpp + src/SetMDFrame.cpp + src/SetMDUsingMask.cpp + src/SliceMD.cpp + src/SlicingAlgorithm.cpp + src/SmoothMD.cpp + src/ThresholdMD.cpp + src/TransformMD.cpp + src/TransposeMD.cpp + src/UnaryOperationMD.cpp + src/UnitsConversionHelper.cpp + src/UserFunctionMD.cpp + src/WeightedMeanMD.cpp + src/XorMD.cpp +) #set ( SRC_UNITY_IGNORE_FILES src/IDynamicRebinning.cpp #) set ( INC_FILES - inc/MantidMDAlgorithms/AccumulateMD.h - inc/MantidMDAlgorithms/AndMD.h - inc/MantidMDAlgorithms/BaseConvertToDiffractionMDWorkspace.h - inc/MantidMDAlgorithms/BinMD.h - inc/MantidMDAlgorithms/BinaryOperationMD.h - inc/MantidMDAlgorithms/BooleanBinaryOperationMD.h - inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h - inc/MantidMDAlgorithms/CalculateCoverageDGS.h - inc/MantidMDAlgorithms/CentroidPeaksMD.h - inc/MantidMDAlgorithms/CentroidPeaksMD2.h - inc/MantidMDAlgorithms/ChangeQConvention.h - inc/MantidMDAlgorithms/CloneMDWorkspace.h - inc/MantidMDAlgorithms/CompactMD.h - inc/MantidMDAlgorithms/CompareMDWorkspaces.h - inc/MantidMDAlgorithms/ConvToMDBase.h - inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h - inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h - inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h - inc/MantidMDAlgorithms/ConvertMDHistoToMatrixWorkspace.h - inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h - inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h - inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace.h - inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace2.h - inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace3.h - inc/MantidMDAlgorithms/ConvertToMD.h - inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h - inc/MantidMDAlgorithms/ConvertToMDMinMaxLocal.h - inc/MantidMDAlgorithms/ConvertToMDParent.h - inc/MantidMDAlgorithms/ConvertToReflectometryQ.h - inc/MantidMDAlgorithms/CreateMD.h - inc/MantidMDAlgorithms/CreateMDHistoWorkspace.h - inc/MantidMDAlgorithms/CreateMDWorkspace.h - inc/MantidMDAlgorithms/CutMD.h - inc/MantidMDAlgorithms/DisplayNormalizationSetter.h - inc/MantidMDAlgorithms/DivideMD.h - inc/MantidMDAlgorithms/DllConfig.h - inc/MantidMDAlgorithms/EqualToMD.h - inc/MantidMDAlgorithms/EvaluateMDFunction.h - inc/MantidMDAlgorithms/ExponentialMD.h - inc/MantidMDAlgorithms/FakeMDEventData.h - inc/MantidMDAlgorithms/FindPeaksMD.h - inc/MantidMDAlgorithms/FitMD.h - inc/MantidMDAlgorithms/GSLFunctions.h - inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h - inc/MantidMDAlgorithms/GreaterThanMD.h - inc/MantidMDAlgorithms/IDynamicRebinning.h - inc/MantidMDAlgorithms/ImportMDEventWorkspace.h - inc/MantidMDAlgorithms/ImportMDHistoWorkspace.h - inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h - inc/MantidMDAlgorithms/Integrate3DEvents.h - inc/MantidMDAlgorithms/IntegrateEllipsoids.h - inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h - inc/MantidMDAlgorithms/IntegrateFlux.h - inc/MantidMDAlgorithms/IntegrateMDHistoWorkspace.h - inc/MantidMDAlgorithms/IntegratePeaksMD.h - inc/MantidMDAlgorithms/IntegratePeaksMD2.h - inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h - inc/MantidMDAlgorithms/IntegratePeaksCWSD.h - inc/MantidMDAlgorithms/InvalidParameter.h - inc/MantidMDAlgorithms/InvalidParameterParser.h - inc/MantidMDAlgorithms/LessThanMD.h - inc/MantidMDAlgorithms/LoadMD.h - inc/MantidMDAlgorithms/LoadSQW.h - inc/MantidMDAlgorithms/LoadSQW2.h - inc/MantidMDAlgorithms/LogarithmMD.h - inc/MantidMDAlgorithms/MDEventWSWrapper.h - inc/MantidMDAlgorithms/MDNormDirectSC.h - inc/MantidMDAlgorithms/MDNormSCD.h - inc/MantidMDAlgorithms/MDTransfAxisNames.h - inc/MantidMDAlgorithms/MDTransfFactory.h - inc/MantidMDAlgorithms/MDTransfInterface.h - inc/MantidMDAlgorithms/MDTransfModQ.h - inc/MantidMDAlgorithms/MDTransfNoQ.h - inc/MantidMDAlgorithms/MDTransfQ3D.h - inc/MantidMDAlgorithms/MDWSDescription.h - inc/MantidMDAlgorithms/MDWSTransform.h - inc/MantidMDAlgorithms/MaskMD.h - inc/MantidMDAlgorithms/MergeMD.h - inc/MantidMDAlgorithms/MergeMDFiles.h - inc/MantidMDAlgorithms/MinusMD.h - inc/MantidMDAlgorithms/MultiplyMD.h - inc/MantidMDAlgorithms/NotMD.h - inc/MantidMDAlgorithms/OneStepMDEW.h - inc/MantidMDAlgorithms/OrMD.h - inc/MantidMDAlgorithms/PlusMD.h - inc/MantidMDAlgorithms/PowerMD.h - inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h - inc/MantidMDAlgorithms/Quantification/CachedExperimentInfo.h - inc/MantidMDAlgorithms/Quantification/FitResolutionConvolvedModel.h - inc/MantidMDAlgorithms/Quantification/ForegroundModel.h - inc/MantidMDAlgorithms/Quantification/ForegroundModelFactory.h - inc/MantidMDAlgorithms/Quantification/MDResolutionConvolution.h - inc/MantidMDAlgorithms/Quantification/MDResolutionConvolutionFactory.h - inc/MantidMDAlgorithms/Quantification/Models/MullerAnsatz.h - inc/MantidMDAlgorithms/Quantification/Models/QCoordinate.h - inc/MantidMDAlgorithms/Quantification/Models/Strontium122.h - inc/MantidMDAlgorithms/Quantification/Resolution/ModeratorChopperResolution.h - inc/MantidMDAlgorithms/Quantification/Resolution/TobyFitBMatrix.h - inc/MantidMDAlgorithms/Quantification/Resolution/TobyFitResolutionModel.h - inc/MantidMDAlgorithms/Quantification/Resolution/TobyFitYVector.h - inc/MantidMDAlgorithms/Quantification/ResolutionConvolvedCrossSection.h - inc/MantidMDAlgorithms/Quantification/SimulateResolutionConvolvedModel.h - inc/MantidMDAlgorithms/QueryMDWorkspace.h - inc/MantidMDAlgorithms/ReflectometryTransformKiKf.h - inc/MantidMDAlgorithms/ReflectometryTransformP.h - inc/MantidMDAlgorithms/ReflectometryTransformQxQz.h - inc/MantidMDAlgorithms/ReplicateMD.h - inc/MantidMDAlgorithms/SaveIsawQvector.h - inc/MantidMDAlgorithms/SaveMD.h - inc/MantidMDAlgorithms/SaveMD2.h - inc/MantidMDAlgorithms/SaveZODS.h - inc/MantidMDAlgorithms/SetMDFrame.h - inc/MantidMDAlgorithms/SetMDUsingMask.h - inc/MantidMDAlgorithms/SliceMD.h - inc/MantidMDAlgorithms/SlicingAlgorithm.h - inc/MantidMDAlgorithms/SmoothMD.h - inc/MantidMDAlgorithms/ThresholdMD.h - inc/MantidMDAlgorithms/TransformMD.h - inc/MantidMDAlgorithms/TransposeMD.h - inc/MantidMDAlgorithms/UnaryOperationMD.h - inc/MantidMDAlgorithms/UnitsConversionHelper.h - inc/MantidMDAlgorithms/Vector3DParameter.h - inc/MantidMDAlgorithms/Vector3DParameterParser.h - inc/MantidMDAlgorithms/WeightedMeanMD.h - inc/MantidMDAlgorithms/XorMD.h - ) + inc/MantidMDAlgorithms/AccumulateMD.h + inc/MantidMDAlgorithms/AndMD.h + inc/MantidMDAlgorithms/BaseConvertToDiffractionMDWorkspace.h + inc/MantidMDAlgorithms/BinMD.h + inc/MantidMDAlgorithms/BinaryOperationMD.h + inc/MantidMDAlgorithms/BooleanBinaryOperationMD.h + inc/MantidMDAlgorithms/BoxControllerSettingsAlgorithm.h + inc/MantidMDAlgorithms/CalculateCoverageDGS.h + inc/MantidMDAlgorithms/CentroidPeaksMD.h + inc/MantidMDAlgorithms/CentroidPeaksMD2.h + inc/MantidMDAlgorithms/ChangeQConvention.h + inc/MantidMDAlgorithms/CloneMDWorkspace.h + inc/MantidMDAlgorithms/CompactMD.h + inc/MantidMDAlgorithms/CompareMDWorkspaces.h + inc/MantidMDAlgorithms/ConvToMDBase.h + inc/MantidMDAlgorithms/ConvertCWPDMDToSpectra.h + inc/MantidMDAlgorithms/ConvertCWSDExpToMomentum.h + inc/MantidMDAlgorithms/ConvertCWSDMDtoHKL.h + inc/MantidMDAlgorithms/ConvertMDHistoToMatrixWorkspace.h + inc/MantidMDAlgorithms/ConvertSpiceDataToRealSpace.h + inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h + inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace.h + inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace2.h + inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace3.h + inc/MantidMDAlgorithms/ConvertToMD.h + inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h + inc/MantidMDAlgorithms/ConvertToMDMinMaxLocal.h + inc/MantidMDAlgorithms/ConvertToMDParent.h + inc/MantidMDAlgorithms/ConvertToReflectometryQ.h + inc/MantidMDAlgorithms/CreateMD.h + inc/MantidMDAlgorithms/CreateMDHistoWorkspace.h + inc/MantidMDAlgorithms/CreateMDWorkspace.h + inc/MantidMDAlgorithms/CutMD.h + inc/MantidMDAlgorithms/DisplayNormalizationSetter.h + inc/MantidMDAlgorithms/DivideMD.h + inc/MantidMDAlgorithms/DllConfig.h + inc/MantidMDAlgorithms/EqualToMD.h + inc/MantidMDAlgorithms/EvaluateMDFunction.h + inc/MantidMDAlgorithms/ExponentialMD.h + inc/MantidMDAlgorithms/FakeMDEventData.h + inc/MantidMDAlgorithms/FindPeaksMD.h + inc/MantidMDAlgorithms/FitMD.h + inc/MantidMDAlgorithms/GSLFunctions.h + inc/MantidMDAlgorithms/GetSpiceDataRawCountsFromMD.h + inc/MantidMDAlgorithms/GreaterThanMD.h + inc/MantidMDAlgorithms/IDynamicRebinning.h + inc/MantidMDAlgorithms/ImportMDEventWorkspace.h + inc/MantidMDAlgorithms/ImportMDHistoWorkspace.h + inc/MantidMDAlgorithms/ImportMDHistoWorkspaceBase.h + inc/MantidMDAlgorithms/Integrate3DEvents.h + inc/MantidMDAlgorithms/IntegrateEllipsoids.h + inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h + inc/MantidMDAlgorithms/IntegrateFlux.h + inc/MantidMDAlgorithms/IntegrateMDHistoWorkspace.h + inc/MantidMDAlgorithms/IntegratePeaksCWSD.h + inc/MantidMDAlgorithms/IntegratePeaksMD.h + inc/MantidMDAlgorithms/IntegratePeaksMD2.h + inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h + inc/MantidMDAlgorithms/InvalidParameter.h + inc/MantidMDAlgorithms/InvalidParameterParser.h + inc/MantidMDAlgorithms/LessThanMD.h + inc/MantidMDAlgorithms/LoadDNSSCD.h + inc/MantidMDAlgorithms/LoadMD.h + inc/MantidMDAlgorithms/LoadSQW.h + inc/MantidMDAlgorithms/LoadSQW2.h + inc/MantidMDAlgorithms/LogarithmMD.h + inc/MantidMDAlgorithms/MDEventWSWrapper.h + inc/MantidMDAlgorithms/MDNormDirectSC.h + inc/MantidMDAlgorithms/MDNormSCD.h + inc/MantidMDAlgorithms/MDTransfAxisNames.h + inc/MantidMDAlgorithms/MDTransfFactory.h + inc/MantidMDAlgorithms/MDTransfInterface.h + inc/MantidMDAlgorithms/MDTransfModQ.h + inc/MantidMDAlgorithms/MDTransfNoQ.h + inc/MantidMDAlgorithms/MDTransfQ3D.h + inc/MantidMDAlgorithms/MDWSDescription.h + inc/MantidMDAlgorithms/MDWSTransform.h + inc/MantidMDAlgorithms/MaskMD.h + inc/MantidMDAlgorithms/MergeMD.h + inc/MantidMDAlgorithms/MergeMDFiles.h + inc/MantidMDAlgorithms/MinusMD.h + inc/MantidMDAlgorithms/MultiplyMD.h + inc/MantidMDAlgorithms/NotMD.h + inc/MantidMDAlgorithms/OneStepMDEW.h + inc/MantidMDAlgorithms/OrMD.h + inc/MantidMDAlgorithms/PlusMD.h + inc/MantidMDAlgorithms/PowerMD.h + inc/MantidMDAlgorithms/PreprocessDetectorsToMD.h + inc/MantidMDAlgorithms/Quantification/CachedExperimentInfo.h + inc/MantidMDAlgorithms/Quantification/FitResolutionConvolvedModel.h + inc/MantidMDAlgorithms/Quantification/ForegroundModel.h + inc/MantidMDAlgorithms/Quantification/ForegroundModelFactory.h + inc/MantidMDAlgorithms/Quantification/MDResolutionConvolution.h + inc/MantidMDAlgorithms/Quantification/MDResolutionConvolutionFactory.h + inc/MantidMDAlgorithms/Quantification/Models/MullerAnsatz.h + inc/MantidMDAlgorithms/Quantification/Models/QCoordinate.h + inc/MantidMDAlgorithms/Quantification/Models/Strontium122.h + inc/MantidMDAlgorithms/Quantification/Resolution/ModeratorChopperResolution.h + inc/MantidMDAlgorithms/Quantification/Resolution/TobyFitBMatrix.h + inc/MantidMDAlgorithms/Quantification/Resolution/TobyFitResolutionModel.h + inc/MantidMDAlgorithms/Quantification/Resolution/TobyFitYVector.h + inc/MantidMDAlgorithms/Quantification/ResolutionConvolvedCrossSection.h + inc/MantidMDAlgorithms/Quantification/SimulateResolutionConvolvedModel.h + inc/MantidMDAlgorithms/QueryMDWorkspace.h + inc/MantidMDAlgorithms/ReflectometryTransformKiKf.h + inc/MantidMDAlgorithms/ReflectometryTransformP.h + inc/MantidMDAlgorithms/ReflectometryTransformQxQz.h + inc/MantidMDAlgorithms/ReplicateMD.h + inc/MantidMDAlgorithms/SaveIsawQvector.h + inc/MantidMDAlgorithms/SaveMD.h + inc/MantidMDAlgorithms/SaveMD2.h + inc/MantidMDAlgorithms/SaveZODS.h + inc/MantidMDAlgorithms/SetMDFrame.h + inc/MantidMDAlgorithms/SetMDUsingMask.h + inc/MantidMDAlgorithms/SliceMD.h + inc/MantidMDAlgorithms/SlicingAlgorithm.h + inc/MantidMDAlgorithms/SmoothMD.h + inc/MantidMDAlgorithms/ThresholdMD.h + inc/MantidMDAlgorithms/TransformMD.h + inc/MantidMDAlgorithms/TransposeMD.h + inc/MantidMDAlgorithms/UnaryOperationMD.h + inc/MantidMDAlgorithms/UnitsConversionHelper.h + inc/MantidMDAlgorithms/Vector3DParameter.h + inc/MantidMDAlgorithms/Vector3DParameterParser.h + inc/MantidMDAlgorithms/WeightedMeanMD.h + inc/MantidMDAlgorithms/XorMD.h +) # Test files. Other source files required. set ( TEST_FILES - # - # these tests are as they test verify different parts of the CPR algorithms - #CreateMDFitWorkspaceTest.h - AccumulateMDTest.h - AndMDTest.h - BooleanBinaryOperationMDTest.h - BoxControllerSettingsAlgorithmTest.h - CachedExperimentInfoTest.h - CalculateCoverageDGSTest.h - CentroidPeaksMD2Test.h - CentroidPeaksMDTest.h - ChangeQConventionTest.h - CloneMDWorkspaceTest.h - CompactMDTest.h - CompareMDWorkspacesTest.h - ConvertCWPDMDToSpectraTest.h - ConvertCWSDExpToMomentumTest.h - ConvertCWSDMDtoHKLTest.h - ConvertEventsToMDTest.h - ConvertMDHistoToMatrixWorkspaceTest.h - ConvertSpiceDataToRealSpaceTest.h - ConvertToDetectorFaceMDTest.h - ConvertToDiffractionMDWorkspaceTest.h - ConvertToDiffractionMDWorkspace2Test.h - ConvertToDiffractionMDWorkspace3Test.h - ConvertToMDComponentsTest.h - ConvertToMDMinMaxGlobalTest.h - ConvertToMDMinMaxLocalTest.h - ConvertToMDTest.h - ConvertToQ3DdETest.h - ConvertToReflectometryQTest.h - CreateMDHistoWorkspaceTest.h - CreateMDTest.h - CreateMDWorkspaceTest.h - CutMDTest.h - DisplayNormalizationSetterTest.h - DivideMDTest.h - EqualToMDTest.h - EvaluateMDFunctionTest.h - ExponentialMDTest.h - FakeMDEventDataTest.h - FindPeaksMDTest.h - FitMDTest.h - FitResolutionConvolvedModelTest.h - ForegroundModelTest.h - GetSpiceDataRawCountsFromMDTest.h - GreaterThanMDTest.h - ImportMDEventWorkspaceTest.h - ImportMDHistoWorkspaceTest.h - Integrate3DEventsTest.h - IntegrateEllipsoidsTest.h - IntegrateEllipsoidsTwoStepTest.h - IntegrateFluxTest.h - IntegrateMDHistoWorkspaceTest.h - IntegratePeaksMD2Test.h - IntegratePeaksMDHKLTest.h - IntegratePeaksMDTest.h - IntegratePeaksCWSDTest.h - InvalidParameterParserTest.h - InvalidParameterTest.h - LessThanMDTest.h - LoadMDTest.h - LoadSQWTest.h - LoadSQW2Test.h - LogarithmMDTest.h - MDEventWSWrapperTest.h - MDNormDirectSCTest.h - MDNormSCDTest.h - MDResolutionConvolutionFactoryTest.h - MDTransfAxisNamesTest.h - MDTransfFactoryTest.h - MDTransfModQTest.h - MDTransfQ3DTest.h - MDWSDescriptionTest.h - MDWSTransfTest.h - MaskMDTest.h - MergeMDFilesTest.h - MergeMDTest.h - MinusMDTest.h - ModeratorChopperResolutionTest.h - MullerAnsatzTest.h - MultiplyMDTest.h - NotMDTest.h - OneStepMDEWTest.h - OrMDTest.h - PlusMDTest.h - PowerMDTest.h - PreprocessDetectorsToMDTest.h - QueryMDWorkspaceTest.h - ReflectometryTransformKiKfTest.h - ReflectometryTransformPTest.h - ReflectometryTransformQxQzTest.h - ReplicateMDTest.h - ResolutionConvolvedCrossSectionTest.h - SaveIsawQvectorTest.h - SaveMD2Test.h - SaveMDTest.h - SaveZODSTest.h - SetMDFrameTest.h - SetMDUsingMaskTest.h - SimulateResolutionConvolvedModelTest.h - SliceMDTest.h - SlicingAlgorithmTest.h - SmoothMDTest.h - Strontium122Test.h - ThresholdMDTest.h - TobyFitBMatrixTest.h - TobyFitResolutionModelTest.h - TobyFitYVectorTest.h - TransformMDTest.h - TransposeMDTest.h - UnaryOperationMDTest.h - UnitsConversionHelperTest.h - WeightedMeanMDTest.h - XorMDTest.h - ) + # + # these tests are as they test verify different parts of the CPR algorithms + #CreateMDFitWorkspaceTest.h + AccumulateMDTest.h + AndMDTest.h + BooleanBinaryOperationMDTest.h + BoxControllerSettingsAlgorithmTest.h + CachedExperimentInfoTest.h + CalculateCoverageDGSTest.h + CentroidPeaksMD2Test.h + CentroidPeaksMDTest.h + ChangeQConventionTest.h + CloneMDWorkspaceTest.h + CompactMDTest.h + CompareMDWorkspacesTest.h + ConvertCWPDMDToSpectraTest.h + ConvertCWSDExpToMomentumTest.h + ConvertCWSDMDtoHKLTest.h + ConvertEventsToMDTest.h + ConvertMDHistoToMatrixWorkspaceTest.h + ConvertSpiceDataToRealSpaceTest.h + ConvertToDetectorFaceMDTest.h + ConvertToDiffractionMDWorkspace2Test.h + ConvertToDiffractionMDWorkspace3Test.h + ConvertToDiffractionMDWorkspaceTest.h + ConvertToMDComponentsTest.h + ConvertToMDMinMaxGlobalTest.h + ConvertToMDMinMaxLocalTest.h + ConvertToMDTest.h + ConvertToQ3DdETest.h + ConvertToReflectometryQTest.h + CreateMDHistoWorkspaceTest.h + CreateMDTest.h + CreateMDWorkspaceTest.h + CutMDTest.h + DisplayNormalizationSetterTest.h + DivideMDTest.h + EqualToMDTest.h + EvaluateMDFunctionTest.h + ExponentialMDTest.h + FakeMDEventDataTest.h + FindPeaksMDTest.h + FitMDTest.h + FitResolutionConvolvedModelTest.h + ForegroundModelTest.h + GetSpiceDataRawCountsFromMDTest.h + GreaterThanMDTest.h + ImportMDEventWorkspaceTest.h + ImportMDHistoWorkspaceTest.h + Integrate3DEventsTest.h + IntegrateEllipsoidsTest.h + IntegrateEllipsoidsTwoStepTest.h + IntegrateFluxTest.h + IntegrateMDHistoWorkspaceTest.h + IntegratePeaksCWSDTest.h + IntegratePeaksMD2Test.h + IntegratePeaksMDHKLTest.h + IntegratePeaksMDTest.h + InvalidParameterParserTest.h + InvalidParameterTest.h + LessThanMDTest.h + LoadDNSSCDTest.h + LoadMDTest.h + LoadSQW2Test.h + LoadSQWTest.h + LogarithmMDTest.h + MDEventWSWrapperTest.h + MDNormDirectSCTest.h + MDNormSCDTest.h + MDResolutionConvolutionFactoryTest.h + MDTransfAxisNamesTest.h + MDTransfFactoryTest.h + MDTransfModQTest.h + MDTransfQ3DTest.h + MDWSDescriptionTest.h + MDWSTransfTest.h + MaskMDTest.h + MergeMDFilesTest.h + MergeMDTest.h + MinusMDTest.h + ModeratorChopperResolutionTest.h + MullerAnsatzTest.h + MultiplyMDTest.h + NotMDTest.h + OneStepMDEWTest.h + OrMDTest.h + PlusMDTest.h + PowerMDTest.h + PreprocessDetectorsToMDTest.h + QueryMDWorkspaceTest.h + ReflectometryTransformKiKfTest.h + ReflectometryTransformPTest.h + ReflectometryTransformQxQzTest.h + ReplicateMDTest.h + ResolutionConvolvedCrossSectionTest.h + SaveIsawQvectorTest.h + SaveMD2Test.h + SaveMDTest.h + SaveZODSTest.h + SetMDFrameTest.h + SetMDUsingMaskTest.h + SimulateResolutionConvolvedModelTest.h + SliceMDTest.h + SlicingAlgorithmTest.h + SmoothMDTest.h + Strontium122Test.h + ThresholdMDTest.h + TobyFitBMatrixTest.h + TobyFitResolutionModelTest.h + TobyFitYVectorTest.h + TransformMDTest.h + TransposeMDTest.h + UnaryOperationMDTest.h + UnitsConversionHelperTest.h + WeightedMeanMDTest.h + XorMDTest.h +) set ( GMOCK_TEST_FILES BinaryOperationMDTest.h diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h new file mode 100644 index 0000000000000000000000000000000000000000..ccbe77a9ce6a651d724cfc6930a808bebab045fe --- /dev/null +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadDNSSCD.h @@ -0,0 +1,106 @@ +#ifndef MANTID_MDALGORITHMS_LOADDNSSCD_H_ +#define MANTID_MDALGORITHMS_LOADDNSSCD_H_ + +#include <vector> +#include "MantidAPI/DataProcessorAlgorithm.h" +#include "MantidAPI/IFileLoader.h" +#include "MantidAPI/IMDEventWorkspace_fwd.h" +#include "MantidKernel/System.h" +#include "MantidDataObjects/MDEventWorkspace.h" +#include "MantidKernel/Matrix.h" +#include "MantidKernel/V3D.h" + + +namespace Mantid { +namespace MDAlgorithms { + +/** LoadDNSSCD : Load a list of DNS .d_dat files into a MDEventWorkspace + + @author Marina Ganeva + @date 2018-02-15 + + Copyright © 2018 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + National Laboratory & European Spallation Source + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + File change history is stored at: <https://github.com/mantidproject/mantid> + Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class DLLExport LoadDNSSCD : public API::IFileLoader<Kernel::FileDescriptor> { +public: + LoadDNSSCD(); + + /// Algorithm's name for identification + const std::string name() const override { return "LoadDNSSCD"; } + + /// Summary of algorithms purpose + const std::string summary() const override { + return "Load a list of DNS .d_dat files into a MDEventWorkspace."; + } + + /// Algorithm's version for identification + int version() const override { return 1; } + + /// Algorithm's category for identification + const std::string category() const override { + return "MDAlgorithms\\DataHandling"; + } + + /// Returns a confidence value that this algorithm can load a file + int confidence(Kernel::FileDescriptor &descriptor) const override; + +private: + /// Initialise the properties + void init() override; + /// Run the algorithm + void exec() override; + + /// number of workspace dimensions + size_t m_nDims; + + /// type of normalization; + std::string m_normtype; + /// factor to multiply the error^2 for normalization + double m_normfactor; + + /// structure for experimental data + struct ExpData { + double deterota; + double huber; + double wavelength; + double norm; + std::vector<double> signal; + std::vector<int> detID; + }; + + std::vector<ExpData> m_data; + + /// Output IMDEventWorkspace + Mantid::API::IMDEventWorkspace_sptr m_OutWS; + + void read_data(const std::string fname, std::map<std::string, std::string> &str_metadata, std::map<std::string, double> &num_metadata); + void fillOutputWorkspace(double wavelength); + API::ITableWorkspace_sptr saveHuber(); + void loadHuber(API::ITableWorkspace_sptr tws); + template<class T> + void updateProperties(API::Run &run, std::map<std::string, T> &metadata, std::string time); +}; + +} // namespace MDAlgorithms +} // namespace Mantid + +#endif /* MANTID_MDALGORITHMS_LOADDNSSCD_H_ */ diff --git a/Framework/MDAlgorithms/src/LoadDNSSCD.cpp b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ffc471e2b30b42571282cfa18f78f6aa8bc6c09f --- /dev/null +++ b/Framework/MDAlgorithms/src/LoadDNSSCD.cpp @@ -0,0 +1,592 @@ +#include <regex> +#include <map> +#include <iterator> +#include <iomanip> +#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/regex.hpp> +#include <Poco/DateTimeFormat.h> +#include <Poco/DateTimeFormatter.h> +#include <Poco/DirectoryIterator.h> +#include <Poco/Path.h> +#include <Poco/File.h> +#include "MantidMDAlgorithms/LoadDNSSCD.h" +#include "MantidAPI/RegisterFileLoader.h" +#include "MantidAPI/FileProperty.h" +#include "MantidAPI/MultipleFileProperty.h" +#include "MantidKernel/ConfigService.h" +#include "MantidKernel/ArrayProperty.h" +#include "MantidKernel/ArrayLengthValidator.h" +#include "MantidKernel/BoundedValidator.h" +#include "MantidKernel/ListValidator.h" +#include "MantidGeometry/Crystal/OrientedLattice.h" +#include "MantidKernel/VectorHelper.h" +#include "MantidDataObjects/MDEventFactory.h" +#include "MantidAPI/ExperimentInfo.h" +#include "MantidAPI/Run.h" +#include "MantidKernel/TimeSeriesProperty.h" +#include "MantidGeometry/Crystal/IndexingUtils.h" +#include "MantidGeometry/Crystal/OrientedLattice.h" +#include "MantidGeometry/MDGeometry/HKL.h" +#include "MantidKernel/UnitLabelTypes.h" +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/WorkspaceFactory.h" + +#include "MantidMDAlgorithms/MDWSDescription.h" +#include "MantidMDAlgorithms/MDWSTransform.h" +#include "MantidDataObjects/MDBoxBase.h" +#include "MantidDataObjects/MDEventInserter.h" + + +//======================== +// helper functions +namespace { +void eraseSubStr(std::string & str, const std::string & toErase) { + // Search for the substring in string + size_t pos = str.find(toErase); + if (pos != std::string::npos) { + // If found then erase it from string + str.erase(pos, toErase.length()); + } +} + +std::string parseTime(std::string &str){ + // remove unnecessary symbols + eraseSubStr(str, "#"); + eraseSubStr(str, "start"); + eraseSubStr(str, "stopped"); + eraseSubStr(str, "at"); + auto it = std::find_if(str.begin() , str.end() , + [](char ch){ return !std::isspace<char>(ch , std::locale::classic()) ; } ); + str.erase(str.begin(), it); + using namespace boost::posix_time; + // try to parse as a posix time + try{ + auto time = time_from_string(str); + return to_iso_extended_string(time); + } catch (std::exception &) { + // if time is not in posix format + // change all sindle-digit days to 0d (otherwise get_time does not parse) + boost::regex expr("\\s+([0-9]\\s+)"); + std::string fmt{" 0\\1"}; + str = boost::regex_replace(str, expr, fmt); + std::istringstream ss(str); + std::tm t = {}; + ss >> std::get_time(&t, "%a %b %d %H:%M:%S %Y"); + std::string result(""); + if (!ss.fail()) { + auto time = ptime_from_tm(t); + return to_iso_extended_string(time); + } + + return result; + } +} + + +} // anonymous namespace +//============================ + +using namespace Mantid::Kernel; +using namespace Mantid::API; +using namespace Mantid::DataObjects; +using namespace Mantid::Geometry; + +namespace Mantid { +namespace MDAlgorithms { + +DECLARE_FILELOADER_ALGORITHM(LoadDNSSCD) + +//---------------------------------------------------------------------------------------------- +/** Constructor +*/ +LoadDNSSCD::LoadDNSSCD() : m_nDims(3){} + +/** +* Return the confidence with with this algorithm can load the file +* @param descriptor A descriptor for the file +* @returns An integer specifying the confidence level. 0 indicates it will not +* be used +*/ +int LoadDNSSCD::confidence(Kernel::FileDescriptor &descriptor) const { + // DNS data acquisition writes ascii files with .d_dat extension + int confidence(0); + if ((descriptor.extension() == ".d_dat") && descriptor.isAscii()) { + confidence = 80; + } + return confidence; +} + +//---------------------------------------------------------------------------------------------- +/** Initialize the algorithm's properties. + */ +void LoadDNSSCD::init() { + std::vector<std::string> exts(1, ".d_dat"); + declareProperty(Kernel::make_unique<MultipleFileProperty>("Filenames", exts), + "Select one or more DNS SCD .d_dat files to load." + "Files must be measured at the same conditions."); + + declareProperty(make_unique<WorkspaceProperty<IMDEventWorkspace>>( + "OutputWorkspace", "", Direction::Output), + "An output MDEventWorkspace."); + + declareProperty(make_unique<WorkspaceProperty<IMDEventWorkspace>>( + "NormalizationWorkspace", "", Direction::Output), + "An output normalization MDEventWorkspace."); + + const std::vector<std::string> normOptions = {"monitor", "time"}; + declareProperty("Normalization", "monitor", + boost::make_shared<StringListValidator>(normOptions), + "Algorithm will create a separate normalization workspace. " + "Choose whether it should contain monitor counts or time."); + + auto mustBePositive = boost::make_shared<BoundedValidator<double>>(); + mustBePositive->setLower(0.0); + auto reasonableAngle = boost::make_shared<BoundedValidator<double>>(); + reasonableAngle->setLower(5.0); + reasonableAngle->setUpper(175.0); + // clang-format off + auto mustBe3D = boost::make_shared<ArrayLengthValidator<double> >(3); + auto mustBe2D = boost::make_shared<ArrayLengthValidator<double> >(2); + // clang-format on + std::vector<double> u0(3, 0), v0(3, 0); + u0[0] = 1.; + u0[1] = 1.; + v0[2] = 1.; + + declareProperty(make_unique<PropertyWithValue<double>>( + "a", 1.0, mustBePositive, Direction::Input), + "Lattice parameter a in Angstrom"); + declareProperty(make_unique<PropertyWithValue<double>>( + "b", 1.0, mustBePositive, Direction::Input), + "Lattice parameter b in Angstrom"); + declareProperty(make_unique<PropertyWithValue<double>>( + "c", 1.0, mustBePositive, Direction::Input), + "Lattice parameter c in Angstrom"); + declareProperty(make_unique<PropertyWithValue<double>>( + "alpha", 90.0, reasonableAngle, Direction::Input), + "Angle between b and c in degrees"); + declareProperty(make_unique<PropertyWithValue<double>>( + "beta", 90.0, reasonableAngle, Direction::Input), + "Angle between a and c in degrees"); + declareProperty(make_unique<PropertyWithValue<double>>( + "gamma", 90.0, reasonableAngle, Direction::Input), + "Angle between a and b in degrees"); + + declareProperty(make_unique<PropertyWithValue<double>>( + "OmegaOffset", 0.0, boost::make_shared<BoundedValidator<double>>(), + Direction::Input), + "Angle in degrees between (hkl1) and the beam axis" + "if the goniometer is at zero."); + declareProperty( + Kernel::make_unique<ArrayProperty<double>>("hkl1", u0, mustBe3D), + "Indices of the vector in reciprocal space in the horizontal plane at angle Omegaoffset," + "if the goniometer is at zero (considered absolute true in UB calculation)"); + + declareProperty( + Kernel::make_unique<ArrayProperty<double>>("hkl2", v0, mustBe3D), + "Indices of a second vector in reciprocal space in the horizontal plane not parallel to hkl1"); + + std::vector<double> ttl(2, 0); + ttl[1] = 180.0; + declareProperty( + Kernel::make_unique<ArrayProperty<double>>("2ThetaLimits", ttl, mustBe2D), + "Range (min, max) of scattering angles (2theta, degrees) to consider." + "Everything out of this range will be cut."); + + declareProperty( + Kernel::make_unique<WorkspaceProperty<API::ITableWorkspace>>( + "LoadHuberFrom", "", Direction::Input, PropertyMode::Optional), + "A table workspace to load a list of raw sample rotation angles." + "Huber angles given in the data files will be ignored."); + + declareProperty( + Kernel::make_unique<WorkspaceProperty<API::ITableWorkspace>>( + "SaveHuberTo", "", Direction::Output, PropertyMode::Optional), + "A workspace name to save a list of raw sample rotation angles."); +} + +//---------------------------------------------------------------------------------------------- +/** Read Huber angles from a given table workspace. + */ + +void LoadDNSSCD::loadHuber(ITableWorkspace_sptr tws) { + ColumnVector<double> huber = tws->getVector("Huber(degrees)"); + // set huber[0] for each run in m_data + for(auto &ds : m_data) { + ds.huber = huber[0]; + } + // dublicate runs for each huber in the table + std::vector<ExpData> old(m_data); + for (size_t i = 1; i < huber.size(); ++i){ + for(auto &ds : old) { + ds.huber = huber[i]; + m_data.push_back(ds); + } + } +} + +//---------------------------------------------------------------------------------------------- +/** Save Huber angles to a given table workspace. + */ +Mantid::API::ITableWorkspace_sptr LoadDNSSCD::saveHuber() { + std::vector<double> huber; + for(auto ds : m_data) + huber.push_back(ds.huber); + // remove dublicates + std::sort(huber.begin(), huber.end()); + huber.erase(unique(huber.begin(), huber.end()), huber.end()); + + Mantid::API::ITableWorkspace_sptr huberWS = WorkspaceFactory::Instance().createTable("TableWorkspace"); + huberWS->addColumn("double", "Huber(degrees)"); + for(size_t i=0; i< huber.size(); i++) { + huberWS->appendRow(); + huberWS->cell<double>(i, 0) = huber[i]; + } + return huberWS; +} +//---------------------------------------------------------------------------------------------- +/** Execute the algorithm. + */ +void LoadDNSSCD::exec() { + MultipleFileProperty *multiFileProp = + dynamic_cast<MultipleFileProperty *>(getPointerToProperty("Filenames")); + if (!multiFileProp) { + throw std::logic_error( + "Filenames property must have MultipleFileProperty type."); + } + std::vector<std::string> filenames = VectorHelper::flattenVector(multiFileProp->operator()()); + if (filenames.empty()) + throw std::invalid_argument("Must specify at least one filename."); + + // set type of normalization + std::string normtype = getProperty("Normalization"); + if (normtype=="monitor") { + m_normtype = "Monitor"; + m_normfactor = 1.0; + } else { + m_normtype = "Timer"; + m_normfactor = 0.0; // error for time should be 0 + } + + g_log.notice() << "The normalization workspace will contain " << m_normtype << ".\n"; + + ExperimentInfo_sptr expinfo = boost::make_shared<ExperimentInfo>(); + API::Run &run = expinfo->mutableRun(); + for (auto fname : filenames) { + std::map<std::string, std::string> str_metadata; + std::map<std::string, double> num_metadata; + try { + read_data(fname, str_metadata, num_metadata); + //if no stop_time, take file_save_time + std::string time(str_metadata["stop_time"]); + if (time.empty()) { + g_log.warning() << "stop_time is empty! File save time will be used instead." << std::endl; + time = str_metadata["file_save_time"]; + } + updateProperties<std::string>(run, str_metadata, time); + updateProperties<double>(run, num_metadata, time); + } catch(...) { + g_log.warning() << "Failed to read file " << fname; + g_log.warning() << ". This file will be ignored. " << std::endl; + } + } + + if (m_data.empty()) + throw std::runtime_error("No valid DNS files have been provided. Nothing to load."); + + m_OutWS = MDEventFactory::CreateMDWorkspace(m_nDims, "MDEvent"); + + m_OutWS->addExperimentInfo(expinfo); + + // load huber angles from a table workspace if given + ITableWorkspace_sptr huberWS = getProperty("LoadHuberFrom"); + if(huberWS){ + g_log.notice() << "Huber angles will be loaded from " << huberWS->getName() << std::endl; + loadHuber(huberWS); + } + + // get wavelength + TimeSeriesProperty<double> *wlprop = dynamic_cast<TimeSeriesProperty<double> *>(expinfo->run().getProperty("Lambda")); + // assume, that lambda is in nm + double wavelength = wlprop->minValue()*10.0; // needed to estimate extents => minValue + run.addProperty("wavelength", wavelength); + run.getProperty("wavelength")->setUnits("Angstrom"); + + fillOutputWorkspace(wavelength); + + std::string saveHuberTableWS = getProperty("SaveHuberTo"); + if (!saveHuberTableWS.empty()) { + Mantid::API::ITableWorkspace_sptr huber_table = saveHuber(); + setProperty("SaveHuberTo", huber_table); + } + setProperty("OutputWorkspace", m_OutWS); +} + +//---------------------------------------------------------------------------------------------- + +template <class T> void LoadDNSSCD::updateProperties(API::Run &run, std::map<std::string, T> &metadata, std::string time) { + typename std::map<std::string, T>::iterator it = metadata.begin(); + while(it != metadata.end()) { + TimeSeriesProperty<T> *timeSeries(nullptr); + std::string name(it->first); + std::string units; + std::regex reg ("([a-zA-Z-_]+)\\[(.*)]"); + std::smatch match; + if (std::regex_search(name, match, reg) && match.size() > 2) { + std::string new_name(match.str(1)); + units.assign(match.str(2)); + name = new_name; + } + if (run.hasProperty(name)) { + timeSeries = + dynamic_cast<TimeSeriesProperty<T> *>(run.getLogData(name)); + if (!timeSeries) + throw std::invalid_argument( + "Log '" + name + + "' already exists but the values are a different type."); + } else { + timeSeries = new TimeSeriesProperty<T>(name); + if (!units.empty()) + timeSeries->setUnits(units); + run.addProperty(timeSeries); + } + timeSeries->addValue(time, it->second); + it++; + } +} +//---------------------------------------------------------------------------------------------- +/// Create output workspace +void LoadDNSSCD::fillOutputWorkspace(double wavelength) { + + // dimensions + std::vector<std::string> vec_ID(3); + vec_ID[0] = "H"; + vec_ID[1] = "K"; + vec_ID[2] = "L"; + + std::vector<std::string> dimensionNames(3); + dimensionNames[0] = "H"; + dimensionNames[1] = "K"; + dimensionNames[2] = "L"; + + Mantid::Kernel::SpecialCoordinateSystem coordinateSystem = + Mantid::Kernel::HKL; + + double a, b, c, alpha, beta, gamma; + a = getProperty("a"); + b = getProperty("b"); + c = getProperty("c"); + alpha = getProperty("alpha"); + beta = getProperty("beta"); + gamma = getProperty("gamma"); + std::vector<double> u = getProperty("hkl1"); + std::vector<double> v = getProperty("hkl2"); + + // estimate extents + double qmax = 4.0*M_PI/wavelength; + std::vector<double> extentMins = {-qmax*a, -qmax*b, -qmax*c}; + std::vector<double> extentMaxs = {qmax*a, qmax*b, qmax*c}; + + // Get MDFrame of HKL type with RLU + auto unitFactory = makeMDUnitFactoryChain(); + auto unit = unitFactory->create(Units::Symbol::RLU.ascii()); + Mantid::Geometry::HKL frame(unit); + + // add dimensions + for (size_t i = 0; i < m_nDims; ++i) { + std::string id = vec_ID[i]; + std::string name = dimensionNames[i]; + m_OutWS->addDimension( + Geometry::MDHistoDimension_sptr(new Geometry::MDHistoDimension( + id, name, frame, static_cast<coord_t>(extentMins[i]), + static_cast<coord_t>(extentMaxs[i]), 5))); + } + + // Set coordinate system + m_OutWS->setCoordinateSystem(coordinateSystem); + + // calculate RUB matrix + Mantid::Geometry::OrientedLattice o; + o = Mantid::Geometry::OrientedLattice(a, b, c, alpha, beta, gamma); + o.setUFromVectors(Mantid::Kernel::V3D(u[0], u[1], u[2]), + Mantid::Kernel::V3D(v[0], v[1], v[2])); + + double omega_offset = getProperty("OmegaOffset"); + omega_offset *= -1.0*deg2rad; + DblMatrix rotm(3,3); + rotm[0][0] = std::cos(omega_offset); + rotm[0][1] = 0.0; + rotm[0][2] = std::sin(omega_offset); + rotm[1][0] = 0.0; + rotm[1][1] = 1.0; + rotm[1][2] = 0.0; + rotm[2][0] = -std::sin(omega_offset); + rotm[2][1] = 0.0; + rotm[2][2] = std::cos(omega_offset); + + DblMatrix ub(o.getUB()); + ub = rotm * ub; + o.setUB(ub); + DblMatrix ub_inv(ub); + // invert the UB matrix + ub_inv.Invert(); + + // Creates a new instance of the MDEventInserter to output workspace + MDEventWorkspace<MDEvent<3>, 3>::sptr mdws_mdevt_3 = + boost::dynamic_pointer_cast<MDEventWorkspace<MDEvent<3>, 3>>(m_OutWS); + MDEventInserter<MDEventWorkspace<MDEvent<3>, 3>::sptr> inserter(mdws_mdevt_3); + + // create a normalization workspace + IMDEventWorkspace_sptr normWS = m_OutWS->clone(); + + // Creates a new instance of the MDEventInserter to norm workspace + MDEventWorkspace<MDEvent<3>, 3>::sptr normws_mdevt_3 = + boost::dynamic_pointer_cast<MDEventWorkspace<MDEvent<3>, 3>>(normWS); + MDEventInserter<MDEventWorkspace<MDEvent<3>, 3>::sptr> norm_inserter(normws_mdevt_3); + + // scattering angle limits + std::vector<double> tth_limits = getProperty("2ThetaLimits"); + double theta_min = tth_limits[0]*deg2rad/2.0; + double theta_max = tth_limits[1]*deg2rad/2.0; + + // Go though each element of m_data to convert to MDEvent + for (ExpData ds: m_data) { + uint16_t runnumber = 1; + signal_t norm_signal(ds.norm); + signal_t norm_error = std::sqrt(m_normfactor*norm_signal); + double k = 2.0/ds.wavelength; + for (size_t i=0; i< ds.detID.size(); i++){ + signal_t signal(ds.signal[i]); + signal_t error = std::sqrt(signal); + detid_t detid(ds.detID[i]); + double theta = 0.5*(ds.detID[i]*5.0 - ds.deterota)*deg2rad; + if ((theta > theta_min) && (theta < theta_max)) { + double omega = (ds.huber - ds.deterota)*deg2rad - theta; + V3D uphi (-cos(omega), 0, -sin(omega)); + V3D hphi = uphi*k*sin(theta); + V3D hkl = ub_inv*hphi; + std::vector<Mantid::coord_t> millerindex(3); + millerindex[0] = static_cast<float>(hkl.X()); + millerindex[1] = static_cast<float>(hkl.Y()); + millerindex[2] = static_cast<float>(hkl.Z()); + inserter.insertMDEvent( + static_cast<float>(signal), static_cast<float>(error * error), + static_cast<uint16_t>(runnumber), detid, millerindex.data()); + + norm_inserter.insertMDEvent( + static_cast<float>(norm_signal), static_cast<float>(norm_error * norm_error), + static_cast<uint16_t>(runnumber), detid, millerindex.data()); + } + + } + + } + setProperty("NormalizationWorkspace", normWS); + +} + + +void LoadDNSSCD::read_data(const std::string fname, + std::map<std::string, std::string> &str_metadata, + std::map<std::string, double> &num_metadata) { + std::ifstream file (fname); + std::string line; + std::string::size_type n; + std::string s; + std::regex reg1("^#\\s+(\\w+):(.*)"); + std::regex reg2("^#\\s+((\\w+\\s)+)\\s+(-?\\d+(,\\d+)*(\\.\\d+(e\\d+)?)?)"); + std::smatch match; + getline(file, line); + n = line.find("DNS"); + if (n == std::string::npos) { + throw std::invalid_argument("Not a DNS file"); + } + // get file save time + Poco::File pfile(fname); + Poco::DateTime lastModified = pfile.getLastModified(); + std::string wtime(Poco::DateTimeFormatter::format(lastModified, "%Y-%m-%dT%H:%M:%S")); + str_metadata.insert(std::make_pair("file_save_time", wtime)); + + // get file basename + Poco::Path p(fname); + str_metadata.insert(std::make_pair("run_number", p.getBaseName())); + + // parse metadata + while(getline(file, line)){ + n = line.find("Lambda"); + if (n != std::string::npos) { + std::regex re("[\\s]+"); + s = line.substr(5); + std::sregex_token_iterator it(s.begin(), s.end(), re, -1); + std::sregex_token_iterator reg_end; + getline(file, line); + std::string s2 = line.substr(2); + std::sregex_token_iterator it2(s2.begin(), s2.end(), re, -1); + for (; (it != reg_end) && (it2 != reg_end); ++it) { + std::string token (it->str()); + if (token.find_first_not_of(' ') == std::string::npos) { + ++it2; + continue; + } + if (token == "Mono") { + str_metadata.insert(std::make_pair(token, it2->str())); + } else { + num_metadata.insert(std::make_pair(token, std::stod(it2->str()))); + } + ++it2; + } + } + // parse start and stop time + n = line.find("start"); + if (n != std::string::npos) { + str_metadata.insert(std::make_pair("start_time", parseTime(line))); + getline(file, line); + str_metadata.insert(std::make_pair("stop_time", parseTime(line))); + getline(file, line); + } + if (std::regex_search(line, match, reg1) && match.size() > 2) { + str_metadata.insert(std::make_pair(match.str(1), match.str(2))); + } + if (std::regex_search(line, match, reg2) && match.size() > 2) { + s = match.str(1); + s.erase(std::find_if_not(s.rbegin(), s.rend(), ::isspace).base(), s.end()); + num_metadata.insert(std::make_pair(s, std::stod(match.str(3)))); + } + n = line.find("DATA"); + if (n != std::string::npos) { + break; + } + } + + // the algorithm does not work with TOF data for the moment + std::map<std::string,double>::const_iterator m = num_metadata.lower_bound("TOF"); + g_log.debug() << "TOF Channels number: " << m->second << std::endl; + if (m->second != 1) + throw std::runtime_error("Algorithm does not support TOF data. TOF Channels number must be 1."); + + ExpData ds; + ds.deterota = num_metadata["DeteRota"]; + ds.huber = num_metadata["Huber"]; + ds.wavelength = 10.0*num_metadata["Lambda[nm]"]; + ds.norm = num_metadata[m_normtype]; + + // read data array + getline(file, line); + int d; + double x; + while(file){ + file >> d >> x; + ds.detID.push_back(d); + ds.signal.push_back(x); + } + // DNS PA detector bank has only 24 detectors + ds.detID.resize(24); + ds.signal.resize(24); + m_data.push_back(ds); +} + +} // namespace MDAlgorithms +} // namespace Mantid + + + diff --git a/Framework/MDAlgorithms/test/LoadDNSSCDTest.h b/Framework/MDAlgorithms/test/LoadDNSSCDTest.h new file mode 100644 index 0000000000000000000000000000000000000000..d266b53873274ce771442a5ee71207f4bc5eaea9 --- /dev/null +++ b/Framework/MDAlgorithms/test/LoadDNSSCDTest.h @@ -0,0 +1,665 @@ +#ifndef MANTID_MDALGORITHMS_LOADDNSSCDEWTEST_H_ +#define MANTID_MDALGORITHMS_LOADDNSSCDEWTEST_H_ + +#include "MantidKernel/Strings.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/IMDIterator.h" +#include "MantidAPI/IMDEventWorkspace.h" +#include "MantidDataObjects/MDBox.h" +#include "MantidDataObjects/MDGridBox.h" +#include "MantidDataObjects/MDEventFactory.h" +#include "MantidDataObjects/MDEventWorkspace.h" +#include "MantidAPI/BoxController.h" +#include "MantidGeometry/MDGeometry/HKL.h" +#include "MantidAPI/ExperimentInfo.h" +#include "MantidAPI/Run.h" +#include "MantidKernel/TimeSeriesProperty.h" +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/WorkspaceFactory.h" +#include "MantidMDAlgorithms/LoadDNSSCD.h" +#include <cxxtest/TestSuite.h> + +using namespace Mantid; +using namespace Mantid::Kernel; +using namespace Mantid::API; +using namespace Mantid::DataObjects; +using namespace Mantid::MDAlgorithms; + +class LoadDNSSCDTest : public CxxTest::TestSuite { +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static LoadDNSSCDTest *createSuite() { return new LoadDNSSCDTest(); } + static void destroySuite( LoadDNSSCDTest *suite ) { delete suite; } + + LoadDNSSCDTest() : m_fileName("dn134011vana.d_dat") {} + + void test_Init() + { + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + } + + void test_Name() { + LoadDNSSCD alg; + TS_ASSERT_EQUALS(alg.name(), "LoadDNSSCD"); + } + + void test_Metadata() { + // test whether the metadata were loaded correctly + + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr iws; + TS_ASSERT_THROWS_NOTHING( + iws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + outWSName)); + TS_ASSERT(iws); + TS_ASSERT_EQUALS(iws->getNumExperimentInfo(), 1); + + ExperimentInfo_sptr expinfo = iws->getExperimentInfo(0); + auto &run = expinfo->run(); + double d(1e-05); + TS_ASSERT_DELTA(run.getPropertyValueAsType<double>("wavelength"), 4.2, d); + TimeSeriesProperty<double> *p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Lambda")); + TS_ASSERT_DELTA(p->firstValue(), 0.42, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Energy")); + TS_ASSERT_DELTA(p->firstValue(), 4.640, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Speed")); + TS_ASSERT_DELTA(p->firstValue(), 949.0, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("DeteRota")); + TS_ASSERT_DELTA(p->firstValue(), -8.54, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Huber")); + TS_ASSERT_DELTA(p->firstValue(), 79.0, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Flipper_precession")); + TS_ASSERT_DELTA(p->firstValue(), 0.970, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Flipper_z_compensation")); + TS_ASSERT_DELTA(p->firstValue(), 0.400, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("C_a")); + TS_ASSERT_DELTA(p->firstValue(), 0.0, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("C_b")); + TS_ASSERT_DELTA(p->firstValue(), 0.110, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("C_c")); + TS_ASSERT_DELTA(p->firstValue(), -0.500, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("C_z")); + TS_ASSERT_DELTA(p->firstValue(), 0.0, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("T1")); + TS_ASSERT_DELTA(p->firstValue(), 295.0, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("T2")); + TS_ASSERT_DELTA(p->firstValue(), 296.477, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("sample_setpoint")); + TS_ASSERT_DELTA(p->firstValue(), 295.0, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Timer")); + TS_ASSERT_DELTA(p->firstValue(), 600.0, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("Monitor")); + TS_ASSERT_DELTA(p->firstValue(), 8332872, d); + p = dynamic_cast<TimeSeriesProperty<double> *>(run.getProperty("TOF channels")); + TS_ASSERT_DELTA(p->firstValue(), 1.0, d); + TimeSeriesProperty<std::string> *s = dynamic_cast<TimeSeriesProperty<std::string> *>(run.getProperty("start_time")); + TS_ASSERT_EQUALS(s->firstValue(), "2013-04-16T16:11:02"); + s = dynamic_cast<TimeSeriesProperty<std::string> *>(run.getProperty("stop_time")); + TS_ASSERT_EQUALS(s->firstValue(), "2013-04-16T16:21:03"); + AnalysisDataService::Instance().remove(outWSName); + } + + void test_DataWSStructure() { + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr iws; + TS_ASSERT_THROWS_NOTHING( + iws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + outWSName)); + TS_ASSERT(iws); + + TS_ASSERT_EQUALS(iws->getNumDims(), 3); + TS_ASSERT_EQUALS(iws->getNPoints(), 24); + TS_ASSERT_EQUALS(iws->id(), "MDEventWorkspace<MDEvent,3>"); + + // test box controller + BoxController_sptr bc = iws->getBoxController(); + TS_ASSERT(bc); + TS_ASSERT_EQUALS(bc->getNumMDBoxes().size(), 6); + + // test dimensions + std::vector<std::string> v = {"H", "K", "L"}; + for (auto i=0; i<3; i++) { + auto dim = iws->getDimension(i); + TS_ASSERT(dim); + TS_ASSERT_EQUALS(dim->getName(), v[i]); + TS_ASSERT_EQUALS(dim->getNBins(), 5); + double d(1.0e-05); + TS_ASSERT_DELTA(dim->getMinimum(), -2.991993, d); + TS_ASSERT_DELTA(dim->getMaximum(), 2.991993, d); + } + AnalysisDataService::Instance().remove(outWSName); + } + + void test_DataWS() { + // test whether the metadata were loaded correctly + + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("a", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("b", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("c", 4.77)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("alpha", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("beta", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("gamma", 120.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("OmegaOffset", -43.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl1", "1,1,0")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl2", "0,0,1")); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr iws; + TS_ASSERT_THROWS_NOTHING( + iws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + outWSName)); + TS_ASSERT(iws); + + std::vector<API::IMDNode *> boxes(0, NULL); + iws->getBoxes(boxes, 10000, false); + TSM_ASSERT_EQUALS("Number of boxes", boxes.size(), 1); + API::IMDNode *box = boxes[0]; + // there are 24 points in the data file + TS_ASSERT_EQUALS(box->getNPoints(), 24); + std::vector<coord_t> events; + size_t ncols; + box->getEventsData(events, ncols); + // 7 columns: I, err^2, run_num, det_id, h, k, l + TS_ASSERT_EQUALS(ncols, 7); + // 7*24 = 168 + TS_ASSERT_EQUALS(events.size(), 168); + // reference vector + const std::vector<coord_t> ref = {4366, 4366, 1, 0, -0.09776273, -0.09776273, 0.10005156, + 31461, 31461, 1, 1, -0.15959044, -0.15959044, 0.14884006, + 33314, 33314, 1, 2, -0.224231616093, -0.224231616093, 0.189927174618, + 32369, 32369, 1, 3, -0.291194311172, -0.291194311172, 0.223000198347, + 31851, 31851, 1, 4, -0.359968893923, -0.359968893923, 0.247807429194, + 30221, 30221, 1, 5, -0.430031948245, -0.430031948245, 0.264160069153, + 26267, 26267, 1, 6, -0.500850251989, -0.500850251989, 0.271933664761, + 26788, 26788, 1, 7, -0.571884835101, -0.571884835101, 0.27106905426, + 29729, 29729, 1, 8, -0.642595081514, -0.642595081514, 0.26157281786, + 30188, 30188, 1, 9, -0.712442843555, -0.712442843555, 0.243517227652, + 28116, 28116, 1, 10, -0.78089653758, -0.78089653758, 0.217039697581, + 30277, 30277, 1, 11, -0.847435189645, -0.847435189645, 0.182341737639, + 20231, 20231, 1, 12, -0.911552400429, -0.911552400429, 0.13968742025, + 24538, 24538, 1, 13, -0.972760199244, -0.972760199244, 0.089401370527, + 16416, 16416, 1, 14, -1.03059275778, -1.03059275778, 0.0318662956709, + 20225, 20225, 1, 15, -1.08460993535, -1.08460993535, -0.0324799276578, + 19957, 19957, 1, 16, -1.13440062862, -1.13440062862, -0.103147585846, + 19570, 19570, 1, 17, -1.17958590034, -1.17958590034, -0.179598855345, + 20743, 20743, 1, 18, -1.21982186332, -1.21982186332, -0.261251895832, + 22758, 22758, 1, 19, -1.25480229757, -1.25480229757, -0.347485278364, + 23001, 23001, 1, 20, -1.28426098088, -1.28426098088, -0.437642714831, + 21836, 21836, 1, 21, -1.30797371487, -1.30797371487, -0.531038052704, + 23877, 23877, 1, 22, -1.32576003133, -1.32576003133, -0.626960497068, + 13340, 13340, 1, 23, -1.33748456564, -1.33748456564, -0.724680020201}; + double d(1.0e-06); + for (auto i=0; i<168; i++){ + TS_ASSERT_DELTA(events[i], ref[i], d); + } + + AnalysisDataService::Instance().remove(outWSName); + } + + void test_NormWSStructure() { + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr nws; + TS_ASSERT_THROWS_NOTHING( + nws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + normWSName)); + TS_ASSERT(nws); + + TS_ASSERT_EQUALS(nws->getNumDims(), 3); + TS_ASSERT_EQUALS(nws->getNPoints(), 24); + TS_ASSERT_EQUALS(nws->id(), "MDEventWorkspace<MDEvent,3>"); + + // test box controller + BoxController_sptr bc = nws->getBoxController(); + TS_ASSERT(bc); + TS_ASSERT_EQUALS(bc->getNumMDBoxes().size(), 6); + + // test dimensions + std::vector<std::string> v = {"H", "K", "L"}; + for (auto i=0; i<3; i++) { + auto dim = nws->getDimension(i); + TS_ASSERT(dim); + TS_ASSERT_EQUALS(dim->getName(), v[i]); + TS_ASSERT_EQUALS(dim->getNBins(), 5); + double d(1.0e-05); + TS_ASSERT_DELTA(dim->getMinimum(), -2.991993, d); + TS_ASSERT_DELTA(dim->getMaximum(), 2.991993, d); + } + AnalysisDataService::Instance().remove(normWSName); + } + + void test_NormMonitor() { + // test whether the metadata were loaded correctly + + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("a", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("b", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("c", 4.77)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("alpha", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("beta", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("gamma", 120.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("OmegaOffset", -43.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl1", "1,1,0")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl2", "0,0,1")); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr nws; + TS_ASSERT_THROWS_NOTHING( + nws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + normWSName)); + TS_ASSERT(nws); + + std::vector<API::IMDNode *> boxes(0, NULL); + nws->getBoxes(boxes, 10000, false); + TSM_ASSERT_EQUALS("Number of boxes", boxes.size(), 1); + API::IMDNode *box = boxes[0]; + // there are 24 points in the data file + TS_ASSERT_EQUALS(box->getNPoints(), 24); + std::vector<coord_t> events; + size_t ncols; + box->getEventsData(events, ncols); + // 7 columns: I, err^2, run_num, det_id, h, k, l + TS_ASSERT_EQUALS(ncols, 7); + // 7*24 = 168 + TS_ASSERT_EQUALS(events.size(), 168); + // reference vector + const std::vector<coord_t> ref = {8332872, 8332872, 1, 0, -0.09776273, -0.09776273, 0.10005156, + 8332872, 8332872, 1, 1, -0.15959044, -0.15959044, 0.14884006, + 8332872, 8332872, 1, 2, -0.224231616093, -0.224231616093, 0.189927174618, + 8332872, 8332872, 1, 3, -0.291194311172, -0.291194311172, 0.223000198347, + 8332872, 8332872, 1, 4, -0.359968893923, -0.359968893923, 0.247807429194, + 8332872, 8332872, 1, 5, -0.430031948245, -0.430031948245, 0.264160069153, + 8332872, 8332872, 1, 6, -0.500850251989, -0.500850251989, 0.271933664761, + 8332872, 8332872, 1, 7, -0.571884835101, -0.571884835101, 0.27106905426, + 8332872, 8332872, 1, 8, -0.642595081514, -0.642595081514, 0.26157281786, + 8332872, 8332872, 1, 9, -0.712442843555, -0.712442843555, 0.243517227652, + 8332872, 8332872, 1, 10, -0.78089653758, -0.78089653758, 0.217039697581, + 8332872, 8332872, 1, 11, -0.847435189645, -0.847435189645, 0.182341737639, + 8332872, 8332872, 1, 12, -0.911552400429, -0.911552400429, 0.13968742025, + 8332872, 8332872, 1, 13, -0.972760199244, -0.972760199244, 0.089401370527, + 8332872, 8332872, 1, 14, -1.03059275778, -1.03059275778, 0.0318662956709, + 8332872, 8332872, 1, 15, -1.08460993535, -1.08460993535, -0.0324799276578, + 8332872, 8332872, 1, 16, -1.13440062862, -1.13440062862, -0.103147585846, + 8332872, 8332872, 1, 17, -1.17958590034, -1.17958590034, -0.179598855345, + 8332872, 8332872, 1, 18, -1.21982186332, -1.21982186332, -0.261251895832, + 8332872, 8332872, 1, 19, -1.25480229757, -1.25480229757, -0.347485278364, + 8332872, 8332872, 1, 20, -1.28426098088, -1.28426098088, -0.437642714831, + 8332872, 8332872, 1, 21, -1.30797371487, -1.30797371487, -0.531038052704, + 8332872, 8332872, 1, 22, -1.32576003133, -1.32576003133, -0.626960497068, + 8332872, 8332872, 1, 23, -1.33748456564, -1.33748456564, -0.724680020201}; + double d(1.0e-06); + for (auto i=0; i<168; i++){ + TS_ASSERT_DELTA(events[i], ref[i], d); + } + + AnalysisDataService::Instance().remove(normWSName); + } + + void test_NormTime() { + // test whether the metadata were loaded correctly + + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "time")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("a", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("b", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("c", 4.77)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("alpha", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("beta", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("gamma", 120.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("OmegaOffset", -43.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl1", "1,1,0")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl2", "0,0,1")); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr nws; + TS_ASSERT_THROWS_NOTHING( + nws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + normWSName)); + TS_ASSERT(nws); + + std::vector<API::IMDNode *> boxes(0, NULL); + nws->getBoxes(boxes, 10000, false); + TSM_ASSERT_EQUALS("Number of boxes", boxes.size(), 1); + API::IMDNode *box = boxes[0]; + // there are 24 points in the data file + TS_ASSERT_EQUALS(box->getNPoints(), 24); + std::vector<coord_t> events; + size_t ncols; + box->getEventsData(events, ncols); + // 7 columns: I, err^2, run_num, det_id, h, k, l + TS_ASSERT_EQUALS(ncols, 7); + // 7*24 = 168 + TS_ASSERT_EQUALS(events.size(), 168); + // reference vector + const std::vector<coord_t> ref = {600, 0, 1, 0, -0.09776273, -0.09776273, 0.10005156, + 600, 0, 1, 1, -0.15959044, -0.15959044, 0.14884006, + 600, 0, 1, 2, -0.224231616093, -0.224231616093, 0.189927174618, + 600, 0, 1, 3, -0.291194311172, -0.291194311172, 0.223000198347, + 600, 0, 1, 4, -0.359968893923, -0.359968893923, 0.247807429194, + 600, 0, 1, 5, -0.430031948245, -0.430031948245, 0.264160069153, + 600, 0, 1, 6, -0.500850251989, -0.500850251989, 0.271933664761, + 600, 0, 1, 7, -0.571884835101, -0.571884835101, 0.27106905426, + 600, 0, 1, 8, -0.642595081514, -0.642595081514, 0.26157281786, + 600, 0, 1, 9, -0.712442843555, -0.712442843555, 0.243517227652, + 600, 0, 1, 10, -0.78089653758, -0.78089653758, 0.217039697581, + 600, 0, 1, 11, -0.847435189645, -0.847435189645, 0.182341737639, + 600, 0, 1, 12, -0.911552400429, -0.911552400429, 0.13968742025, + 600, 0, 1, 13, -0.972760199244, -0.972760199244, 0.089401370527, + 600, 0, 1, 14, -1.03059275778, -1.03059275778, 0.0318662956709, + 600, 0, 1, 15, -1.08460993535, -1.08460993535, -0.0324799276578, + 600, 0, 1, 16, -1.13440062862, -1.13440062862, -0.103147585846, + 600, 0, 1, 17, -1.17958590034, -1.17958590034, -0.179598855345, + 600, 0, 1, 18, -1.21982186332, -1.21982186332, -0.261251895832, + 600, 0, 1, 19, -1.25480229757, -1.25480229757, -0.347485278364, + 600, 0, 1, 20, -1.28426098088, -1.28426098088, -0.437642714831, + 600, 0, 1, 21, -1.30797371487, -1.30797371487, -0.531038052704, + 600, 0, 1, 22, -1.32576003133, -1.32576003133, -0.626960497068, + 600, 0, 1, 23, -1.33748456564, -1.33748456564, -0.724680020201}; + double d(1.0e-06); + for (auto i=0; i<168; i++){ + TS_ASSERT_DELTA(events[i], ref[i], d); + } + + AnalysisDataService::Instance().remove(normWSName); + } + + void test_SaveHuber() { + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + std::string tWSName("LoadDNSSCDTest_Huber"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("SaveHuberTo", tWSName)); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + ITableWorkspace_sptr tws; + TS_ASSERT_THROWS_NOTHING( + tws = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>(tWSName)); + TS_ASSERT(tws); + + // check that workspace has 1 row and 1 column + TS_ASSERT_EQUALS(tws->rowCount(), 1); + TS_ASSERT_EQUALS(tws->columnCount(), 1); + std::vector<std::string> columnNames = {"Huber(degrees)"}; + TS_ASSERT_EQUALS(tws->getColumnNames(), columnNames); + + // test the value + TS_ASSERT_DELTA(tws->cell<double>(0, 0), 79.0, 1.0e-06); + AnalysisDataService::Instance().remove(tWSName); + } + + void test_LoadHuber() { + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + std::string tWSName2("LoadDNSSCDTest_Huber_save"); + std::string tWSName1("LoadDNSSCDTest_Huber_load"); + + // create a test table workspace + ITableWorkspace_sptr huberWS = WorkspaceFactory::Instance().createTable("TableWorkspace"); + huberWS->addColumn("double", "Huber(degrees)"); + const std::vector<double> vals = {77.0, 92.0, 122.0}; + auto n = vals.size(); + for (size_t i=0; i< n; i++) { + huberWS->appendRow(); + huberWS->cell<double>(i, 0) = vals[i]; + } + AnalysisDataService::Instance().add(tWSName1, huberWS); + + // run the algorithm + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("LoadHuberFrom", tWSName1)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("SaveHuberTo", tWSName2)); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr iws; + TS_ASSERT_THROWS_NOTHING( + iws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + outWSName)); + TS_ASSERT(iws); + + TS_ASSERT_EQUALS(iws->getNumDims(), 3); + // data should be replicated for each huber value + TS_ASSERT_EQUALS(iws->getNPoints(), 24*n); + + // Retrieve the table workspace from data service. + ITableWorkspace_sptr tws; + TS_ASSERT_THROWS_NOTHING( + tws = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>(tWSName2)); + TS_ASSERT(tws); + + // check that workspace has 1 row and 1 column + TS_ASSERT_EQUALS(tws->rowCount(), n); + TS_ASSERT_EQUALS(tws->columnCount(), 1); + std::vector<std::string> columnNames = {"Huber(degrees)"}; + TS_ASSERT_EQUALS(tws->getColumnNames(), columnNames); + + // test the values + for (size_t i=0; i<n; i++) + TS_ASSERT_DELTA(tws->cell<double>(i, 0), vals[i], 1.0e-06); + AnalysisDataService::Instance().remove(tWSName1); + AnalysisDataService::Instance().remove(tWSName2); + AnalysisDataService::Instance().remove(outWSName); + } + + void test_2ThetaLimits() { + // test whether the scattering angle limits work correctly + + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", m_fileName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("a", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("b", 6.84)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("c", 4.77)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("alpha", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("beta", 90.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("gamma", 120.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("OmegaOffset", -43.0)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl1", "1,1,0")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("hkl2", "0,0,1")); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("2ThetaLimits", "20.0,55.0")); + TS_ASSERT_THROWS_NOTHING(alg.execute();); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr iws; + TS_ASSERT_THROWS_NOTHING( + iws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + outWSName)); + TS_ASSERT(iws); + + std::vector<API::IMDNode *> boxes(0, NULL); + iws->getBoxes(boxes, 10000, false); + TSM_ASSERT_EQUALS("Number of boxes", boxes.size(), 1); + API::IMDNode *box = boxes[0]; + // there are 7 points (the rest is outside of 2theta limits) + TS_ASSERT_EQUALS(box->getNPoints(), 7); + std::vector<coord_t> events; + size_t ncols; + box->getEventsData(events, ncols); + // 7 columns: I, err^2, run_num, det_id, h, k, l + TS_ASSERT_EQUALS(ncols, 7); + // 7*7 = 49 + TS_ASSERT_EQUALS(events.size(), 49); + // reference vector + const std::vector<coord_t> ref = {32369, 32369, 1, 3, -0.291194311172, -0.291194311172, 0.223000198347, + 31851, 31851, 1, 4, -0.359968893923, -0.359968893923, 0.247807429194, + 30221, 30221, 1, 5, -0.430031948245, -0.430031948245, 0.264160069153, + 26267, 26267, 1, 6, -0.500850251989, -0.500850251989, 0.271933664761, + 26788, 26788, 1, 7, -0.571884835101, -0.571884835101, 0.27106905426, + 29729, 29729, 1, 8, -0.642595081514, -0.642595081514, 0.26157281786, + 30188, 30188, 1, 9, -0.712442843555, -0.712442843555, 0.243517227652}; + double d(1.0e-06); + for (auto i=0; i<49; i++){ + TS_ASSERT_DELTA(events[i], ref[i], d); + } + + AnalysisDataService::Instance().remove(outWSName); + + // test the normalization workspace as well + IMDEventWorkspace_sptr nws; + TS_ASSERT_THROWS_NOTHING( + nws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + normWSName)); + TS_ASSERT(nws); + // there are 7 points (the rest is outside of 2theta limits) + TS_ASSERT_EQUALS(nws->getNPoints(), 7); + + AnalysisDataService::Instance().remove(normWSName); + } + + void test_Load2() { + // algorithm should load one file and skip the TOF file + + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + std::string filenames = "dn134011vana.d_dat,dnstof.d_dat"; + + LoadDNSSCD alg; + alg.setRethrows(true); + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", filenames)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + + // algorithm should throw only if no valid files is provided + TS_ASSERT_THROWS_NOTHING(alg.execute()); + TS_ASSERT(alg.isExecuted()); + + // Retrieve the workspace from data service. + IMDEventWorkspace_sptr iws; + TS_ASSERT_THROWS_NOTHING( + iws = AnalysisDataService::Instance().retrieveWS<IMDEventWorkspace>( + outWSName)); + TS_ASSERT(iws); + + TS_ASSERT_EQUALS(iws->getNumDims(), 3); + TS_ASSERT_EQUALS(iws->getNPoints(), 24); + AnalysisDataService::Instance().remove(outWSName); + } + + //-------------------- Test failure -------------------------------------- + void test_failTOF() { + // algorithm does not load TOF files + + std::string outWSName("LoadDNSSCDTest_OutputWS"); + std::string normWSName("LoadDNSSCDTest_OutputWS_norm"); + + LoadDNSSCD alg; + alg.setRethrows(true); + TS_ASSERT_THROWS_NOTHING(alg.initialize()); + TS_ASSERT(alg.isInitialized()); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("Filenames", "dnstof.d_dat")); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("NormalizationWorkspace", normWSName)); + TS_ASSERT_THROWS_NOTHING(alg.setProperty("Normalization", "monitor")); + + // algorithm should throw if no valid files is provided + TS_ASSERT_THROWS(alg.execute(), std::runtime_error); + TS_ASSERT(!alg.isExecuted()); + } + +private: + std::string m_fileName; +}; + + +#endif /* MANTID_MDALGORITHMS_LOADDNSSCDEWEST_H_ */